You are here : assembly8051DA

DA - 8051

The DA instruction 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 (xxx1010-xxx1111), 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 (1010xxx-111xxxx), 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 would not 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 it apply to decimal subtraction.


Syntax

DA A


Example

DA A		;1 byte 1 cycle


Output / Return Value


Limitations


Alternatives / See Also


Reference