sext.h
Sign-extend halfword
- Extension
- Zbb
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
sext.h xd, xs1- Length
- 32-bit
Encoding
| 3120 | 1915 | 1412 | 117 | 62 | 10 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 011000000101 | rs1 | 001 | rd | 00100 | 11 | ||||||||||||||||||||||||||
Match 0x60501013, mask 0xfff0707f. Source: sext.h rd rs1 31..20=0x605 14..12=1 6..2=0x04 1..0=3 in riscv-opcodes/extensions/rv_zbb.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| rs1 | 19:15 | rs1 |
| rd | 11:7 | rd |
Description
Sign-extends the least-significant halfword in the source to XLEN by copying the most-significant bit in the halfword (i.e., bit 15) to all of the more-significant bits.
Description from riscv-unified-db, reformatted.
Operation
if (xlen() == 32) {
X[xd] = {{16{X[xs1][15]}}, X[xs1][15:0]};
} else if (xlen() == 64) {
X[xd] = {{48{X[xs1][15]}}, X[xs1][15:0]};
}Pseudocode in riscv-unified-db’s IDL, quoted unchanged.