Question: 1 2 . 1 6 Zylab 5 - Recursive Procedure Call 1 2 . 1 6 Zylab 5 - Recursive Procedure Call This lab will

12.16 Zylab 5- Recursive Procedure Call12.16 Zylab 5- Recursive Procedure Call
This lab will be available until February 23rd,11:59 PM MST
Write a MIPS program using *Recursive Procedure Execution to perform the following tasks: If your code runs perfectly, but you
didn't use Procedure Execution correctly, you will be given zero points.
Write the following functions in MIPS.
main
inputs: integers a,b
task: Compute the integer: a**F(|a+b|,|a-b|)-b**F(|b-a|,|b+a|).
recursion F(x,y)
inputs: integers x,y.
task:
F(x,y)=F(x-1,y)+F(x,y-1), if x,y>0
F(x,y)=y if x=0,y>0
F(x,y)=x if y=0,x>0
F(x,y)=0 if x,y=0
Following is a sample C code segment. You may modify the code for the functions, but the task performed should not be changed, i.e., you
should use recursive procedure calls.
int main (int a, int b){
int result =a**recursion(/abs (a+b)(,)/(a)bs (a-b))-b**recursion(/abs (b-a)(,)/(a)bs (b+a));
}
int recursion (int x, int y ){
if ( x=0 && y=0)
return (0);
else if ( x>0&y=0
return (x);should use recursive procedure calls.
int main(int a, int b){
int result =a** recursion (/abs (a+b)(,)/(a)bs (a-b))-b** recursion (/abs (b-a)(,)/(a)bs (b+a));
}
int recursion(int x, int y ){
if ( x=0 && y=0)
return (0);
else if ( x>0 && y=0)
return (x);
else if ( x=0 & & y>0)
return(y);
else
return(recursion (x-1,y)+recursion(x,y-1);
}
Example Test: If the values of $ s 1 and $$2 are initialized in the simulator as:
(Use the '+' button under the Registers display to initialize register values for $$1,$s2.)
The resultant registers are: $s2 result
Example Test: If the values of $s1 and $ s 2 are initialized in the simulator as:
(Use the '+' button under the Registers display to initialize register values for $s1,$s2.)
The resultant registers are:
Grading: Manual score (1 points) will be added after the deadline.
4 automated tests each worth 1 points. The registers $s0,$s1 and $s2 will be checked by the automated tests.
Comments specifying your choice of registers and each line of your code (0.5 points).
Correct use of Recursive Procedure Calls (0.5 points).
Submission Attempts: You will have limited number of submissions (5), i.e., only 5 attempts to compare with the automated tests, but you
can run the simulator any number of times without clicking on submit for grading. Also, the first time you open the assignment, canvas will
consider it as the first attempt even if you do not click submit to canvas.
Write a MIPS program using *Recursive Procedure Execution to perform the following tasks: *Note:* If your code runs perfectly, but you didn't use Procedure Execution correctly, you will be given zero points.
Write the following functions in MIPS.
main
inputs: integers a, b
task: Compute the integer: a * F(|a+b|,|a-b|)- b * F(|b-a|,|b+a|).
recursion F(x, y)
inputs: integers x, y.
task:
F(x, y)= F(x-1, y)+ F(x, y-1), if x, y >0
F(x, y)= y if x =0, y >0
F(x, y)= x if y =0, x >0
F(x, y)=0 if x, y =0
Following is a sample C code segment. You may modify the code for the functions, but the task performed should not be changed, i.e., you should use recursive procedure calls.
int main(int a, int b){
int result = a * recursion(abs(a+b), abs(a-b))- b * recursion(abs(b-a), abs(b+a));
}
int recursion(int x, int y){
if (x =0 && y =0)
return(0);
else if (x >0 && y =0)
return(x);
else if (x =0 && y >0)
return(y);
else
return(recursion(x-1, y)+ recursion(x, y-1));
}should use recursive procedure calls.
int main(int a, int b){
int result =a** recursion (?abs(a+b),abs(a-b))-b** recursion (?abs(b-a),abs(b+a));
}
int recursion(int x, int y){
if (x0 && y0)
return (0);
else if (x>0 && y0)
return (x);
else if (x0 & & y>0)
return(y);
else
return(recursion (x-1,y)+recursion(x,y-1);
}
Example Test: If the values of $ s 1 and $$2 are initialized in the simulator as:
(Use the '+' button under the Registers display to initialize register values for $$1,$s2.)
The resultant registers are:
 12.16 Zylab 5- Recursive Procedure Call12.16 Zylab 5- Recursive Procedure Call

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!