Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively. Answer the following question.
1.For the following C statement, what is the corresponding MIPS assembly code?
B[8] = A[i−j]
我的過程:
sub $t0,s2,s3
lw $t0,t0($s6)
sw $t0,32($s7)
想問這樣對嗎 還是第二行應該要改成lw $t1,t0($s6)第三行改成sw $t1,32($s7)
2.For the MIPS assembly instructions below, what is thecorresponding C statement?
sll $t0, $s0, 2 # $t0 = f * 4
add $t0, $s6, $t0 # $t0 = &A[f]
sll $t1, $s1, 2 # $t1 = g * 4
add $t1, $s7, $t1 # $t1 = &B[g]
lw $s0, 0($t0) # f = A[f]
addi $t2, $t0, 4
lw $t0, 0($t2)
add $t0, $t0, $s0
sw $t0, 0($t1)
我的答案是B[4g]=A[4f+4]+f 總覺得怪怪的 想確認對不對 |