Chapter 6: Instructions 77
Arithmetic Instruction Details
Instruction
Mnemonic Addition Range
Bit
■ Byte
ADD
DADD
ADDB
DADDB
Decimal addition (ADD, DADD)
BCD addition (ADDB, DADDB)
■ Word
Ladder
D = S1 + S2
Decimal: S1 = 21, and S2 = 22
Hexadecimal: S1 = $15 and S2 = $16
ADD Example:
Decimal: 21 + 22 = 43
ADDB Example:
BCD: $15 + $16 = $31
Description
1. Add the data in the S1 and S2 addresses, then store the result in the D register.
2. When using ADD and ADDB, the calculation ranges are as follows:
S1: 0 to 255 (0 to $FF)
S2: 0 to 255 (0 to $FF)
D: 0 to 255 (0 to $FF)
3. When using DADD and DADDB, the calculation ranges are as follows:
S1: 0 to 65,535 (0 to $FFFF)
S2: 0 to 65,535 (0 to $FFFF)
D: 0 to 65,535 (0 to $FFFF)
4. If the result exceeds the range of calculation, a carry occurs. The carry flag (F1.8) is changed
to On.
5. This operation will occur on every scan for which the input condition is true (On). To perform
the operation only on a change of input condition, use the rising/falling edge contact.
ADD
D =
S1 =
S2 =
R
R
ADDB
D =
S1 =
S2 =
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com