Update: This due date for this assignment was extended to October 18th
[CSC 211.01] Assignment 6.Show the machine code (in binary and hex) for the following MIPS code segment.
lw $s0, 2($s7)
andi $t0, $s0, 0x8
srl $t0, $t0, 3
Translate the following C code into MIPS assembly. Assume that values of the variables a, b, c, and d are held in registers $s0, $s1, $s2, and $s3, respectively.
if (a == b) {
d = c;
} else if (a == c) {
d = b;
} else {
d = a;
}
Translate the following C code into MIPS assembly. Assume that values of the integer variables n, i, and sum are held in registers $s0, $s1, and $s2, respectively.
sum = 0;
for (i=1; i < n; i++) {
sum += i;
}
Translate the following C code into MIPS assembly. Assume that the base address of array A is held in register $s7 and that values for the variables n, i, and sum are held in registers $s0, $s1 and $s2.
sum = 0;
for (i=0; i < n; i++) {
sum += A[i];
}
Translate the following C function into MIPS assembly.
int arraysum(int array[], int size) {
int i;
int sum = 0;
for (i=0; i < size; i++) {
sum += array[i];
}
return sum;
}
Translate the following C function call into assembly. Assume $s5 contains the address of the array numbers, $s6 contains the value n, and the value total will be stored in $s7.
total = arraysum(numbers, n);
Translate the following recursive C function into MIPS assembly.
int termial(int n) {
if (n < 1) {
return 0;
} else {
return n + termial(n - 1);
}
}
This derivative work of Janet Davis and Marge Coahran, used under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License was developed in collaboration with Jerod Weinman.