Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Addition of Two 16 Bit Number

8086 Assembly Language Programs

S. Alwyn Rajiv,
Assistant Professor,
Department of ECE,
Kamaraj College of Engineering and Technology
Problem
Write an Assembly Language Program to ADD two numbers of a 16 bit data.

KCET/SARLC/Program 1 2
Algorithm
1. Load the first data in AX register

2. Load the second data in BX register

3. Clear CL register

4. Add the two data and get the sum in AX register

5. Store the sum in memory

6. Check for Carry. If Carry flag is set than go to next step, otherwise go to step 8.

7. Increment CL register

8. Store the Carry in Memory

9. Stop
KCET/SARLC/Program 1 3
Flow Chart
Start
Store the Sum (AX register) in Memory

Load the 1st Data in AX Register


Is Yes Increment
CF=1? CL register
Load the 2nd Data in BX Register
No

Clear CL Register Story Carry (CL Register) in Memory

Get the Sum of AX Register Stop

KCET/SARLC/Program 1 4
Program
MOV AX,[1000h]
MOV BX,[1002h]
MOV CL,00h
ADD AX,BX
MOV [1004h],AX
JNC jump
INC CL
jump:
MOV [1006h],CL
HLT

KCET/SARLC/Program 1 5
Example 1
INPUT
AX 2316 Memory
Content
AH 23 AL 16

Address BH 32 BL 43
BX 3243 1000 16 CH CL 00
1001 23 DH DL
Sum 5559 1002
1003
43
32

OUTPUT
AH 55 AL 59
Memory
BH 32 BL 43 Content
Address
CH CL
CF 0 1004 59
DH DL 1005 55
1006 00
KCET/SARLC/Program 1 6
Example 2
INPUT
AX FE1C Memory
Content
AH FE AL 1C

Address BH A2 BL 43
BX A2 4 3 1000 1C CH CL 00
1001 FE DH DL
Sum 1 A 0 5 F 1002
1003
43
A2

OUTPUT
AH A0 AL 5F
Memory
BH A2 BL 43 Content
Address
CH CL 01
CF 1 1004 5F
DH DL 1005 A0
1006 01
KCET/SARLC/Program 1 7
Thank You…..

KCET/SARLC/Program 1 8

You might also like