5 Applied Instructions and Basic Usage
DVP-20PM Application Manual
5-36
API
Applicable model
20PM
20
D
D
ADD
P
P
Binary addition
Bit device Word device
X Y M S K H KnX KnY KnM KnS T C D V Z
S
1
* *
* * * * * * * * *
S
2
* *
* * * * * * * * *
D
* * * * * * * *
Note: The instruction supports V devices and Z devices. (If the 16-bit
instruction is used, Z devices can not be used. If the 32-bit
instruction is used, V devices can not be used.)
Please refer to specifications for more information about device
ranges.
16-bit instruction (7 steps)
ADD
Continuity
instruction
ADDP
Pulse
instruction
32-bit instruction (9 steps)
DADD
Continuity
instruction
DADDP
Pulse
instruction
Flags
Ox O100
M1808 M1968 Zero flag
M1809 M1969 Borrow flag
M1810 M1970 Carry flag
Please refer to the additional remark below.
Explanation
The binary value in S
2
is added to the binary value in S
1
, and the sum is stored
in D.
S
1
: Augend; S
2
: Addend; D: Sum
The highest bit in S
1
and the highest bit in S
2
are sign bits. If the sign bit in a
register is 0, the value in the register is a positive value. If the sign bit in a
register is 1, the value in the register is a negative value.
The flags related to 16-bit binary addition and 32-bit binary addition are listed
below.
16-bit binary addition:
1. If the operation result gotten is 0, a zero flag will be ON.
2. If the operation result gotten is less than – 32,768, a borrow flag will be
ON.
3. If the operation result gotten is greater than 32,767, a carry flag will be ON.
32-bit binary addition:
1. If the operation result gotten is 0, a zero flag will be ON.
2. If the operation result gotten is less than – 2,147,483,648, a borrow flag will
be ON.
3. If the operation result gotten is greater than 2,147,483,647, a carry flag will
be ON.
Example 1
16-bit binary addition: When X0 is ON, the addend in D10 is added to the
augend in D0, and the sum is stored in D20.
X0
DD D0 D10 D20
Example 2
32-bit binary addition: When X1 is ON, the value in (D41, D40) is added to the
augend in (D31, D30), and the sum is stored in (D51, D50).
X
DADD D30 D40 D50