jal

Jump and link

Saves the return address in $ra and jumps to label, the usual way to call a function.

Forms

  • jal

Operands

label
A named address in the program, such as the start of a loop or a variable in .data.

The standard function-call instruction in MIPS. The called function returns with 'jr $ra'. Same address-range restriction as 'j'.

# jal calls a local routine and saves the return address in $ra. Inspect $t2: 1 after return.
jal routine
li $t2, 1
b done # Skip the routine after returning.
routine: li $t2, 2
jr $ra # Return to the instruction after the call.
done: