Give code file one: Given code file two: 1. Please submit your work directly in
ID: 3915876 • Letter: G
Question
Give code file one:Given code file two:
1. Please submit your work directly in TRACS (using the TRACS editor) or as a text/MS-word/PDF attachment by the due date/time Please use only zip for compression Please write your name in the assignment header and as a part of the file name of any file attached 2. 3. 4. It must be your own work - a penalty of at least one grade in your final grade and a report to the Dean of Students will result from sharing work or using other people work. Please do not submit your assignment via email. If you miss the deadline, then please submit it on TRACS and send me an email notification. 5. 6. A penalty of 10% per day will be assessed for late submission. In addition, it will be graded only at the end of the semester The factorial of a non-negative integer n, denoted by n, is the product of all positive integers less than or equal ton. The textbook has an example of a recursive MIPS implementation of factorial. Additionally, a simplified version of the MIPS assembly language recursive implementation of the factorial function is attached. Trace the factorial example carefully using QTSPIM 2) a, and 1 b, is defined as the The function rmult(a, b) for two positive integers 1 following rmult(a, 1) = a; rmult(a, b) = a + rmult(a, b-1) Write a recursive version of rmult) in C or C++ and a pseudo C program (based on chapter 2 in the book) then use these programs to develop a MIPS program that gets as input two integers 0
Explanation / Answer
#====================================================================================
The C program for rmult implementation is :
#include <stdio.h>
int rmult(int a, int b)
{
if(b==1)
{
return(a);
}
else
{
return(a+rmult(a,b-1));
}
}
int main(void) {
int a,b,v1;
scanf("%d",&a);
scanf("%d",&b);
v1=rmult(a,b);
return 0;
}
#====================================================================================
Corresponding MIPS Assembly code is:
#====================================================================================
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.