270
FX3G/FX3U/FX3UC Series Programmable Controllers
Programming Manual - Basic & Applied Instruction Edition
10 Arithmetic and Logical Operation (
+
,
−
,
×
,
÷
) – FNC 20 to FNC 29
10.2 FNC 21 – SUB / Subtraction
10.2 FNC 21 – SUB / Subtraction
Outline
This instruction executes subtraction using two values to obtain the result (A − B = C).
→ For the floating point subtraction instruction ESUB (FNC121), refer to Section 18.9.
1. Instruction format
2. Set data
3. Applicable devices
S: This function is supported only in FX3U/FX3UC PLCs.
Explanation of function and operation
1. 16-bit operation (SUB and SUBP)
The contents of are subtracted from in the binary format, and the subtraction result is transferred to
.
• The most significant bit of each data indicates the sign (positive: 0 or negative: 1), and data are subtracted
algebraically.
5 − (−8) = 13
• When a constant (K) is specified in or , it is automatically converted into the binary format.
2. 32-bit operation (DSUB and DSUBP)
The contents of [ +1, ] are subtracted from [ +1, ] in the binary format, and the subtraction
result is transferred to [ +1, ].
• The most significant bit of each data indicates the sign (positive: 0 or negative: 1), and data are subtracted
algebraically.
5500 − (−8540) = 14040
• When a constant (K) is specified in [ +1, ] or [ +1, ], it is automatically converted into the
binary format.
Operand type Description Data type
Data for subtraction or word device number storing data 16- or 32-bit binary
Data for subtraction or word device number storing data 16- or 32-bit binary
Word device number storing the subtraction result 16- or 32-bit binary
Oper-
and
Type
Bit Devices Word Devices Others
System User Digit Specification System User
Special
Unit
Index
Con-
stant
Real
Number
Charac-
ter String
Pointer
XYMTCSD.b KnX KnY KnM KnS T C D R U\G VZModifyKH E ""P
33333333 S 33 3 33
33333333 S 33 3 33
3333333 S 33 3
DSUB
DSUBP
Mnemonic Operation Condition
P
FNC 21
SUB
D
16-bit Instruction
7 steps
SUB
SUBP
Mnemonic Operation Condition
Continuous
Operation
Pulse (Single)
Operation
32-bit Instruction
13 steps
Continuous
Operation
Pulse (Single)
Operation
S
1
S
2
D
S
1
S
2
D
S
2
S
1
D
FNC 21
SUB
S
1
S
2
−
→
Command
input
D
S
1
S
2
D
S
1
S
2
S
2
S
2
S
1
S
1
D
1
D
1
FNC 21
DSUB
S
1
S
2
[ +1, ]
−
[ +1, ]
→
[ +1, ]
Command
input
D
S
1
S
2
D
S
1
S
2
D
S
1
S
1
S
2
S
2