Chapter
3.
Instruction
Set
DAA
operates
as
follows:
1. If the least significant four bits
of
the accumulator have a value greater than nine, or
if
the auxiliary
carry flag
is
ON,
DAA
adds
six
to the accumulator.
2.
If
the most significant four bits
of
the accumulator have a value greater than nine, or
if
the carry
flag
is
ON,
DAA
adds
six
to
the most significant four bits of the accumulator.
Example:
I
L(_)
__
O
______
O
___
O
_____
l_~
Cycles:
States:
Addressing:
Flags:
4
register
Z,S,P,CY,AC
Assume
that
the accumulator contains the value 9BH
as
a result of adding 08
to
93:
CY
AC
o 0
1001 0011
0000 1000
1001 1011
= 9BH
Since
OBH
is
greater than nine, the instruction adds six to contents of the accumulator:
CY
AC
o
1001 1011
0000
0110
1010 0001
=
AI
H
Now
that
the most significant bits have a value greater than nine, the instruction adds six to them:
CY
AC
1
1010 0001
0110 0000
0000
0001
When the DAA has finished, the accumulator contains the value
01
in
a
BCD
format; both the carry and auxiliary
carry flags are set
ON. Since the actual result of this addition
is
101, the carry flag
is
probably significant to the
program. The program
is
responsible for recovering and using this information. Notice that the carry flag setting
is
lost
as
soon
as
the program executes any subsequent instruction
that
alters the flag.
3-19