TEST Instruction


The instruction performs an implied operation between each pair of matching bits in two operands and sets the flags accordingly. The only difference between and is that does not modify the destination operand.

TEST — Test for Bit Pattern

Usage: TEST dest, src

Flag O D I S Z A P C
Result *     * * ? * 0

Performs a logical of the two operands updating the flags register without saving the result.
Clocks
Operands 286 386 486 Size Bytes
reg, reg 2 1 1 2
reg, mem 6 5 1 2-4
mem, reg 6 5 2 2-4
reg, immed 3 2 1 3-4
mem, immed 6 5 2 3-6
accum, immed 3 2 1 2-3

The instruction copies bits 0-7 of the flags register into .
        AH := S Z ? A ? P ? C
Sign & Carry Test Odd Number Test > 15 Test
 INCLUDE Irvine32.inc
 .data
  dummy  WORD  ?
 .code
 main PROC
  mov   bh, 80h
  neg   bh
  lahf
  test  ah, 10000001b
  jnz   L1
  call  WaitMsg
 L1:
  exit
 main ENDP
 END main
 INCLUDE Irvine32.inc
 .data
  dummy  WORD  ?
 .code
 main PROC
  mov   al, 0
  mov   bl, 1
  count = 5
  mov   ecx, count
 L1:
  add   al, bl
  xchg  al, bl
  loop  L1
  test  bl, 00000001b
  jnz   L2
  call  WaitMsg
 L2:
  exit
 main ENDP
 END main
 INCLUDE Irvine32.inc
 .data
  dummy  WORD  ?
 .code
 main PROC
  count = 5
  mov   al, 0
  mov   ecx, count
 L1:
  add   al, cl
  loop  L1
  test  al, 11110000b
  jnz   L2
  call  WaitMsg
 L2:
  exit
 main ENDP
 END main
Output Output Output

 

 

 

 

 

 






      “I’m not arguing, I’m just explaining why I’m right.”    
      ― Unknown