jal
Jump and link
Saves the return address in t1 and jumps to label, or saves it in ra when only a label is given.
Used in
- if, else and jump tablesRISC-V assembly
- jal, ret and the calling conventionRISC-V assembly
- Floating point and the F and D extensionsRISC-V assembly
- A subroutine with its arguments in registersRISC-V assembly
- Stack arguments and a stack frameRISC-V assembly
- Recursion: factorial and FibonacciRISC-V assembly
- Print a nonnegative number in bases 2–36RISC-V assembly
- Drawing shapes on the screenRISC-V assembly
- A bouncing ballRISC-V assembly
- Move a square with the keyboardRISC-V assembly
Forms
jal ,
Pseudo-instructions
The assembler turns these into one or more real instructions.
-
Jump to statement at label and set the return address to ra
Operands
t1- Any integer register,
x0tox31, or its named alias, such aszero,t0ort6. label- A named address in the program, such as the start of a loop or a variable in
.data.
# jal saves the next instruction address (0x00400008) in ra. link_marker is that skipped instruction; t2 ends at 1.
.text
li t2, 0
jal ra, done
link_marker:
addi t2, t2, 100
done:
addi t2, t2, 1