Omron CP1E-N@@D@-@ Computer Hardware User Manual


 
2-97
2 Instructions
CP1E CPU Unit Instructions Reference Manual(W483)
Comparison Instructions
2
CMP/CMPL
Precautions
Using CMP(020)Results in the Program
When CMP(020)/CMPL(060) is executed, the result is reflected in the Arithmetic Flags. Control the
desired output or right-hand instruction with a branch from the same input condition that controls
CMP(020)/CMPL(060), as shown in the following diagram. In this case, the Equals Flag and output A
will be turned ON when S
1
= S
2
or S
1
+ 1, S
1
= S
2
+ 1, S
2
.
Using CMP(020) Results in the Program
Do not program another instruction between CMP(020)/CMPL(060) and the instruction controlled by
the Arithmetic Flag because the other instruction might change the status of the Arithmetic Flag.
The immediate-refreshing variation (!CMP(020)) can be used with words allocated to CPU Unit built-
in inputs specified in S
1
and/or S
2
. When !CMP(020) is executed, input refreshing will be performed
for the external input word specified in S
1
and/or S
2
and that refreshed value will be compared.
Sample program
When CIO 0.00 is ON in the following example, the eight-digit unsigned binary data in CIO 0011 and
CIO 0010 is compared to the eight-digit unsigned binary data in CIO 0009 and CIO 0008 and the
result is output to the Arithmetic Flags. The results recorded in the Greater Than, Equals, and Less
Than Flags are immediately saved to CIO 20.00 (Greater Than), CIO 20.01 (Equals), and CIO 20.02
(Less Than).
i
CMP
S1
S2
A
Arithmetic Flag
(Example: Equal Flag)
CMPL
S1
S2
A
Instruction B
Arithmetic Flag
(Example: Equal Flag)
In this case, the results of instruction B might
change the results of CMP(020).
CMPL
10
8
20.00
0.00
>
20.01
=
20.02
<
S1+1=11CH
1 2 3 4
S1=10CH
5 6 7 8
S2+1=9CH
A B C D
S2=8CH
E F 1 2
Result
Comparison
Flag status
> OFF (0)
= OFF (0)
< ON (1)