sext.b
Sign-extend byte
This instruction is defined by:
-
anyOf:
-
B, version >= 0
-
Zbb, version >= 0
-
This instruction is included in the following profiles:
-
RVA22S64 (Mandatory)
-
RVA22U64 (Mandatory)
Synopsis
This instruction 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.
Execution
-
IDL
-
Sail
if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) {
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
if (xlen() == 32) {
X[rd] = {{24{X[rs1][7]}}, X[rs1][7:0]};
} else if (xlen() == 64) {
X[rd] = {{56{X[rs1][7]}}, X[rs1][7:0]};
}
{
let rs1_val = X(rs1);
let result : xlenbits = match op {
RISCV_SEXTB => sign_extend(rs1_val[7..0]),
RISCV_SEXTH => sign_extend(rs1_val[15..0]),
RISCV_ZEXTH => zero_extend(rs1_val[15..0])
};
X(rd) = result;
RETIRE_SUCCESS
}