title: Translating a C statement into MIPS assembly instructions?
body: <p>I have another homework question that, like the last question I asked on this site, wasn't explained well by the teacher nor the textbook. Here's the question:</p>
  
  <p>Translate this C statement into MIPS assembly instructions:</p>
  
  <pre><code>   B[8] = A[i-j];
  </code></pre>
  
  <p>Assume variables f, g, h, i and j and are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume the base addresses of the arrays A and B are in registers $s6 and $s7, respectively.</p>
  
  <p>Now, where I'm stuck is adding the two variables and using the result as an offset. So far, I have the following: </p>
  
  <pre><code>sub $t0, $s3, $s4 # add values to get offset amount, store in $t0
  sll $t1, $t0,2    # multiply the offset by 4, store in $t1
  </code></pre>
  
  <p>Now, I don't know if I can use <code>$t1</code> as an offset to access that array element. It looks like the textbook only uses numbers (e.g. <code>4($s7)</code>) instead of registers (e.g. <code>$t1($s7)</code>) What do I do next?</p>