; Multiplcation by Successive addition
;----------------------------------------------------------------------------
.model small
.data
display_message macro msg
mov dx,offset msg
mov ah,09h
int 21h
endm
num1 db 00h
num2 db 00h
msg1 db 10,13,"Enter first number $"
msg2 db 10,13,"Enter second number $"
msg3 db 10,13,"Multiplication is $"
msg4 db 10,13,"$"
result dw 0000h
.code
mov ax,@data
mov ds,ax
display_message msg1
mov ah,01h
int 21h
cmp al,39h
jbe dnt_sub
sub al,07h
dnt_sub: sub al,30h
mov cl,04h
shl al,cl
mov bl,al
mov ah,01h
int 21h
cmp al,39h
jbe dnt_sub1
sub al,07h
dnt_sub1: sub al,30h
add bl,al
mov num1,bl ; mov number1 into num1
display_message msg2
mov ah,01h
int 21h
cmp al,39h
jbe dnt_sub2
sub al,07h
dnt_sub2: sub al,30h
mov cl,04h
shl al,cl
mov bl,al
mov ah,01h
int 21h
cmp al,39h
jbe dnt_sub3
sub al,07h
dnt_sub3: sub al,30h
add bl,al
mov num2,bl ; mov number2 in num2
mov ah,00h
mov al,num1
add_again: add result,ax ; add num1 in result for num2 times
dec num2
jnz add_again
mov ch,04h
mov cl,04h
mov bx,result
display_message msg3
loop1: rol bx,cl ; display final result
mov result,bx
and bx,000fh
mov dl,bl
cmp dl,09h
jbe dnt_add
add dl,07h
dnt_add: add dl,30h
mov ah,02h
int 21h
dec ch
mov bx,result
jnz loop1
mov ah,4ch
int 21h
end
;------------------------------------------------------------------------------------------
; done by Prof. Dhumane A.V. VIIT, Pune
No comments:
Post a Comment