Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(1)Suppose that you are given the following program (with memory addresses shown

ID: 3670379 • Letter: #

Question

(1)Suppose that you are given the following program (with memory addresses shown on the left). What hexadecimal value does EIP hold immediately after "inc EAX" has executed?

.data
0x100   x   DWORD 153461
0x104   y   BYTE   37
0x105   z   BYTE   90


.code
main PROC
0x12   push x
0x17   mov   AH, y
0x1C   mov   AL, z
0x21   call someProcedure
0x26   inc   EAX
0x2B   mov   EBX, z
0x30   xor   EAX, EBX
0x35   exit
main ENDP
END MAIN

(2) The following instruction will increment the stack pointer (ESP) by how many bytes?

ret 11

Answer_____

(3)True or F The following two instructions are equivalent.

ret

ret 4

(4) When passing parameters to a procedure on the stack, it is usually okay to change the value of the EBP register within the procedure. True False

(5) The RET instruction (without operands) will pop how many bytes off the stack? 4 16 8 2

(6)

Given the following register states, and using Base Indexed Addressing, which of the following lines of code will move the 11th element of the list array (of DWORDs) to the EAX register?

EDX register contans the address of the first element of list.
ESI register contains the address of the eleventh element of list.
EBX register contains the value 40,

mov eax, [esi]

Explanation / Answer

1.

EIP register stores the next instruction to be executed.
So in the program it is clearly visible after instruction inc EAX, the next hexa decimal value
in EIP is 0x2B and it executes the instruction mov EBX, z

2.

Return instruction (ret) will return to return address specified by stack. The address is placed on stack by CALL instruction. CALL and RET instructions are used mainly in subroutines. CALL issued when procedure calls to a subroutine and RET issued when it returns to main program.

RET 11 instruction returns to located address but it adds 11 to the stack pointer (ESP). Therefore, ESP is increments by 11 bytes.

3.

RET instruction returns to the address specified by the top of the stack.

RET 4 also same as return but it adds 4 to the ESP that means ESP is incremented by 4 bytes.

Hence, the given statement is false.

4.

EBP is a base pointer holds the reference address. It is used when a procedure is called; it stores the address and used it when procedure call returns.

IF we change the EBP register value after the parameters passed on to stack, the reference address is changed and it goes to another address when it return from the procedure call.

Hence, the statement is false.

5.

The instruction mov eax, list[ebx] will goes to the 11th element of the list array. Because ebx contains the value of 40, it contains the address of list of elements in the array. And it is loaded into eax.

Hence, the correct option is mov eax, list[ebx]