TEST (x86 instruction)
Encyclopedia
In the x86 assembly language
, the TEST instruction performs a bitwise AND on two operand
s. The flags SF, ZF
, PF
, CF
, OF
and AF
are modified while the result of the AND is discarded. There are 9 different opcode
s for the TEST instruction depending on the type and size of the operand
s. It can compare 8-bit, 16-bit, 32-bit or 64-bit values. It can also compare registers, immediate values and register indirect values.
of the result of the AND. If the result of the AND is 0, the ZF is set to 1, otherwise set to 0. The parity flag is set to the bitwise
XNOR of the result of the AND. The value of AF is undefined.
X86 assembly language
x86 assembly language is a family of backward-compatible assembly languages, which provide some level of compatibility all the way back to the Intel 8008. x86 assembly languages are used to produce object code for the x86 class of processors, which includes Intel's Core series and AMD's Phenom and...
, the TEST instruction performs a bitwise AND on two operand
Operand
In mathematics, an operand is the object of a mathematical operation, a quantity on which an operation is performed.-Example :The following arithmetic expression shows an example of operators and operands:3 + 6 = 9\;...
s. The flags SF, ZF
Zero flag
The Zero Flag is a single bit flag that is a central feature on most conventional CPU architectures . It is often stored in a dedicated register, typically called status register or flag register, along with other flags...
, PF
Parity flag
In computer processors the parity flag indicates if the number of set bits is odd or even in the binary representation of the result of the last operation. It is normally a single bit in a processor status register....
, CF
Carry flag
In computer processors the carry flag is a single bit in a system status register used to indicate when an arithmetic carry or borrow has been generated out of the most significant ALU bit position...
, OF
Overflow flag
In computer processors, the overflow flag is usually a single bit in a system status register used to indicate when an arithmetic overflow has occurred in an operation, indicating that the signed two's-complement result would not fit in the number of bits used for the operation...
and AF
Adjust flag
The Adjust flag is a flag stored in the FLAGS register on all x86 compatible CPUs. It is bit 4. It is used to indicate when an arithmetic carry or borrow has been generated out of the 4 least significant bits. It is primarily used in BCD arithmetics....
are modified while the result of the AND is discarded. There are 9 different opcode
Opcode
In computer science engineering, an opcode is the portion of a machine language instruction that specifies the operation to be performed. Their specification and format are laid out in the instruction set architecture of the processor in question...
s for the TEST instruction depending on the type and size of the operand
Operand
In mathematics, an operand is the object of a mathematical operation, a quantity on which an operation is performed.-Example :The following arithmetic expression shows an example of operators and operands:3 + 6 = 9\;...
s. It can compare 8-bit, 16-bit, 32-bit or 64-bit values. It can also compare registers, immediate values and register indirect values.
TEST opcode variations
The TEST operation sets the flags CF and OF to zero. The SF is set to the MSBMost significant bit
In computing, the most significant bit is the bit position in a binary number having the greatest value...
of the result of the AND. If the result of the AND is 0, the ZF is set to 1, otherwise set to 0. The parity flag is set to the bitwise
Bitwise operation
A bitwise operation operates on one or more bit patterns or binary numerals at the level of their individual bits. This is used directly at the digital hardware level as well as in microcode, machine code and certain kinds of high level languages...
XNOR of the result of the AND. The value of AF is undefined.