Chapter 7 Second Development Platform VP3000
300
API Instruction code Operand Function
10 D CMP P S
1
, S
2
, D Compare output value
Type
Operand
Bit devices Word devices
16-bit instruction (7 steps)
CMP
Continuous
execution
type
CMPP
Pulse
execution
type
32-bit instruction (13 steps)
DCMP
Continuous
execution
type
DCMPP
Pulse
execution
type
Associated flag: none
X Y M K H KnX KnY KnM T C D
S
1
S
2
D
Caution for using operand
Operand D occupies 3 consecutive devices.
Description
S
1
: comparison value 1
S
2
: comparison value 2
D: comparison result
Compare operand S
1
and S
2
, and the comparison result is stored in D.
The two comparison values are compared algebraically and the two values are signed binary
values. When b15 = 1 in 16-bit instruction, the comparison regards the value as negative
binary values.
Example
Designate device Y0, and operand D automatically occupies Y0, Y1, and Y2.
When X10 = ON, CMP instruction is executed, and one of Y0, Y1, and Y2 will be ON. When
X10 = OFF, CMP instruction is not executed, and Y0, Y1, and Y2 remain their status before
X10 = OFF.
If you need to obtain a comparison result with ≥, ≤, and ≠, make a serial-parallel connection
between Y0–Y2.
To clear the comparison result, use RST or ZRST instruction.
X10
M0
RST
M1
RST
M2
RST
X10
M0ZRST
M2