CAS

CAS

Operation:
CAS Destination -- Compare Operand -->; cc;
if Z, Update Operand -->; Destination
else Destination -->; Compare Operand

Compatibility: MC68020/MC68030/MC68040

Assembler Syntax:
CAS Dc, Du, <ea>

Attributes: Size = (Byte, Word, Long)

Description: CAS compares the effective address operand to
the compare operand (Dc). If the operands are equal, the
instruction writes the update operand (Du) to the effective
address operand; otherwise, the instruction writes the
effective address operand to the compare operand (Dc).
The instruction accesses memory using locked or read-
modify-write transfer sequences. This provides a means
of synchronizing several processors.

Condition Codes:
\c32222
X Not affected.
N Set if the result is negative. Cleared otherwise.
Z Set if the result is zero. Cleared otherwise.
V Set if an overflow is generated. Cleared otherwise.
C Set if a borrow is generated. Cleared otherwise.

Instruction Format:
\i2----+2Size,-++u6Effective Address,3Mode,3Reg,-------3Du,---3Dc,

Instruction Fields:
Size field -- Specifies the size of the operation.
01 -- Byte operation.
10 -- Word operation.
11 -- Long operation.
Effective Address field -- Specifies the location of the memory
operand. Only memory alterable addressing modes are
allowed as shown:
\m3F8

Du field -- Specifies the data register that contains the update
value to be written to the memory operand location if
the comparison is successful.
Dc field -- Specifies the data register that contains the value
to be compared to the memory operand.

Notes:
The CAS and CAS2 instructions can be used to perform secure
update operations on system control data structures in
a multiprocessing environment.

In the MC68040 if the operands are not equal, the destination
operand is written back to memory to complete the locked
access.

Related Instructions:
CAS2,429
.427429