EasyManua.ls Logo

Motorola 68000 - Page 18

Motorola 68000
60 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
16
The 68000's Instruction Set
Destination operand addressing modes for BTST Dn,<ea> form
Note that data register direct (i.e., Dn) addressing uses a longword
operand, while all other modes use a byte operand.
CHK Check register against bounds
Operation: IF [Dn] < 0 OR [Dn] > [<ea>] THEN TRAP
Syntax: CHK <ea>,Dn
Attributes: Size = word
Description: The contents of the low-order word in the data register specified
in the instruction are examined and compared with the upper
bound at the effective address. The upper bound is a twos
complement integer. If the data register value is less than zero or
greater than the upper bound contained in the operand word,
then the processor initiates exception processing.
Application: The CHK instruction can be used to test the bounds of an array
element before it is used. By performing this test, you can make
certain that you do not access an element outside an array.
Consider the following fragment of code:
MOVE.W subscript,D0 Get subscript to test
CHK #max_bound,D0 Test subscript against 0 and upper bound
* TRAP on error ELSE continue if ok
Condition codes: X N Z V C
- * U U U
N: set if [Dn] < 0; cleared if [Dn] > [<ea>]; undefined otherwise.
Source operand addressing modes

Other manuals for Motorola 68000

Related product manuals