QuestionQuestion

Write a program that calculates the expression Res = (A + B) – (C + D), using registers and variables. Several steps are suggested:
• In the data segment, define variables ordered by: varA, varB, varC, varD, and Res with some integers initialized
• In the code segment
o calculate A + B with mov and add
o calculate C + D with mov and add
o calculate (A + B) – (C + D) with sub
o save the result in Res with mov

You can copy the following to fill the blanks with your implementations.
.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword

.data
; define variables: varA, varB, varC, varD, and Res
; ... ...

.code
main1 proc
; calculate Res = (A + B) – (C + D)
   ; calculate A + B
   ; ... ...
   ; calculate C + D
   ; ... ...
   ; calculate (A + B) – (C + D)
   ; ... ...
   ; save the result in Res

invoke ExitProcess,0
main1 endp
end main1

When finished, test your program in debugger. If you define DWORD varA as 10, varB 20, varC 30, and varD 40, Res should be -40.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

.386
.model flat,stdcall
.stack 4096

ExitProcess proto,dwExitCode:dword

.data
; define variables: varA, varB, varC, varD, and Res
varA DWORD 10d
varB DWORD 20d
varC DWORD 30d
varD DWORD 40d
Res DWORD 0h

.code
main proc
; calculate Res = (A + B) – (C + D)
   ; calculate A + B...
$30.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Assembly Language Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats