Comparison Instructions
Flags
Example:
Saving CMPL(60) Results
TR
0
00000
25505
25506
25507
7-19-5 AREA RANGE COMPARE – ZCP(––)
Limitations
Description
Indirectly addressed DM word is non-existent. (Content of *DM word is
ER:
not BCD, or the DM area boundary has been exceeded.)
GR:
ON if Cp1+1,Cp1 is greater than Cp2+1,Cp2.
EQ:
ON if Cp1+1,Cp1 equals Cp2+1,Cp2.
LE:
ON if Cp1+1,Cp1 is less than Cp2+1,Cp2.
The following example shows how to save the comparison result immediately. If
the content of HR 10, HR 09 is greater than that of DM 0001, DM 0000, then
20000 is turned ON; if the two contents are equal, 20001 is turned ON; if content
of HR 10, HR 09 is less than that of DM 0001, DM 0000, then 20002 is turned ON.
In some applications, only one of the three OUTs would be necessary, making
the use of TR 0 unnecessary. With this type of programming, 20000, 20001, and
20002 are changed only when CMPL(60) is executed.
CMPL(60)
HR 09
DM 0000
---
20000
Greater Than
20001
Equal
20002
Less Than
Ladder Symbol
ZCP(––)
CD
LL
UL
This instruction is available in the CPM2A/CPM2C/SRM1(-V2) only.
LL must be less than or equal to UL.
When the execution condition is OFF, ZCP(––) is not executed. When the
execution condition is ON, ZCP(––) compares CD to the range defined by lower
limit LL and upper limit UL and outputs the result to the GR, EQ, and LE flags in
the SR area. The resulting flag status is shown in the following table.
Comparison result
p
CD < LL
LL
CD
UL
UL < CD
Address Instruction
00000
LD
00001
OUT
00002
CMPL(60)
00003
AND
00004
OUT
00005
LD
00006
AND
00007
OUT
00008
LD
00009
AND
00010
OUT
Operand Data Areas
CD: Compare data
IR, SR, AR, DM, HR, TC, LR, #
LL: Lower limit of range
IR, SR, AR, DM, HR, TC, LR, #
UL: Upper limit of range
IR, SR, AR, DM, HR, TC, LR, #
Flag status
GR (SR 25505)
EQ (SR 25506)
0
0
0
1
1
0
Section
7-19
Operands
00000
TR
0
HR
09
DM
0000
25505
20000
TR
0
25506
20001
TR
0
25507
20002
LE (SR 25507)
1
0
0
437
Need help?
Do you have a question about the CPM1 - PROGRAMING MANUAL 02-2001 and is the answer not in the manual?