Starting from:

$25

CSE3038-Homework 1 Solved

1.              For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables f, g, h, i, and j are assigned to registers $s2, $s3, $s4, $s5, and $s6, respectively. Assume that the base address of the arrays A and B are in registers $s0 and $s1, respectively.                B[i+3] = A[i+4*j];

2.              Show how the value 0xcabd1f2e would be arranged in memory of a little-endian and a big-endian machine. Assume the data is stored starting at address 0.

3.              Translate the following C code to MIPS. Assume that the variables f, g, h, i, and jare assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively. Assume that the elements of the arrays A and B are 4-byte words: B[i+j+1] = A[i+j-2] + A[i-j+1];

4.              Provide the type, assembly language instruction, and binary representation ofinstruction described by the following MIPS fields: op=0, rs=5, rt=8, rd=20, shamt=0, funct=36.

5.              For the following C statement, write a minimal sequence of MIPS assembly instructions that does the identical operation. Assume $t1 = A, $t2 = B, and $s1 is the base address of C.

                  A = C[0] << 8;

6.              Translate the following C code to MIPS assembly code. Use a minimum number ofinstructions. Assume that the values of a, b, i, and j are in registers $s0, $s1, $t0, and $t1, respectively. Also, assume that register $s2 holds the base address of the array D.

for(j=0; j<a; j++) for(i=0; i<b; i++)

D[2*i] = i + j - 5;

7.              How many MIPS instructions does it take to implement the C code from Exercise2.27? If the variables a and b are initialized to 10 and 1 and all elements of D are initially 0, what is the total number of MIPS instructions that is executed to complete the loop?

More products