RISC-V negw Pseudo-Instruction Details
Assembler pseudo-instructionRV64 word-negate pseudo-instruction, expanding to subw rd, x0, rs. It negates only the low 32 bits in two’s-complement arithmetic and sign-extends the 32-bit result to XLEN.
What This Pseudo Instruction Is Saving You From Writing
RV64 has both XLEN-wide and word operations; negw makes the common C/ABI 32-bit integer negation semantics explicit.
Official Semantics Checklist
Availability And Extension Conditions
- RV64I word-instruction semantics
- RV64 uses SUBW rd, x0, rs
- The result is computed in the low 32 bits and sign-extended; original upper bits are not preserved.
How To Read The Expansion
What You May See In objdump / Disassembly
Official References And Reading Order
This page treats pseudo-instructions as assembler-level aliases or macros: first read what real instructions they expand to, then use the official ISA manual for the behavior of those real instructions. ABI, relocation, and linker-relaxation details follow the psABI document.
When To Think Of It First
Pitfalls / Common Confusions
FAQ
Is negw a real RISC-V instruction?
negw is an assembler pseudo-instruction or alias, not a separate hardware opcode. The “Typical Real Expansion” section lists the official expansion, and behavior is defined by the expanded ISA instructions.
What is the main trap when using negw?
Applies to RV64 word-instruction semantics; on RV32 ordinary neg already covers XLEN width