title: Adding integer value to an array?
body: <p>I am new to MIPS and do not understand what is going on here:</p>
  
  <p>Suppose word array A stores 0,1,2,3,4,5,6,7,8,9, in this order. Assume the starting address of A is in $s0. After the following instructions, what will be the values this array?</p>
  
  <pre><code>addi $t0, $s0, 32
  lw $t1, 0($t0)
  sw $t1, 4($t0)
  
  (a) 0,1,2,3,4,5,6,7,8,9
  (b) 0,1,2,3,4,5,6,7,9,9  
  (c) 0,1,2,3,4,5,6,7,8,8
  (d) None of the above.
  </code></pre>
  
  <p>The answer is "c", but I do not understand why. Here is my thought process:</p>
  
  <p>First line of code:</p>
  
  <blockquote>
    <p>Since this is an integer array, adding 32 to the address $s0 and giving it to $t0 would mean giving  the address of A[8] to $t0. A[8] because each integer requires 4 bytes, thus adding 0 to $s0 would result in the address of A[0] and adding 4 to $s0 would result in the address of A[1], and so on...</p>
  </blockquote>
  
  <p>Second line of code:</p>
  
  <blockquote>
    <p>0($t0) is referencing the first element in $t0 (which I have no idea what that is) and loading it to the register $t1.</p>
  </blockquote>
  
  <p>Third line of code:</p>
  
  <blockquote>
    <p>The address of $t1 is stored in memory to the first element of $t0, which is symbolized by 4($t0).</p>
  </blockquote>
  
  <p>Again, the above is my thought process, which is most likely wrong</p>