Webcentive RISC-V Reference

jalr

Jump and link register

Extension
RV32I/RV64I base integer
XLEN
RV32 and RV64
Assembly (riscv-unified-db)
jalr xd, imm(xs1)
Length
32-bit

Encoding

RV32 and RV64 form

3120191514121176210
imm[11:0]rs1000rd1100111

Match 0x00000067, mask 0x0000707f. Source: jalr rd rs1 imm12 14..12=0 6..2=0x19 1..0=3 in riscv-opcodes/extensions/rv_i.

FieldBitsriscv-opcodes name
imm[11:0]31:20imm12
rs119:15rs1
rd11:7rd

RV32 and RV64 form; listed in riscv-opcodes as a pseudo-op of jalr

3120191514121176210
000000000000rs1000000011100111

Match 0x000000e7, mask 0xfff07fff. Source: $pseudo_op rv_i::jalr jalr rs1 31..20=0 14..12=0 11..7=0x01 6..2=0x19 1..0=3 in riscv-opcodes/extensions/rv_i.

FieldBitsriscv-opcodes name
rs119:15rs1

Description

Jump to an address formed by adding xs1 to a signed offset then clearing the least significant bit, and store the return address in xd.

Description from riscv-unified-db, reformatted.

Operation

XReg addr = (X[xs1] + $signed(imm)) & ~MXLEN'1;
XReg returnaddr;
returnaddr = $pc + 4;

X[xd] = returnaddr;
jump(addr);

Pseudocode in riscv-unified-db’s IDL, quoted unchanged.

Specification and related pages