Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider following procedure calls implemented in MIPS. Assume the implementation of each function in each case is unknown. Case 1: main calls function sum() and

Consider following procedure calls implemented in MIPS. Assume the implementation of each function in each case is unknown.

Case 1: main calls function sum() and sum() calls function bin(). Both sum() and bin() are void functions which take no parameters. In the body of sum(), $s1, $s2 registers are used before and after bin() function call. Function bin() also uses $s1 and $s2

Case 2: main calls function sum(int n) which returns an integer and takes an integer parameter. Function sum(int n) is described below:

int sum(int n) {

if (n == 0) { return 0;}

return n+ sum(n - 1) + sum( n - 2);

}

Case 3: main calls funcA() and funcA() calls funcB(). Both funcA() and funcB() are void functions which take no parameters. funcA() uses $a0, $s2, $t0, $t1 before and after funcB() function call. Function funcB() uses $v0, $s1, $t0, $a0, $s5.

Answer the following questions; adhere to register saving conventions when answering each problem. Each answer should contain specific register names (i.e $s1), not generalized statements like saved/temporary registers.

1. For Case 1, which registers should be pushed to the stack in the body of main?

2. For Case 2, which registers should be pushed to the stack in the body of function sum(int n)?

3. For Case 3, which registers should be pushed to stack in the body of function funcB()?

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

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions

Question

2. What are the components of IT infrastructure?

Answered: 1 week ago