<<< Jumps Based on Comparison of Two Values | Index | Jumps Based on a Value of Zero >>> |
Individual bit settings in a single value can serve as criteria for a conditional jumps.
The TEST instruction sets the zero flag ZF accordingly to specific bit settings of the instruction operands.
The TEST instruction is the same as AND instruction, except that TEST does not change its operand.
The source operand for TEST is often a mask in which the test bits are specified.
The destination operand contains the value to be tested.
TEST sets the zero flag if none of the bits in the destination operand match the mask
For example,
test al, 10100y jz skip1 ; Do something if either bit 2 or 4 are set, or both . skip1:
Note: There is also BT (Bit Test) instruction, which copies a specified bit from the destination operand to the carry flag CF.
<<< Jumps Based on Comparison of Two Values | Index | Jumps Based on a Value of Zero >>> |