275
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
1
Introduction
2
Overview
3
Instruction
List
4
Devices
in Detail
5
Specified the
Device &
Constant
6
Before
Programming
7
Basic
Instruction
8
FNC00-FNC09
Program Flow
9
FNC10-FNC19
Move & Compare
10
FNC20-FNC29
Arith. & Logic
Operation
Program example
1. Difference between the SUB instruction and the DEC instruction used by a program for
subtracting "1"
When SUB[P] is executed, "1" is subtracted from the contents of D0 every time X001 turns from OFF to ON.
SUB[P] instruction is similar to DECP instruction described later except the contents shown in the table below:
[D] SUB [P] instruction [D] DEC [P] instruction
Flag (zero, borrow or carry) Operates Does not operate
Operation result
16-bit
operation
−(+1)=
←−2←−1←0←−32768 −32,768→+32,767→+32,766
−(−1)=
+32767→0→+1→+2→⎯
32-bit
operation
−(+1)=
←−2←−1←0←−2,147,483,648 −2,147,483,648→+2,147,483,647→+2,147,483,646
−(−1)=
+2,147,483,647→0→+1→+2→⎯
S D
S D
S D
S D
FNC 21
SUBP
D 0 K 1 D 0
X001
(D 0)
−
1
→
(D 0)
FNC 25
DECP
D 0
X001
(D 0)
−
1
→
(D 0)
S
1
S
2
D