0% found this document useful (0 votes)
240 views3 pages

Add Two 8 Bit Numbers and Show The Result in Decimal

This program adds two 8-bit numbers stored in memory and displays the result in decimal. It loads the operands from memory into registers A and B, adds them, converts the result to decimal using DAA, stores the result in memory, and stores the carry flag in memory. For example, if the operands were 8 and 5 stored at addresses 3000H and 3001H, the result 13 would be stored at 3002H and a carry of 0 would be stored at 3003H.

Uploaded by

AmeenSonu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
240 views3 pages

Add Two 8 Bit Numbers and Show The Result in Decimal

This program adds two 8-bit numbers stored in memory and displays the result in decimal. It loads the operands from memory into registers A and B, adds them, converts the result to decimal using DAA, stores the result in memory, and stores the carry flag in memory. For example, if the operands were 8 and 5 stored at addresses 3000H and 3001H, the result 13 would be stored at 3002H and a carry of 0 would be stored at 3003H.

Uploaded by

AmeenSonu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

8085 Programs

Program 15: Add two 8-bit numbers and show the result in decimal number system.
Flowchart:
Start

Load H-L pair with address


of first operands memory
location.
Move the first operand from
memory to accumulator.

Increment H-L pair to point


to next memory location.

Move the result from


accumulator to memory.

Increment H-L pair.

Move the carry from


register C to memory.

Stop
Move the second operand
from memory to register B.

Initialize register C with 0.

Add B with A.

Convert the result to


decimal.

If
Carry?

No

Yes
Increment register C.

Increment H-L pair.

Gursharan Singh Tatla

Page 1 of 3

8085 Programs

Program:
Address
2000

Mnemonics
LXI

Operand
H, 3000H

Opcode
21

Remarks
Load H-L pair with address 3000H.

2001

00

Lower-order of 3000H.

2002

30

Higher-order of 3000H.

2003

MOV

A, M

7E

Move the 1st operand from memory to reg. A.

2004

INX

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.

00

Immediate value 00H.

80

Add B with A.

27

Convert the result to decimal.

D2

Jump to address 200EH if there is no carry.

200B

0E

Lower-order of 200EH.

200C

20

Higher-order of 200EH.

2007
2008

ADD

2009

DAA

200A

JNC

B
200EH

200D

INR

0C

Increment reg. C.

200E

INX

23

Increment H-L pair.

200F

MOV

M, A

77

Move the result from reg. A to memory.

2010

INX

23

Increment H-L pair.

2011

MOV

M, C

71

Move carry from reg. C to memory.

2012

HLT

76

Halt.

Explanation:

This program adds two operands stored in memory location 3000H and 3001H, and shows
the result in decimal number system.

Let us assume that the operands stored at memory location 3000H is 08H and 3001H is 05H.

After addition, instead of showing the result in hexadecimal as 0DH, it shows the result in
decimal as 13.

Initially, H-L pair is loaded with the address of first memory location.

The first operand is moved to accumulator from memory location 3000H and H-L pair is
incremented to point to next memory location.

The second operand is moved to register B from memory location 3001H.

Register C is initialized to 00H. It stores the carry (if any).

The two operands stored in register A and B are added and the result is stored in accumulator.

The result is converted to decimal by using the DAA instruction.

Gursharan Singh Tatla

Page 2 of 3

8085 Programs

Then, carry flag is checked for carry. If there is a carry, C register is incremented.

H-L pair is incremented and the result is moved from accumulator to memory location
3002H.

H-L pair is again incremented and carry (either 0 or 1) is moved from register C to memory
location 3003H.

Output:
Before Execution:
3000H:

08H

3001H:

05H

After Execution:
3002H:

13

3003H:

00H

Gursharan Singh Tatla

Page 3 of 3

You might also like