
6 BASIC INSTRUCTIONS
6.2 Arithmetic Operation Instructions
167
6
SUB(P)(_U)
These instructions subtract the 16-bit binary data in the device specified by (s1) and the 16-bit binary data in the device
specified by (s2), and store the result in the device specified by (d).
*1
The SUB instruction is not supported by the ST language. Use SUB of the standard function.
Setting data
■
Descriptions, ranges, and data types
■
Applicable devices
Processing details
• These instructions subtract the 16-bit binary data in the device specified by (s1) and the 16-bit binary data in the device
specified by (s2), and store the subtraction result in the device specified by (d).
■
Relationship between the flag operation and the sign (positive or negative) of a numeric value
Ladder diagram
Structured text
ENO:=SUBP(EN,s1,s2,d);
ENO:=SUB_U(EN,s1,s2,d);
ENO:=SUBP_U(EN,s1,s2,d);
Operand
Description
Range
Data type
Data type (label)
(s1)
SUB(P)
Subtrahend data or the device where the data
to be subtracted from another is stored
-32768 to +32767
16-bit signed binary
ANY16_S
SUB(P)_U
0 to 65535
16-bit unsigned binary
ANY16_U
(s2)
SUB(P)
Subtrahend data or the device where the data
to be subtracted from another is stored
-32768 to +32767
16-bit signed binary
ANY16_S
SUB(P)_U
0 to 65535
16-bit unsigned binary
ANY16_U
(d)
SUB(P)
Device for storing the operation result
16-bit signed binary
ANY16_S
SUB(P)_U
16-bit unsigned binary
ANY16_U
Operand
Bit
Word
Double word
Indirect
specification
Constant
Others
X, Y, M, L,
SM, F, B, SB
U
\G
T, ST,
C, LC
T, ST, C, D,
W, SD, SW, R
U
\G
Z
LC
LZ
K, H
E
$
(s1)
(s2)
(d)
Device
Name
Description
SM700, SM8022
Carry
When the operation result exceeds the upper limit of the data setting range, the carry flag is turned ON.
SM8020
Zero
When the operation result is 0, the zero flag is turned ON.
SM8021
Borrow
When the operation result is less than the lower limit of the data setting range, the borrow flag is turned ON.
(s1)
(s2)
(d)
b15
b0
5678 (BIN)
(s1)
(s2)
(d)
1234 (BIN)
4444 (BIN)
-
···
b15
b0
···
b15
b0
···
Zero Flag
Borrow flag
Zero Flag
Carry flag
Zero Flag
-2, -1, 0, -32768
32767, 0, 1, 2
-1, 0, 1
The most significant
bit of data becomes "1".
The most significant
bit of data becomes "0".
Summary of Contents for MELSEC iQ-F FX5 series
Page 1: ...MELSEC iQ F FX5 Series Programming Manual Instructions Standard Functions Function Blocks ...
Page 2: ......
Page 21: ...19 PART 1 PART 1 OVERVIEW Part 1 consists of the following chapter 1 OVERVIEW ...
Page 98: ...96 4 STANDARD FUNCTIONS FUNCTION BLOCKS 4 2 Standard Function Blocks MEMO ...
Page 840: ...838 23 TIME DATA FUNCTIONS 23 4 Division MEMO ...
Page 887: ......