Professional Documents
Culture Documents
Language of The Machine Function Calling
Language of The Machine Function Calling
Language of The Machine Function Calling
• slow way:
1008 addi $ra,$zero,1016 #$ra=1016
1012 j sum #go to sum
• Step 1 (link):
Save address of next instruction into $ra (Why?)
• Step 2 (jump):
Jump to the given label
stack
• C Procedure Call Frame grows
Address
• Pass arguments ($a0- high
$a3 ) ...
• Save caller-saved regs $fp
saved $a0-a3
• call function: jal $ra
• space on stack ($sp-n) Saved
$sp@last word of frame Registers
• Save callee-saved regs Local
• set $fp ($sp+n-4) Variables
$sp
$fp@first word of frame
low
CWRU EECS 322 26
MIPS Register Summary