Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a recursive MIPS program that compute x to the power y, that is, xv Write

ID: 3554588 • Letter: W

Question

Write a recursive MIPS program that compute x to the power y, that is, xv 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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote