![]() |
|
| << Previous | Next >> | |
| | |
CP HL,d Compare Rabbit 4000/5000 Instruction
48 d CP HL,d HL - d
(d sign-extended to 16 bits)
Description
Compares HL with the 8-bit signed value d, which is sign-extended to 16 bits. These compares are accomplished by subtracting d from HL. The result is:
HL < d : S=1, C=1, Z=0, L/V=V
HL = d : S=0, C=0, Z=1, L/V=V
HL > d : S=0, C=0, Z=0, L/V=Vwhere "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 if HL contains 0x8000 and you're comparing it to 0x01 (sign-extended to 0x0001). The result of the subtraction is 0x7FFF, which has a different sign than 0x8000.
| Rabbit Instructions | << Previous | Next >> | rabbit.com |