7-19
Section
Comparison Instructions
433
The following example shows how to save the comparison result immediately. If
the content of HR 09 is greater than that of DM 0000, 20000 is turned ON; if the
two contents are equal, 20001 is turned ON; if content of HR 09 is less than that
of DM 0000, 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 CMP(20) is
executed.
00000
LD
00000
00001
OUT
TR
0
00002
CMP(20)
HR
09
DM
0000
00003
AND
25505
00004
OUT
20000
00005
LD
TR
0
00006
AND
25506
00007
OUT
20001
00008
LD
TR
0
00009
AND
25507
00010
OUT
20002
Address
Instruction
Operands
Address
Instruction
Operands
CMP(20)
DM 0000
HR 09
00000
25505
20000
25507
20002
TR
0
25506
20001
Greater Than
Equal
Less Than
7-19-2
TABLE COMPARE – TCMP(85)
CD
: Compare data
IR, SR, DM, HR, TC, LR, #
TB
: First comparison table word
IR, SR, DM, HR, TC, LR
Ladder Symbols
Operand Data Areas
R
: Result word
IR, SR, DM, HR, TC, LR
TCMP(85)
CD
TB
R
@TCMP(85)
CD
TB
R
DM 6144 to DM 6655 cannot be used for R.
When the execution condition is OFF, TCMP(85) is not executed. When the
execution condition is ON, TCMP(85) compares CD to the content of TB, TB+1,
TB+2, ..., and TB+15. If CD is equal to the content of any of these words, the
corresponding bit in R is set, e.g., if the CD equals the content of TB, bit 00 is
turned ON, if it equals that of TB+1, bit 01 is turned ON, etc. The rest of the bits in
R will be turned OFF.
Flags
ER:
The comparison table (i.e., TB through TB+15) exceeds the data area.
Indirectly addressed DM word is non-existent. (Content of
*
DM word is
not BCD, or the DM area boundary has been exceeded.)
Example:
Saving CMP(20) Results
Limitations
Description