Write a recursive MIPS program that compute x to the power y, that is, xy Write
ID: 3554739 • Letter: W
Question
Write a recursive MIPS program that compute x to the power y, that is, xy Write your recursive function in Java and show how you make the call from main(). For example, in main() you should invoke power ( ) as follows: result = power(2, 4); // returns 16 to main(). Then translate the recursive program of A. into MIPS. State the buttom of the stack address explicitly in your program. Your implementation should show explicitly all activities of the caller and caller that take place on the run - time stack using the call power (2, 4)Explanation / Answer
.IF N == 0
Mov eAx, 1
Ret
.ELSE
Mov eCx, N
Dec eCx
invoke Power, X, eCx
Imul X
.ENDIF
Ret
Power Endp
Main Proc near
invoke Power, -5, 2
Call WriteInt
Exit
Main Endp
End Main
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.