Thursday, 16 April 2009

Addition of two numbers

data segment
msg1 db "Enter the first 2 digit number: $"
msg2 db 0dh,0ah,"Enter the second 2 digit number: $"
msg3 db 0dh,0ah,"Sum = $"
data ends

print macro msg
lea dx,msg
mov ah,09h
int 21h
endm

read macro
mov al,01h
int 21h
endm

display macro num
mov dl,num
mov al,02h
int 21h
endm

code segment
start:mov ax,data
mov ds,ax

print msg1
read
mov bh,al
read
mov bl,al
print msg2
read
mov ch,al
read
mov cl,al

mov ax,bx
add al,cl
aaa
mov bl,al
mov al,ah
add al,ch
aaa
mov cx,ax

add cl,30h
add ch,30h
add bl,30h
print msg3
display ch
display cl
display bl

code ends
end start

querrymail@gmail.com

0 comments: