so I've been writing mips program that uses loops, branch, then store the values once the computation is done.
I'm not asking question directly from my coding; but, rather some general questions about the mips programming as I'm not that experienced with it.
Question is that is it possible to store word, byte (sw, sb) to a register using offset which is also a register?
What I mean by this is that when I'm using loop sometimes I want to store values in address from say 0-8 (0offset to 8th offset).
In this case, I cannot just do something like
sb $t0, 0($a0)
# assume $t0 is my value, and $a0 is the register that contains the address I want to access to
because this will always store value at the same address no matter how many times I go through the loop, and will overwrite values each time.
So is it possible to have something like this
# assume $t0 is my value, $t1 is my offset index,
# $a0 is the register that contains the address I want to access to
.... outside the loop ....
add $t1, $zero, $zero # initialize $t1=0
.... inside the loop ....
sb $t0, $t1($a0) # store $t0(byte) to 0($a0)
addi $t1, $t1, 1 # increment the value of $t1 by 1
In this case, I can store byte from 0($a0) to say 8($a0).
Another question is about using move instruction.
Are these instructions equivalent to each other?
# assume $t0 is empty register, $s0 is the target
add $t0, $s0, $zero # $t0 = $s0+0
move $t0, $s0 # $t0 = $s0
When can they be equivalent and when can't they be?
Thanks in advance and sorry for lack of explanation if the questions are confusing.
p.s. for the first question, sll or srl may be better off but if so can you give examples?