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

We have Function callee is called by caller as below left and there assembly cod

ID: 3752872 • Letter: W

Question

We have Function callee is called by caller as below left and there assembly code on the right: caller: push %ebp %esp, %ebp sex18,%esp mov sub mov xc(%ebp),%eax mov mov mov call 0x80483ed %eax,8x4(%esp) 0x8(%ebp),%eax %eax,(%esp) void caller(int x, int y) int z; z - callee(x,y); mov sh1l mov leave ret %eax,-9x4(%ebp) $0x2, -0x4(Kebp) -9x4(%ebp),%eax return; int callee(int x, int y) callee: if (x>y) push %ebp return x %esp, %ebp 0x8(%ebp),%eax mov mov return y; jle 8x80483fd(callee+16> mov 0x8(%ebp),%eax jmp 0x8048400 mov xc(%ebp),%eax pop ret %ebp When caller starts executing(before push %ebp), we have %esp: 0xbffff13c %ebp: Oxbffff1a8 What value does %esp get when callee starts executing?

Explanation / Answer

Answer is as follows :

According to given information, before the caller part, the %esp contians 0xbffff18c, in this first %esp is updated at instruction mov %esp,%ebp i.e. value of %ebp is transfer to %esp , means now %esp contains 0xbffff1a8.

After that %esp is updated at instruction sub $0x18,%esp, means it subtract the contents of %esp with 18 and update value of %esp. Here 0x18 is decimal value due to $ sign. So we convert it to hexadecimal i.e. 12 and 12 is equal to C.

0xbffff1a8 - 0xC = BFFFF196

in instruction mov 0xc(%ebp),eax , 0xbffff1a8 + c = 0xbffff19c i.e. value of eax

in instruction mov 0x8(%ebp),eax,  0xbffff1a8 + 8 = 0xbffff130

So after getting subtract we get 0xbffff19c - 0xbffff130 = 0xbffff16c

So when callee function starts execution the %esp contains BFFFF16C i.e. option 3

if there is any query please ask in comments..

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote