<< Previous | Next >>

CP (IX+d)
CP (IY+d)
    Compare
    Rabbit 2000/3000/4000/5000 Instruction

Opcode
Instruction
Operation
DD BE d CP (IX+d) A - (IX+d)
FD BE d CP (IY+d) A - (HL+d)

8-Bit Access
16-Bit Unaligned
16-Bit Aligned
Rabbit 2000/3000/4000
9
n/a
n/a
Rabbit 5000
10
9
8

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

Description

Compares A with the data whose address is:

These compares are accomplished by subtracting the data from A. (This operation does not affect A.) The result is:


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

where "x" is the addressed data and "V" indicates that the overflow flag is set on an arithmetic overflow result. That is, the overflow flag is set 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 0x800.

The Rabbit 4000/5000 assemblers view "CP A,(IX+d)" and "CP (IX+d)" as equivalent instructions. The same is true for "CP A,(IY+d)" and "CP (IY+d)."


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