86.4k views
2 votes
Install Visual Studio on your computer and practice the example problems (addition with registers, addition with variables). To get points for this problem, you need to show proofs: screenshots of VS running on your computer, system time information (the exact time when you are performing this), debugging screens, register window and memory window for both examples. If you cannot use your own computer, let me know why. In such a case, consider using a lab Write an assembly program that evaluates the following expression using MOV, ADD/SUB instructions. Do not change the original values in each variable. varA=(varA−varB)−(varC+ varD++), where varA, varB, etc., are variables and ++ is the increment operator. Assign integer values to the variables. (Meaning, you may hardcode the inputs.) You do not need to print out the result. You may simply store the result in EAX. Debugging should reveal that the result is correctly stored in EAX.

1 Answer

4 votes

Final answer:

The task is to write an assembly program that calculates the expression varA=(varA−varB)−(varC + varD++), with the result stored in the EAX register.

Step-by-step explanation:

The task involves writing an assembly program to compute the expression varA=(varA−varB)−(varC + varD++), where varA, varB, varC, and varD are integer variables. The results of the computation should be stored in the EAX register, without printing the outcome. Here's a simplified version of how one might write this in assembly, using the Intel syntax:

; Assign initial values to variables
mov eax, varA ; EAX = varA
mov ebx, varB ; EBX = varB
mov ecx, varC ; ECX = varC
mov edx, varD ; EDX = varD
; Compute varD++
add edx, 1 ; EDX = varD + 1
; Compute varC + varD++
add ecx, edx ; ECX = varC + varD
; Compute varA - varB
sub eax, ebx ; EAX = varA - varB
; Compute final result
sub eax, ecx ; EAX = (varA - varB) - (varC + varD)

Note that in assembly programming, when performing arithmetic operations, you often need to use registers to hold intermediate results and then combine these as needed. The specific syntax and instructions may vary based on the assembly language and architecture (e.g., x86, ARM, etc.).

User Alp
by
8.8k points