CP
Comparison
\(A - s\)
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |
---|---|---|---|---|---|---|---|---|
CP r | ||||||||
1 | 0 | 1 | 1 | 1 | r | |||
CP n | ||||||||
1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | FE |
n | ||||||||
CP (HL) | ||||||||
1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | BE |
CP (IX+d) | ||||||||
1 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | DD |
1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | BE |
d | ||||||||
CP (IY+d) | ||||||||
1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | FD |
1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | BE |
d |
Register | r |
---|---|
B | 000 |
C | 001 |
D | 010 |
E | 011 |
H | 100 |
L | 101 |
A | 111 |
Flags Affected
Flags |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
s | set if result negative | ||||||||
z | set if result is 0 | ||||||||
h | set if borrow from bit 4 | ||||||||
p/v | set if overflow | ||||||||
c | set if borrow |
Opcode Matrix
A | B | C | D | E | H | L | (HL) | (IX+d) | (IY+d) | n | |
---|---|---|---|---|---|---|---|---|---|---|---|
Op |
CP A
BF14 |
CP B
B814 |
CP C
B914 |
CP D
BA14 |
CP E
BB14 |
CP H
BC14 |
CP L
BD14 |
CP (HL)
BE17 |
CP (IX+d)
DDBEnn319 |
CP (IY+d)
FDBEnn319 |
CP n
FEnn27 |
Instruction
Opcode hexSize bytesCycle count
| Register | Memory | Implicit |
Last modified November 16, 2021: Add flags to math operations (63d34c2)