
Instruction Set Description
4.6.2.16 DADD
* DADD[.W]
Add source word and carry decimally to destination word
* DADD.B
Add source byte and carry decimally to destination byte
Syntax
DADD src,dst
or
DADD.W src,dst
DADD.B src,dst
Operation
src + dst + C
→
dst (decimally)
Description
The source operand and the destination operand are treated as two (.B) or four (.W)
binary coded decimals (BCD) with positive signs. The source operand and the carry bit C
are added decimally to the destination operand. The source operand is not affected. The
previous content of the destination is lost. The result is not defined for non-BCD
numbers.
Status Bits
N:
Set if MSB of result is 1 (word > 7999h, byte > 79h), reset if MSB is 0
Z:
Set if result is zero, reset otherwise
C:
Set if the BCD result is too large (word > 9999h, byte > 99h), reset otherwise
V:
Undefined
Mode Bits
OSCOFF, CPUOFF, and GIE are not affected.
Example
Decimal 10 is added to the 16-bit BCD counter DECCNTR.
DADD
#10h,&DECCNTR
; Add 10 to 4-digit BCD counter
Example
The eight-digit BCD number contained in 16-bit RAM addresses BCD and BCD+2 is
added decimally to an eight-digit BCD number contained in R4 and R5 (BCD+2 and R5
contain the MSDs). The carry C is added, and cleared.
CLRC
; Clear carry
DADD.W
&BCD,R4
; Add LSDs. R4.19:16 = 0
DADD.W
&BCD+2,R5
; Add MSDs with carry. R5.19:16 = 0
JC
OVERFLOW
; Result >9999,9999: go to error routine
...
; Result ok
Example
The two-digit BCD number contained in word BCD (16-bit address) is added decimally to
a two-digit BCD number contained in R4. The carry C is added, also. R4.19:8 = 0
CLRC
; Clear carry
DADD.B
&BCD,R4
; Add BCD to R4 decimally.
R4: 0,00ddh
149
SLAU272C – May 2011 – Revised November 2013
CPUX
Copyright © 2011–2013, Texas Instruments Incorporated