51. CoMPare register against upper and lower bounds

51.1. Name

Cmp2 -- Compare register against upper and lower bounds        (68020+)

51.2. Synopsis

        CMP2        <ea>,Rn

51.3. Function

Used to compare value of Rn (Dn or An) with two lower and upper bounds, which are stored in memory, at address given by <ea> (in two adjacent areas). Lower bound have to be stored before upper bound. Flags are set following to the result of comparison. If Rn is a data register Dn, and if operation is made on 8 or 16 bits, only the 8 or 16 bits of Dn are taken in count. In opposite, in the case of Rn as an address register and if a 16 bits operation is granted, the 32 bits of An are compared to bounds which are, them, extended on 32 bits by their signs.

51.4. Format

                                                          <ea>
        ----------------------------------------=========================
        |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
        |---|---|---|---|---|-------|---|---|---|-----------|-----------|
        | 0 | 0 | 0 | 0 | 0 | SIZE  | 0 | 1 | 1 |   MODE    | REGISTER  |
        |---|-----------|---|-------|---|---|---|-----------|-----------|
        |D/A| REGISTER  | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 
        -----------------------------------------------------------------

REGISTER
        Register specifies the register Rn which contains the value to test.
        If D/A = 0: Rn = Dn
        If D/A = 1: Rn = An
        <ea> specifies bounds, addressing modes allowed are:
        --------------------------------- -------------------------------
        |Addressing Mode|Mode| Register | |Addressing Mode|Mode|Register|
        |-------------------------------| |-----------------------------|
        |      Dn       | -  |     -    | |   (Abs).W     |111 |  000   |
        |-------------------------------| |-----------------------------|
        |      An       | -  |     -    | |   (Abs).L     |111 |  001   |
        |-------------------------------| |-----------------------------|
        |     (An)      |010 |No reg. An| |   (d16,PC)    |111 |  010   |
        |-------------------------------| |-----------------------------|
        |     (An)+     | -  |     -    | |   (d8,PC,Xi)  |111 |  011   |
        |-------------------------------| |-----------------------------|
        |    -(An)      | -  |     -    | |   (bd,PC,Xi)  |111 |  011   |
        |-------------------------------| |-----------------------------|
        |    (d16,An)   |101 |No reg. An| |([bd,PC,Xi],od)|111 |  011   |
        |-------------------------------| |-----------------------------|
        |   (d8,An,Xi)  |110 |No reg. An| |([bd,PC],Xi,od)|111 |  011   |
        |-------------------------------| |-----------------------------|
        |   (bd,An,Xi)  |110 |No reg. An| |    #data      | -  |   -    |
        |-------------------------------| -------------------------------
        |([bd,An,Xi],od)|110 |No reg. An|
        |-------------------------------|
        |([bd,An],Xi,od)|110 |No reg. An|
        ---------------------------------

SIZE
        00->one Byte operation
        01->one Word operation
        10->one Long operation

51.5. Result

        X - Not affected
        N - Undefined.
        Z - Set if Rn is equal to one of the two bounds. Cleared otherwise.
        V - Undefined.
        C - Set if Rn is out of bounds. Cleared otherwise.

51.6. See also

CMP CMPI CMPA CHK2