Crossware

Table of Contents        Previous topic       Next topic       

MICROPROCESSOR INSTRUCTION REFERENCE->CAS2

CAS2    Compare Two Operands and Swap

Destination 1 - Compare Operand 1 -> Condition Codes
If Zero Flag set:
    Destination 2 - Compare Operand 2 -> Condition Codes
If Zero Flag set:
    Update Operand 1 > Destination 1 and Update Operand 2 > Destination 2 else:
    Destination 1 -> Compare Operand 1 and Destination 2 -> Compare Operand 2

Assembler Syntax:    CAS2 Dc1:Dc2,Du1:Du2,(Rn1):(Rn2)

Size:    Word, Long

Memory operand 1 (Rn1) is compared with compare operand 1 (Dc1).  If they are equal, memory operand 2 (Rn2) is compared with compare operand 2 (Dc2). If these are also equal, the update operands (Du1 and Du2) are written to the memory operands (Rn1 and Rn2).  If either comparison is not equal, the memory operands (Rn1 and Rn2) are written to the compare operands (Dc1 and Dc2).

This instruction is not supported by CPU32 based microcontrollers.


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


Rn1 and Rn2     specify the registers that contain the addresses of the  memory operands.  If the operands overlap in memory, the result of any memory update is undefined.

Du1 and Du2     specify the data registers that contain the update values to be written to memory if the comparisons are successful.

Dc1 and Dc2     specify the data registers that contain the values to be compared with the memory operands.