
CPU16
REFERENCE MANUAL
INSTRUCTION SET
MOTOROLA
5-5
5.3.2 Binary Coded Decimal Instructions
To add binary coded decimal operands, use addition instructions that set the half-carry
bit in the CCR, then adjust the result with the DAA instruction.
The following table shows DAA operation for all legal combinations of input operands.
Columns 1 through 4 represent the results of addition operations on BCD operands.
The correction factor in column 5 is added to the accumulator to restore the result of
an operation on two BCD operands to a valid BCD value, and to set or clear the C bit.
All values are hexadecimal.
5.3.3 Compare and Test Instructions
Compare and test instructions perform subtraction between a pair of registers or be-
tween a register and memory. The result is not stored, but condition codes are set by
the operation. These instructions are generally used to establish conditions for branch
instructions.
Table 5-9 BCD Summary
Mnemonic
ABA
ADCA
ADCB
ADDA
ADDB
DAA
Function
Add B to A
Add with Carry to A
Add with Carry to B
Add to A
Add to B
Decimal Adjust A
Operation
(A) + (B)
A
(A) + (M) + C
A
(B) + (M) + C
B
(A) + (M)
A
(B) + (M)
B
(A)
10
If B7 = 1
then A = $FF
else A = $00
SXT
Sign Extend B into A
Table 5-10 DAA Function Summary
1
2
3
4
5
6
Initial
C Bit Value
0
0
0
0
0
0
1
1
1
Value of
A[7:4]
0 – 9
0 – 8
0 – 9
A – F
9 – F
A – F
0 – 2
0 – 2
0 – 3
Initial
H Bit Value
0
0
1
0
0
1
0
0
1
Value of
A[3:0]
0 – 9
A – F
0 – 3
0 – 9
A – F
0 – 3
0 – 9
A – F
0 – 3
Correction
Factor
00
06
06
60
66
66
60
66
66
Corrected
C Bit Value
0
0
0
1
1
1
1
1
1
F
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
.