3. Instructions
274
CS/CJ/NSJ Series Instructions Reference Manual (W474)
z Operand Specifications
Flags
Function
BCMP2(502) compares the source data (S) to the ranges defined by pairs of lower and upper limit
values in the comparison block. If S is within any of these ranges (inclusive of the upper and lower
limits), the corresponding bits in the result words (R to R+15 max.) are turned ON. The rest of the bits in
R will be turned OFF.
The number of ranges is determined by the value N set in the lower byte of B. N can be between 0 and
255. The upper byte of B must be 00 hex.
z Number of Ranges
The number of ranges in the comparison block is set in the first word of the block. Up to 256 ranges can
be set.
z Setting Ranges
The values A and B for each range will determine how the comparison operates depending on which
value is larger, as shown below.
Area
Word addresses
Indirect
DM/EM
addresses
Con-
stants
Registers
TK CF
Pulse
bits
TR
bits
CIO WR HR AR T C DM EM
@DM
@EM
*DM
*EM
DR IR
Indirect
using IR
S
OK OK OK OK OK OK OK OK OK OK
OK OK
--- OK --- --- --- ---B
--- ---
R
Name Label Operation
Error Flag P_ER OFF
B+1
B+3
B+5
B+31
B+33
B+35
B+37
B+2N+1
B
0
1
2
15
0
1
2
R
R+1
078
15
S
::
::
B+2
B+4
B+6
B+32
B+34
B+36
B+38
B+2N+2
Bit
Bit
Result words
Comparison ranges
Comparison block
Source data
Range 0 value A
Range 1 value A
Range 2 value A
Range 15 value A
00 hex
Last range
"N"
N: 00 to FF hex (0 to 255)
Range 0 value B
Range 1 value B
Range 2 value B
Range 15 value B
In range: ON
Not in range: OFF
Ranges
Range 16 value A
Range 17 value A
Range 18 value A
Range N value A
Range 16 value B
Range 17 value B
Range 18 value B
Range N value B
Value A Value B
Comparison range
· If Value A ≤ Value B
Then, Value A ≤ Comparison range ≤ Value B
Value B
Comparison
range
· If Value A ≤ Value B
Then, Comparison range ≤ Value B and Value A ≤ Comparison range
Comparison
range
Value A