Question: For the following C code, what is the corresponding MIPS assembly instructions. What is the total number of MIPS instructions needed to execute the function?

For the following C code, what is the corresponding MIPS assembly instructions. What is the total number of MIPS instructions needed to execute the function?

int recFunc(int a, int b){

if (b == 0)

return a;

else

return recFunc(a+1,b-1);

Translate the following loop into C. Assume the C-level integer x is held in $t1 and integer y is held in $t2. Also, assume $s0 holds the base address of the integer Array1. The base address= 0x00000000.

LOOP: addi $t1, $0, 16

lw $s1, 0($s0)

add $s1, $s1, $t1

sw $s1, 0($s0)

addi $s0, $s0, 4

addi $t2, $t1, 100

beq $t1, $s0, END

beq $t2, $t1, END

j LOOP

END:

Rewrite the loop from exercise 2 to reduce the number of MIPS instructions executed.

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!