196k views
4 votes
Suppose that you are given the following program (with memory addresses shown on the left).

After the instruction "mov ebp, esp", which of the following is referenced by each of the following?

.data

x DWORD 153461

y WORD 37

z WORD 90

.code

main PROC

push x

push y

push z

call someProcedure...

exit

main ENDP

someProcedure PROC

push ebp

mov ebp, esp

...

pop ebp

ret 8

someProcedure ENDP

END MAIN

Match

1) [ebp + 4] a. The previous value of EBP

2) [ebp + 8] b. the return address from someProcedure

3) [ebp + 10] c. The decimal value 90

4) [ebp + 12] d. the memory address of someProcedure

5) [ebp] e. The decimal value 37

6) [ebp + 6] f. The decimal value 153461

g. none of these

User Theraneman
by
7.0k points

1 Answer

3 votes

Answer:

Let's go through each of the options to determine what they reference after the instruction "mov ebp, esp" inside the `someProcedure`.

After the instruction "mov ebp, esp", the base pointer (`ebp`) will be pointing to the beginning of the current stack frame of the `someProcedure`.

1) [ebp + 4] - This would be the value stored at the memory location `ebp + 4` in the current stack frame. This corresponds to the memory location just above the stored previous value of `ebp`. So, this points to the previous value of `ebp`.

2) [ebp + 8] - This would be the value stored at the memory location `ebp + 8` in the current stack frame. This corresponds to the memory location where the return address from `someProcedure` is stored. So, this points to the return address from `someProcedure`.

3) [ebp + 10] - This would be the value stored at the memory location `ebp + 10` in the current stack frame. This does not correspond to any specific variable or value in the given code, and it's not mentioned in the options, so it's not matched to any of the provided values.

4) [ebp + 12] - This would be the value stored at the memory location `ebp + 12` in the current stack frame. This does not correspond to any specific variable or value in the given code, and it's not mentioned in the options, so it's not matched to any of the provided values.

5) [ebp] - This would be the value stored at the memory location `ebp` in the current stack frame. This corresponds to the memory location where the previous value of `ebp` is stored (just before `mov ebp, esp`), so this points to the previous value of `ebp`.

6) [ebp + 6] - This would be the value stored at the memory location `ebp + 6` in the current stack frame. This does not correspond to any specific variable or value in the given code, and it's not mentioned in the options, so it's not matched to any of the provided values.

Based on this analysis, the correct matches are:

1) [ebp + 4] - a. The previous value of EBP

2) [ebp + 8] - b. the return address from someProcedure

The other options (3, 4, 6) do not correspond to any specific values in the given code. Therefore, the answer is:

g. none of these

Step-by-step explanation:

User Vijay Joshi
by
8.2k points