Homework 2
Due Date: 9/5 (fri.)
Assignment:
| 0 |
8 |
2 |
3 |
0 |
32 |
A[j-i] = A[2*k];
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.
000000 01101 00000 00000 00000 001000
000000 00001 00010 00011 00000 100010
000010 00000 00000 00000 00000 001100
100011 00011 00100 00000 00000 000100
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: