main:
jal function1
#Exit Program
li $v0, 10
syscall
function1:
li $s0, 0
jal function2
jr $ra
function2:
jal external_function
beq $s0, 5, function2_end
#Run loop 5 times
addi $s0, $s0, 1
function2_end:
jr $ra
external_function:
#Does random operation
jr $ra
So this is just an example of a problem of what I am having with MIPS. I get stuck in an infinite loop because function2_end will keep on jumping to the external_function.
Is there a way to have function2_end jump back to function1, so it can exit the loop?