CHK2

CHK2

Operation:
If Rn < lower bound or Rn > upper bound then TRAP

Compatibility: MC68020/MC68030/MC68040

Assembler Syntax:
CHK2 <ea>, Rn

Attributes: Size = (Byte, Word, Long)

Description: Compares the value in Rn to each bound. The
effective address contains the bounds pair: the lower bound
followed by the upper bound. For signed comparisons, the
arithmetically smaller value should be used as the lower
bound. For unsigned comparisons, the logically smaller
value should be the lower bound.

The size of the data and the bounds can be specified as byte,
word, or long. If Rn is a data register and operation size
is a byte or word, only the appropriate low-order part of
Rn is checked. If Rn is an address register and the operation
size is byte or word, the bounds operands are sign extended
to 32 bits and the resultant operands are compared to the full
32 bits of An.

If the upper bound equals the lower bound, the valid range is
a single value. If the register value is less than the lower
bound or greater than the upper bound, a CHK instruction
exception, vector number 6, occurs.

Condition Codes:
\c34242
X Not affected.
N Undefined.
Z Set if Rn is equal to either bound. Cleared otherwise.
V Undefined.
C Set if Rn is out of bounds. Cleared otherwise.

Instruction Format:
\i2-----2Size,-++u6Effective Address,3Mode,3Reg,1DA,3Reg,+-----------

Instruction Fields:
Size field -- Specifies the size of the operation.
00 -- Byte operation.
01 -- Word operation.
10 -- Long operation.
Effective Address field -- Specifies the location of the bounds
operands. Only control addressing modes are allowed as
shown:
\m27B

DA field -- Specifies whether an address register or data register
is to be checked.
0 -- Data register.
1 -- Address register.
Register field -- Specifies the address or data register that
contains the value to be checked.

Related Instructions:
CHK,430
.430432