Normally I would terminate my programm with
li $v0, 10
syscall
Now I've seen many code examples where they terminate the programm by jumping back to the $ra register.
jr $ra
Why is this possible to terminate the program like this? Does it depend on the compiling program?
Recent main I've looked in:
main:
addi $sp, $sp, -4 # save return adress
sw $ra, 0($sp)
lw $a0, x #get some arguments for a function called exp
lw $a1, n #get more args
jal exp #call the function
move $s1, $v0
move $a0, $s1
li $v0, 1 #print return value
syscall
lw $ra, 0($sp) #here we load the ra for the jr
addi $sp, $sp, 4
jr $ra