# 1 convert the following c program to mips program assuming that i j k f are stored i 5346464

1. Convert the following C program to MIPS program. Assuming that i, j, k, f, are stored in registers \$s0, \$s1, \$s2, \$s3 already. The base address of arrays A and B are in registers \$s4 and \$s5, respectively.

1) f = k + A;

2) B = A[i – 3];

3) f = A[B[i]-10] + 3;

2. Consider the following C program

for (i = 0; i

a = a + b;

1)Draw a flowchart for the above program

2) Translate the C program to MIPS assembly code. Assume that the values of a, b, i are in registers \$s0, \$s1, \$t0, respectively.

3) How many MIPS instructions does it take to implement the above C program? What is the total number of MIPS instructions that is executed to complete the program?

3. Convert the following C procedure into MIPS assembly code.

1)

int compare(int a, int b)

{

if (a

return 1;

else

return 0;

}

2)

int compare(int a, int b)

{

if (subit (a, b)

return 1;

else

return 0;

}

int subit (int a, int b)

{

return a-b;

}