# RISC-V Registers

[RISC-V Documentation](https://asm-editor.specy.app/documentation/risc-v.md)

Web page: https://asm-editor.specy.app/documentation/risc-v/registers

The general purpose registers, the FPU and the control and status registers.

34 entries, each with its own page of markdown:

- [The register files](https://asm-editor.specy.app/documentation/risc-v/registers/the-register-files.md): A RISC-V processor holds three sets of registers: the 32 general purpose ones every instruction works on, the 32 floating point registers the extension adds,…
- [General purpose registers](https://asm-editor.specy.app/documentation/risc-v/registers/general-registers.md): RISC-V has 32 general purpose registers, and with one exception the hardware treats them all alike: x0 reads as zero whatever is written to it, and the other…
- [`zero`](https://asm-editor.specy.app/documentation/risc-v/registers/general-registers-zero.md) `x0`: Always reads as 0, and writing to it is silently ignored.
- [`ra`](https://asm-editor.specy.app/documentation/risc-v/registers/general-registers-ra.md) `x1`: Return address.
- [`sp`](https://asm-editor.specy.app/documentation/risc-v/registers/general-registers-sp.md) `x2`: Stack pointer, pointing at the lowest used word of the stack.
- [`gp`](https://asm-editor.specy.app/documentation/risc-v/registers/general-registers-gp.md) `x3`: Global pointer.
- [`tp`](https://asm-editor.specy.app/documentation/risc-v/registers/general-registers-tp.md) `x4`: Thread pointer, the base of the storage private to the running thread.
- [`t0 - t2`](https://asm-editor.specy.app/documentation/risc-v/registers/general-registers-t0-t2.md) `x5 - x7`: Temporaries.
- [`s0, also written fp`](https://asm-editor.specy.app/documentation/risc-v/registers/general-registers-s0-also-written-fp.md) `x8`: The first saved register, and by convention the frame pointer: the fixed handle on the current stack frame for functions whose stack pointer moves while they…
- [`s1`](https://asm-editor.specy.app/documentation/risc-v/registers/general-registers-s1.md) `x9`: A saved register.
- [`a0 - a1`](https://asm-editor.specy.app/documentation/risc-v/registers/general-registers-a0-a1.md) `x10 - x11`: The first two arguments of a call, and the registers a result comes back in: a0 carries a single return value and a1 the second half of a pair.
- [`a2 - a7`](https://asm-editor.specy.app/documentation/risc-v/registers/general-registers-a2-a7.md) `x12 - x17`: Six more argument registers; anything beyond the eighth argument is passed on the stack.
- [`s2 - s11`](https://asm-editor.specy.app/documentation/risc-v/registers/general-registers-s2-s11.md) `x18 - x27`: Ten more saved registers, preserved across calls by whoever uses them.
- [`t3 - t6`](https://asm-editor.specy.app/documentation/risc-v/registers/general-registers-t3-t6.md) `x28 - x31`: Four more temporaries, with the same rule as t0 to t2: free to use, gone after a call.
- [Floating point registers](https://asm-editor.specy.app/documentation/risc-v/registers/fpu.md): The floating point extension adds 32 registers of its own, f0 to f31, with the same kind of ABI names as the general ones.
- [`ft0 - ft7`](https://asm-editor.specy.app/documentation/risc-v/registers/fpu-ft0-ft7.md) `f0 - f7`: Floating point temporaries, destroyed by a call like the integer ones.
- [`fs0 - fs1`](https://asm-editor.specy.app/documentation/risc-v/registers/fpu-fs0-fs1.md) `f8 - f9`: The first two floating point saved registers, preserved across calls by the function that uses them.
- [`fa0 - fa7`](https://asm-editor.specy.app/documentation/risc-v/registers/fpu-fa0-fa7.md) `f10 - f17`: The floating point arguments of a call, and in fa0 the floating point return value.
- [`fs2 - fs11`](https://asm-editor.specy.app/documentation/risc-v/registers/fpu-fs2-fs11.md) `f18 - f27`: Ten more floating point saved registers.
- [`ft8 - ft11`](https://asm-editor.specy.app/documentation/risc-v/registers/fpu-ft8-ft11.md) `f28 - f31`: Four more floating point temporaries, closing the file.
- [Control and status registers](https://asm-editor.specy.app/documentation/risc-v/registers/csr.md): Control and status registers (CSRs) hold floating point settings, trap state and counters.
- [`ustatus`](https://asm-editor.specy.app/documentation/risc-v/registers/csr-ustatus.md) `0x000`: Bit 0, UIE, enables user interrupts.
- [`fflags`](https://asm-editor.specy.app/documentation/risc-v/registers/csr-fflags.md) `0x001`: The five floating point exception flags: invalid operation, divide by zero, overflow, underflow and inexact.
- [`frm`](https://asm-editor.specy.app/documentation/risc-v/registers/csr-frm.md) `0x002`: The rounding mode the floating point instructions use when they are not given one: round to nearest with ties to even by default, with truncation and the two…
- [`fcsr`](https://asm-editor.specy.app/documentation/risc-v/registers/csr-fcsr.md) `0x003`: The floating point control and status register, which is the two registers above in one place: fflags is its low five bits and frm the three above them.
- [`uie`](https://asm-editor.specy.app/documentation/risc-v/registers/csr-uie.md) `0x004`: The source mask: bit 0 enables software interrupts, bit 4 the timer, and bit 8 external interrupts from the keyboard and display.
- [`utvec`](https://asm-editor.specy.app/documentation/risc-v/registers/csr-utvec.md) `0x005`: The address of the handler shared by exceptions and enabled interrupts.
- [`uscratch`](https://asm-editor.specy.app/documentation/risc-v/registers/csr-uscratch.md) `0x040`: A register for the handler to use freely.
- [`uepc`](https://asm-editor.specy.app/documentation/risc-v/registers/csr-uepc.md) `0x041`: The return address used by uret.
- [`ucause`](https://asm-editor.specy.app/documentation/risc-v/registers/csr-ucause.md) `0x042`: The trap cause.
- [`utval`](https://asm-editor.specy.app/documentation/risc-v/registers/csr-utval.md) `0x043`: Extra detail for the cause: the address a load or store failed on, the instruction that could not be decoded, or the external device requesting an interrupt…
- [`uip`](https://asm-editor.specy.app/documentation/risc-v/registers/csr-uip.md) `0x044`: Pending interrupt requests, using the same bits as uie.
- [`cycle, time, instret`](https://asm-editor.specy.app/documentation/risc-v/registers/csr-cycle-time-instret.md) `0xC00 - 0xC02`: Three read-only 64-bit counters.
- [`cycleh, timeh, instreth`](https://asm-editor.specy.app/documentation/risc-v/registers/csr-cycleh-timeh-instreth.md) `0xC80 - 0xC82`: The high 32 bits of cycle, time and instret for RV32.
