Z8 Microcontrollers
Instruction Descriptions and Formats ZiLOG
12-22 UM001601-0803
CP
COMPARE
CP
Compare
CP dst, src
Instruction Format:
Operation:
dst - src
The source operand is compared to (subtracted from) the destination operand, and the appropriate flags are set
accordingly. The contents of both operands are unaffected.
Note:
Address modes R or IR can be used to specify a 4-bit Working Register. In this format, the source or destination
Working Register operand is specified by adding 1110B (EH) to the high nibble of the operand. For example, if
Working Register R12 (CH) is the destination operand, then ECH will be used as the destination operand in the Op
Code.
Example:
If Working Register R3 contains 16H and Working Register R11 contains 20H, the statement:
CP R3, R11
Op Code: A2 3B
sets the C and S Flags, and the Z and V Flags are cleared.
Flags: C: Cleared if there is a carry from the most significant bit of the result. Set otherwise indicating a borrow.
Z: Set if the result is zero; cleared otherwise.
S: Set if result bit 7 is set (negative); cleared otherwise.
V: Set if arithmetic overflow occurs; cleared otherwise.
D: Unaffected
H: Unaffected