Chapter 3. Instruction Set
Compare Register with Accumulator
Opcode
Operand
CMP
reg
The operand must name one
of
the registers A through
E,
H or
L.
o
S
s]
Cycles:
States:
4
Addressing: regis ter
Flags: Z
,S ,P
,CY
,AC
Compare Memory with Accumulator
Opcode
Operand
CMP
M
This instruction compares the contents
of
the memory location addressed
by
the
Hand
L registers with the
contents
of
the accumulator. M
is
a symbolic reference
to
the
Hand
L register pair.
Example
1:
I
'--1_0
_____
1_~
Cycles:
States:
Addressing:
Flags:
2
7
register indirect
Z,S,P,CY,AC
Assume that the accumulator contains the value
OAH
and regi,ter E contains the value
OSH.
The instruction
CMP
E performs the following internal subtraction (remember
that
subtraction
is
actually two's complement
addition) :
Accumulator
+(
-E
Register)
00001010
11111011
00000101
+(-carry)
After the carry
is
complemented to account for the subtract operation, both the zero and carry bits arc zero,
thus indicating A greater than
E.
Example
2:
As'>ume
that the accumulator contains the value
--1
BH
and register E contains
OSH:
Accumulator
+(E
Register)
11100101
11111011
11100000
+ (--carry)
3-13