5 Categories and Use of Basic Application Instructions
DVP-PM Application Manual 5-23
API Mnemonic Operands Function
10
D CMP P
Compare
Controllers
20PM 10PM
Bit Devices Word Devices Program Steps
Type
OP
X Y M S K H KnX KnY KnM KnS T C D V Z
S
1
* * * * * * * * ***
S
2
* * * * * * * * ***
D * * *
CMP, CMPP: 7 steps
DCMP, DCMPP: 9 steps
Operands:
S
1
: Comparison value 1 S
2
: Comparison value 2 D: Comparison result
Explanations:
1. The contents of S
1
and S
2
are compared and D stores the comparison result.
2. When CMP is used as 16-bit instruction, Z device cannot be adopted; when CMP is used as 32-bit instruction, V
device cannot be adopted.
3. D will occupy 3 consecutive devices.
D, D +1, D +2 hold the comparison results: D = ON if S
1
> S
2
, D +1 = ON if
S
1
= S
2
, D +2 = ON if S
1
< S
2.
Program Example:
1. If D is set as Y0, then Y0, Y1, Y2 will display the comparison results as shown below..
2. When X10 = ON, CMP instruction is executed and one of Y0, Y1, Y2 will be ON. When X10 = OFF, CMP
instruction is not executed and Y0, Y1, Y2 remain in their previous condition.
3. If you need to obtain a comparison result with , and ≠≧≦ , make a series/parallel connection between Y0 and
Y2.
X10
CMP
K10
D10 Y0
Y0
Y1
Y2
When K10 > D10, Y0 = On
When K10 = D10, Y1 = On
When K10 < D10, Y2 = On