The following assembly code includes a call to the function “secretFunc” and the
ID: 3909828 • Letter: T
Question
The following assembly code includes a call to the function
“secretFunc” and the content of that same function.
a. (2 pt) What is the return address of “secretFunc” _________
b. (6 pts) Comment each line as to what it is doing. The comment
should be in plain English as shown.
004014FF push 0FFFFFF80h push -128, the 2nd parameter of “SecretFunc”
NOTE: “push 0xFFFFFF80 to the stack” is not acceptable
00401501 push 0FFFFFFFFh ___________
00401503 call secretFunc ___________
00401508 add esp, 8 ___________
0040150B mov [ebp-1], al ; declare a char in C for this
0040150E nop ---
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00401000 secretFunc
00401000 push ebp
00401001 mov ebp, esp Copy stack pointer to ebp to use as a frame pointer for this function. It references both parameters and local variables.
00401003 push ecx
00401004 movsx eax, [ebp+8]
00401008 movsx ecx, [ebp+12]
0040100C add eax, ecx
0040100E mov [ebp-1], al
00401011 mov al, [ebp-1]
00401014 mov esp, ebp
00401016 pop ebp
00401017 ret
2.) Description of Function – what does it do?
Explanation / Answer
1)
a) return address of "secretFunc: = 0x00401508
b)
00401501 push 0FFFFFFFFh ___________ push the value 0FFFFFFFFh into stack
00401503 call secretFunc ___________ jumping to label secretFunc and storing the next address as return address
00401508 add esp, 8 ___________ retaining the stack pointer position
0040150B mov [ebp-1], al ; declare a char in C for this
0040150E nop ---
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00401000 secretFunc
00401000 push ebp ________ base pointer address is stored which is retained later
00401001 mov ebp, esp Copy stack pointer to ebp to use as a frame pointer for this function. It references both parameters and local variables.
00401003 push ecx ________ ecx value is stored in stack
00401004 movsx eax, [ebp+8] ___________ 0FFFFFFFFh value is popped and stored in eax
00401008 movsx ecx, [ebp+12] ____________ 0FFFFFF80h value is popped and stored in ecx
0040100C add eax, ecx _____________ values are added and stored in eax
0040100E mov [ebp-1], al _____________ first byte of result is stored in stack
00401011 mov al, [ebp-1]
00401014 mov esp, ebp _______ starting stack pointer is retained
00401016 pop ebp ________ base pointer value is popped and stored
00401017 ret ___________ return to caller function
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.