Professional Documents
Culture Documents
N098 - MM - Exp 2
N098 - MM - Exp 2
EXP. 2
Theory:
The add instruction requires either the addend or the augend to be in a register, unless the
source operand is immediate since the addressing modes permitted for the source and
destination are register-register, memory to register, register to memory, register to immediate,
and finally memory to immediate. Hence one of the operands is initially moved to AX. Then
using the add instruction, 16-bit addition is performed.
Program:
data segment
num1 db 98h
num2 db 99h
result dw ?
data ends
code segment
start: assume ds: data, cs: code
mov ax,data
mov ds,ax
mov ah,00h
mov al,num1
add al,num2
jnc down
inc ah
down:mov result,ax
mov ax,4c00h
int 21h
code ends
end start
B) Addition of two 16-bit numbers:
Program:
data segment
num1 dw 98ABh
num2 dw 99CDh
result dw ?
data ends
code segment
start: assume ds: data, cs: code
mov ax,data
mov ds,ax
mov ax,num1
mov bx,num2
add ax,bx
jnc down
inc ah
down:mov result,ax
mov ax,4c00h
int 21h
code ends
end start
Program:
data segment
n1 db 37H
n2 db 01H
result db ?
data ends
code segment
start: assume ds: data, cs: code
mov ax,data
mov ds,ax
mov al,n1
mov bl,n2
sub al,bl
mov result,al
mov ax,4c00h
int 21h
code ends
end start
D) Subtraction of two 16-bit numbers:
Program:
data segment
n1 dw 3067H
n2 dw 0333H
result dw ?
data ends
code segment
start: assume ds: data, cs: code
mov ax,data
mov ds,ax
mov ax,n1
sub ax,n2
mov result,ax
mov ax,4c00h
int 21h
code ends
end start
Procedure:
Steps to be followed to execute 8086 program in tasm software
Write Assembly language program in notepad.
Save this program file in tasm /bin folder with .asm exetention
Go to window start then select run
Type command cmd (command window will pop up for dos prompt).
Change the directory (cd\)
Select path c:cd tasm/bin
Write command tasm/zi file name .asm
Write command tlink/v file name .obj
Write command td file name .exe
Program Window will appear
Select view tab then select cpu
Press F8 to execute program in single step mode
Select view tab then select variable to see the result.
Result:
A) 8-bit Addition
B) 16-bit Addition
C) 8-bit Subtraction
D) 16-bit Subtraction