Crossware

Table of Contents        Previous topic       Next topic       

MICROPROCESSOR INSTRUCTION REFERENCE->CAS

CAS    Compare and Swap with Operand

Compatibility: 68020 only


Destination - Compare Operand -> Condition Codes
If Zero Flag set, Update Operand -> Destination
else              Destination -> Compare Operand

Assembler Syntax:    CAS Dc,Du,<ea>

Size: Byte, Word, Long

The effective address operand is compared with the compare operand (Dc).  If the operands are equal, the update operand (Du) is written to the effective address operand, otherwise the effective address operand is written to the compare operand (Dc).

Condition Codes:

N    Set if result negative, else cleared
Z    Set if result zero, else cleared
V    Set if overflow, else cleared
C    Set if borrow generated, else cleared
X    Not affected
This instruction is not supported by CPU32 based microcontrollers.

    
Allowable Addressing Modes
    
CASDc,Du,(An)
CASDc,Du,(An)+
CASDc,Du,-(An)
CASDc,Du,(d16,An)
CASDc,Du,(d8,An,Xn)
CASDc,Du,(bd,An,Xn)
CASDc,Du,([bd,An,Xn],od)
CASDc,Du,([bd,An],Xn,od)
CASDc,Du,(xxx).W
CASDc,Du,(xxx).L

Du specifies the data register that contains the update value to be written to memory if the comparison is successful.  Dc specifies the data register that contains the value to be compared with the memory operand.