8085 Program to convert binary number to decimal

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).

Algorithm

Start
Read binary number(C)
Clear accumulator(A)
D <- 0
A <- A + 1
Adjust for BCD count
If CS != 1 go to 9
D <- D + 1
C <- C - 1
if CS != 0 go to 5
Store A as lower bits
Store D as upper bits
Stop

Flow Chart

Program

      LXI H, 2100H
      MVI D, 00H
      XRA A
      MOV C, M
LOOP: ADI 01H
      DAA
      JNC SKIP
      INR D
SKIP: DCR C
      JNZ LOOP
      MOV L, A
      MOV H, D
      SHLD 2201H
      RST-5

Example

2100H: F0
2101H: 40  ->  lower bits
2105H: 02  ->  upper bits
// output is 240

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