jal

Jump and link

Saves the return address in a register and jumps to label, or saves it in ra when only a label is given.

RISC-V manual: jal

Forms

  • jal ,

Pseudo-instructions

The processor does not have these forms. The assembler replaces each of them with one or more real instructions. Open a row to see them.

  • Jump to statement at label and set the return address to ra

Operands

t1
Any integer register, x0 to x31, or its named alias, such as zero, t0 or t6.
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