Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 . Write an explanation for each line of code. 2 . Write the logic of each procedure ( function ) . How does it
Write an explanation for each line of code. Write the logic of each procedure function How does it work? Run all the options of the program and explain in details the logic of the entire program and how does it achieves its goals Program model small stack h data msg db "Enter any number $ msg db "Enter an operation or $ msg db "The Operation is $ msg db "The result is $ Bybase dd 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 call operation mov dxoffset msg call displaymessage call mkeyin cmp optype, jnz short skipplus call opplus skiPplus: cmp optype, jnz short skipminus call opminus skipminus: cmp optype, jnz short skipmul call opmult skipmul: cmp optype, jnz short skipdiv call opdiv skipdiv: call mdisplay mov axch int h operation proc mov dxoffset msg rpt: call displaymessage mov dxoffset msg call displaymessage mov ah int h cmp alh jns rpt mov optype, al ret operation endp mdisplay proc mov dxoffset msg call displaymessage mov eax, dispnumber mov spcounter, Baselp: LP: mov edx, div ByBase push dx inc spcounter cmp eax, jnz lp LP: pop dx call display dec spcounter jnz lp mov edx, call display mov edx, bybase call display mov edx, call display dec Bybase mov eax, dispnumber cmp Bybase, jnz Baselp ret mdisplay endp opminus proc mov eax, dispnumber sub eax, dispnumber mov dispnumber, eax ret opminus endp opdiv proc mov eax, dispnumber div dispnumber mov dispnumber, eax mov remainder, dl call display call mdisplay mov dl call display mov dl remainder call display mov dl call display mov edx, dispnumber call display mov axch int h opdiv endp opmult proc mov eax, dispnumber mul dispnumber mov dispnumber, eax ret opmult endp opplus proc mov eax, dispnumber add eax, dispnumber mov dispnumber, eax ret opplus 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 ; eax eax add eax, lastkey mov DISPNUMBER, eax mov ah int h AND eax, ffh cmp al jz short finkey sub alh MOV LASTKEY, EAX jmp lpkey finkey: MOV eax, DISPNUMBER cmp DISPNUMBER jnz short skip MOV DISPNUMBER EAX skip: MOV DISPNUMBER EAX ret mkeyin endp main endp end main
Write an explanation for each line of code.
Write the logic of each procedure function How does it work?
Run all the options of the program and explain in details the logic of the
entire program and how does it achieves its goals
Program
model small
stack h
data
msg db "Enter any number $
msg db "Enter an operation or $
msg db "The Operation is $
msg db "The result is $
Bybase dd
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
call operation
mov dxoffset msg
call displaymessage
call mkeyin
cmp optype,
jnz short skipplus
call opplus
skiPplus:
cmp optype,
jnz short skipminus
call opminus
skipminus:
cmp optype,
jnz short skipmul
call opmult
skipmul:
cmp optype,
jnz short skipdiv
call opdiv
skipdiv:
call mdisplay
mov axch
int h
operation proc
mov dxoffset msg
rpt:
call displaymessage
mov dxoffset msg
call displaymessage
mov ah
int h
cmp alh
jns rpt
mov optype, al
ret
operation endp
mdisplay proc
mov dxoffset msg
call displaymessage
mov eax, dispnumber
mov spcounter,
Baselp:
LP:
mov edx,
div ByBase
push dx
inc spcounter
cmp eax,
jnz lp
LP:
pop dx
call display
dec spcounter
jnz lp
mov edx,
call display
mov edx, bybase
call display
mov edx,
call display
dec Bybase
mov eax, dispnumber
cmp Bybase,
jnz Baselp
ret
mdisplay endp
opminus proc
mov eax, dispnumber
sub eax, dispnumber
mov dispnumber, eax
ret
opminus endp
opdiv proc
mov eax, dispnumber
div dispnumber
mov dispnumber, eax
mov remainder, dl
call display
call mdisplay
mov dl
call display
mov dl remainder
call display
mov dl
call display
mov edx, dispnumber
call display
mov axch
int h
opdiv endp
opmult proc
mov eax, dispnumber
mul dispnumber
mov dispnumber, eax
ret
opmult endp
opplus proc
mov eax, dispnumber
add eax, dispnumber
mov dispnumber, eax
ret
opplus 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 ; eax eax
add eax, lastkey
mov DISPNUMBER, eax
mov ah
int h
AND eax, ffh
cmp al
jz short finkey
sub alh
MOV LASTKEY, EAX
jmp lpkey
finkey:
MOV eax, DISPNUMBER
cmp DISPNUMBER
jnz short skip
MOV DISPNUMBER EAX
skip:
MOV DISPNUMBER EAX
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