
Untitled
By: a guest on
Jun 26th, 2012 | syntax:
None | size: 0.89 KB | hits: 10 | expires: Never
stack figuration
Parameter #N
...
...
Parameter 2
Parameter 1
Return Address
Old %ebp
Local Variable 1
Local Variable 2
I have no idea what `"Old %ebp"` for.
+------------------+
+-> | prev-prev EBP |
| +------------------+
| | function param 2 |
| +------------------+
| | function param 1 |
| +------------------+
| | return address |
| +------------------+
+---| previous EBP | <-- current EBP
+------------------+
| local var 1 |
+------------------+
push ebp ; save old base pointer.
mov ebp, esp ; set new copy.
sub esp, 16h ; allocate space for local variables.
add esp, 16h ; forget about locals.
pop ebp ; restore previous value
ret ; return to calling code.
push %ebp ; save old ebp to stack, this will become old ebp
mov %esp, %ebp ; moving current base pointer to epp