我有一个这样的数组:
r_clues: .word 0 : 512 # array full of zero
我做
la $s0, r_clues
lw $t1, 0($s1)
我取第一个4
个字节的地址,如果我想拿,例如,我会做的第四个地址
lw $t1, 16($s1)
因为4(address) * 4(bytes)
如何通过一个循环访问此数组并将字加载到每个8
个字节的寄存器?
答案 0 :(得分:1)
计算元素的地址和加载单词。
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