Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Assembly Language - <b>test test flags: o d i t s z a p c</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
TEST             Test                                Flags: O D I T S Z A P C
                                                            0       * * ? * 0
TEST destination,source

          Logic:    (destination AND source)            ; Set flags only
                    CF . 0
                    OF . 0

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

  --------------------------------------------------------------------------
   Operands                  Clocks   Transfers  Bytes   Example
                           byte(word)
   register, register          3          -        2     TEST SI,DX
   register, memory        9(13) + EA     1       2-4    TEST SI,MASK
   accumulator, immediate      4          -       2-3    TEST AL,00000100b
   register, immediate         5          -       3-4    TEST CX,1234
   memory, immediate        11 + EA       -       3-6    TEST PARAM,1F1Fh
  --------------------------------------------------------------------------

    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
                          .
                          .

See Also: CMP AND NOT OR XOR EA Flags

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