Frame Structure A stack frame is delimited by oebp The frame pointer %ebp es The stack pointer %oesp The stack pointer can move when the procedure is executing (/oesp Frame pointer relative accessing (ebp)
11 Frame Structure • A stack frame is delimited by – The frame pointer %ebp – The stack pointer %esp • The stack pointer can move when the procedure is executing (%esp ) • Frame pointer relative accessing (%ebp ) %ebp %esp
Frame Structure Frames are chained Old eb Old ebp b ebp Old ebp esp 12
12 Frame Structure • Frames are chained %ebp %esp Old ebp Old ebp Old ebp
Caller and callee Callero call callee(argument1,., argument)
13 Caller and Callee Caller() { call callee (argument1, … , argumentn); }
Register Usage Caller saved registers %eax % edx. %ecx saved b y caller Callee can use these registers freely The contents in these registers may be changed after return Caller must restore them if it tries to use them after calling
14 Register Usage • Caller saved registers – %eax, %edx, %ecx – Saved by caller – Callee can use these registers freely – The contents in these registers may be changed after return – Caller must restore them if it tries to use them after calling
Register Usage Callee saved registers %ebx. esi. edi Callee must save them before using Callee must restore them before return 15
15 Register Usage • Callee saved registers – %ebx, %esi, %edi – Callee must save them before using – Callee must restore them before return