- Given the following C statement:
a += 2;
What is the corresponding MIPS assembly?
- Given the following C statement:
a = 3;
a = a + someArray[3];
What is the corresponding MIPS assembly? (Assume the base address of someArray is stored in $s3
.)
- Given the following assembly instructions:
addi $s6, $s6, -20
add $s6, $s6, $s1
lw $s0, 8($s6)
What is the corresponding C statement(s)?
-
Given the following 32-bit number,
1001-1110-0000-1010-0001-1100-0101-0010
, how would this be stored in MIPS memory? Be sure to annotate the relative byte addresses (you may start at 0).
Rubric (40 points)
You should have read about addi
, constants, and register $zero
.
-
addi $s0, $s0, 2
-
addi $s0, $zero, 3
lw $t0, 12($s3)
add $s0, $s0, $t0
- Note that the variable names are arbitrary for this exercise.
x = x - 20;
x = x + y;
z = someArrayOfCandy[2];
- MIPS is 32-bit, byte-addressed big-endian. Therefore:
Address |
0 |
1 |
2 |
3 |
Value |
1001-1110 |
0000-1010 |
0001-1100 |
0101-0010 |