Chapter 7 Second Development PlatformVP3000
309
API Instruction code Operand Function
20 D ADD P S
1
, S
2
, D BIN addition
Type
Operand
Bit devices Word devices
16-bit instruction (7 steps)
ADD
Continuous
execution
type
ADDP
Pulse
execution
type
32-bit instruction (13 steps)
DADD
Continuous
execution
type
DADDP
Pulse
execution
type
Associated flag:
M1020: Zero flag
M1021: Borrow flag
M1022: Carry flag
See the following descriptions.
X Y M K H KnX KnY KnM T C D
S
1
S
2
D
Caution for using operand: none
Description
S
1
: summand
S
2
: addend
D: sum
This instruction adds S
1
and S
2
in BIN format and store the result in D.
The highest bit is symbolic bit 0 (+) and 1 (-), which is suitable for algebraic addition, e.g. 3 + (-
9) = -6.
Flag changes in binary addition:
1. If the operation result = 0, zero flag M1020 = ON.
2. If the operation result < -32,768, borrow flag M1021 = ON.
3. If the operation result > 32,767, carry flag M1022 = ON.
Example
In 16-bit BIN addition:
When X0 = ON, the content in D0 plus the content in D10 and the sum is stored in D20.
X0
D0 D10
D20
DD
Remark
Flags and the positive / negative sign of the values: