2. Translate the following code into MIPS
code.
B [0] = 5;
for (i = 1 ; i < 50 ; i = i + 2)
{
B[i] =i + B[i-1];
}
Assume the compiler associates the variable i to the register
$t0. Also, assume B is an array of integers and its address is
stored at register $s1.
# i -> $t0 # B -> $s1 li $t1, 5 sw $t1, 0($s1) # B[0] = 5; li $t0, 1 # i = 1 for: bge $t0, 50, end addi $t2, $t0, -1 sll $t2, $t2, 2 add $t2, $t2, $s1 lw $t2, 0($t2) # $t2 = B[i-1] add $t2, $t2, $t0 # $t2 = i + B[i-1] addi $t3, $t0, 0 sll $t3, $t3, 2 add $t3, $t3, $s1 sw $t2, 0($t3) # B[i] = i + B[i-1] addi $t0, $t0, 2 # i = i+2; j for end:
2. Translate the following code into MIPS code. B [0] = 5; for (i =...
Translate the following code into MIPS code. j=0; k=0; for (i = 1 ; i < 50 ; i = i + 2) { K=k+1; j = (i + j); B[k] = j; } Assume the compiler associates the variables i, j, and k to the registers $t0, $t1, and $t2 respectively. Also, assume B is an array of integers and its address is stored at register $s1. PLEASE DO NOT COPY DOWN ANOTHER SOLUTION
Translate the following code into MIPS code. Test (int i, int j) { int k; k = Double(i+1) + Double (j-10) return k; } Sub (int m) { int g; g = m + m; return g; } Assume the compiler associates the variable k to the register $s0. Assume the compiler associates the variable g to the register $t0.
Translate the following C code to MIPS assembly. Assume that the values of a, b, i, and j are in registers $s0, $s1, $t0, and $t1, respectively. Also assume that $s2 holds the base address of the array D. for (i = 0: i < a: i++) for (j = 0: j < b: j++) D[2 * j] = i + j;
IN MIPS AND MUST RUN IN QTSPIM
Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Assume that the values of a, b, i and j are stored in registers Ss0, Ss1, St0 and Stl, respectively. Also assume that register Ss2 holds the base address of the array D. for (i=0; i<a; itt) for (i-0j<b:jt+)
Using beq only, not bge! Translate the following C code to MIPS assembly code. Use a minimum number of instructions. 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 integer array D. Comments are required. for(i=1; i<a; i++) for(j=1; j<b; j++) D[2*j] = i + j;
C code to MIPS Translate the following C command into MIPS assembly. Assume that the base address of arrays A is stored in register $s1. 시 I-A[2] + 7;
Translate the following C code to MIPS assembly code. Assume that the value of i is in register $t0, and $s0 holds the base address of the integer MemArray if (i > 10) MemArray[i] = 0; else MemArray[i] = -MemArray[i];
7. Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Assume that the values of a,b, i and j are in registers Ss0, Ss1, St0, and St1, respectively. Also, assume that register SS2 holds the base address of the array D. for(i-0; i<a; i++) for(j=0 ; j<b; j++)
Translate each of the following pseudo-instructions into MIPS instructions. You should Produce a minimal sequence of MIPS instructions to accomplish the required computation. (8 Points) 1) bgt $t1, 100, Label # bgt means branch if greater than 2) ble $s2, 10, Next # ble means branch if less than or equal 3) ror $s0, $s4, 7 # ror means rotate right $s4 by 7 bits and store the result in $s0 4) neg $s5, $s4 # $s5 will have the...
Using MIPS:
Consider the following fragment of C code: for i=0: i < = 100: i = i + 1) {a[i] = b[i] + c;} Assume that a and bare arrays of words and the base address of a is in $a0 and the base address of b is in $a1. Register $t0 is associated with variable i and register $s0 with c. Write the code for MIPS. How many instructions are executed during the running of this code? How...