A Function calling convention that involves pushing and popping arguments onto the Stack
Function Call Process
Caller calls callee
- Caller pushes
$ra
- Caller pushes arguments
- Callee pops arguments from the stack
- Callee performs function using temporary variables
$t0,...,$t9
- Callee pops
$ra
from the stack - Callee pushes return value onto the stack
- Callee jumps to the return address
$ra
- Caller pops return value from stack
- Caller continues its original logic
MIPS
Using a Stack, you can push and pop.
Push
# push $t0 onto the stack
addi $sp, $sp, -4
sw $t0, 0($sp)
Pop
# pop from the stack
lw $t0, 0($sp)
addi $sp, $sp, 4