ARM / OFFLINE REFERENCE

On this page
← Home

RCWSCAS, RCWSCASA, RCWSCASAL, RCWSCASL

Read check write software compare and swap doubleword in memory

This instruction 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 and RCWS Checks. If the compare fails, the RCW Checks fail, or the RCWS Checks fail, the architecture permits writing the value read from the location to memory. 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.


Note

This instruction is for performing atomic updates of translation table entries and not for general use.


Integer class
(FEAT_THE)

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 0 1 1 0 0 1 A R 1 Rs 0 0 0 0 1 0 Rn Rt
S

RCWSCAS encoding

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

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

RCWSCASA encoding

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

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

RCWSCASAL encoding

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

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

RCWSCASL encoding

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

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

Decode (all encodings)

if !IsFeatureImplemented(FEAT_THE) then EndOfDecode(Decode_UNDEF); end;
let s : integer{} = UInt(Rs);
let t : integer{} = UInt(Rt);
let n : integer{} = UInt(Rn);
let soft : boolean = TRUE;

let acquire : boolean = A == '1' && s != 31;
let release : boolean = R == '1';
let tagchecked : boolean = 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(); end;
var address : bits(64);
let newdata : bits(64) = X{}(t);
let compdata : bits(64) = X{}(s);
var readdata : bits(64);
var nzcv : bits(4);

let accdesc : AccessDescriptor = CreateAccDescRCW(MemAtomicOp_CAS, soft, acquire,
                                                  release, tagchecked, t, s);

if n == 31 then
    CheckSPAlignment();
    address = SP{64}();
else
    address = X{64}(n);
end;

(nzcv, readdata) = MemAtomicRCW{64}(address, compdata, newdata, accdesc);

PSTATE.[N,Z,C,V] = nzcv;
X{64}(s) = readdata;   // Return the old value when s!=31

Version 2026.09 — Copyright © 2010-2026 Arm Limited or its affiliates.

This site is provided as a community resource and is NOT affiliated with nor endorsed by Arm Limited.