amoswap.h

Atomic SWAP halfword

Atomically:

  • Load the halfword at address xs1

  • Write the sign-extended value into xd

  • Store the least-significant halfword of register xs2 to the address in xs1

Assembly format

amoswap.h xd, xs2, (xs1)

Decode Variables

Bits<5> xs2 = $encoding[24:20];
Bits<5> xs1 = $encoding[19:15];
Bits<5> xd = $encoding[11:7];

Execution

if (implemented?(ExtensionName::A) && MISA_CSR_IMPLEMENTED && CSR[misa].A == 1'b0) {
  reserved_instruction($encoding);
}
XReg virtual_address = X[xs1];
X[xd] = amo(16, virtual_address, X[xs2][15:0], AmoOperation::Swap, 1'b0, 1'b0, $encoding);

Exceptions

This instruction may result in the following synchronous exceptions:

  • IllegalInstruction

  • LoadAccessFault

  • StoreAmoAccessFault

  • StoreAmoAddressMisaligned

  • StoreAmoPageFault

Encoding

svg

Defining extension

Access

M

Always

Containing profiles

  • Mandatory: None

  • Optional: RVA23U64, RVB23U64