So your program starts execution at the beginning of the .text
segment and continues straight onto the line jal GCD
after the L
label.
Next your program jumps to the GCD
label where it executes until the jr $ra
which makes it return to the jal
which has as its next instruction of course GCD
. This causes the infinite loop.
So the problem here is that you have inserted the GCD
function in the middle of your main function. Generally speaking it is always an error to jal
to the next line.
So you should move the definition of GCD
elsewhere and consider what it is that you would like to run after returning from this function.