Webcentive RISC-V Reference

c.sext.b

Sign-extend byte, 16-bit encoding

Extension
Zcb
XLEN
RV32 and RV64
Assembly (riscv-unified-db)
c.sext.b xd
Length
16-bit (compressed)

Encoding

1513121097654210
100111rs1′/rs2′1100101

Match 0x9c65, mask 0xfc7f. Source: c.sext.b rd_rs1_p 1..0=1 15..13=4 12..10=7 6..5=3 4..2=1 in riscv-opcodes/extensions/rv_zcb.

FieldBitsriscv-opcodes name
rs1′/rs2′9:7rd_rs1_p

Description

Takes a single source/destination operand. This instruction sign-extends the least-significant byte of 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 (implemented?(ExtensionName::C) && MISA_CSR_IMPLEMENTED && (CSR[misa].C == 1'b0)) {
  reserved_instruction($encoding);
}

X[creg2reg(xd)] = $signed(X[creg2reg(xd)][7:0]);

Pseudocode in riscv-unified-db’s IDL, quoted unchanged.

Specification and related pages