Introduction
There are 32 integer registers, x0 to x31, each as wide as the word size (XLEN: 32 or
64 bits). x0 always reads as zero and ignores writes. The program counter is a separate register
with no number. With the floating-point extensions there are 32 more registers f0 to
f31 (32, 64 or 128 bits wide: as wide as the widest of F, D and Q present), and with V there are
32 vector registers v0 to v31. The ABI names are those of the calling convention
(the RISC-V ELF psABI); the explorer writes them unless the options bar asks for numbers.
Integer registers
| Number | ABI name | Role in the calling convention | Saved by |
|---|---|---|---|
x0 | zero | Hard-wired zero | n/a |
x1 | ra | Return address | caller |
x2 | sp | Stack pointer | callee |
x3 | gp | Global pointer | n/a |
x4 | tp | Thread pointer | n/a |
x5 to x7 | t0 to t2 | Temporaries (t0 is the alternate link register) | caller |
x8 | s0 / fp | Saved register, frame pointer | callee |
x9 | s1 | Saved register | callee |
x10, x11 | a0, a1 | Arguments and return values | caller |
x12 to x17 | a2 to a7 | Arguments (a7 holds the system-call number on Linux) | caller |
x18 to x27 | s2 to s11 | Saved registers | callee |
x28 to x31 | t3 to t6 | Temporaries | caller |
The explorer writes s0, not fp. RV32E and RV64E have only
x0 to x15; an instruction that names a higher register is
reserved.
Floating-point registers
| Number | ABI name | Role |
|---|---|---|
f0 to f7 | ft0 to ft7 | Temporaries |
f8, f9 | fs0, fs1 | Saved |
f10, f11 | fa0, fa1 | Arguments and return values |
f12 to f17 | fa2 to fa7 | Arguments |
f18 to f27 | fs2 to fs11 | Saved |
f28 to f31 | ft8 to ft11 | Temporaries |
Vector registers
v0 to v31, no ABI names. v0 holds the mask for a masked instruction
(written v0.t in the operands) and is the carry or select register of vadc and
vmerge. A group of registers (LMUL 2, 4 or 8) is named by its first register.
Registers in compressed instructions
Most 16-bit instructions have room for only three bits of register number (the “primed” registers rd′, rs1′,
rs2′), which name x8 to x15 (s0, s1, a0 to
a5) or f8 to f15. Others have a five-bit register field, with a few using
sp implicitly. The Zcmp instructions cm.mvsa01 and cm.mva01s name the
s-registers by a three-bit number: 0 and 1 are s0 and s1, 2 to 7 are s2
to s7.
Control and status registers
A separate 4096-entry space of CSRs, read and written by the Zicsr instructions; see the CSR list.