MIPS/GCC Procedure Calling Conventions (cont.)
Step-1: Establish stack frame.
- Subtract the frame size from the stack pointer. subiu $sp, $sp, <frame-size>
- Typically, minimum frame size is 32 bytes (8 words).
Step-2: Save callee saved registers in the frame.
- Register $fp is always saved.
- Register $ra is saved if routine makes a call.
- Registers $s0-$s7 are saved if they are used.
Step-3: Establish Frame pointer
- Add the stack <frame size> - 4 to the address in $sp addiu $fp, $sp, <frame-size> - 4