Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that calculates the expression Res = (A + B) (C + D), using registers and variables. Several steps are suggested: In the

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

calculate (A + B) (C + D)

save the result in Res

You can copy the following to fill the blanks with your implementations. Please do not use more than six instructions.

- If you can use registers, dont use memory variables. E.g., if available, use EAX,EBX,ECX,EDX, ESI,EDI, instead of creating var1, var2, etc..

- If possible, use less instructions (no more than 6 instructions), E.g., for

MOV ebx, var1

ADD eax, ebx

simply

ADD eax, var1

- Use an instruction with less bytes. E.g., both can move EAX value to var1

MOV var1, eax

XCHG var1, eax

If only want to move, logically use MOV, also because here MOV takes 5 bytes machine code but XCHG 6. - If you can use symbolic constant, dont use memory variable. E.g., for make an array count for

ary BYTE 1,2,3,4,5,6,7,8,9

use constant

aryCount = ($ - myArray)

dont use variable

aryCount BYTE ($ - myArray)

---------------------- CODE ----------------------
.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)  (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

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_2

Step: 3

blur-text-image_3

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

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions

Question

1. Signs and symbols of the map Briefly by box ?

Answered: 1 week ago

Question

Types of physical Maps?

Answered: 1 week ago

Question

Explain Intermediate term financing in detail.

Answered: 1 week ago