[prev] 35 [next]

Function Prologue

Before a function starts working, it needs to ...
  • create a stack frame for itself  (change $fp and $sp)
  • save the return address ($ra) in the stack frame
  • save any $s? registers that it plans to change
We can determine the initial size of the stack frame via
  • 4 bytes for saved $fp + 4 bytes for saved $ra
  • + 4 bytes for each saved $s?
Changing $fp and $sp ...
  • new $fp = old $sp - 4
  • new $sp = old $sp - size of frame (in bytes)