Stack Flashcards
Where is stack allocated?
Primary memory
___ is pushed onto the stack when function is called
stack frame
stack uses high or low memory? which direction does the stack grow towards?
high, towards 0
what does the frame pointer do?
points to local variables in a stack frame
What size of address does ARMv8 use?
64 bit
How many bytes can ARMv8 address?
2^64
What is stack?
A space in RAM provided by the OS to store data for functions
What does the stack frame hold?
A function’s parameters, lvars and return values
What happens to the stack frame when the function returns?
It is popped
What does the stack diagram look like?
Check notes
Where are programs loaded (think of stack diagram)
Into low mem, just above the space for the OS
What is the heap used for?
dynamically allocated mem in a program. done in c using malloc() and free()
Where does the stack pointer (SP) point to and what happens to it when the stack grows?
The top of the stack. It is decremented when the stack grows
How does a program allocate stack mem?
By subtracting the number of bytes needed from SP
The stack must be ____ aligned. What does this mean?
Quadword. The address in SP must be evenly divisible by 16