These instructions perform the sign-extension or zero-extension of the least significant 8 bits, 16 bits or 32 bits of the source register.
These instructions replace the generalized idioms slli rD,rS,(XLEN-<size>) + srli
(for zero-extension) or slli + srai
(for sign-extension) for the sign-extension of 8-bit and 16-bit quantities, and for the zero-extension of 16-bit and 32-bit quantities.
RV32 | RV64 | Mnemonic | Instruction |
---|---|---|---|
✓ |
✓ |
sext.b rd, rs |
|
✓ |
✓ |
sext.h rd, rs |
|
✓ |
✓ |
zext.h rd, rs |