8085 program to add 2-BCD numbers

MicrocontrollerMicroprocessor8085

In this program we will see how to add two 8-bit BCD numbers.

Problem Statement

Write 8085 Assembly language program to add two 8-bit BCD number stored in memory location 8000H – 8001H.

Discussion

This task is too simple. Here we are taking the numbers from memory and after adding we need to put DAA instruction to adjust the accumulator content to decimal form. The DAA will check the AC and CY flags to adjust a number to its decimal form.

Input

Address
Data
...
...
8000
99
8001
25
...
...


Flow Diagram

Program

Address
HEX Codes
Labels
Mnemonics
Comments
F000
21, 00, 80


LXI H,8000H
Point to first operand
F003
7E


MOV A, M
Load A with first operand
F004
23


INX H
Point to next operand
F005
86


ADD M
Add Acc and memory element
F006
27


DAA
Adjust decimal
F007
21, 50, 80


LXI H,8050H
Locate destination address
F00A
77


MOV M, A
Store the result into memory
F00B
D2, 12, F0


JNC DONE
If CY = 0, jump to Done
F00E
3E, 01


MVI A, 01H
Load 01H into Acc
F010
23


INX H
Point to next location
F011
77


MOV M,A
Store the carry
F012
76
DONE
HLT
Terminate the program


Output

Address
Data
...
...
8050
25
8051
01
...
...
raja
Published on 22-Jan-2019 14:26:37
Advertisements