Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Question: Right before your function f from Exercise 2.34 returns, what do we know about contents of registers \(t5, \)s3, \(ra, and \)sp? Keep in mind that we know what the entire function f looks like, but for function func, we only know its declaration.

Short Answer

Expert verified

The register ‘$ra’ returns the address of the variable. There will be no change in the value of ‘$sp,’ ‘$s3’. The register ‘$t5’ contains some random values.

Step by step solution

01

MIPS language

The language MIPS was started by John L. Hennessy, the tenth president of Stanford University, who worked in the electrical engineering and computer science department. He is the co-founder of the MIPS computer systems now known as MIPS technologies. They developed one of the first commercial RISC microprocessors. Every processor performs a different type of operation like arithmetic, and these instructions can be easily expressed by the MIPS notation. Some of the operations performed by the processors are arithmetic, data transfer, logical, conditional, and unconditional branches.

02

Contents of the registers

The function from exercise 2.34 is as follows:

int f(int a, int b, int c, int d)

{

return func(func(a,b),c+d);

}

The above function calls another function “func” inside of it, bypassing the argument, and the return value is an integer type.

Here the register ‘$ra,’ which is m, means to return the address for the variable inwhich the function is called. The registers ‘$sp’ and ‘$s3’ will have the same values they contain when the function f is called. Register ‘$t5’ contains the random value. Because the function f is not modifying the ‘$t5’but the function “func“ has permission to change it, we cannot predict the values of the register “$t5,” and the function “func” is called inside the function “f.”

The “ra” in the MIPS instruction is an instruction that means to return the address.

The “sp” in the MIPS instruction is an instruction that means the top of the stack pointer.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

For the following MIPS assembly instructions above, what is a corresponding C statement?

add f, g, h

add f, i, f

Assume \(t0 holds the value 0x00101000. What is the value of \)t2 after the following instructions?

slt \(t2, \)0, \(t0

bne \)t2, \(0, ELSE

j DONE

ELSE: addi \)t2,$t2, 2

DONE:

Question: [5] Assume for a given processor the CPI of arithmetic instructions is 1, the CPI of load/store instructions is 10, and the CPI of branch instructions is 3.

Assume a program has the following instruction breakdowns: 500 million arithmetic instructions, 300 million load/store instructions, 100 million branch instructions.

2.46.1 [5] <§2.19> Suppose that new, more powerful arithmetic instructions are added to the instruction set. On average, through the use of these more powerful arithmetic instructions, we can reduce the number of arithmetic instructions needed to execute a program by 25%, and the cost of increasing the clock cycle time by only 10%. Is this a good design choice? Why?

2.46.2 [5] <§2.19> Suppose that we find a way to double the performance of arithmetic instructions. What is the overall speedup of our machine? What if we find a way to improve the performance of arithmetic instructions by 10 times?

Implement the following C code in MIPS assembly. What is the total number of MIPS instructions needed to execute the function?

int fib(int n){

ifn==0

return 0;

else ifn=1

return 1;

else

return fibn-1+fibn-2
;

}

Question: If the current value of the PC is 0x00000000, can you use a single jump instruction to get to the PC address as shown in Exercise 2.39?

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free