<< Previous | Next >>

CP HL,DE     Compare     Rabbit 4000/5000 Instruction

Opcode
Instruction
Operation
ED 48 CP HL,DE HL - DE

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 HL with DE. These compares are accomplished by subtracting DE from HL. The result is:


HL < DE : S=1, C=1, Z=0, L/V=V
HL = DE : S=0, C=0, Z=1, L/V=V
HL > DE : 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 set when the operands have different signs and the sign of the result is different from the argument you are subtracting from (HL in this case). For example, the overflow flag will be set after the compare instruction if HL contains 0x8000 and DE contains 0x0001. The result of the subtraction is 0x7FFF, which has a different sign than 0x8000.

This operation does not affect HL or DE.


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