Homework 2
Due Date: Sept 8 (wed.)
Assignment:
0 |
8 |
2 |
3 |
0 |
32 |
A[2*i] = A[2*k+j];
where the array A starts at address Astart, and variables i, j, and k are, respectively, registers $3, $4, and $5. You may use registers $6, $7, and $8 for temporary values if needed.
Instruction 1: 100011 00011 00100 00000 00000 000100
Instruction 2: 000000 01101 00000 00000 00000 001000
Instruction 3: 000000 00001 00010 00011 00000 100010
Instruction 4: 000010 00000 00000 00000 00000 00110
[2 pts]Problem C (You should be able do this problem after lecture
on wed 9/3). Convert each of the following lines of C language code
to MIPS assembly language. Note that two of the six lines are done as examples,
so you only need to do the other four (each counts half a point). The variables
"k" and "j" are stored in registers $3 and $4, respectively. You may
use register $2 for temporary storage.
bne $3,$4,Skip # if (k != j) goto Skip
add $3,$0,$0 # k = 0;
Skip:
# if (k <= j) goto Skip
slt $2,$4,$3 # if (k > j) then $2 = 1
# Otherwise, "k <= j" and $2 = 0
beq $2,$0,Skip # if (k <= j) goto Skip
add $3,$0,$0
Skip: