c.jal
Jump and Link
- Extension
- C
- XLEN
- RV32 only
- Assembly (riscv-unified-db)
c.jal imm- Length
- 16-bit (compressed)
Encoding
| 1513 | 122 | 10 | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 001 | imm[11|4|9:8|10|6|7|3:1|5] | 01 | |||||||||||||
Match 0x2001, mask 0xe003. Source: c.jal c_imm12 1..0=1 15..13=1 in riscv-opcodes/extensions/rv32_c.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| imm[11|4|9:8|10|6|7|3:1|5] | 12:2 | c_imm12 |
Description
C.JAL is an RV32C-only instruction that performs the same operation as C.J, but additionally writes the address of the instruction following the jump (pc+2) to the link register, x1.
It expands to jal x1, offset.
Description from riscv-unified-db, reformatted.
Operation
if (implemented?(ExtensionName::C) && MISA_CSR_IMPLEMENTED && (CSR[misa].C == 1'b0)) {
reserved_instruction($encoding);
}
XReg return_addr = $pc + 2;
X[1] = return_addr;
jump_halfword($pc + $signed(imm));Pseudocode in riscv-unified-db’s IDL, quoted unchanged.