<< Previous | Next >>

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

> Opcode | Instruction | Clocks | Operation
> DD BE d | CP (IX+d) | 9 (2,2,2,1,2) | A - (IX+d)
> FD BE d | CP (IY+d) | 9 (2,2,2,1,2) | A - (HL+d)

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

> #### Description

> Compares A with the data whose address is:

> - the sum of IX and the 8-bit signed displacement value d, or

> - the sum of IY and the 8-bit signed displacement value d.

> 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 assembler views "CP A,(IX+d)" and "CP (IX+d)" as equivalent instructions.The same is true for "CP A,(IY+d)" and "CP (IY+d)."

<< Previous | Next >>