Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . Write an explanation for each line of code. 2 . Write the logic of each procedure ( function ) . How does it

1. Write an explanation for each line of code.
2. Write the logic of each procedure (function). How does it work?
3. 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
.386
.stack 100h
.data
msg1 db 13,10, "Enter any number -->","$"
msg2 db "Enter an operation +,-* or /-->",13,10,"$"
msg3 db "The Operation is -->","$"
msg4 db "The result is -->","$"
By_base dd 21
by_10 dd 10
sp_counter db 0
disp_number dd 0
disp_number2 dd 0
disp_number3 dd 0
op_type db 0
last_key dd 0
remainder db 0
.code
main proc
mov ax,@data
mov ds,ax
mov dx,offset msg1
call display_message
call m_keyin
call operation
mov dx,offset msg1
call display_message
call m_keyin
cmp op_type, "+"
jnz short skip_plus
call op_plus
skiP_plus:
cmp op_type, "-"
jnz short skip_minus
call op_minus
skip_minus:
cmp op_type, "*"
jnz short skip_mul
call op_mult
skip_mul:
cmp op_type, "/"
jnz short skip_div
call op_div
skip_div:
call m_display
mov ax,4c00h
int 21h
operation proc
mov dx,offset msg2
rpt4:
call display_message
mov dx,offset msg3
call display_message
mov ah,1
int 21h
cmp al,30h
jns rpt4
mov op_type, al
ret
operation endp
m_display proc
mov dx,offset msg4
call display_message
mov eax, disp_number
mov sp_counter, 0
Base_lp:
LP1:
mov edx, 0
div By_Base
push dx
inc sp_counter
cmp eax, 0
jnz lp1
LP2:
pop dx
call display
dec sp_counter
jnz lp2
mov edx, -8
call display
mov edx, by_base
call display
mov edx, -7
call display
dec By_base
mov eax, disp_number
cmp By_base, 1
jnz Base_lp
ret
m_display endp
op_minus proc
mov eax, disp_number2
sub eax, disp_number3
mov disp_number, eax
ret
op_minus endp
op_div proc
mov eax, disp_number2
div disp_number3
mov disp_number, eax
mov remainder, dl
call display
call m_display
mov dl,-16
call display
mov dl, remainder
call display
mov dl,-1
call display
mov edx, disp_number3
call display
mov ax,4c00h
int 21h
op_div endp
op_mult proc
mov eax, disp_number2
mul disp_number3
mov disp_number, eax
ret
op_mult endp
op_plus proc
mov eax, disp_number2
add eax, disp_number3
mov disp_number, eax
ret
op_plus endp
display proc
add dl,30h
cmp dl,3ah
js short skip_hex
add dl,7
Skip_hex:
mov ah,6
int 21h
ret
display endp
display_message proc
mov ah,9
int 21h
mov edx, 0
ret
display_message endp
m_keyin proc
MOV disp_number, 0
mov last_key, 0
LP_key:
mov eax, disp_number
mul by_10 ; eax =(eax)*10
add eax, last_key
mov DISP_NUMBER, eax
mov ah,1
int 21h
AND eax, 000000ffh
cmp al,13
jz short finkey
sub al,30h
MOV LAST_KEY, EAX
jmp lp_key
finkey:
MOV eax, DISP_NUMBER
cmp DISP_NUMBER2,0
jnz short skip
MOV DISP_NUMBER2, EAX
skip:
MOV DISP_NUMBER3, EAX
ret
m_keyin endp
main endp
end main

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Accounting

Authors: Joe Hoyle, Thomas Schaefer, Timothy Doupnik

10th edition

0-07-794127-6, 978-0-07-79412, 978-0077431808

Students also viewed these Databases questions