Intel 64 and IA-32 Architectures Software Developers Manual Volume 1, Basic Architecture

7-20 Vol. 1
PROGRAMMING WITH GENERAL-PURPOSE INSTRUCTIONS
“EFLAGS Condition Codes,” lists the conditions it is possible to test for with this
instruction.
7.3.7.4 Test Inst r uction
The TEST instruction performs a logical AND of two operands and sets the SF, ZF, and
PF flags according to the results. The flags can then be tested by the conditional jump
or loop instructions or the SETcc instructions. The TEST instruction differs from the
AND instruction in that it does not alter either of the operands.
7.3.8 Control Transfer Instructions
The processor provides both conditional and unconditional control transfer instruc-
tions to direct the flow of program execution. Conditional transfers are taken only for
specified states of the status flags in the EFLAGS register. Unconditional control
transfers are always executed.
For the purpose of this discussion, these instructions are further divided subordinate
subgroups that process:
Unconditional transfers
Conditional transfers
Software interrupts
7.3.8.1 Unconditional Transfer Instructions
The JMP, CALL, RET, INT, and IRET instructions transfer program control to another
location (destination address) in the instruction stream. The destination can be
within the same code segment (near transfer) or in a different code segment (far
transfer).
Jump instruction — The JMP (jump) instruction unconditionally transfers program
control to a destination instruction. The transfer is one-way; that is, a return address
is not saved. A destination operand specifies the address (the instruction pointer) of
the destination instruction. The address can be a relative address or an absolute
address.
A relative address is a displacement (offset) with respect to the address in the EIP
register. The destination address (a near pointer) is formed by adding the displace-
ment to the address in the EIP register. The displacement is specified with a signed
integer, allowing jumps either forward or backward in the instruction stream.
An absolute address is a offset from address 0 of a segment. It can be specified in
either of the following ways:
An address in a general-purpose register — This address is treated as a near
pointer, which is copied into the EIP register. Program execution then continues at
the new address within the current code segment.