Webcentive RISC-V Reference

c.sext.h

Sign-extend halfword, 16-bit encoding

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

Encoding

1513121097654210
100111rs1′/rs2′1101101

Match 0x9c6d, mask 0xfc7f. Source: c.sext.h rd_rs1_p 1..0=1 15..13=4 12..10=7 6..5=3 4..2=3 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 halfword of 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 (implemented?(ExtensionName::C) && MISA_CSR_IMPLEMENTED && (CSR[misa].C == 1'b0)) {
  reserved_instruction($encoding);
}

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

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

Specification and related pages