.model small
disp macro a
mov ah,09h
lea dx,a
int 21h
endm
.data
msg1 db 10,13,"Enter the no1:$"
msg2 db 10,13,"Enter the no2:$"
num1 db 00h
num2 db 00h
mult dw 0000h
msg8 db 10,13,"$"
msg3 db 10,13,"Multiplication:$"
msg4 db 10,13,"1)Successive addition.$"
msg5 db 10,13,"2)Shift and add method.$"
msg6 db 10,13,"3)Exit.$"
msg7 db 10,13,"Enter your choice:$"
.code
main:
mov ax,@data
mov ds,ax
top:
disp msg8
disp msg4
disp msg5
disp msg6
disp msg7
mov ah,01h
int 21h
mov bl,al
sub bl,30h
cmp bl,01
je succ
cmp bl,02
je shiftadd
cmp bl,03
je exit1
exit1:
mov ah,4ch
int 21h
succ:
disp msg1
call accept
mov num1,bl
disp msg2
call accept
mov num2,bl
mov bl,num1
mov al,num2
mov ah,00
mov cl,num1
mov mult,0000h
up1:
add mult,ax
dec cl
cmp cl,00
jg up1
disp msg3
call print
jmp top
shiftadd:
disp msg1
call accept
mov num1,bl
disp msg2
call accept
mov num2,bl
mov bl,num1
mov al,num2
mov ah,00
mov cl,08
up:
mov dl,al
and dl,01h
cmp dl,01h
jne l1
add ah,bl
l1:
shr ax,01
dec cl
cmp cl,00
jg up
mov mult,ax
disp msg3
call print
jmp top
accept proc near
mov ah,01h
int 21h
sub al,30h
cmp al,09h
jle down
sub al,07h
down:
shl al,04h
mov bl,al
mov ah,01h
int 21h
sub al,30h
cmp al,09h
jle down1
sub al,07h
down1:
add bl,al
ret
accept endp
print proc near
mov bx,mult
shr bx,0Ch
cmp bl,09h
jle down2
add bl,07h
down2:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
mov bx,mult
shr bx,08h
and bl,0Fh
cmp bl,09h
jle down3
add bl,07h
down3:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
mov bx,mult
shr bx,04h
and bl,0Fh
cmp bl,09h
jle down4
add bl,07h
down4:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
mov bx,mult
and bl,0Fh
cmp bl,09h
jle down5
add bl,07h
down5:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
ret
print endp
exit:
end main
end
disp macro a
mov ah,09h
lea dx,a
int 21h
endm
.data
msg1 db 10,13,"Enter the no1:$"
msg2 db 10,13,"Enter the no2:$"
num1 db 00h
num2 db 00h
mult dw 0000h
msg8 db 10,13,"$"
msg3 db 10,13,"Multiplication:$"
msg4 db 10,13,"1)Successive addition.$"
msg5 db 10,13,"2)Shift and add method.$"
msg6 db 10,13,"3)Exit.$"
msg7 db 10,13,"Enter your choice:$"
.code
main:
mov ax,@data
mov ds,ax
top:
disp msg8
disp msg4
disp msg5
disp msg6
disp msg7
mov ah,01h
int 21h
mov bl,al
sub bl,30h
cmp bl,01
je succ
cmp bl,02
je shiftadd
cmp bl,03
je exit1
exit1:
mov ah,4ch
int 21h
succ:
disp msg1
call accept
mov num1,bl
disp msg2
call accept
mov num2,bl
mov bl,num1
mov al,num2
mov ah,00
mov cl,num1
mov mult,0000h
up1:
add mult,ax
dec cl
cmp cl,00
jg up1
disp msg3
call print
jmp top
shiftadd:
disp msg1
call accept
mov num1,bl
disp msg2
call accept
mov num2,bl
mov bl,num1
mov al,num2
mov ah,00
mov cl,08
up:
mov dl,al
and dl,01h
cmp dl,01h
jne l1
add ah,bl
l1:
shr ax,01
dec cl
cmp cl,00
jg up
mov mult,ax
disp msg3
call print
jmp top
accept proc near
mov ah,01h
int 21h
sub al,30h
cmp al,09h
jle down
sub al,07h
down:
shl al,04h
mov bl,al
mov ah,01h
int 21h
sub al,30h
cmp al,09h
jle down1
sub al,07h
down1:
add bl,al
ret
accept endp
print proc near
mov bx,mult
shr bx,0Ch
cmp bl,09h
jle down2
add bl,07h
down2:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
mov bx,mult
shr bx,08h
and bl,0Fh
cmp bl,09h
jle down3
add bl,07h
down3:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
mov bx,mult
shr bx,04h
and bl,0Fh
cmp bl,09h
jle down4
add bl,07h
down4:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
mov bx,mult
and bl,0Fh
cmp bl,09h
jle down5
add bl,07h
down5:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
ret
print endp
exit:
end main
end
--------------------------------------------------OUTPUT-----------------------------------------------
D:\TASM\BIN>edit mul.asm
D:\TASM\BIN>tasm mul.asm
Turbo Assembler Version 4.1 Copyright (c) 1988, 1996 Borland International
Assembling file: mul.asm
Error messages: None
Warning messages: None
Passes: 1
Remaining memory: 450k
D:\TASM\BIN>tlink mul.obj
Turbo Link Version 7.1.30.1. Copyright (c) 1987, 1996 Borland International
Warning: No stack
D:\TASM\BIN>
D:\TASM\BIN>mul
1)Successive addition.
2)Shift and add method.
3)Exit.
Enter your choice:1
Enter the no1:07
Enter the no2:02
Multiplication:000E
1)Successive addition.
2)Shift and add method.
3)Exit.
Enter your choice:2
Enter the no1:04
Enter the no2:03
Multiplication:000C
1)Successive addition.
2)Shift and add method.
3)Exit.
Enter your choice:3
D:\TASM\BIN>