Register Guide

RISC-V zero / x0 Register: Hardwired Zero, Discarded Writes, and Common Uses

zero is the first RISC-V register worth memorizing: reading x0 always returns 0, and writes to x0 are ignored. You will see it in comparisons against zero, writing a result to x0, NOP, and several assembler pseudoinstruction patterns.

ISA: x0 is hardwired to all zero bits.
The RISC-V Assembly Programmer's Manual: reads return 0 and writes are ignored.
Beginner rule: treat zero as a constant 0 or discard destination, never as storage.
Physical Name x0ABI Name zeroSave Rule Immutable
Role
Zero constant
Convention
Immutable
Remember This First
zero is not an ABI preservation subject: x0 is hardwired to zero by the hardware.
psABI Reference

Hardwired zero register

The psABI names x0 as zero, the immutable zero-value register. Reads always produce 0 and writes do not preserve a result.

Preserved across calls: Not applicable
RISC-V psABI integer register convention
Quick Understanding & Search Notes

zero / x0 is the RISC-V hardwired zero register. Reads always produce 0 and writes are ignored, so it is used for constant zero, zero comparisons, and discarded writebacks.

The ISA defines x0 as hardwired with all bits equal to zero.
The psABI ABI name is zero, and preservation responsibility is not applicable.

When It Fits Best

  • - Read it directly when you need the constant 0, without an extra clearing instruction.
  • - Writing a result to zero discards it on purpose.
  • - The canonical nop expansion is addi x0, x0, 0.

When Not To Use It This Way

  • - Do not treat it like a normal writable register.
  • - Do not store temporary state in it; hardware discards writes to zero.

Hardware Behavior

1

zero is not an ABI preservation subject: x0 is hardwired to zero by the hardware.

2

Regardless of which instruction executes, reading zero yields 0 and writes have no effect.

Common Patterns Built With zero

Examples explain the rule, not a complete program
addi a0, zero, 0   # a0 = 0
add  zero, a0, a1  # result is discarded
beq  a0, zero, done

FAQ

Can zero / x0 store data?

No. Reads of x0 always return 0 and writes are ignored.

Why do many instructions use x0?

x0 can act as the constant zero or as a destination that discards the writeback result.