MIPS Question: A main program will call a procedure Power for computing x^y. Currently, x is in $s0, y is in $s1. How might the program pass the parameter values to Power?
MIPS uses the jump-and-link instruction jal to call
functions.
The jal saves the return address (the address of the next
instruction) in the dedicated register $ra, before jumping to the
function.
jal is the only MIPS instruction that can access the value of the
program counter, so it can store the return address PC+4 in
$ra.
Up to four function arguments can be “passed” by placing them in argument registers $a0-$a3 before calling the function with jal.
Put power’s args in $a0-$a3
ld $a0 $s0
ld $a1 $s1
jal Power
Get Answers For Free
Most questions answered within 1 hours.