Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

Computer organization and assembly language

Please help me with this.

I have to write line by line what each line of codes does.

CODE IS BELOW:

.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  ; 32 bits variable with initial value = 10

sp_counter db 0 ; 8 bits variable with initial value of zero

disp_number dd 0 ; 32 bits variable with initial value = 0

disp_number2 dd 0

disp_number3 dd 0

op_type db 0

last_key dd 0 ; 32 bits variable with initial value of zero

remainder db 0

.code 

 

main proc

mov ax,@data;set up datasegment

movds,ax

        mov dx,offset msg1

call display_message

 

callm_keyin

 

calloperation

mov dx,offset msg1

calldisplay_message

 

callm_keyin

cmpop_type, "+"

jnz short skip_plus

 

callop_plus

 

skiP_plus:

cmp op_type, "-"

jnz short skip_minus

callop_minus

 

skip_minus:

 

cmp op_type, "*"

jnz short skip_mul

 

callop_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

jsshort skip_hex

add dl, 7

Skip_hex:

 

mov ah, 6

int 21h

ret

display endp

 

display_message proc

mov ah, 9 ; to display to screen the string pointed by the DX register.

int 21h

mov edx, 0

ret

display_message endp

 

m_keyin proc

MOV disp_number, 0

mov last_key, 0

LP_key:; location in the program label

mov eax, disp_number

mul by_10  ; eax = (eax) * 10

add eax, last_key

mov DISP_NUMBER, eax  ; save it to the number to display

 

mov ah, 1 ; enables a single key entry

int 21h

AND eax, 000000ffh

cmp al, 13 ; compare the key entered to 13 i.e. ascii of CR

jzshort finkey ; if CR was pressed then exit the enter key routine

sub al, 30h  ; remove the ascii from the number entered to get a pure number.

MOV LAST_KEY, EAX  ; save the last digit entered

jmp lp_key  ; unconditional jump to the enter key routine in a loop

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

1. Write a line by line explanation to this program.
2. What does the program do at every routine? Explain.
expand button
Transcribed Image Text:1. Write a line by line explanation to this program. 2. What does the program do at every routine? Explain.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY