Answered step by step
Verified Expert Solution
Question
1 Approved Answer
program 2 - . model small . 3 8 6 . stack 1 0 0 h . data msg 1 db 1 3 , 1
program
model small
stack h
data msg db "Enter any key $
by dd
spcounter db
dispnumber dd
dispnumber dd
dispnumber dd
optype db
lastkey dd
remainder db
code
main proc
mov ax@data
mov dsax
mov dxoffset msg
call displaymessage
call mkeyin
mov EAX, DISPNUMBER
zzz:
dec DISPNUMBER
mul DISPNUMBER
cmp DISPNUMBER,
jnz zzz
mov DISPNUMBER, eax
call mdisplay
mov axch
int h
mdisplay proc
mov eax, dispnumber
mov spcounter,
Baselp:
LP:
mov edx,
div By
push dx
inc spcounter
cmp eax,
jnz lp
LP:
pop dx
call display
dec spcounter
jnz lp
mov edx,
call display
mov edx, by
call display
mov edx,
call display
dec By
mov eax, dispnumber
cmp By
jnz Baselp
ret
mdisplay endp
iii:
mov axch
int h
opmult proc
mov eax, dispnumber
mul dispnumber
mov dispnumber, eax
ret
opmult endp
display proc
add dlh
cmp dlah
js short skiphex
add dl
Skiphex:
mov ah
int h
ret
display endp
displaymessage proc
mov ah
int h
mov edx,
ret
displaymessage endp
mkeyin proc
MOV dispnumber,
mov lastkey,
LPkey:
mov eax, dispnumber
mul by
add eax, lastkey
mov DISPNUMBER, eax
mov ah
int h
AND eax, ffh
cmp al
jz short finkey
cmp alh
js iii
cmp alAh
jns iii
sub alh
MOV LASTKEY, EAX
jmp lpkey
finkey:
MOV eax, DISPNUMBER
cmp DISPNUMBER
jnz short skip
MOV DISPNUMBER EAX
skip:
MOV DISPNUMBER EAX
cmp DISPNUMBER,
jns iii
cmp DISPNUMBER,
jz iii
ret
mkeyin endp
main endp
end main
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started