Mitsubishi Electronics FXCPU Video Game Controller User Manual


 
9 Applied Instructions (Arithmetic and Logical Operation)
9.2 SUBP / Subtraction
173
FXCPU Structured Programming Manual
[Basic & Applied Instruction]
1
Outline
2
Instruction List
3
Configuration of
Instruction
4
How to Read
Explanation of
Instructions
5
Basic Instruction
6
Step Ladder
Instructions
7
Applied Instructions
(Program Flow)
8
Applied Instructions
(Move and
Compare)
9
Applied Instructions
(Arithmetic and
Logical Operation)
10
Applied Instructions
(Rotation and
Shift Operation)
Cautions
1) Instructions of pulse operation type are not provided in the FX0, FX0S or FX0N PLC.
To execute pulse operation, make the instruction execution condition pulse type.
2) When using a 32-bit operation instruction (DSUB or DSUBP) and specifying word devices, a 16-bit word
device on the low-order side is specified first, and a word device with the subsequent device number is
automatically set for the high-order 16 bits.
To prevent number overlap, it is recommended to always specify an even number, for example.
3) The same device number can be specified for both the source and the destination.
In this case, note that the addition result changes in every operation cycle if a continuous operation type
instruction (DSUB) is used.
4) Some restrictions to applicable devices
S1:The FX
3G, FX3GC, FX3U and FX3UC PLCs only are applicable.
S2:The FX
3U and FX3UC PLCs only are applicable.
Program examples
1. Difference between SUBP and DECP instruction caused by a program for subtracting "1"
"1" is subtracted from the contents of D0 every time X001 turns ON from OFF.
SUB instruction is similar to DECP instruction described later except the contents shown in the table below.
SUBP/DSUB/DSUBP instructions DEC/DECP/DDEC/DDECP instructions
Flag (zero, borrow, carry) Operates Does not operate
Operation result
16-bit
operation
-(+1)=
-2 -1 0 -32,768 -32,768 +32,767 +32,766
-(-1)=
+32,767 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 -
X001
D0
D0
K25
DSUB
EN
s1
s2
ENO
d
(D1,D0) – 25 (D1,D0)
(D 0) – 1 (D 0)
X001
D0
D0
SUBP
EN
s1
s2
ENO
d
K1
DECP
EN ENO
d
X001
D0
[Structured ladder/FBD] [ ST ]
SUBP(X001, D0, K1, D0);
DECP(X001, D0);
(D 0) – 1 (D 0)