EasyManua.ls Logo

Mitsubishi Electric MELSEC-Q/L - Page 229

Mitsubishi Electric MELSEC-Q/L
1084 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
6 BASIC INSTRUCTIONS
6.2 Arithmetic Operation Instructions
227
6
D-
Subtracts 32-bit BIN data designated by (S1) from 32-bit BIN data designated by (S2) and stores the result of the
subtraction at the device designated by (D).
The values for (S1), (S2) and (D) can be designated at between -2147483648 and 2147483647 (BIN 32 bits).
Judgment of whether the data is positive or negative is made on the basis of the most significant bit (b31).
The following will happen when an underflow or overflow is generated in an operation result: The carry flag (SM700) in this
case does not turn ON.
Operation error
There is no operation error in the D+(P) or D-(P) instruction.
Program example
The following program adds 28-bit data from X10 to X2B to the data at D9 and D10 when X0 goes ON, and outputs the
result of the operation to Y30 to Y4B.
The following program subtracts the data from M0 to M23 from the data at D0 and D1 when XB goes ON, and stores the
result at D10 and D11.
•0  Positive
•1  Negative
[Ladder Mode] [List Mode]
[Ladder Mode] [List Mode]
123456 (BIN)
b0b16 b15
+1
567890 (BIN)
b31
+1
444434 (BIN)
+1
S1 S2
D
S1 S2
D
b0b16 b15b31 b0b16 b15b31
Since bit 31 value is "0",
result of operation takes a positive value.
Since bit 31 value is "1",
result of operation takes a negative value.
K 2147483648
(80000000H)
K2147483647
(7FFFFFFFH)
K2
(00000002
H)
K2
(FFFFFFFEH)
K214748364
6
K 214748364
7
(80000001H)
(7FFFFFFEH)
Step
Instruction
Device
Step
Instruction
Device

Table of Contents

Related product manuals