240
Comparison Instructions Section 3-6
Description 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.
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.
Setting Ranges
The values A and B for each range will determine how the comparison oper-
ates depending on which value is larger, as shown below.
Example
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.
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 ran
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
Value B
Comparison
range
· If Value A ≤ Value B
Then, Value A ≤ Comparison range ≤ Value B
· If Value A > Value B
Then, Comparison range ≤ Value B and Value A ≤ Comparison range
Comparison
range
Value A