MIPS:如何使用循环访问一个全为零的数组

MIPS: How to access an array full of zero with loop

我有一个这样的数组:

r_clues: .word 0 : 512 #  array full of zero

我愿意

la $s0, r_clues
lw $t1, 0($s1)

我取第一个 4 字节的地址,如果我想取,例如,第 4 个地址,我会做

lw $t1, 16($s1)

因为它 4(address) * 4(bytes)

我如何通过一个循环访问这个数组并将每个 8 字节的字加载到一个寄存器?

计算元素地址和加载字。

    la $s0, r_clues            # the address
    addiu $s2, $zero, 0        # offset
    addiu $s3, $zero,  64      # number of loops
loop_begin:
    addu $s1, $s0, $s2         # address = base + offset
    lw $t1, 0($s1)             # load the array
    addiu $s2, $s2, 8          # proceed to the next element
    addi $s3, $s3, -1          # substract the counter
    bne $s3, $zero, loop_begin # if there are more elements to load, go to loop
    nop                        # prevent next instruction from being executed before exiting the loop