Function Epilogue
Before a function returns, it needs to ...
- place the return value in
$v0 (and maybe $v1 )
- pop any pushed arguments off the stack
- restore the values of any saved
$s? registers
- restore the saved value of
$ra (return address)
- remove its stack frame (change
$fp and $sp )
- return to the calling function (
jr $ra )
Locations of saved values computed relative to $fp
Changing $fp and $sp ...
- new
$sp = old $fp + 4,
new $fp = memory[ old $fp]
|