Question: fix this assembly language formula. The output should be 9 when it is calculated correctly .model small .stack 100h .data ;int loc,X,Y,W,Sum loc dw ?

fix this assembly language formula. The output should be 9 when it is calculated correctly

fix this assembly language formula. The output should be 9 when it

.model small

.stack 100h

.data

;int loc,X,Y,W,Sum

loc dw ?

X dw ?

Y dw ?

W dw ?

Sum dw ?

.code

main PROC

mov ax,@data ;set up data segment register

mov ds,ax

;X=40

mov X,40

;Y=24

mov Y,24

Y*160+X*2

mov ax,160

mul Y

mov loc,ax

mov ax,X

add loc,ax

;Y=2000

mov Y,2000

;Y=Y-1

dec Y

;Sum=loc/4+Y

xor dx,dx

mov ax,loc

mov bx,4

div bx

add ax,Y

mov Sum,ax

;W=Sum%7+5

xor dx,dx

mov ax,Sum

mov bx,7

div bx

mov W,dx

add W,5

mov ax,4c00h

int 21h

MAIN endp

END main

a) Write an assembly program which computes the following int W, X, Y, loc, sum; X=40 Y= 24 loc = Y * 160 * 2 Y = 2000 Y= Y-1 Sum = loc/16 + Y +Y/4 Y/200 W=Sum % 7+5 c/2 The instruction for Division is DIV reg/mem Where the operand is the divisor For 8 bit operands the Dividendmust be AX. The result of the division will be as follows. The quotient will be in AL and the remainder in AH. For 16 bit operands, the Dividend must be in DX:AX with the quotient in AX and the Remainder in DX. Here is an example for c/2 code Mov dx, (0 Mov cx, 2 Div cx a) Write an assembly program which computes the following int W, X, Y, loc, sum; X=40 Y= 24 loc = Y * 160 * 2 Y = 2000 Y= Y-1 Sum = loc/16 + Y +Y/4 Y/200 W=Sum % 7+5 c/2 The instruction for Division is DIV reg/mem Where the operand is the divisor For 8 bit operands the Dividendmust be AX. The result of the division will be as follows. The quotient will be in AL and the remainder in AH. For 16 bit operands, the Dividend must be in DX:AX with the quotient in AX and the Remainder in DX. Here is an example for c/2 code Mov dx, (0 Mov cx, 2 Div cx

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!