8086 program to convert binary to Grey code
Prerequisite – Binary to/from Gray Code
Problem – Write a program to convert Binary number to Grey code 8-bit number where starting address is 2000 and the number is stored at 2500 memory address and store result into 2600 memory address.
Example –

Algorithm –
- Move value at [2500] into AL
- Move AL into BL
- Logical shift right AL one time
- XOR BL with AL (Logically) and store into BL
- Move content of BL into 2600
- Stop
Program –
| Memory | Mnemonics | Operands | Comment |
|---|---|---|---|
| 2000 | MOV | AL, [2500] | [AL] <- [2500] |
| 2004 | MOV | BL, AL | [BL] <- [AL] |
| 2006 | SHR | AL, 01 | Shift Right one time |
| 2008 | XOR | BL, AL | [BL] <- [BL] @ AL |
| 200A | MOV | [2600], BL | [2600] <- [BL] |
| 200E | HLT | Stop |
Explanation – Registers AL, BL are used for general purpose
- MOV is used to transfer the data
- SHR is used to shift right (logically) up to counter is not zero
- XOR is used to exclusive-or of two values (logically)
- HLT is used to halt the program
See for 8085 program to convert binary numbers to gray
Recommended Posts:
- 8086 program to convert 8 bit BCD number into ASCII Code
- 8086 program to convert a 16 bit decimal number to binary
- 8085 code to convert binary number to ASCII code
- 8085 program to convert ASCII code into HEX code
- 8085 program to convert an 8 bit number into Grey number
- 8086 program to convert 8 bit ASCII to BCD number
- 8086 program to convert a 16 bit decimal number to Hexadecimal
- 8086 program to convert a 16 bit Decimal number to Octal
- 8085 program to convert 8 bit BCD number into ASCII Code
- 8085 program to convert a hexadecimal number into ASCII code
- 8086 program to convert an 8 bit BCD number into hexadecimal number
- 8085 program to convert gray to binary
- 8085 program to convert a BCD number to binary
- 8085 program to convert binary numbers to gray
- Convert C/C++ code to assembly language
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




