ISA & Assembly
What is the property of register x0 (zero) in RISC-V?
- AIt always reads as 0, and writes to it have no effect
- BIt holds the return address of a function
- CIt acts as a flag showing whether the last result was zero
Show answer and explanation
Answer: A. It always reads as 0, and writes to it have no effect
x0 always returns 0, and writes to it are ignored. Having the constant 0 always available lets "add rd, rs, x0" copy a value, "addi rd, x0, 5" set a constant, and a destination of x0 discard a result, without extra dedicated instructions. The return address goes in x1 (ra). RISC-V has no result flags; branch instructions compare two registers directly.
- A. Correct. It is a constant-zero register.
- B. The return address goes in x1 (ra).
- C. RISC-V has no flag register for results.