sext.b
Sign-extend byte
- Extension
- Zbb
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
sext.b xd, xs1- Length
- 32-bit
Encoding
| 3120 | 1915 | 1412 | 117 | 62 | 10 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 011000000100 | rs1 | 001 | rd | 00100 | 11 | ||||||||||||||||||||||||||
Match 0x60401013, mask 0xfff0707f. Source: sext.b rd rs1 31..20=0x604 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 byte in the source to XLEN by copying the most-significant bit in the byte (i.e., bit 7) to all of the more-significant bits.
Description from riscv-unified-db, reformatted.
Operation
if (xlen() == 32) {
X[xd] = {{24{X[xs1][7]}}, X[xs1][7:0]};
} else if (xlen() == 64) {
X[xd] = {{56{X[xs1][7]}}, X[xs1][7:0]};
}Pseudocode in riscv-unified-db’s IDL, quoted unchanged.