Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a MIPS program using * Recursive Procedure Execution to perform the following tasks: * Note: * If your code runs perfectly, but you didn't

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));
}
Registers Variables
$s0 a
$s1 b
$s2 result
Example Test: If the values of $s1 and $s2 are initialized in the simulator as:
(Use the '+' button under the Registers display to initialize register values for $s1, $s2.)
Registers Data
$s01
$s12
$s20
The resultant registers are:
Registers Data
$s01
$s12
$s2-7
Important: only use the opcode below
Arithmetic:add, addi, div, mul, mult, sub
Data transfer: lb, lbu, lh, lhu, lui, lw, move, mfhi, mflo, sb, sh, sw
Logical: and, andi, nor, or, ori, slt, slti, sltiu, sltu, sll, srl
Conditional branch: beq, bgt, bge, blt, ble, bne
Unconditional jump: j, jal, jr

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

Transactions On Large Scale Data And Knowledge Centered Systems Vi Special Issue On Database And Expert Systems Applications Lncs 7600

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2012th Edition

3642341780, 978-3642341786

More Books

Students also viewed these Databases questions

Question

Define the term Working Capital Gap.

Answered: 1 week ago