Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

What factors must be present for a strong family business?

Answered: 1 week ago

Question

1 1 . 1 Define Bandwidth, Delay, Jitter and Loss?

Answered: 1 week ago