title: GCD mips program that starts an infinite loop
body: <p>I'm having an issue with with my stack I believe.  I ran it a couple times step by step and each time it got to this section it would work fine until the branch which finding the number not equal to zero continue to "repeat" but it would just jump back to "GCD" without any change in the stack or arguments and thus starting the infinite loop.
  I tried putting a "#" in front of the first "jal GCD" under repeat but the program would stop after reaching "lw $a2, 8($s1)" and give me an exception.  What can I do so that the quotient replaces argument 2 and can continue to search for the GCD? </p>
  
  <pre><code>GCD: 
  addi $sp, $sp, -16  #   
  sw $ra, 0($sp)      #set stack
  sw $s0, 4($sp)      #
  sw $a1, 8($sp)      #
  sw $a2, 12($sp)     #
  
  div $a1, $a2        #n1/n2
  mfhi $s1
  bnez $s1, repeat    #repeat until equals 0
  
  addi $v0, $a2, 0
  addi $sp, $sp, 16
  
  jr $ra          #return gcd
  
  repeat:
  jal GCD
  lw $a1, 4($sp)
  lw $a2, 8($s1)
  jal GCD
  lw $a1, 4($sp)
  lw $a2, 8($sp)
  jr $ra
  </code></pre>