In this program, we are going to write an assembly language program to add two 8-bit numbers in the 8085 microprocessor with a program flow chart and explanation of the program.
Add two 8-bit numbers in 8085
Program Statement
Write an assembly language program of 8085 to add the two 8-bit numbers which are stored in the memory locations D000H and D001H. Store the result in memory location D002H.
Explanation of Program
- We have two numbers at memory locations D000H and D001H. Let these numbers be 20H and 23H. We have to add these two numbers.
- Using ADD instruction we will add the two numbers.
- Store the result at memory location D002H.
- e.g. D000H = 20H, D001H = 23H
- Result D002G = 20H + 23H = 43H
Assembly Language Program
Instruction | Comment | Operation |
---|---|---|
LXI H, D000H | Set HL as memory pointer at memory location D000H. | H = D0H, L = 00H |
MOV A, M | Load the first operand in the accumulator | A = 20H |
INX H | Increment HL to point next memory location i.e. D001H | H = D0H, L = 01H D001 : 23H |
ADD M | Add the second operand with the first operand. | A = A + M A = 20 + 23 A = 43 H |
INX H | Increment HL to point to the next memory location | H = D0H, L = 02H |
MOV M, A | Store the result | D002H = 43H result |
HLT | Terminate program execution | Stop |