Memory Layout Flashcards
What is the stack?
Used to collect items or elements with fixed origin and variable size
Initially, the size of the stack is zero and the stack pointer (%esp) points to the top of the stack
Items are added in last in first out order (higher to lower memory addresses)
What happens when a function is called?
Frame containing
- functions actual parameters
- return address to jump to at end of function
- pointer to previous frame
- functions local variables
is pushed onto the stack
What does function prologue consist of?
push %ebp
mov %esp, %ebp
sub $n, %esp
What does function epilogue include?
leave
mov %ebp, %esp
pop %ebp
ret
places value at top of stack (pointed to by %esp) in instruction pointer %eip