How stacks are used
A stack is used to store the sequence of return addresses when there are nested calls
The calling (outer) procedure
- pushes address in $31 onto stack
- calls the procedure ($31 contains return address)
- pops stack to restore $31 (after procedure returns)
The called procedure ... before returning
- if it has called another procedure, it overwrites $31 with a pop from the stack
- jr $31