Program 1 Addition of Two 16 Bit Numbers 8086
Program 1 Addition of Two 16 Bit Numbers 8086
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
3. Clear CL register
6. Check for Carry. If Carry flag is set than go to next step, otherwise go to step 8.
7. Increment CL register
9. Stop
KCET/SARLC/Program 1 3
Flow Chart
Start
Store the Sum (AX register) in Memory
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