Question: Write a MIPS program called recurse.s that computes f(N), where N is an integer greater than zero that is input to the program. f(N) =

Write a MIPS program called recurse.s that computes f(N), where N is an integer greater than zero that is input to the program. f(N) = 3*(N-1)+f(N-1)+1. The base case is f(0)=2. Your code must be recursive, and it must follow proper MIPS calling conventions. The key aspect of this program is to teach you how to obey calling conventions; code that is not recursive or that does not follow MIPS calling conventions will be severely penalized (-75% penalty)! Your program should prompt the user for the value of N via the console and receive input from the user via the console using syscalls.

Note: the calling conventions must be followed in every function, including main! Your main function should return (jr $ra) when finished rather than using the exit syscall. Caller- and callee-saved registers should be saved as needed at the appropriate times. There should be no data sharing via registers between functions other than $a for arguments and $v for return values.

You will upload recurse.s into Sakai (via Assignments). The following tests cases are provided:

Test #

Input

Expected output file

What is tested

0

1

recurse_expected_0.txt

input of 1

1

2

recurse_expected_1.txt

recursion of 2

2

3

recurse_expected_2.txt

deeper recursion

3

4

recurse_expected_3.txt

even more recursion

Please I need help with my homework and this has to be in MIPS language. Thank you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Writing a recursive MIPS program requires understanding of both recursion and MIPS calling conventio... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!