
12.6 8-Bit Arithmetic
(Continued)
7
6
5
4
3
2
1
0
1
1
1
0
1
1
1
0
n
Timing:
M cyclesD2
T statesD7 (4, 3)
Addressing Mode:
SourceDImmediate
DestinationDImplied
CP
n
Compare the immediate data n with the contents of the Ac-
cumulator via subtraction and return the appropriate flags.
The contents of the Accumulator are not affected.
A
b
n
S: Set if result is negative
Z: Set if result is zero
H: Set if borrow from bit 4
P/V: Set if result exceeds 8-bit 2’s
complement range
N: Set
C: Set according to borrow condi-
tion
0
7
6
5
4
3
2
1
1
1
1
1
1
1
1
0
n
Timing:
M cyclesD2
T statesD7 (4, 3)
Addressing Mode:
Immediate
MEMORY ADDRESSED ARITHMETIC
ADD
A, m1
Add the contents of the memory location m
1
to the Accumu-
lator.
A
w
A
a
m
1
S: Set if result is negative
Z: Set if result is zero
H: Set if carry from bit 3
P/V: Set if result exceeds 8-bit 2’s
complement range
N: Reset
C: Set according to carry from bit
7
0
7
6
5
4
3
2
1
1
0
0
0
0
1
1
0
ADD A, (HL)
Timing:
M cyclesD2
T statesD7 (4, 3)
Addressing Mode:
SourceDRegister Indirect
DestinationDImplied
7
6
5
4
3
2
1
0
ADD A, (IX
a
d) (for N
X
e
0)
1
1
N
X
1
1
1
0
1
ADD A, (IY
a
d) (for N
X
e
1)
1
0
0
0
0
1
1
0
d
Timing:
M cyclesD5
T statesD19 (4, 4, 3, 5, 3)
Addressing Mode:
SourceDIndexed
DestinationDImplied
ADC
A, m
1
Add the contents of the memory location m
1
plus the carry
to the Accumulator.
A
w
A
a
m
1
a
CY
S: Set if result is negative
Z: Set if result is zero
H: Set if carry from bit 3
P/V: Set if result exceeds 8-bit 2’s
complement range
N: Reset
C: Set according to carry from bit
7
0
7
6
5
4
3
2
1
1
0
0
0
1
1
1
0
ADC A, (HL)
Timing:
M cyclesD2
T statesD7 (4, 3)
Addressing Mode:
SourceDRegister Indirect
DestinationDImplied
7
6
5
4
3
2
1
0
ADC A, (IX
a
d) (for N
X
e
0)
1
1
N
X
1
1
1
0
1
ADC A, (IY
a
d) (for N
X
e
1)
1
0
0
0
1
1
1
0
d
Timing:
M cyclesD5
T statesD19 (4, 4, 3, 5, 3)
Addressing Mode:
SourceDIndexed
DestinationDImplied
SUB
m
1
Subtract the contents of memory location m
1
from the Ac-
cumulator.
A
w
A
b
m
1
S: Set if result is negative
Z: Set if result is zero
H: Set if borrow from bit 4
P/V: Set if result exceeds 8-bit 2’s
complement range
N: Set
C: Set according to borrow condi-
tion
40