title: mips store instruction offset, and move instruction
body: <p>so I've been writing mips program that uses loops, branch, then store the values once the computation is done.</p>
  
  <p>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.</p>
  
  <p>Question is that is it possible to store word, byte (sw, sb) to a register using offset which is also a register?</p>
  
  <p>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).</p>
  
  <p>In this case, I cannot just do something like</p>
  
  <pre><code>sb    $t0, 0($a0)
  # assume $t0 is my value, and $a0 is the register that contains the address I want to access to
  </code></pre>
  
  <p>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.</p>
  
  <p>So is it possible to have something like this</p>
  
  <pre><code># 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
  </code></pre>
  
  <p>In this case, I can store byte from 0($a0) to say 8($a0).</p>
  
  <p>Another question is about using move instruction.</p>
  
  <p>Are these instructions equivalent to each other?</p>
  
  <pre><code># assume $t0 is empty register, $s0 is the target
  add    $t0, $s0, $zero    # $t0 = $s0+0
  move   $t0, $s0           # $t0 = $s0
  </code></pre>
  
  <p>When can they be equivalent and when can't they be?</p>
  
  <p>Thanks in advance and sorry for lack of explanation if the questions are confusing.</p>
  
  <p>p.s. for the first question, sll or srl may be better off but if so can you give examples?</p>