Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- iAPx86 - <b>bound check array index agains bounds flags: not altered</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
BOUND           Check Array Index agains Bounds      Flags: Not altered

BOUND destination,source                             CPU: 186+

        Logic   if (destination < source[0]) OR (destination > source[n])
                   INT 5
                endif                   ; n = 2 for word, 4 for dword

    BOUND verifies that the signed destination value lies within
    specified limits. Interrupt 5 occurs if the value in the
    destination register is less than the lower bound or greater than
    the upper bound. The upper and lower limit values may each be a
    word or a doubleword.

    The block of memory that specifies the lower and upper limits of
    an array can typically reside just before the array itself. This
    makes the array bounds accessible at a constant offset from the
    beginning of the array. Because the address of the array is
    already present in a register, this avoids extra calculations to
    obtain the effective address of the array bounds.

    BOUND includes two operands. The first specifies the register
    being tested, and the second contains the effective address of the
    two signed limit values. BOUND assumes that the lower limit and
    the upper limit are in adjacent memory locations.


    Note
    An INT 05h interrupt handler must be installed before using BOUND.
    On the 80186, the exception saves CS:IP pointing to the
    instruction following BOUND; on 286+, to the BOUND instruction.


    Opcode      Format
    62 /r       BOUND r16,m16&16
    62 /r       BOUND r32,m32&32


    Length and timing
    Operands    Bytes   8088    186     286     386     486     Pentium
    reg, mem      4      -      35      13      10       7       8   NP

See Also: CMP

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson