- 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 an 8-bit binary to BCD
In this program we will see how to convert binary numbers to its BCD equivalent.
Problem Statement
A binary number is store dat location 800H. Convert the number into its BCD equivalent and store it to the memory location 8050H.
Discussion
Here we are taking a number from the memory, and initializing it as a counter. Now in each step of this counter we are incrementing the number by 1, and adjust the decimal value. By this process we are finding the BCD value of binary number or hexadecimal number.
We can use INR instruction to increment the counter in this case but this instruction will not affect carry flag, so for that reason we have used ADI 10H
Input
Address | Data |
---|---|
. . . | . . . |
8000 | 34 |
. . . | . . . |
Flow Diagram
Program
Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|
F000 | 21, 00, 80 | LXI H,8000H | Initialize memory pointer | |
F003 | 16, 00 | MVI D,00H | Clear D- reg for Most significant Byte | |
F005 | AF | XRA A | Clear Accumulator | |
F006 | 4E | MOV C, M | Get HEX data | |
F007 | C6, 01 | LOOP | ADI 01H | Count the number one by one |
F009 | 27 | DAA | Adjust for BCD count | |
F00A | D2, 0E, F0 | JNC SKIP | Jump to SKIP | |
F00D | 14 | INR D | Increase D | |
F00E | 0D | SKIP | DCR C | Decrease C register |
F00F | C2, 07, F0 | JNZ LOOP | Jump to LOOP | |
F012 | 6F | MOV L, A | Load the Least Significant Byte | |
F013 | 62 | MOV H, D | Load the Most Significant Byte | |
F014 | 22, 50, 80 | SHLD 8050H | Store the BCD | |
F017 | 76 | HLT | Terminate the program |
Output
Address | Data |
---|---|
. . . | . . . |
8050 | 52 |
. . . | . . . |
- Related Articles
- 8085 Program to convert a 16-bit binary number to BCD
- 8085 program to convert 8 bit BCD number into ASCII Code
- Program to convert a 16-bit binary number to BCD in 8085 Microprocessor
- 8085 Program to convert a two-digit BCD to binary
- 8086 program to convert an 8 bit BCD number into hexadecimal number
- 8085 program to convert an 8 bit number into Grey number
- 8085 Program to convert BCD to HEX
- 8085 Program to convert HEX to BCD
- Program to convert BCD to HEX in 8085 Microprocessor
- Program to convert HEX to BCD in 8085 Microprocessor
- 8085 program to unpack 16-bit BCD, and store consecutive locations
- 8086 program to add two 8 bit BCD numbers
- 8086 program to subtract two 8 bit BCD numbers
- 8085 program to reverse 8 bit number
- 8085 Program to Divide a 16-bit number by an 8-bit number

Advertisements