If I understand your problem correctly, you will want to use the la
(load address) instruction to get the address into a register. You will then use the lw
(load word) and sw
(store word) instructions to manipulate the data. For instance, consider the following piece of code
.data
tmpval: .word 5
__start:
sub $sp, $sp, 12
sw $ra, 0($sp) # Return addy
sw $t0, 4($sp)
sw $t1, 8($sp)
la $t0, tmpval
lw $t1, 0($t0) # $t1 == tmpval == 5
li $t1, $2 # $t1 == 2
sw $t1, 0($t0) # tmpval == 2
lw $ra, 0($sp)
lw $t0, 4($sp)
lw $t1, 8($sp)
add $sp, $sp, 12
jr $ra
So in the inner-block of code you can see that you treat $t0
(or any other register for that matter) as a memory location and work with it appropriately.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…