8085 program to convert gray to binary
Problem – Write an assembly language program in 8085 microprocessor to convert gray numbers to binary.
Example –

Algorithm –
- Load the data from address 2050 in A
- Move the data 07 in C
- Move the data of A to B
- Extract the MSB (Most Significant Bit) of data available in A
- Rotate the bits of A to right
- Take AND between data in A and 7F
- Take XOR between the data present in A and B
- Decrements the contents of C
- If Zero Flag (ZF) is not set go to step 4 else go to step 9
- Store the result at memory address 3050
- Stop
Program –
| MEMORY ADDRESS | MNEMONICS | COMMENT |
|---|---|---|
| 2000 | LDA 2050 | A <- 2050 |
| 2003 | MVI C, 07 | C <- 07 |
| 2005 | MOV B, A | B <- A | 2006 | ANI 80 | A = A AND 80 | 2008 | RRC | Rotate A to Right without carry | 2009 | ANI 7F | A = A AND 7F | 200B | XRA B | A = A XOR B | 200C | DCR C | C = C – 1 | 200D | JNZ 2008 | JUMP to 2008 if ZF = 0 | 2011 | STA 3050 | 3050 <- A | 2014 | HLT | Stop |
Explanation–
- LDA 2050 is used to load the data from address 2050 in A
- MVI C, 07 is used to move the data 07 in C
- MOV B, A moves the data of A to B
- ANI 80 extracts the MSB(Most Significant Bit) of data available in A
- RRC rotates the bits of A to right without carry
- ANI 7F is used to tTake AND between data in A and 7F
- XRA B takes XOR between the data present in A and B
- DCR C is used to decrement the contents of C
- JNZ 2008 is used to jump to address 2008 if ZF = 0
- STA 3050 is used to store the result at memory address 3050
- HLT is used to end the program
Recommended Posts:
- 8085 program to convert binary numbers to gray
- 8085 program to convert a BCD number to binary
- 8085 program to convert 8 bit BCD number into ASCII Code
- 8085 program to convert a hexadecimal number into ASCII code
- 8085 program for Binary search
- 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 BCD number into hexadecimal number
- 8085 program to convert an 8 bit number into Grey number
- 8086 program to convert a 16 bit decimal number to binary
- 8086 program to convert binary to Grey code
- 8085 program to add two 8 bit numbers
- 8085 program to add 2-BCD numbers
- 8085 program to add two 16 bit numbers
- 8085 program for pulse waveform
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.



