275
3. Instructions
CS/CJ/NSJ Series Instructions Reference Manual (W474)
Comparison Instructions
3
BCMP2
• When B+1 ≤ B+2
If B+1 ≤ S ≤ B+2, then bit 0 of R will turn ON,
If B+3 ≤ S ≤ B+4, then bit 1 of R will turn ON,
If S < B+5 and B+6 < S, then bit 2 of R will turn OFF, and
If S < B+7 and B+8 < S, then bit 3 of R will turn OFF.
• When B+1 > B+2
If S ≤ B+2 and B+1 ≤ S, then bit 0 of R will turn ON,
If S ≤ B+4 and B+3 ≤ S, then bit 1 of R will turn ON,
If B+6 < S < B+5, then bit 2 of R will turn OFF, and
If B+8 < S < B+7, then bit 3 of R will turn OFF.
z Results Storage Location
The results are output to corresponding bits in word R. If there are more than 16 comparison ranges,
consecutive words following R will be used.
Example Programming
When CIO 0.00 is ON in the following example, BCMP2(502) compares the content of CIO 10 with the
24 ranges defined in D200 through D247 (N = 17 hex = 23 decimal, i.e., 24 ranges) and turns ON the
corresponding bits in CIO 100 and CIO 101 when S is within the range and OFF when S is not within
the range. For example, if the source data in CIO 10 is in the range defined by D201 and D202, then bit
00 of CIO 100 is turned ON and if it in not in the range, then bit 00 of CIO 100 is turned OFF. Likewise,
the source data in CIO 10 is compared to the ranges defined by D203 and D204, D247 and D248, and
the other words in the comparison block, and bit 1 in CIO 100, bit 7 in CIO 101, and the other bits in the
result words are manipulated according to the results of comparison.
15 014
Comparison result for S
and range 16m + 14
Comparison result for S
and range 16m + n
Comparison result for S
and range 16m
Comparison result for S
and range 16m + 15
R+m
n
The maximum number of result words is 16, i.e., m equals 0 to 15.
BCMP2
10
D200
100
0.00
D202
D204
D206
D232
D234
D236
D238
D248
0100
0180
0260
1800
0500
0100
0200
2000
S: CIO 10 0175
0017
D201
D203
D205
D231
D233
D235
D237
D247
0000
0080
0160
1200
1500
1900
1800
0100
R: CIO 100
R: CIO 101
Bit