Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

8086 program to convert binary to Grey code

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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 –

  1. Move value at [2500] into AL
  2. Move AL into BL
  3. Logical shift right AL one time
  4. XOR BL with AL (Logically) and store into BL
  5. Move content of BL into 2600
  6. Stop

Program –

MemoryMnemonicsOperandsComment
2000MOVAL, [2500][AL] <- [2500]
2004MOVBL, AL[BL] <- [AL]
2006SHRAL, 01Shift Right one time
2008XORBL, AL[BL] <- [BL] @ AL
200AMOV[2600], BL[2600] <- [BL]
200EHLTStop

Explanation – Registers AL, BL are used for general purpose

  1. MOV is used to transfer the data
  2. SHR is used to shift right (logically) up to counter is not zero
  3. XOR is used to exclusive-or of two values (logically)
  4. HLT is used to halt the program

See for 8085 program to convert binary numbers to gray

My Personal Notes arrow_drop_up
Last Updated : 22 May, 2018
Like Article
Save Article
Similar Reads