Test                                     

86/88

Y

186

Y

286

Y

386

Y

486

Y

TEST destination, source

Ovfl

0

Dir

N

Int

N

Trap

N

Sign

Y

Zero

Y

Aux

?

Prty

Y

Carry

0

    TEST performs a logical AND on its two operands and updates the flags.
    Neither the destination nor source is changed.

    TEST is useful for examining the status of individual bits. For
    example, the following section of code will transfer control to
    ONE_FIVE_OFF if both bits one and five of register AL are cleared. The
    status of all other bits will be ignored.

                  TEST    AL,00100010b    ;Mask out all bits except 1 and 5
                  JZ      ONE_FIVE_OFF    ;If either was set, result was not 0
          NOT_BOTH:       .               ;One or both bits was set

          ONE_FIVE_OFF:   .               ; Bits 1 and 5 were off

------------------------------------ Timing ----------------------------------

OpCode          Instruction             386     286     86
A8 ib           TEST AL, imm8           2       3       4
A9 iw           TEST AX, imm16          2       3       4
A9 id           TEST EAX, imm32         2
F6/0 ib         TEST r/m8, imm8         2/5     3/6     5/11+EA
F7/0 iw         TEST r/m16, imm16       2/5     3/6     5/11+EA
F7/0 id         TEST r/m32, imm32       2/5
84/r            TEST r/m8, r8           2/5     2/6     3/9+EA
85/r            TEST r/m16, r16         2/5     2/6     3/9+EA
85/r            TEST r/m32, r32         2/5
------------------------------------ Logic -----------------------------------

        (destination AND source)        ; set flags only
        CF = 0
        OF = 0

See Also CMP AND NOT OR XOR Flags


Copyright © 1985 to 2022 Beta Systems                            Last modified: Wednesday, January 05, 2022 .