Question: I: Write a MIPS program that asks the user for two number inputs (first procedure), then have it ask for a type of operations (add,

I: Write a MIPS program that asks the user for two number inputs (first procedure), then have it ask for a type of operations (add, or multiply), the second procedure should call a third procedure which actually performs the operation as requested.

Feel free to create any extra methods or variables you think you might need, you should probably store A and B in either the $s registers or $a registers (or both, depending on how you do this). Try and catch any overflow exceptions.

Hint: Do the Sri part last as its recursive and a bit tricky.

Pseudocode example:

main()

{

GetInputs();

Print(GetOps(A,B));

}

void GetInputs{

int A=ReadNumber();

int B=ReadNumber();

}

int GetOps

{

Op=ReadString();

if (Op = "add")

result = Add(A,B);

else if (Op = Sri)

result = Sri(A,B);

else

result = Multiply(A,B);

return result;

}

int Add(A, B)

{

return A + B;

}

int multiply(A, B)

{

return A*B;

}

int Sri (A,B)

{

if (A <=1) or (B<=1)

return 1;

else return A*B*Sri(A-1, B-1);

}

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!