Program to add two 8-bit numbers & show result in Decimal Number System

Q. Write an 8085 program and draw a flowchart to add two 8-bit numbers & show the result in the decimal number system.(8085 Microprocessor Program)

Flowchart/Algorithm

Program

 Address Mnemonics Operand Opcode Comments 2000 LXI H, 3000H 21 Load H-L pair with address 3000H. 2001 00 2002 30 2003 MOV A, M 7E Move the 1st operand from memory to reg. A. 2004 INX H 23 Increment H-L pair. 2005 MOV B, M 46 Move the 2nd operand from memory to reg. B. 2006 MVI C, 00H 0E Initialize reg. C with 00H. 2007 00 2008 ADD B 80 Add B with A. 2009 DAA 27 Convert the result to decimal. 200A JNC 200EH D2 Jump to address 200EH if there is no carry. 200B 0E 200C 20 200D INR C 0C Increment reg. C. 200E INX H 23 Increment H-L pair. 200F MOV M, A 77 Move the result from reg. A to memory. 2010 INX H 23 Increment H-L pair. 2011 MOV M, C 71 Move carry from reg. C to memory. 2012 HLT 76 Halt

Output

Before Execution:

3000H: 08H

3001H: 05H

After Execution:

3002H: 13

3003H: 00H

Program Explanation

1. This program adds two operands stored in memory location 3000H and 3001H and shows the result in decimal number system.
2. Let us assume that the operands stored at memory location 3000H are 08H and 3001H is 05H.
3. After addition, instead of showing the result in hexadecimal as 0DH, it shows the result in decimal as 13.
4. Initially, H-L pair is loaded with the address of first memory location.
5. The first operand is moved to accumulator from memory location 3000H and H-L pair is incremented to point to next memory location.
6. The second operand is moved to register B from memory location 3001H.
7. Register C is initialized to 00H. It stores the carry (if any).
8. The two operands stored in register A and B are added and the result is stored in the accumulator.
9. The result is converted to decimal by using the DAA instruction.
10. H-L pair is again incremented and carry (either 0 or 1) is moved from register C to memory location 3003H.

1 thought on “Program to add two 8-bit numbers & show result in Decimal Number System”

1. thanks for this program. save me.tnx guys