- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
8085 program to convert binary numbers to gray
In this program we will see how to find the gray code from an 8-bit number.
Problem Statement
Write 8085 Assembly language program to convert an 8-bit number stored at 8000H to its equivalent gray code. The result will be stored at 8050H.
Discussion
In this program we are converting binary to gray code. The procedure is simple. At first we have to shift the content to the right, then perform XOR operation with the sifted content and the actual content. Thus we will get the gray code. For an example if the number is ABH, then the binary value will be (1010 1011), after shifting the value will be (0101 0101) = 55H, now by XORing ABH and 55H, the result will be (1111 1110) = FEH
Input
first input
Address | Data |
---|---|
... | ... |
8000 | AB |
... | ... |
second input
Address | Data |
---|---|
... | ... |
8000 | 77 |
... | ... |
third input
Address | Data |
---|---|
... | ... |
8000 | CD |
... | ... |
Flow Diagram
Program
Address | HEX Codes | Mnemonics | Comments |
---|---|---|---|
F000 | 21, 00, 80 | LXI H,8000H | Point to the source address |
F003 | 7E | MOV A, M | Take the number from memory to Acc |
F004 | 37 | STC | Set carry flag |
F005 | 3F | CMC | Complement carry flag |
F006 | 1F | RAR | Rotate right Acc content |
F007 | AE | XRA M | XOR memory content with A |
F008 | 32, 50, 80 | STA 8050H | Store the gray code |
F00B | 76 | HLT | Terminate the program |
Output
first input
Address | Data |
---|---|
... | ... |
8050 | FE |
... | ... |
second input
Address | Data |
---|---|
... | ... |
8050 | 4C |
... | ... |
third input
Address | Data |
---|---|
... | ... |
8050 | AB |
... | ... |
- Related Articles
- 8085 program to convert gray to binary
- Python Program to Convert Gray Code to Binary
- Python Program to Convert Binary to Gray Code
- 8085 Program to convert ASCII to binary
- C++ Program to convert the Binary number to Gray code using recursion
- Program to convert ASCII to binary in 8085 Microprocessor
- 8085 Program to convert a two-digit BCD to binary
- 8085 Program to convert an 8-bit binary to BCD
- 8085 Program to multiply two 16-bit binary numbers
- 8085 Program to convert a 16-bit binary number to BCD
- Binary to Gray code using recursion in C program
- Program to multiply two 16-bit binary numbers in 8085 Microprocessor
- Program to convert a 16-bit binary number to BCD in 8085 Microprocessor
- 8085 code to convert binary number to ASCII code
- 8085 Program to convert ASCII to HEX

Advertisements