title: Changing C to MIPS
body: <p>Trying to change the following C code into MIPS Assembly. I know it is very basic code, however my professor has yet to show us any of this...</p>
  
  <pre><code>void main(){
     int sum = 0;
     int high = 0;
     int array[5];
  
     for(int i = 0; i&lt;5; i++){
        array[0] = i;
        sum = sum + i;
     }
     if(sum &gt;10)
        high = 1;
     else
        high = -1;
  }
  </code></pre>
  
  <p>This is the MIPS code. I am not sure why it is not working correctly.</p>
  
  <pre><code>        .data
  sum:    .word 0
  high:   .word 0
  array:  .word 0 0 0 0 0
  
      .text
      li $t0, 5   # constant for loop
      li $t1, 0   # counter
  
  for:    lw $t1, array
      add sum, $t1, sum
      add $t1, 1, $t1
      blt $t1, $t0, for
  
      bgt sum, 10 , if
  
  if: lw high, 1
  
      ble sum, 10, else
  
  else:   lw high, -1
  
      sw sum, high, array
  </code></pre>