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, zeroing a destination, NOP, and several assembler pseudoinstruction patterns.

ISA: x0 is hardwired to all zero bits.
Assembly 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 N/A
Role
Zero constant
Convention
Immutable
Remember This First
zero has no save responsibility in the calling convention because it always reads as 0.
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.
  • - Many pseudo instructions are expressed through zero, including mv / li / nop.

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.

What Happens Around A Call

1

zero has no save responsibility in the calling convention because it always reads as 0.

2

Its value never changes across calls.

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.