Binary to Grey conversion
Write a Program for Binary to Grey conversion in Meeting language . Algorithm for Binary-Grey conversion is given under and it may be simply applied by this algorithm .
Algorithm for Binary to Grey conversion
Step I : Get the quantity whose grey code equal is to be discovered.
Step II : Add quantity with itself.
Step III : XOR this added end result with the unique quantity.
Step IV : Shift the XOR ed quantity by 1 bit place to the best to get the Grey equal.
Step V : Show the end result.
Step VI : Cease.
Program for Binary to Grey conversion
1 |
.mannequin small <br/> .knowledge <br/> a db 0AH <br/> .code <br/> mov ax, @knowledge ; Initialize knowledge part <br/> mov ds, ax <br/> mov al, a ; Load number1 in al <br/> mov bl, al ; get the quantity in bl additionally <br/> mov ah, 00h ; ah=00 <br/> add ax, ax ; add contents of ax with itself <br/> xor bx, ax ; xor the added contents with quantity itself <br/> ror bx, 01h ; roll by 1 bit to proper to get grey equal <br/> mov ax, bx ; copy end result to ax additionally <br/> mov ch, 02h ; Depend of digits to be displayed <br/> mov cl, 04h ; Depend to roll by 4 bits <br/> mov bh, al ; End in reg bh <br/> l2: rol bh, cl ; roll bl in order that msb involves lsb <br/> mov dl, bh ; load dl with knowledge to be displayed <br/> and dl, 0fH ; get solely lsb <br/> cmp dl, 09 ; verify if digit is 0-9 or letter A-F <br/> jbe l4 <br/> add dl, 07 ; if letter add 37H else solely add 30H <br/> l4: add dl, 30H <br/> mov ah, 02 ; Operate 2 below INT 21H (Show character) <br/> int 21H <br/> dec ch ; Decrement Depend <br/> jnz l2 <br/> mov ah, 4cH ; Terminate Program <br/> int 21H <br/> finish |
Learn how to Run this Program
For Operating this program it is best to have put in Tasm on you pc .
C:applications>tasm bin-gray.asm
Turbo Assembler Model 3.Zero Copyright (c) 1988, 1991 Borland Worldwide
Assembling file: bin-gray.asm
Error messages: None
Warning messages: None
Passes: 1
Remaining reminiscence: 438okay
C:applications>tlink bin-gray.obj
Turbo Hyperlink Model 3.Zero Copyright (c) 1987, 1990 Borland Worldwide
Warning: No stack
C:applications>bin-gray
0F
Supply projectgeek.com