Thursday, 16 April 2009

Multiplication

This 8086 program multiplies two numbers.

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

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

read macro
mov ah,01h
int 21h
endm

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

code segment
start:mov ax,data
mov ds,ax
print msg1 ;read 1st number
read
mov bh,al
read
mov bl,al
print msg2 ;read 2nd number
read
mov ch,al
read
mov cl,al
sub bx,3030h
sub cx,3030h
mov dl,bh
rol dl,4
add bl,dl
mov dl,ch
rol dl,4
add cl,dl
and bx,00ffh
and cx,00ffh
mov ax,bx ;multipilication starts
mul cx
mov bx,dx
mov cx,ax
add bx,3030h
add cx,3030h
print msg3
display bh
display bl
display ch
display cl
mov ah,4ch
int 21h
code ends
end start


querrymail@gmail.com

0 comments: