RCWCAS, RCWCASA, RCWCASL, RCWCASAL

Read Check Write Compare and Swap doubleword in memory reads a 64-bit doubleword from memory, and compares it against the value held in a register. If the comparison is equal, the value in a second register is conditionally written to memory. Storing back to memory is conditional on RCW Checks. If the write is performed, the read and the write occur atomically such that no other modification of the memory location can take place between the read and the write. This instruction updates the condition flags based on the result of the update of memory.

Integer
(FEAT_THE)

313029282726252423222120191817161514131211109876543210
00011001AR1Rs000010RnRt
S

RCWCAS (A == 0 && R == 0)

RCWCAS <Xs>, <Xt>, [<Xn|SP>]

RCWCASA (A == 1 && R == 0)

RCWCASA <Xs>, <Xt>, [<Xn|SP>]

RCWCASAL (A == 1 && R == 1)

RCWCASAL <Xs>, <Xt>, [<Xn|SP>]

RCWCASL (A == 0 && R == 1)

RCWCASL <Xs>, <Xt>, [<Xn|SP>]

if !IsFeatureImplemented(FEAT_THE) then UNDEFINED; integer t = UInt(Rt); integer n = UInt(Rn); integer s = UInt(Rs); boolean acquire = A == '1'; boolean release = R == '1'; boolean tagchecked = n != 31;

Assembler Symbols

<Xs>

Is the 64-bit name of the general-purpose register to be compared and loaded, encoded in the "Rs" field.

<Xt>

Is the 64-bit name of the general-purpose register to be conditionally stored, encoded in the "Rt" field.

<Xn|SP>

Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the "Rn" field.

Operation

if IsD128Enabled(PSTATE.EL) then UNDEFINED; bits(64) address; bits(64) newdata = X[t, 64]; bits(64) compdata = X[s, 64]; bits(64) readdata; bits(4) nzcv; AccessDescriptor accdesc = CreateAccDescRCW(MemAtomicOp_CAS, FALSE, acquire, release, tagchecked); if n == 31 then CheckSPAlignment(); address = SP[]; else address = X[n, 64]; (nzcv, readdata) = MemAtomicRCW(address, compdata, newdata, accdesc); PSTATE.<N,Z,C,V> = nzcv; X[s, 64] = readdata; // Return the old value when s!=31

Operational information

If PSTATE.DIT is 1, the timing of this instruction is insensitive to the value of the data being loaded or stored.


Internal version only: aarchmrs v2023-12_rel, pseudocode v2023-12_rel, sve v2023-12_rel ; Build timestamp: 2023-12-15T16:46

Copyright © 2010-2023 Arm Limited or its affiliates. All rights reserved. This document is Non-Confidential.