Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help fixing this program written in assembly language. Its suppose to do an arithmetic operation. The operation goes Z = (-A - B) -

Need help fixing this program written in assembly language. Its suppose to do an arithmetic operation. The operation goes Z = (-A - B) - (-C - D). Where A = 543210 (32-bit) and B = -3210 (16-bit). The other 2 variables C (32-bit) and D (8-bit) are inputted by the user on the console. The program works but the problem is that its not outputting the correct arithmetic answer. Its giving the wrong number. For instance if you set C = 43210 and D = -10 then it should output Z = -496800 but the answer comes out as 589640, which is wrong. The other stuff it outputs is just the values of A, B, C, D and the final value in decimal, binary and hexadecimal. Please help fix.

///////////////////////////////////////////////////////////////////////////Code Below//////////////////////////////////////////////////////////////////////////////

INCLUDE Irvine32.inc INCLUDELIB Irvine32.lib

.data A SDWORD 543210 B SDWORD -3210

strC BYTE "What is the value of C? ",0 varC SDWORD ? strD BYTE "What is the value of D? ",0 varD SDWORD ?

varZ SDWORD ?

eqZ BYTE "Z = (-A - B ) - (-C - D )",0 space BYTE " ",0 colon BYTE ";",0 .code

main PROC mov ebx, B mov ecx, A sub ecx, ebx sub ebx, ebx mov edx, OFFSET strC call WriteString call ReadInt mov varC, eax mov ebx, varC call WriteInt call Crlf mov edx, OFFSET strD call WriteString call ReadInt mov varD, eax sub ebx, varD call WriteInt call Crlf mov edx, OFFSET eqZ call WriteString call Crlf mov eax, A call WriteInt mov edx, OFFSET space call WriteString mov edx, OFFSET colon call WriteString mov edx, OFFSET space call WriteString mov eax, B call WriteInt mov edx, OFFSET space call WriteString mov edx, OFFSET colon call WriteString mov edx, OFFSET space call WriteString mov eax, varC call WriteInt mov edx, OFFSET space call WriteString mov edx, OFFSET colon call WriteString mov edx, OFFSET space call WriteString mov eax, varD call WriteInt call Crlf call Crlf add ecx, ebx mov varZ, ecx mov eax, ecx call WriteBin call Crlf call WriteInt call Crlf call WriteHex call Crlf exit 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

More Books

Students also viewed these Databases questions

Question

=+3. Cash 6. Supplies

Answered: 1 week ago