ISA & Assembly

Which describes the general-purpose integer registers of RISC-V RV32I (the 32-bit base integer instruction set)?

  1. A32 registers (x0-x31), each 32 bits wide
  2. B8 registers (x0-x7), each 32 bits wide
  3. C64 registers (x0-x63), each 64 bits wide
Show answer and explanation

Answer: A. 32 registers (x0-x31), each 32 bits wide

RV32I has 32 integer registers, x0 to x31, each 32 bits wide (the 64-bit RV64I widens them to 64 bits but keeps 32 registers). The register field in an instruction is 5 bits, which can name 2^5 = 32 registers. They also have aliases such as ra, sp and a0, whose roles are set by the calling convention. For embedded use there is RV32E with only 16 registers.

  • A. Correct. x0-x31, with x0 always 0.
  • B. Eight is close to the count of general registers in 32-bit x86.
  • C. Even the 64-bit RV64I has 32 registers.
Practice this topic Back to topic

More ISA & Assembly questions

  1. What is the relationship between assembly language and machine code?
  2. Which real instruction does the assembler use for the RISC-V pseudo-instruction "nop" (do nothing)?
  3. What is the difference between the RISC-V "add" and "addi" instructions?
  4. After running the RISC-V code above, what is the value in register a2?
  5. What does the RISC-V instruction "lw t0, 8(sp)" do?