jal
Jump and link
- Extension
- RV32I/RV64I base integer
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
jal xd, imm- Length
- 32-bit
Encoding
RV32 and RV64 form
| 3112 | 117 | 62 | 10 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| imm[20|10:1|11|19:12] | rd | 11011 | 11 | ||||||||||||||||||||||||||||
Match 0x0000006f, mask 0x0000007f. Source: jal rd jimm20 6..2=0x1b 1..0=3 in riscv-opcodes/extensions/rv_i.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| imm[20|10:1|11|19:12] | 31:12 | jimm20 |
| rd | 11:7 | rd |
RV32 and RV64 form; listed in riscv-opcodes as a pseudo-op of jal
| 3112 | 117 | 62 | 10 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| imm[20|10:1|11|19:12] | 00001 | 11011 | 11 | ||||||||||||||||||||||||||||
Match 0x000000ef, mask 0x00000fff. Source: $pseudo_op rv_i::jal jal jimm20 11..7=0x01 6..2=0x1b 1..0=3 in riscv-opcodes/extensions/rv_i.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| imm[20|10:1|11|19:12] | 31:12 | jimm20 |
Description
Jump to a PC-relative offset and store the return address in xd.
Description from riscv-unified-db, reformatted.
Operation
XReg return_addr = $pc + 4; X[xd] = return_addr; jump_halfword($pc + $signed(imm));
Pseudocode in riscv-unified-db’s IDL, quoted unchanged.