Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need description this assembly code .model print macro msg push ax push bx push cx push dx lea dx,msg mov ah,09h int 21h pop

I need description this assembly code

.model print macro msg push ax push bx push cx push dx lea dx,msg mov ah,09h int 21h pop dx pop cx pop bx pop ax endm

.data msg1 db 0ah,0dh,"enter x:$" msg2 db 0ah,0dh,"enter y:$" msg3 db 0ah,0dh,"r=:$" x db 0 y db 0 r db 0 num dw 0 cnt dw 0 .code mov ax,data mov ds,ax print msg1 call readnum mov ax,num mov x,al mov cl,0006h mul cl mov bx,ax print msg2 call readnum mov ax,num mov y,al mov cl,-0003h mul cl add ax,bx mov bx,0002h div bx mov r,al print msg3 mov num,ax call printnum readnum proc near push ax push bx push cx push dx mov num,00 r1: mov ah,01h int 21h cmp al,0dh je r2 mov cx,ax and cx,00ffh sub cx,30h mov bx,10 mov ax,num mul bx add ax,cx mov num,ax jmp r1 r2: pop dx pop cx pop bx pop ax ret readnum endp

printnum proc near push ax push bx push cx push dx mov ax,num mov bx,10 p1: mov dx,00 div bx push dx inc cnt cmp ax,00 jne p1 p2: cmp cnt,00 je p3 pop dx add dl,30h mov ah,02h int 21h dec cnt jmp p2 p3: pop dx pop cx pop bx pop ax ret printnum endp

For Example:

image text in transcribed

I will write a description to the code I wrote line by line : Firstly I did it with taking the value of X and Y Line #1: .data (here we will define variables X and Y, note that I took the values '12' and '43' just for example try the code ) Line #2 & Line #3 :X DWORD 12 & Y DWORD 43 (here we assigned those values to the variables X and Y) Line #4: .code (this region where we will write our code ) Line #5: MOV R1,X (take the value of X and move it to the register R1 ) Line #6: MOV R2,Y (take the value of Y and move it to the register R2) Line #6: DIV R1,#3 (we devided the content of register R1 BY 3.R1 So now it contains X/3) Line #7 : DIV R2,#2 (we devided the content of register R2 BY 2.R2 SO now it contains Y/2) Line #7 : ADD R1,R2 (we added content of register R1 to the content of the register R2 so R1 now contains the value :X/3 +Y/2 Line #8 : MUL R1,R1 (we took the content of register R1 and multiplied it with herself to get the square in the equation so now R1 now contains the final value in our equation ) Line #9 :MOV R, R1 (we just copied the final value into register R as the question told us )

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

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions