Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MIPS Programming with procedures (You should actually simulate this program using the provided version of MARS to confirm that they work. Do not simply copy
MIPS Programming with procedures (You should actually simulate this program using the provided version of MARS to confirm that they work. Do not simply copy these from online examples or from the result of a compiler. YOU MUST COMMENT WHAT YOU ARE DOING. a. Write a MIPS program that iteratively (i.e., using a for loop) calculates the Fibonacci number, Fn, for an inputted number, N (this is the same functionality as your high-level program from HW0Q2c). Have N be an integer entered by a user and print in to the console. (See MARS lecture companion files for an example of how to read an integer in MARS and print an output.] b. Write a second MIPS program that recursively calculates Fn (i.e., using a procedure that calls itself with an updated argument). Make sure to follow the convention presented in lecture. Specifically, use the appropriate saved vs temporary registers, argument passing registers, return value registers, and a basic stack frame with appropriate alignment C. How many instructions (.e., dynamic instructions) were executed in your two different programs? Briefly show your calculations. (MARS has a tool that can count instructions, which I suggest you use to verify that your hand calculations are reasonably close.) MIPS Programming with procedures (You should actually simulate this program using the provided version of MARS to confirm that they work. Do not simply copy these from online examples or from the result of a compiler. YOU MUST COMMENT WHAT YOU ARE DOING. a. Write a MIPS program that iteratively (i.e., using a for loop) calculates the Fibonacci number, Fn, for an inputted number, N (this is the same functionality as your high-level program from HW0Q2c). Have N be an integer entered by a user and print in to the console. (See MARS lecture companion files for an example of how to read an integer in MARS and print an output.] b. Write a second MIPS program that recursively calculates Fn (i.e., using a procedure that calls itself with an updated argument). Make sure to follow the convention presented in lecture. Specifically, use the appropriate saved vs temporary registers, argument passing registers, return value registers, and a basic stack frame with appropriate alignment C. How many instructions (.e., dynamic instructions) were executed in your two different programs? Briefly show your calculations. (MARS has a tool that can count instructions, which I suggest you use to verify that your hand calculations are reasonably close.)
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