有人可以告诉我我的 MIP 翻译成英文是否好?

can someone tell me if my MIPs translation into english is good?

sll $t0, $s0, 2     #$t0 = f*4
add $t0, $s6, $t0   #$t0 = A[0+f]
sll $t1, $s1, 2     #$t1 = g*4
add $t1, $s7, $t1   #$t1 = B[0+g]
lw $s0, 0($t0)      #f = A[f], f becomes base array value of A + 0 
addi $t2, $t0, 4    #$t2 = A[f+4]
lw $t0, 0($t2)      #A[f] = A[f+4], (the stuff located at the base value of A[f+4+0] is stored in A[f])
add $t0, $t0, $s0   #A[F] = f(which == A[f])
sw $t0, 0($t1)      #B[g] = A[f]

我只是在学习 MIPS,我认为我在注释“#”之后列出的内容是正确的,但我的 mips 编译器无法处理它。不,我不确定代码应该做什么。我在 class 中得到它,我只是想翻译它,这样我就可以知道发生了什么,因为任务是将代码简化为更少的 MIP 指令。谢谢。

假设在 $s0$s1 中有整数值 fg 以及指向数组 A 和 [=16= 的指针] 在 $s6$s7 中,它们是 4 字节整数数组,那么这是:

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)      # $s0 = A[f]
addi $t2, $t0, 4    # $t2 = &A[f+1]
lw $t0, 0($t2)      # $t0 = A[f+1]
add $t0, $t0, $s0   # $t0 = A[f+1] + A[f]
sw $t0, 0($t1)      # B[g] = A[f+1] + A[f]

所以所有这些代码归结为单个赋值 B[g] = A[f+1] + A[f]