
Semiconductor Group
153
Instruction Set
DA
A
Function:
Decimal adjust accumulator for addition
Description:
DA A adjusts the eight-bit value in the accumulator resulting from the earlier
addition of two variables (each in packed BCD format), producing two four-bit digits.
Any ADD or ADDC instruction may have been used to perform the addition.
If accumulator bits 3-0 are greater than nine (xxxx1010-xxxx1111), or if the AC flag
is one, six is added to the accumulator producing the proper BCD digit in the low-
order nibble. This internal addition would set the carry flag if a carry-out of the low-
order four-bit field propagated through all high-order bits, but it would not clear the
carry flag otherwise.
If the carry flag is now set, or if the four high-order bits now exceed nine (1010xxxx-
1111xxxx), these high-order bits are incremented by six, producing the proper BCD
digit in the high-order nibble. Again, this would set the carry flag if there was a carry-
out of the high-order bits, but wouldn’t clear the carry. The carry flag thus indicates
if the sum of the original two BCD variables is greater than 100, allowing multiple
precision decimal addition. OV is not affected.
All of this occurs during the one instruction cycle. Essentially; this instruction
performs the decimal conversion by adding 00H, 06H, 60H, or 66H to the
accumulator, depending on initial accumulator and PSW conditions.
Note:
DA A
cannot
simply convert a hexadecimal number in the accumulator to BCD
notation, nor does DA A apply to decimal subtraction.
Example:
The accumulator holds the value 56H (01010110B) representing the packed BCD
digits of the decimal number 56. Register 3 contains the value 67H (01100111B)
representing the packed BCD digits of the decimal number 67. The carry flag is set.
The instruction sequence
ADDC
A,R3
DA
A
will first perform a standard two’s-complement binary addition, resulting in the value
0BEH (10111110B) in the accumulator. The carry and auxiliary carry flags will be
cleared.
The decimal adjust instruction will then alter the accumulator to the value 24H
(00100100B), indicating the packed BCD digits of the decimal number 24, the low-
order two digits of the decimal sum of 56, 67, and the carry-in. The carry flag will be
set by the decimal adjust instruction, indicating that a decimal overflow occurred.
The true sum 56, 67, and 1 is 124.
*
Summary of Contents for SAB 80515 Series
Page 9: ...Semiconductor Group 9 Introduction Figure 1 2 Block Diagram ...
Page 12: ...Semiconductor Group 12 Fundamental Structure Figure 2 1 Detailed Block Diagram ...
Page 18: ...Semiconductor Group 18 Central Processing Unit Figure 3 1 Fetch Execute Sequence ...
Page 73: ...Semiconductor Group 73 On Chip Peripheral Components Figure 7 25 A D Converter Block Diagram ...
Page 83: ...Semiconductor Group 83 On Chip Peripheral Components Figure 7 33 a Timer 2 Block Diagram ...
Page 215: ...Device Specifications Semiconductor Group 215 ...
Page 217: ...Device Specifications Semiconductor Group 217 Pin Configuration P LCC 68 ...
Page 219: ...Device Specifications Semiconductor Group 219 Logic Symbol ...
Page 226: ...Device Specifications Semiconductor Group 226 Figure 1 Block Diagram ...
Page 229: ...Device Specifications Semiconductor Group 229 Figure 2 Memory Address Spaces ...
Page 239: ...Device Specifications Semiconductor Group 239 Figure 4 Block Diagram of the A D Converter ...
Page 241: ...Device Specifications Semiconductor Group 241 Figure 5 Interrupt Request Sources ...
Page 242: ...Device Specifications Semiconductor Group 242 Figure 6 Interrupt Priority Level Structure ...