CP

CP is a subtraction from A that doesn't update A, only the flags it would have set/reset if it really was subtracted.

Syntax

CP op8

op8 is any one of the allowed inputs.

Allowed instructions

cp a
cp b
cp c
cp d
cp e
cp h
cp l
cp ixh
cp ixl
cp iyh
cp iyl
cp (hl)
cp (ix+n)
cp (iy+n)
cp n        ;8 bit constant

Effects

C, S, and Z flags modified by definition
P/V detects overflow

Uses

Here are some general rules on using CP

Unsigned

If A == N, then Z flag is set.
If A != N, then Z flag is reset.
If A < N, then C flag is set.
If A >= N, then C flag is reset.

Signed

If A == N, then Z flag is set.
If A != N, then Z flag is reset.
If A < N, then S and P/V are different.
A >= N, then S and P/V are the same.

T-States

r denotes 8-bit register.

r 4
X 7
(hl) 7
(ix+X) 19
(iy+X) 19

See also

BIT,CALL,CPD,CPDR,CPI,CPIR,JP,JR,RET

Unless otherwise stated, the content of this page is licensed under GNU Free Documentation License.