8085 Program to convert binary number to decimal without using DAA

8085 is a Microprocessor which was developed by Intel in 1970s. All the instructions in this microprocessor are encoded in a single byte. Some of the instructions are followed by one or two bytes of data, which can be a memory address, an immediate operand or a port number.

In this post, we will write a program in 8085 to convert binary number to binary coded decimal(BCD) without using DAA operation.

Algorithm

Start
Clear D and E registers to account for hundreds and tens
Load data in A
Compare A with 64H
If CS = 1 go to 9
A <- A - 64H
E <- E + 1
Go to 4
Compare A with 0AH
if CS = 1 go to 14
A <- A - 0AH
D <- D + 1
go to 
C <- A
A <- D
Rotate left A 4 times
Combine unit and tens to form lower bit result
Save hundreds as upper bits and combined result as lower bit
Stop

Flow Chart

Program

      MVI E, 00H
      MOV D, E
      LDA 2100H
HUND: CPI 64H
      JC TEN
      SUI 64H
      INR E
      JMP HUND
TEN:  CPI 0AH
      JC UNIT
      SUI 0AH
      INR D
      JMP TEN
UNIT: MOV C, A
      MOV A, D
      RLC
      RLC
      RLC
      RLC
      ADD C
      STA 2101H
      MOV A, E
      STA 2102H
      RST-5

Example

2100H: FF
2101H: 55  ->  lower bits
2105H: 02  ->  upper bits
// output is 255

Check out our other 8085 programs

Let us know in the comments if you are having any questions regarding this microprocessor program.

And if you found this post helpful, then please help us by sharing this post with your friends. Thank You

Leave a Reply