Webcentive RISC-V Reference

c.sh

Store unsigned halfword, 16-bit encoding

Extension
Zcb
XLEN
RV32 and RV64
Assembly (riscv-unified-db)
c.sh xs2, imm(xs1)
Length
16-bit (compressed)

Encoding

1513121097654210
100011rs1′0c_uimm1rs2′00

Match 0x8c00, mask 0xfc43. Source: c.sh rs2_p rs1_p c_uimm1 1..0=0 15..13=4 12..10=3 6=0 in riscv-opcodes/extensions/rv_zcb.

FieldBitsriscv-opcodes name
rs1′9:7rs1_p
c_uimm15c_uimm1
rs2′4:2rs2_p

Description

Stores a 16-bit value from register xs2 into memory. It computes an effective address by adding the zero-extended offset, to the base address in register xs1. It expands to sh xs2, offset(xs1).

Description from riscv-unified-db, reformatted.

Operation

if (implemented?(ExtensionName::C) && MISA_CSR_IMPLEMENTED && (CSR[misa].C == 1'b0)) {
  reserved_instruction($encoding);
}

XReg virtual_address = X[creg2reg(xs1)] + imm;

write_memory(16, virtual_address, X[creg2reg(xs2)][15:0], $encoding);

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

Specification and related pages