RISC-V ADDW Instruction Details
Instruction ManualR-typeAdd lower 32 bits of rs1 and rs2, producing 32-bit result sign-extended to 64 bits
Instruction Syntax
Instruction Behavior
ADDW (R-type, opcode=0111011, funct7=0000000, funct3=000) adds the lower 32 bits of rs1 and rs2, ignores overflow, sign-extends the 32-bit result to 64 bits, and writes it to rd. Unlike ADD (full 64-bit operation), ADDW operates only on the lower 32 bits and sign-extends.
ADDW Decode And Execute Animation
Starts with machine-code field decoding, then shows operand reads, instruction-specific execution, and ISA-visible state update.
Concept Step: receive the 32-bit instruction encoding
The machine code is split by the current instruction format; the animation starts from encoding/decode.
This animation shows ISA-visible decode and state changes, not any specific CPU pipeline, cache, prediction, or timing implementation.
Common Usage Scenarios
Understand this scenario with real code like «addw x10, x11, x12 # x10 = sign-extend((x11[31:0] + x12[31:0])[31:0])».
Understand this scenario with real code like «addw x10, x11, x12 # x10 = sign-extend((x11[31:0] + x12[31:0])[31:0])».
Pre-Use Checklist
- Verify rd, rs1, rs2 (and rs3) are valid GPRs.
- Confirm funct3 and funct7 encoding is correct.
- Check if the result affects subsequent branches or address calculations.
- Ensure the rd register is not overwritten by another instruction.