title: How to convert this mips code to C?
body: <p>I am asked to convert this mips code to c. I really worked very hard and ran this code on the Qtspim simulator. But I don't figure out how to convert to C ?</p>
  
  <p>The initial address of source array (b) is stored in $a1, and the initial address of destination array (a) is stored in $a0. The length of the array is stored in $a2 register.</p>
  
  <pre><code>      li $t0,0
        beq $a2,$0,skip
  loop: lw $t1,0($a1)
        bgt $t0,2,else
        lw $t2,-8($a0)
        lw $t3,-4($a0)
        addu $t2, $t2,$t3
        addu $t1,$t2,$t1
  else: sw $t1,0($a0)
        addiu $a0,$a0,4
        addiu $a1,$a1,4
        addiu $t0,$t0,1
        bne $t0,$a2,loop
  skip:
  </code></pre>
  
  <p>What I don't understand are</p>
  
  <pre><code>lw $t2, -8($a0) 
  </code></pre>
  
  <p>and</p>
  
  <pre><code>lw $t2, -4($a0)
  </code></pre>
  
  <p>In array structure, we know A[-2] or A[-1] is wrong. Then, how does that work ?</p>
  
  <p>Thank you in advance.</p>