Application of cmp instruction – KEYENCE Visual KV Series User Manual
Page 172

2.4 Instruction Details
3-148
2
Chapter 2 Instructions
2009
2010
2011
2002
0502
0501
0500
DM0000<#01000
DM0000=#01000
DM0000>#01000
DM0000
LDA
#01000
CMP
Line No.
Instruction
Operand
Line No.
Instruction
Operand
0000
LD
2002
0007
MRD
0001
LDA
DM0000
0008
AND
2010
0002
CON
0009
OUT
0501
0003
CMP
#01000
0010
MPP
0004
MPS
0011
AND
2011
0005
AND
2009
0012
OUT
0502
0006
OUT
0500
Application of CMP instruction
■ Multi-level counter
Coding
Description
The following outputs are provided according to the current value of the counter.
(Current value)
(Output)
0000 to 0999
0500 turns ON.
1000 to 1999
0501 turns ON.
2000 to 2999
0502 turns ON.
■ When comparing values with no specific range
Turns ON 0500 when the DM0000 value is smaller than the CMP value.
Turns ON 0501 when the DM0000 value is equal to the CMP value.
Turns ON 0502 when the DM0000 value is greater than the CMP value.
Coding
0001
C000
LDA
#00999
CMP
#01999
CMP
#02999
CMP
0500
#09999
0000
C000
2002
2011
0501
2011
0502
2011
0500
0500
0501
Line No.
Instruction
Operand
0000
LDB
0001
0001
C
000 #099999
0000
0002
LD
2002
0003
LDA
C000
0004
CON
0005
MPS
0006
CMP
#00999
0007
CON
0008
ANB
2011
0009
OUT
0500
0010
MRD
0011
CMP
#01999
0012
CON
0013
ANB
2011
0014
ANB
0500
0015
OUT
0501
0016
MPP
0017
CMP
#02999
0018
CON
0019
ANB
2011
0020
ANB
0500
0021
ANB
0501
0022
OUT
0502
CMP / @CMP
KVNKA Chap 02_4cP.p65
08.3.11, 0:02 PM
148