Question: 1 (Written Question). Convert the following C program to MIPS program. Assuming that i, j, k, f, are stored in registers $s0, $s1, $s2, $s3
1 (Written Question). 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. (15 pts)
1) f = k + A[7];
2) B[8] = A[i - 6];
3) f = A[B[i]-10] + 3;
2 (Written Question). Consider the following C program
for (i = 0; i < 200; i++)
{
a = a + b;
}
1)Draw a flowchart for the above program (5 pts)
2) Translate the C program to MIPS assembly code. Assume that the values of a, b, i are in registers $s0, $s1, $t0, respectively. (10 pts)
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? (10 pts)
3 (Coding Question: submit your MIPS program). Write a program in the MIPS assembly language that reads the integers 4, -4, 64679, and -64679, and loads them into registers $s0 to $s3 respectively, and then performs the following operations. Do not change values in saved registers $s0 to $s3. (20 pts)
a. Print each above integers;
b. Add $s2 and $s3, and print the result;
c. Perform logical OR on constant 4 and $s3, and print the result;
d. Shift $s3 one bit left, and then print the result;
4 (Coding Question: submit your MIPS program). Implement a MIPS assembly program that processes two integer arrays of size 20: Raw and Fresh.
The Raw array is initialized with the values {2, 17, 28, 20, 6, 51, 20, 48, 12, 54, 3, 31, 15, 22, 46, 72, 41, 39, 30, 55}. The values for Fresh array will be read in (note: add proper prompt for reading data.) All elements of Fresh will be stored in memory.
The program will output (i.e. display) the sum of two largest integers and the sum of two smallest integers of Raw and store the sum of two largest integers and the sum of two smallest integers of Fresh in memory locations right after where the last element of Fresh is stored. Test the program once and enter the Fresh arrays data of your choice. (40 pts)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
