186k views
0 votes
Assume esp equals 1c3fh at execution point a. Trace the following code to execution point b, then answer the questions below.

mov eax, 7
mov ebx, 11
mov ecx, 42
mov edx, 99 ; nine nine!
; execution point a
push eax
push ebx
push ecx
push edx
pop ecx
pop edx ; execution point b
pop ebx
pop eax
What is the value in the ecx register at execution point b?

a. 11
b. 7
c. 99
d. 42

User Jparaya
by
7.5k points

1 Answer

2 votes

Final answer:

At execution point b, the ecx register contains the value 99, which was the last value pushed onto the stack before the pop instruction was executed.

Step-by-step explanation:

The question involves executing a sequence of assembly language instructions and determining the value of register ecx at a specific point (execution point b).

Initially, the registers are set to the following values:

  • eax = 7
  • ebx = 11
  • ecx = 42
  • edx = 99

At execution point a, the following sequence of push and pop instructions are executed:

  1. push eax - pushes the value 7 to the stack.
  2. push ebx - pushes the value 11 to the stack.
  3. push ecx - pushes the value 42 to the stack.
  4. push edx - pushes the value 99 to the stack.
  5. pop ecx - pops the top value off the stack and into ecx, which was the last value pushed (99).
  6. pop edx - pops the next value off the stack (42) into edx.

At execution point b, just after the pop ecx instruction, the ecx register will have the value obtained from popping the stack, which is 99.

Therefore, the answer to the question of the value in the ecx register at execution point b is c. 99.

User Xeelley
by
8.3k points