<< Previous | Next >>

CP n     Compare     Rabbit 2000/3000/4000/5000 Instruction

Opcode
Instruction
Operation
FE n CP n A - n

8-Bit Access
16-Bit Unaligned
16-Bit Aligned
Rabbit 4000
4
n/a
n/a
Rabbit 5000
4
4
2

Flags ALTD IOI/IOE
S
Z
L/V
C
F
R
SP
S
D
·
·
V
·
·

Description

Compares A with an 8-bit constant n. This compare is accomplished by subtracting n from A. The result is:


A < n : S=1, C=1, Z=0, L/V=V
A = n : S=0, C=0, Z=1, L/V=V
A > n : S=0, C=0, Z=0, L/V=V

where "V" indicates that the overflow flag is set on an arithmetic overflow result. That is, the overflow flag is signalled when the operands have different signs and the sign of the result is different from the argument you are subtracting from (A in this case). For example, the overflow flag will be set if A contains 0x80 and you are comparing it to 0x01. The result of the subtraction is 0x7F, which has a different sign than 0x80.

The Rabbit 4000/5000 assemblers view "CP A,n" and "CP n" as equivalent instructions.

This operation does not affect A.


Rabbit Instructions << Previous | Next >> rabbit.com