125k views
1 vote
Here is a MASM program:

; AddTwoSum.asm

.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword

.data
sum dword 0

.code
main proc
mov eax,5
add eax,6
mov sum,eax

invoke ExitProcess,0
main endp
end main

Please provide answers to the following questions:

(1) [3 points] State all of the immediate values being used in this program.

(2) [2 points] sum is given a value of 0 under the data directive. This is done so that sum can be initialized to 0. If sum were not initialized to 0, would the mov sum,eax instruction store the value 11 with sum? Please answer Yes or No.

User Peastman
by
6.7k points

1 Answer

5 votes

Final answer:

The immediate values used in the MASM program are 5, 6, and 0. Even if 'sum' were not initialized to 0, the 'mov sum,eax' instruction would still store the value 11 into 'sum'.

Step-by-step explanation:

In the given MASM program, the immediate values being used are 5, 6, and 0. An immediate value is a constant data specified in the instruction itself. In this program:

  • The 'mov eax,5' instruction uses the immediate value 5.
  • The 'add eax,6' instruction uses the immediate value 6.
  • The 'invoke ExitProcess,0' instruction uses the immediate value 0.

For question (2), the answer is Yes. If sum were not initialized to 0, the 'mov sum,eax' instruction would still store the value of EAX, which is 11, into sum. The initialization of sum to 0 has no impact on the instruction that moves the content of EAX to sum.

User Laurynas Lazauskas
by
7.5k points