Skip to content
Related Articles

Related Articles

Improve Article
8085 program to convert gray to binary
  • Last Updated : 22 May, 2018

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

Example –

Algorithm –

  1. Load the data from address 2050 in A
  2. Move the data 07 in C
  3. Move the data of A to B
  4. Extract the MSB (Most Significant Bit) of data available in A
  5. Rotate the bits of A to right
  6. Take AND between data in A and 7F
  7. Take XOR between the data present in A and B
  8. Decrements the contents of C
  9. If Zero Flag (ZF) is not set go to step 4 else go to step 9
  10. Store the result at memory address 3050
  11. Stop

Program –

MEMORY ADDRESSMNEMONICSCOMMENT
2000LDA 2050A <- 2050
2003MVI C, 07C <- 07
2005MOV B, AB <- A2006ANI 80A = A AND 802008RRCRotate A to Right without carry2009ANI 7FA = A AND 7F200BXRA BA = A XOR B200CDCR CC = C – 1200DJNZ 2008JUMP to 2008 if ZF = 02011STA 30503050 <- A2014HLTStop

Explanation–

  1. LDA 2050 is used to load the data from address 2050 in A
  2. MVI C, 07 is used to move the data 07 in C
  3. MOV B, A moves the data of A to B
  4. ANI 80 extracts the MSB(Most Significant Bit) of data available in A
  5. RRC rotates the bits of A to right without carry
  6. ANI 7F is used to tTake AND between data in A and 7F
  7. XRA B takes XOR between the data present in A and B
  8. DCR C is used to decrement the contents of C
  9. JNZ 2008 is used to jump to address 2008 if ZF = 0
  10. STA 3050 is used to store the result at memory address 3050
  11. HLT is used to end the program
My Personal Notes arrow_drop_up
Recommended Articles
Page :