6 BASIC INSTRUCTIONS
6.1 Comparison Operation Instructions
149
6
Comparison output 16-bit binary data
CMP(P)(_U)
These instructions perform a comparison operation between the 16-bit binary data in the devices specified by (s1) and (s2).
■Descriptions, ranges, and data types
■Applicable devices
*1 T, ST, C cannot be used.
• These instructions perform a comparison operation between the 16-bit binary data in the device specified by (s1) and the
16-bit binary data in the device specified by (s2) and according to the result (small, equal, large), (d), (d) + 1, or (d) + 2 is
turned ON.
• (s1) and (s2) are handled as binary values within the range of above data setting.
• Large and small comparison is executed algebraically.
Ladder diagram Structured text
ENO:=CMP(EN,s1,s2,d);
ENO:=CMPP(EN,s1,s2,d);
ENO:=CMP_U(EN,s1,s2,d);
ENO:=CMPP_U(EN,s1,s2,d);
Operand Description Range Data type Data type (label)
(s1) CMP(P) Comparison value data or the device where the
comparison value data is stored
-32768 to +32767 16-bit signed binary ANY16
CMP(P)_U 0 to 65535 16-bit unsigned binary ANY16_U
(s2) CMP(P) Comparison source data or the device where
the comparison source data is stored
-32768 to +32767 16-bit signed binary ANY16
CMP(P)_U 0 to 65535 16-bit unsigned binary ANY16_U
(d) The starting bit device to which the comparison
result is output
Bit ANY_BOOL
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)
*1
• With sign… -10 (FFF6H) < 2 (0002H)
• Without sign… 32767 (7FFFH) < 65280 (FF00H)
(d)
CMP
48
49
50
51
(s1) (s2)
(d)
(s2)
(d)
(s1)
(d)+1
(d)+2
(d)+1
(d)+2
Command input
Command input
Latched
Latched
Latched
Turns ON in the case of (s1)>(s2).
Turns ON in the case of (s1)=(s2).
Turns ON in the case of (s1)<(s2).
Even if the command input turns OFF and the CMP instruction is not executed, (d) to (d)+2 latches the status
just before the command input turns from ON to OFF.