RISC-V sext-w Pseudo-Instruction Details
Assembler pseudo-instructionRV64 sign-extend-word pseudo-instruction, expanding to addiw rd, rs, 0. It takes the low 32 bits of rs and sign-extends bit 31 to XLEN.
What This Pseudo Instruction Is Saving You From Writing
RV64 32-bit integer results often need the sign-extension invariant; sext.w names the common addiw +0 use directly.
Official Semantics Checklist
Availability And Extension Conditions
- RV64I word-instruction semantics
- RV64 uses ADDIW rd, rs, 0
- The result is sign-extended from bit 31 to XLEN.
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 sext-w a real RISC-V instruction?
sext-w 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 sext-w?
This is sign extension, not zero extension; when bit31 is 1 the high bits become 1