NEC 78K/0 Series User Manual

Page of 129
62
CHAPTER 5  EXPLANATION OF INSTRUCTIONS
User's Manual  U12326EJ4V0UM
Compare
CMP
Byte Data Comparison
[Instruction format]
CMP dst, src
[Operation]
dst – src
[Operand]
Mnemonic
Operand(dst,src)
Mnemonic
Operand(dst,src)
CMP
A, #byte
CMP
A, !addr16
saddr, #byte
A, [HL]
A, r                             
Note
A, [HL+byte]
r, A
A, [HL+B]
A, saddr
A, [HL+C]
Note  Except r = A
[Flag]
Z
AC
CY
×
×
×
[Description]
The source operand (src) specified by the 2nd operand is subtracted from the destination operand (dst)
specified by the 1st operand.
The subtraction result is not stored anywhere and only the Z, AC and CY flags are changed.
If the subtraction result is 0, the Z flag is set (1).  In all other cases, the Z flag is cleared (0).
If the subtraction generates a borrow out of bit 7, the CY flag is set (1).  In all other cases, the CY flag is
cleared (0).
If the subtraction generates a borrow for bit 3 out of bit 4, the AC flag is set (1).  In all other cases, the AC
flag is cleared (0).
[Description example]
CMP FE38H, #38H;
38H is subtracted from the contents at address FE38H and only the flags are changed
(comparison of contents at address FE38H and the immediate data).