CSE 230 - MIPS Procedure Calls
CSE 230 - MIPS Procedure Calls
high address
Stack Space for saved procedure information
$sp (Note: the stack is up side down.)
stack
pointer Heap Explicitly created space, (e.g., malloc() in C)
Static Variables declared once per program
Code Programs
reserved
address 0
Register Spilling using Stack
• Stack – Last In First Out Structure
• Stack Pointer ($sp) – Always points to last used space in Stack
• Register Spilling – Write data from Registers to Memory
• To Push to stack
• Decrement $sp
• Write to Memory (using $sp as reference)
• To Pop or retrieve from Stack
• Read from Memory (using $sp as reference)
• Increment $sp
Register Spilling using Stack
lw $s0, 0($sp)
lw $t0, 4($sp)
lw $t1, 8($sp)
addi $sp, $sp, 12
Zylab Demo
• MIPS Code:
Exit:
Zylab Demo
• MIPS Code: