# Assuming $s0 is base address of A and $s1 is base address of B # Assuming $s2 is a lw $t0, 8($s0) # $t0 = A[2] add $s3, $s2, $t0 # $s3 = a + A[2] sw $s3, 64($t1) # B[8] = a + A[2] Answer: -------- B[8] = a + A[2];
the first symbol reads '$t0' Consider to translate the to following MIPs instructions C code. AW...
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++)
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+)
2- Consider the C++ code below. Translate the code into MIPS instructions as directly as possible. Put them in a file called program1.s. int x 20; // use $t0 to keep track of x's value /use $t1 int y = x + 5; to keep track of y's value y = y| 2; X = X &4; /use $t2 to keep track of z's value Z ~X ^ y >> 2; Z Z Run your code to make sure it...
Assignment 3 Translate the following MIPS code to C. Assume that the variables f, g, h, i and j are assigned to registers Ss0, Ss1, Ss2, Ss3 and Ss4, respectively. Assume that the base address of the arrays A and B are in registers Ss6 and $s7, respectively. addi St0, Ss6, 4 add $t1, $s6, $0 #register $0 always holds 320s sw St1, 0(Sto) add Ss0, St1, Sto
.Translate the following MIPS code into C . Let integers x, y, and z be stored in $a0, $a1, and $a2, respectively. fun: add $t0, $a0, $a1 sub $t0, $t0, $a2 add $v0, $t0, $zero jr $ra
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;
Convert the following instructions from MIPS assembly language to machine language add $50, $t0, $s3 (op code: 0, function code: 32) sub $t9, $50, $zero (op code: 0, function code: 34) addi $s2, $t0, 16 (op code: 8, function code: Does not exist for I-type instructions)
directly 3- Consider the C++ code below. Translate the code into MIPS instructions as possible. Put them in a file called program2.s. as int B[4] {300, 200, 100, 0 }; = int i = 3; B[i =BI01 + B[1] B 21; Run your code to make sure it has correct behavior. You should make sure the memory locations of the array hold the expected values. directly 3- Consider the C++ code below. Translate the code into MIPS instructions as possible....
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];
Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Register allocations - i $s0 - j $s1 - base of A[] $s2 - base of B[] $s3 2) A[3] = B[i] + B[j]; 3) i = 0; while (j != A[i]) { i++; }