DAA

Operation

@

Mnemonic

DAA

Operands

None

b7b6b5b4b3b2b1b0
0 0 1 0 0 1 1 1$27

Description

This instruction conditionally adjusts the Accumulator for BCD addition and subtraction operations. For addition (ADD, ADC, INC) or subtraction (SUB, SBC, DEC, NEG), the following table indicates the operation being performed:

OperationC before
DAA
Hex in
upper digit
(bits 7-4)
H before
DAA
Hex in
lower digit
(bits 3-0)
Number
added to
byte
C after
DAA
09-000-9000
00-80A-F060
00-910-3060
ADD0A-F00-9601
ADC09-F0A-F661
INC0A-F10-3661
10-200-9601
10-20A-F661
10-310-3661
SUB00-900-9000
SBC00-816-FFA0
DEC17-F00-9A01
NEG16-716-F9A1

Condition Bits Affected

Sis set if most-significant bit of the Accumulator is 1 after an operation, otherwise it is reset.
Zis set if the Accumulator is 1 after an operation, otherwise it is reset.
Hsee the DAA instruction table above.
P/Vis set if the Accumulator is at even parity after an operation, otherwise it is reset.
Nis not affected.
Csee the DAA instruction table above.

Example

An addition operation is performed between 15 (BCD) and 27 (BCD); simple decimal arithmetic provides the following result:

15
+27
----
42

The binary representations are added in the Accumulator according to standard binary arithmetic, as follows:

0001 0101
+ 0010 0111
------- -------
0011 1100= 3C

The sum is ambiguous. The DAA instruction adjusts this result so that the correct BCD representation is obtained, as follows:

0011 1100
+ 0000 0110
------- -------
0100 0010= 42