304
Comparison Instructions Section 3-7
Description CMP(020) compares the unsigned binary data in S
1
and S
2
and outputs the
result to Arithmetic Flags (the Greater Than, Greater Than or Equal, Equal,
Less Than or Equal, Less Than, and Not Equal Flags) in the Auxiliary Area.
Condition Flag Status
The following table shows the status of the Arithmetic Flags after execution of
CMP(020). (A status of “---” indicates that the Flag may be ON or OFF.)
Using CMP(020) Results in the Program
When CMP(020) 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), as shown in the following dia-
gram. In this case, the Equals Flag and output A will be turned ON when S
1
=
S
2
.
Using CMP(020) Results in the Program
Do not program another instruction between CMP(020) and the instruction
controlled by the Arithmetic Flag because the other instruction might change
the status of the Arithmetic Flag. In this case, the results of instruction B might
change the results of CMP(020).
Index Registers ---
Indirect addressing using
Index Registers
,IR0 to ,IR15
–2048 to +2047 ,IR0 to –2048 to +2047 ,IR15
DR0 to DR15, IR0 to IR15
,IR0+(++) to ,IR15+(++)
,–(– –)IR0 to, –(– –)IR15
Area S
1
S
2
CMP(020)
Result
Flag status
>> ==< =<< >
S
1
> S
2
ON ON OFF OFF OFF ON
S
1
= S
2
OFFONONONOFFOFF
S
1
< S
2
OFF OFF OFF ON ON ON
(>, >=, =, <=, <, <>)
Unsigned binary
comparison
Arithmetic Flags
CMP
S1
S2
A
Arithmetic Flag
(Example: Equal Flag)
Correct Use of CMP(020)