![Mitsubishi Electric FX3G SERIES Programming Manual Download Page 277](http://html.mh-extra.com/html/mitsubishi-electric/fx3g-series/fx3g-series_programming-manual_238902277.webp)
275
FX
3G
/FX
3U
/FX
3UC
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
Introdu
ction
2
Ov
ervi
ew
3
Instruction
Li
st
4
D
evices
in Det
ail
5
Specifi
ed the
De
vice
&
C
onst
ant
6
Bef
ore
Pr
og
ra
mmi
ng
7
Bas
ic
Instruction
8
FN
C00-FN
C0
9
Program Fl
ow
9
FNC
10-FN
C19
Mov
e & Com
pare
10
FNC
20-FNC
29
Arith. & Lo
gi
c
Operati
on
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
O
per
at
io
n r
e
su
lt
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