cp
Compare
Compares A with a register, memory byte or immediate value, setting flags as for subtraction without changing A.
- The F registerZ80 assembly
- jp, jr and the conditionsZ80 assembly
- 8-bit and 16-bit arithmetic, logic and bitsZ80 assembly
- Arrays, strings and ixZ80 assembly
- The stack, push and popZ80 assembly
- Ports: in and outZ80 assembly
- The screen, keyboard and mouse through portsZ80 assembly
- Interrupts: im, ei, di and haltZ80 assembly
- The bigger of two numbersZ80 assembly
- The largest elementZ80 assembly
- ● set from the result
- 1 always 1
Forms
-
Subtracts
rfrom A and affects flags according to the result. A is not modified. cp1 byte · 7 cyclesSubtracts (HL) from A and affects flags according to the result. A is not modified.
cp2 bytes · 7 cyclesSubtracts
nnfrom A and affects flags according to the result. A is not modified.-
Subtracts the value pointed to by IX plus
ddfrom A and affects flags according to the result. A is not modified.
Pseudo-instructions
Other spellings the assembler accepts; each form shows the instruction it becomes.
-
Subtracts
rfrom A and affects flags according to the result. A is not modified. -
Subtracts (HL) from A and affects flags according to the result. A is not modified.
-
Subtracts
nnfrom A and affects flags according to the result. A is not modified. -
Subtracts the value pointed to by IX plus
ddfrom A and affects flags according to the result. A is not modified.
Undocumented 1 row
Left out of Zilog's manual, but the Z80 runs them, and so does this emulator.
-
Subtracts
ixh/lfrom A and affects flags according to the result. A is not modified.
Pseudo-instructions · Undocumented 1 row
Other spellings the assembler accepts; each form shows the instruction it becomes. Left out of Zilog's manual, but the Z80 runs them, and so does this emulator.
-
Subtracts
ixh/lfrom A and affects flags according to the result. A is not modified.
Operands
r- An 8-bit register:
a,b,c,d,e,horl. (hl)- The byte in memory at the address stored in
hl. More nn- An 8-bit immediate value,
0to255or-128to127, written as a number, character constant or symbol. More (ix+dd)- The byte in memory at
ix + dd, whereddis a signed displacement from-128to127, for example(ix+5)or(ix-3).(iy+dd)works the same way. More ixh/l- The high or low byte of
ix:ixhorixl. Foriy, useiyhoriyl. More
.org 0x8000
ld a, 5
ld b, 3
cp b
halt