title: Unable to figure out MIPS error in MARS: Error in : invalid program counter value: 0x00000000 Go: execution terminated with errors
body: <p>I am trying to translate this simple C fragment into MIPS:</p>
  
  <pre><code>int leaf_example(int g, int h, int i, int j) {
      int f;
      f = (g + h) - (i + j);
      return f;
  }
  </code></pre>
  
  <p>This is my MIPS code:</p>
  
  <pre><code>.text
      main:
          leaf:
              addi $sp, $sp, -8   #adjust stack to make room for 3 items
              sw $t1, 8($sp)      #save register $t1 for use in memory location 8
              sw $t0, 4($sp)      #save register $t0 for use in memory location 4
              sw $s0, 0($sp)      #save register $s0 for use in memory location 0
  
              add $t0, $a0, $a1   #register $t0 contains $a0 + $a1
              add $t1, $a2, $a3   #register $t1 contains $a2 + $a3
              sub $s0, $t0, $t1   #$t0 = $t0 - $t1 -&gt; $t0 = ($a0 + $a1) - ($a2 + $a3)
  
              add $v0, $s0, $zero #copy $s0 to return register $v0
  
              #Before returning, we restore three original values of registers we pushed onto stack by popping them
              lw $s0, 0($sp)      #restore register $s0 for caller
              lw $t0, 4($sp)      #restore register $t0 for caller
              lw $t1, 8($sp)      #restore register $t1 for caller
              addi $sp, $sp, 8    #adjust stack to delete 3 items
  
              jr $ra          #jump back to calling routine
  </code></pre>
  
  <p>However, when I compile and attempt to run this, it gives me this error:</p>
  
  <p>"Error in : invalid program counter value: 0x00000000</p>
  
  <p>Go: execution terminated with errors."</p>
  
  <p>I do not understand this error at all. Can anyone point me in the right direction?</p>