Question: Write a MIPSzy subroutine, power, that accepts 2 arguments x and y and computes x^y . You can assume that x and y are both
Write a MIPSzy subroutine, power, that accepts 2 arguments x and y and computes x^y . You can assume that x and y are both larger than 0. The main program passes the two parameters and receives the return value through the program stack.
addi $t0, $zero, 5100
top:
lw $t1, 0($t0)
beq $t1, $zero, done
addi $sp, $sp, -4
sw $t1, 0($sp)
addi $t2, $zero,4
addi $sp, $sp, -4
sw $t2, 0($sp)
addi $sp, $sp, -4
jal power
lw $t3, 0($sp)
sw $t3, 0($t0)
addi $sp, $sp,12
addi $t0, $t0, 4
j top
power:
*** Put your subroutine
done:
(Memory configuration)
5100 1
5104 2
5108 3
5112 5
5116 2
5120 1
5124 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
