Question: Write a MIPSzy subroutine, power , that accepts 2 arguments x and y and computes x y . You can assume that x and y
Write a MIPSzy subroutine, power, that accepts 2 arguments x and y and computes xy. 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. 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.
Test your subroutine with the following program:
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 here
done:
DATA MEMORY:

5100 1 5104 2 5108 3 5112 5 5116 2 51201 51240 Note that your program will be tested with a main program that is similar to the above program but uses different registers. Make sure that your subroutine restores the values of all the registers that it uses to their original values before returning 5100 1 5104 2 5108 3 5112 5 5116 2 51201 51240 Note that your program will be tested with a main program that is similar to the above program but uses different registers. Make sure that your subroutine restores the values of all the registers that it uses to their original values before returning
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
