TEST Instruction
TEST instruction performs an implied AND operation between each pair of matching bits in two operands and sets the flags accordingly.
The only difference between TEST and AND is that TEST does not modify the destination operand.
TEST — Test for Bit Pattern |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LAHF instruction copies bits 0-7 of the flags register into AH.
AH := S Z ? A ? P ? C
| Sign & Carry Test | Odd Number Test | > 15 Test |
INCLUDE Irvine32.inc
.code
main PROC
mov bh, 80h
neg bh
lahf
test ah, 10000001b
jnz L1
call WaitMsg
L1: exit
main ENDP
END main
|
.code
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
|
.code
count = 5
mov al, 0
mov ecx, count
L1: add al, cl
loop L1
test al, 11110000b
jnz L2
call WaitMsg
L2: exit
|
| Output | Output | Output |