CMP

CMP

Operation:
Destination - Source -->; cc

Assembler Syntax:
CMP <ea>, Dn

Attributes: Size = (Byte, Word, Long)

Description: Subtracts the source operand from the destination
data register and sets the condition codes according to the
result; the data register is not changed. The size of the operation
can be byte, word, or long.

Condition Codes:

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 occurs. Cleared otherwise.
C Set if a borrow occurs. Cleared otherwise.

CMP A,B         signed          unsigned
-------         ------          --------
B <; A           BLT             BLO (or BCS)
B <;= A          BLE             BLS
B = A           BEQ             BEQ
B <;>; A          BNE             BNE
B >; A           BGT             BHI
B >;= A          BGE             BHS (or BCC)

TST A            signed          unsigned
-------          ------          --------
A <;  0           BLT (or BMI)    NOP
A <;= 0           BLE             BZ (or BEQ)
A =  0           BZ (or BEQ)     BZ (or BEQ)
A <;>; 0           BNZ (or BNE)    BNZ (or BNE)
A >;  0           BGT             BNZ (or BNE)
A >;= 0           BGE (or BPL)    BRA