c.sb

Store unsigned byte, 16-bit encoding

This instruction is defined by:

  • anyOf:

    • Zcb, version >= 0

    • Zce, version >= 0

This instruction is included in the following profiles:

Encoding

svg

Assembly format

c.sb rs2, imm(rs1)

Synopsis

Stores a 8-bit value from register rs2 into memory. It computes an effective address by adding the zero-extended offset, to the base address in register rs1. It expands to sb rs2, offset(rs1).

Access

M HS U VS VU

Always

Always

Always

Always

Always

Decode Variables

Bits<2> imm = {$encoding[5], $encoding[6]};
Bits<3> rs2 = $encoding[4:2];
Bits<3> rs1 = $encoding[9:7];

Execution

  • IDL

if (implemented?(ExtensionName::C) && (CSR[misa].C == 1'b0)) {
  raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
XReg virtual_address = X[rs1 + 8] + imm;
write_memory<8>(virtual_address, X[rs2 + 8][7:0], $encoding);

Exceptions

This instruction may result in the following synchronous exceptions:

  • IllegalInstruction

  • LoadAccessFault

  • StoreAmoAccessFault

  • StoreAmoAddressMisaligned

  • StoreAmoPageFault