Memory Layout Flashcards

1
Q

What is the stack?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What happens when a function is called?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does function prologue consist of?

A

push %ebp
mov %esp, %ebp
sub $n, %esp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does function epilogue include?

A

leave
mov %ebp, %esp
pop %ebp
ret
places value at top of stack (pointed to by %esp) in instruction pointer %eip

How well did you know this?
1
Not at all
2
3
4
5
Perfectly