R-type: Register-Register
Two source registers and one destination register. opcode gives the major class, while funct3 and funct7 further select the operation.
This is the RISC-V instruction format online reference page, showing 32-bit instruction layouts for R/I/S/U base formats and B/J immediate variants, including opcode, rd, rs1, rs2, funct3, funct7, and immediate field layouts. Use it to quickly identify an instruction's format, understand how machine code fields are allocated, and how related instructions are encoded.
Two source registers and one destination register. opcode gives the major class, while funct3 and funct7 further select the operation.
Contains a 12-bit immediate plus rs1/rd. Immediate arithmetic, loads, JALR, FENCE, CSR, and SYSTEM-class instructions use this layout or close variants.
Write to memory. The immediate is split (high 7 bits at 31:25, low 5 bits at 11:7).
Conditional branch format. The branch offset is encoded in 2-byte units and immediate bits are distributed across several instruction-word positions.
A 20-bit immediate occupies the upper part of the instruction word. LUI and AUIPC use this format.
The jump format used by JAL. The jump offset is encoded in 2-byte units and immediate bits are rearranged by the specification.
CSR instructions are I-type variants under the SYSTEM major opcode. The csr field occupies bits[31:20], and funct3 distinguishes read/write, set, and clear forms.
ECALL/EBREAK and related SYSTEM instructions use I-type-style encoding space, but their semantics are defined by the SYSTEM class rather than ordinary immediate arithmetic.
The C extension provides 16-bit compressed encodings to improve code density; compressed instructions are separate from the R/I/S/U base formats and B/J immediate variants shown here.
The formats page shows field positions; the immediate encoding guide explains sign extension, branch/jal offset alignment, and how each immediate bit maps into the machine word.
Open Immediate Encoding GuideThis page is organized with reference to the official RISC-V documents below for architecture, ABI, CSR, and pseudo-instruction notes; platform or OS ABI differences still need to be checked against their own specifications.
Base integer ISA, RV32/RV64, instruction formats, load/store, control flow, and atomic instruction semantics.
Privilege modes, trap entry/return, CSRs, address translation, PMP, and interrupt-related architectural state.
Assembly syntax, pseudo-instructions, common expansions, register names, and programmer-visible conventions.
Procedure calling convention, register preservation, stack alignment, ELF, DWARF, and relocation rules.