Question
Please save as .s file and run in QTspim. 1. Write and debug a MIPS program that computes factorial iteratively (not recursively). This is a
Please save as .s file and run in QTspim.
1. Write and debug a MIPS program that computes factorial iteratively (not recursively). This is a MIPS program with looping.
2. You should in general be familiar with the algorithms for calculating both Factorial and Fibonacci. You must have practiced and understood the iterative Fibonacci calculation. Attached at the end of this assignment is a practice problem in both Python and MIPS assembler. Note that it would have been possible to write the Python differently to achieve the same function.
3. Begin by writing the factorial calculation in your favorite high-level programming language and including the entire program as a comment in your MIPS program like the Python code as in the practice problem. Your high-level code must work correctly for any value from 0! upward (remember that 0! =1 by definition) for answers that will fit in 32 bits. Your high level language implementation and your MIPS implementation must use the SAME algorithm (same type of loop, same number of and location of branches, no try statements etc.) You will want to use an algorithm that will minimize the number of branches necessary to make the assembly version simpler.
4. Your code should display an error message for answers that will not fit in 32 bits.
5. If you wish, you can start with the Fibonacci practice program and modify it to complete this assignment.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started