gc80c520a CORERIVER Semiconductor, gc80c520a Datasheet - Page 106

no-image

gc80c520a

Manufacturer Part Number
gc80c520a
Description
Midas1.0 Family Mask Rom/eprom/romless 8-bit Turbo Microcontrollers
Manufacturer
CORERIVER Semiconductor
Datasheet
DA
Description:
A
Function:
Example:
Decimal-adjust Accumulator for Addition
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 carryout 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.
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
DA
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
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.
(00100100b), indicating the packed BCD digits of the decimal number 24, the
Preliminary
A, R3
A
Page 106 of 187
Instruction Set

Related parts for gc80c520a