Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This problem is to be solved in MIPS assembly language and submitted as a .s file. Run on QtSpim. Write a main program that prompts

This problem is to be solved in MIPS assembly language and submitted as a .s file. Run on QtSpim.

Write a main program that prompts the user to enter a decimal integer between 1 and 12, inclusive. The main program should call a recursive function (recurse) and pass the integer as an argument to the function.

The recursive function accepts a single positive integer as an input argument and is defined as:

recurse(n) = 1 if n=0

recurse(n) = n * recurse(n-1) + 1 if n >0

In addition, the recursive function should print an entry message each time that the function is entered and an exit message upon each return from the recursive function.

The entry message should consist of 2n spaces (where n is the function argument), followed by Recursing , followed by the decimal value of the argument n.

The exit message should consist of 2n spaces, followed by Returning , followed by the decimal value of the returned result.

While you don't need to completely follow the MIPS procedure call conventions, you should at least save and restore any registers that are modified in your procedure and are designated as "preserved across a call" on the MIPS green card.

Make sure that you include a comment block at the head of the source file that specifies your name and explains the purpose of the program. Also comment the code to make it easier to read and follow the program logic. After you have written and tested your program using the SPIM simulator, submit a text-only version of the source code with a .s file extension.

The figures below show output for inputs 0 and 7, respectively.

Enter an integer between 0 and 12: 0

Recursing 0

Returning 1

Goodbye

Enter an integer between 0 and 12: 7

Recursing 7

Recursing 6

Recursing 5

Recursing 4

Recursing 3

Recursing 2

Recursing 1

Recursing 0

Returning 1

Returning 2

Returning 5

Returning 16

Returning 65

Returning 326

Returning 1957

Returning 13700

Goodbye

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions

Question

Question What is an educational benefit trust and how is it used?

Answered: 1 week ago

Question

Question How are VEBA assets allocated when a plan terminates?

Answered: 1 week ago

Question

Question May a taxpayer roll over money from an IRA to an HSA?

Answered: 1 week ago