X86 assembly language

x86 assembly language is the name for the family of assembly languages which provide some level of backward compatibility with CPUs back to the Intel 8008 microprocessor, which was launched in April 1972. It is used to produce object code for the x86 class of processors.

Regarded as a programming language, assembly is machine-specific and low-level. Like all assembly languages, x86 assembly uses mnemonics to represent fundamental CPU instructions, or machine code. Assembly languages are most often used for detailed and time-critical applications such as small real-time embedded systems, operating-system kernels, and device drivers, but can also be used for other applications. A compiler will sometimes produce assembly code as an intermediate step when translating a high-level program into machine code.

Keyword
Reserved keywords of x86 assembly language • • aaa

• • aad

• • aam

• • aas

• • adc

• • add

• • and

• • arpl

• • bound

• • bsf

• • bsr

• • bswap

• • bt

• • btc

• • btr

• • bts

• • call

• • cbtw

• • clc

• • cld

• • cli

• • cltd

• • clts

• • cmc

• • cmp

• • cmps

• • cmpxchg

• • cwtd

• • cwtl

• • daa

• • das

• • dec

• • div

• • enter

• • f2xm1

• • fabs

• • fadd

• • faddp

• • fbld

• • fbstp

• • fchs

• • fclex

• • fcom

• • fcomp

• • fcompp

• • fcos

• • fdecstp

• • fdiv

• • fdivp

• • fdivr

• • fdivrp

• • ffree

• • fiadd

• • ficom

• • ficomp

• • fidiv

• • fidivr

• • fild

• • fimul

• • fincstp

• • finit

• • fist

• • fistp

• • fisubr

• • fisubrp

• • fld

• • fld

• • fldcw

• • fldenv

• • fldl2e

• • fldl2t

• • fldlg2

• • fldln2

• • fldpi

• • fldz

• • fmul

• • fmulp

• • fnclex

• • fnint

• • fnop

• • fnsave

• • fnstenv

• • fnstew

• • fnstsw

• • fpatan

• • fprem

• • fprem

• • fptan

• • frndint

• • frstor

• • fsave

• • fscale

• • fsin

• • fsincos

• • fsqrt

• • fst

• • fstenv

• • fstew

• • fstp

• • fstsw

• • fsub

• • fsubp

• • fsubr

• • fsubrp

• • ftst

• • fucom

• • fucomp

• • fucompp

• • fwait

• • fxam

• • fxch

• • fxtract

• • fyl2x

• • fyl2xp1

• • hlt

• • idiv

• • imul

• • in

• • inc

• • ins

• • int

• • into

• • invd

• • invlpg

• • iret

• • jcxz

• • jmp

• • lahf

• • lar

• • lcall

• • ldx

• • lea

• • leave

• • les

• • lfs

• • lgdt

• • lgs

• • lidt

• • ljmp

• • lldt

• • lmsw

• • lock

• • lods

• • loop

• • loopnz

• • loopz

• • lret

• • lsl

• • lss

• • ltr

• • mov

• • movs

• • movsx

• • movw

• • movzb

• • mul

• • neg

• • nop

• • not

• • or

• • out

• • outs

• • pop

• • popa

• • popf

• • push

• • pusha

• • pushf

• • rcl

• • rcr

• • rep

• • repnz

• • repz

• • ret

• • rol

• • ror

• • sahf

• • sal

• • sar

• • sbb

• • scas

• • setcc

• • sgdt

• • shl

• • shld

• • shr

• • shrd

• • sidt

• • sldt

• • smsw

• • stc

• • std

• • sti

• • stos

• • str

• • sub

• • test

• • verr

• • verw

• • wait

• • wbinvd

• • xadd

• • xchg

• • xlat

• • xor

Mnemonics and opcodes
Each x86 assembly instruction is represented by a mnemonic which, often combined with one or more operands, translates to one or more bytes called an opcode; the NOP instruction translates to 0x90, for instance, and the HLT instruction translates to 0xF4. There are potential opcodes with no documented mnemonic which different processors may interpret differently, making a program using them behave inconsistently or even generate an exception on some processors. These opcodes often turn up in code writing competitions as a way to make the code smaller, faster, more elegant or just show off the author's prowess.

Syntax
x86 assembly language has two main syntax branches: Intel syntax and AT&amp;T syntax. Intel syntax is dominant in the DOS and Windows world, and AT&amp;T syntax is dominant in the Unix world, since Unix was created at AT&amp;T Bell Labs. Here is a summary of the main differences between Intel syntax and AT&amp;T syntax:

Many x86 assemblers use Intel syntax, including FASM, MASM, NASM, TASM, and YASM. GAS, which originally used AT&amp;T syntax, has supported both syntaxes since version 2.10 via the   directive. A quirk in the AT&amp;T syntax for x86 is that x87 operands are reversed, an inherited bug from the original AT&T assembler.

The AT&T syntax is nearly universal to all other architectures (retaining the same mov order); it was originally a syntax for PDP-11 assembly. The Intel syntax is specific to the x86 architecture, and is the one used in the x86 platform's documentation. The Intel 8080, which predates the x86, also uses the "destination-first" order for mov.

Registers
x86 processors have a collection of registers available to be used as stores for binary data. Collectively the data and address registers are called the general registers. Each register has a special purpose in addition to what they can all do:
 * AX multiply/divide, string load & store
 * BX index register for MOVE
 * CX count for string operations & shifts
 * DX port address for IN and OUT
 * SP points to top of the stack
 * BP points to base of the stack frame
 * SI points to a source in stream operations
 * DI points to a destination in stream operations

Along with the general registers there are additionally the:
 * IP instruction pointer
 * FLAGS
 * segment registers (CS, DS, ES, FS, GS, SS) which determine where a 64k segment starts (no FS & GS in 80286 & earlier)
 * extra extension registers (MMX, 3DNow!, SSE, etc.) (Pentium & later only).

The IP register points to the memory offset of the next instruction in the code segment (it points to the first byte of the instruction). The IP register cannot be accessed by the programmer directly.

The x86 registers can be used by using the MOV instructions. For example, in Intel syntax:

Segmented addressing
The x86 architecture in real and virtual 8086 mode uses a process known as segmentation to address memory, not the flat memory model used in many other environments. Segmentation involves composing a memory address from two parts, a segment and an offset; the segment points to the beginning of a 64 KiB (64×210) group of addresses and the offset determines how far from this beginning address the desired address is. In segmented addressing, two registers are required for a complete memory address. One to hold the segment, the other to hold the offset. In order to translate back into a flat address, the segment value is shifted four bits left (equivalent to multiplication by 24 or 16) then added to the offset to form the full address, which allows breaking the 64k barrier through clever choice of addresses, though it makes programming considerably more complex.

In real mode/protected only, for example, if DS contains the hexadecimal number 0xDEAD and DX contains the number 0xCAFE they would together point to the memory address 0xDEAD * 0x10 + 0xCAFE == 0xEB5CE. Therefore, the CPU can address up to 1,048,576 bytes (1 MB) in real mode. By combining segment and offset values we find a 20-bit address.

The original IBM PC restricted programs to 640 KB but an expanded memory specification was used to implement a bank switching scheme that fell out of use when later operating systems, such as Windows, used the larger address ranges of newer processors and implemented their own virtual memory schemes.

Protected mode, starting with the Intel 80286, was utilized by OS/2. Several shortcomings, such as the inability to access the BIOS and the inability to switch back to real mode without resetting the processor, prevented widespread usage. The 80286 was also still limited to addressing memory in 16-bit segments, meaning only 216 bytes (64 kilobytes) could be accessed at a time. To access the extended functionality of the 80286, the operating system would set the processor into protected mode, enabling 24-bit addressing and thus 224 bytes of memory (16 megabytes).

In protected mode, the segment selector can be broken down into three parts: a 13-bit index, a Table Indicator bit that determines whether the entry is in the GDT or LDT and a 2-bit Requested Privilege Level; see x86 memory segmentation.

When referring to an address with a segment and an offset the notation of segment:offset is used, so in the above example the flat address 0xEB5CE can be written as 0xDEAD:0xCAFE or as a segment and offset register pair; DS:DX.

There are some special combinations of segment registers and general registers that point to important addresses:
 * CS:IP (CS is Code Segment, IP is Instruction Pointer) points to the address where the processor will fetch the next byte of code.
 * SS:SP (SS is Stack Segment, SP is Stack Pointer) points to the address of the top of the stack, i.e. the most recently pushed byte.
 * SS:BP (SS is Stack Segment, BP is Stack Frame Pointer) points to the address of the top of the stack frame, i.e. the base of the data area in the call stack for the currently active subprogram.
 * DS:SI (DS is Data Segment, SI is Source Index) is often used to point to string data that is about to be copied to ES:DI.
 * ES:DI (ES is Extra Segment, DI is Destination Index) is typically used to point to the destination for a string copy, as mentioned above.

The Intel 80386 featured three operating modes: real mode, protected mode and virtual mode. The protected mode which debuted in the 80286 was extended to allow the 80386 to address up to 4 GB of memory, the all new virtual 8086 mode (VM86) made it possible to run one or more real mode programs in a protected environment which largely emulated real mode, though some programs were not compatible (typically as a result of memory addressing tricks or using unspecified op-codes).

The 32-bit flat memory model of the 80386's extended protected mode may be the most important feature change for the x86 processor family until AMD released x86-64 in 2003, as it helped drive large scale adoption of Windows 3.1 (which relied on protected mode) since Windows could now run many applications at once, including DOS applications, by using virtual memory and simple multitasking.

Execution modes
The x86 processors support five modes of operation for x86 code, Real Mode, Protected Mode, Long Mode, Virtual 86 Mode, and System Management Mode, in which some instructions are available and others are not. A 16-bit subset of instructions is available on the 16-bit x86 processors, which are the 8086, 8088, 80186, 80188, and 80286. These instructions are available in real mode on all x86 processors, and in 16-bit protected mode (80286 onwards), additional instructions relating to protected mode are available. On the 80386 and later, 32-bit instructions (including later extensions) are also available in all modes, including real mode; on these CPUs, V86 mode and 32-bit protected mode are added, with additional instructions provided in these modes to manage their features. SMM, with some of its own special instructions, is available on some Intel i386SL, i486 and later CPUs. Finally, in long mode (AMD Opteron onwards), 64-bit instructions, and more registers, are also available. The instruction set is similar in each mode but memory addressing and word size vary, requiring different programming strategies.

The modes in which x86 code can be executed in are:
 * Real mode (16-bit)
 * 20-bit segmented memory address space (meaning that only 1 MB of memory can be addressed— actually since 80286 a little more through HMA), direct software access to peripheral hardware, and no concept of memory protection or multitasking at the hardware level. Computers that use BIOS start up in this mode.
 * Protected mode (16-bit and 32-bit)
 * Expands addressable physical memory to 16 MB and addressable virtual memory to 1 GB. Provides privilege levels and protected memory, which prevents programs from corrupting one another. 16-bit protected mode (used during the end of the DOS era) used a complex, multi-segmented memory model. 32-bit protected mode uses a simple, flat memory model.
 * Long mode (64-bit)
 * Mostly an extension of the 32-bit (protected mode) instruction set, but unlike the 16–to–32-bit transition, many instructions were dropped in the 64-bit mode. Pioneered by AMD.
 * Virtual 8086 mode (16-bit)
 * A special hybrid operating mode that allows real mode programs and operating systems to run while under the control of a protected mode supervisor operating system
 * System Management Mode (16-bit)
 * Handles system-wide functions like power management, system hardware control, and proprietary OEM designed code. It is intended for use only by system firmware. All normal execution, including the operating system, is suspended. An alternate software system (which usually resides in the computer's firmware, or a hardware-assisted debugger) is then executed with high privileges.

Switching modes
The processor runs in real mode immediately after power on, so an operating system kernel, or other program, must explicitly switch to another mode if it wishes to run in anything but real mode. Switching modes is accomplished by modifying certain bits of the processor's control registers after some preparation, and some additional setup may be required after the switch.

Examples
With a computer running legacy BIOS, the BIOS and the boot loader run in Real mode. The 64-bit operating system kernel checks and switches the CPU into Long mode and then starts new kernel-mode threads running 64-bit code.

With a computer running UEFI, the UEFI firmware (except CSM and legacy Option ROM), the UEFI boot loader and the UEFI operating system kernel all run in Long mode.

Instruction types
In general, the features of the modern x86 instruction set are:


 * A compact encoding
 * Variable length and alignment independent (encoded as little endian, as is all data in the x86 architecture)
 * Mainly one-address and two-address instructions, that is to say, the first operand is also the destination.
 * Memory operands as both source and destination are supported (frequently used to read/write stack elements addressed using small immediate offsets).
 * Both general and implicit register usage; although all seven (counting ) general registers in 32-bit mode, and all fifteen (counting  ) general registers in 64-bit mode, can be freely used as accumulators or for addressing, most of them are also implicitly used by certain (more or less) special instructions; affected registers must therefore be temporarily preserved (normally stacked), if active during such instruction sequences.
 * Produces conditional flags implicitly through most integer ALU instructions.
 * Supports various addressing modes including immediate, offset, and scaled index but not PC-relative, except jumps (introduced as an improvement in the x86-64 architecture).
 * Includes floating point to a stack of registers.
 * Contains special support for atomic read-modify-write instructions (, / ,  , and integer instructions which combine with the   prefix)
 * SIMD instructions (instructions which perform parallel simultaneous single instructions on many operands encoded in adjacent cells of wider registers).

Stack instructions
The x86 architecture has hardware support for an execution stack mechanism. Instructions such as,  ,   and   are used with the properly set up stack to pass parameters, to allocate space for local data, and to save and restore call-return points. The  size instruction is very useful for implementing space efficient (and fast) calling conventions where the callee is responsible for reclaiming stack space occupied by parameters.

When setting up a stack frame to hold local data of a recursive procedure there are several choices; the high level  instruction (introduced with the 80186) takes a procedure-nesting-depth argument as well as a local size argument, and may be faster than more explicit manipulation of the registers (such as   ;   ;  ). Whether it is faster or slower depends on the particular x86-processor implementation as well as the calling convention used by the compiler, programmer or particular program code; most x86 code is intended to run on x86-processors from several manufacturers and on different technological generations of processors, which implies highly varying microarchitectures and microcode solutions as well as varying gate- and transistor-level design choices.

The full range of addressing modes (including immediate and base+offset) even for instructions such as  and , makes direct usage of the stack for integer, floating point and address data simple, as well as keeping the ABI specifications and mechanisms relatively simple compared to some RISC architectures (require more explicit call stack details).

Integer ALU instructions
x86 assembly has the standard mathematical operations,,  ,  ,   and   (for signed integers), with   and   (for unsigned integers); the logical operators  ,  ,  ,  ; bitshift arithmetic and logical,  /  (for signed integers),  /  (for unsigned integers); rotate with and without carry,  / ,  / , a complement of BCD arithmetic instructions,  ,  ,   and others.

Floating-point instructions
x86 assembly language includes instructions for a stack-based floating-point unit (FPU). The FPU was an optional separate coprocessor for the 8086 through the 80386, it was an on-chip option for the 80486 series, and it is a standard feature in every Intel x86 CPU since the 80486, starting with the Pentium. The FPU instructions include addition, subtraction, negation, multiplication, division, remainder, square roots, integer truncation, fraction truncation, and scale by power of two. The operations also include conversion instructions, which can load or store a value from memory in any of the following formats: binary-coded decimal, 32-bit integer, 64-bit integer, 32-bit floating-point, 64-bit floating-point or 80-bit floating-point (upon loading, the value is converted to the currently used floating-point mode). x86 also includes a number of transcendental functions, including sine, cosine, tangent, arctangent, exponentiation with the base 2 and logarithms to bases 2, 10, or e.

The stack register to stack register format of the instructions is usually  or , where   is equivalent to  , and   is one of the 8 stack registers ( ,  , ...,  ). Like the integers, the first operand is both the first source operand and the destination operand. and  should be singled out as first swapping the source operands before performing the subtraction or division. The addition, subtraction, multiplication, division, store and comparison instructions include instruction modes that pop the top of the stack after their operation is complete. So, for example,  performs the calculation , then removes   from the top of stack, thus making what was the result in   the top of the stack in.

SIMD instructions
Modern x86 CPUs contain SIMD instructions, which largely perform the same operation in parallel on many values encoded in a wide SIMD register. Various instruction technologies support different operations on different register sets, but taken as complete whole (from MMX to SSE4.2) they include general computations on integer or floating-point arithmetic (addition, subtraction, multiplication, shift, minimization, maximization, comparison, division or square root). So for example,  performs 4 parallel 16-bit (indicated by the  ) integer adds (indicated by the  ) of   values to   and stores the result in. Streaming SIMD Extensions or SSE also includes a floating-point mode in which only the very first value of the registers is actually modified (expanded in SSE2). Some other unusual instructions have been added including a sum of absolute differences (used for motion estimation in video compression, such as is done in MPEG) and a 16-bit multiply accumulation instruction (useful for software-based alpha-blending and digital filtering). SSE (since SSE3) and 3DNow! extensions include addition and subtraction instructions for treating paired floating-point values like complex numbers.

These instruction sets also include numerous fixed sub-word instructions for shuffling, inserting and extracting the values around within the registers. In addition there are instructions for moving data between the integer registers and XMM (used in SSE)/FPU (used in MMX) registers.

Memory instructions
The x86 processor also includes complex addressing modes for addressing memory with an immediate offset, a register, a register with an offset, a scaled register with or without an offset, and a register with an optional offset and another scaled register. So for example, one can encode  as a single instruction which loads 32 bits of data from the address computed as   offset from the   selector, and stores it to the   register. In general x86 processors can load and use memory matched to the size of any register it is operating on. (The SIMD instructions also include half-load instructions.)

Most 2-operand x86 instructions, including integer ALU instructions, use a standard "addressing mode byte" often called the MOD-REG-R/M byte. Many 32-bit x86 instructions also have a SIB addressing mode byte that follows the MOD-REG-R/M byte.

In principle, because the instruction opcode is separate from the addressing mode byte, those instructions are orthogonal because any of those opcodes can be mixed-and-matched with any addressing mode. However, the x86 instruction set is generally considered non-orthogonal because many other opcodes have some fixed addressing mode (they have no addressing mode byte), and every register is special.

The x86 instruction set includes string load, store, move, scan and compare instructions (, ,  ,   and  ) which perform each operation to a specified size (  for 8-bit byte,   for 16-bit word,   for 32-bit double word) then increments/decrements (depending on DF, direction flag) the implicit address register (  for  ,   for   and  , and both for   and  ). For the load, store and scan operations, the implicit target/source/comparison register is in the,   or   register (depending on size). The implicit segment registers used are  for   and   for. The  or   register is used as a decrementing counter, and the operation stops when the counter reaches zero or (for scans and comparisons) when inequality is detected. Unfortunately, over the years the performance of some of these instructions became neglected and in certain cases it is now possible to get faster results by writing out the algorithms yourself. Intel and AMD have refreshed some of the instructions though, and a few now have very respectable performance, so it is recommended that the programmer should read recent respected benchmark articles before choosing to use a particular instruction from this group.

The stack is a region of memory and an associated ‘stack pointer’, which points to the bottom of the stack. The stack pointer is decremented when items are added (‘push’) and incremented after things are removed (‘pop’). In 16-bit mode, this implicit stack pointer is addressed as SS:[SP], in 32-bit mode it is SS:[ESP], and in 64-bit mode it is [RSP]. The stack pointer actually points to the last value that was stored, under the assumption that its size will match the operating mode of the processor (i.e., 16, 32, or 64 bits) to match the default width of the / / /  instructions. Also included are the instructions  and   which reserve and remove data from the top of the stack while setting up a stack frame pointer in  / /. However, direct setting, or addition and subtraction to the / /  register is also supported, so the  /  instructions are generally unnecessary.

This code is the beginning of a function typical for a high-level language when compiler optimisation is turned off for ease of debugging: ...is functionally equivalent to just:

Other instructions for manipulating the stack include (32-bit) /  (64-bit) and   for storing and retrieving the EFLAGS (32-bit) / RFLAGS (64-bit) register.

Values for a SIMD load or store are assumed to be packed in adjacent positions for the SIMD register and will align them in sequential little-endian order. Some SSE load and store instructions require 16-byte alignment to function properly. The SIMD instruction sets also include "prefetch" instructions which perform the load but do not target any register, used for cache loading. The SSE instruction sets also include non-temporal store instructions which will perform stores straight to memory without performing a cache allocate if the destination is not already cached (otherwise it will behave like a regular store.)

Most generic integer and floating-point (but no SIMD) instructions can use one parameter as a complex address as the second source parameter. Integer instructions can also accept one memory parameter as a destination operand.

Program flow
The x86 assembly has an unconditional jump operation,, which can take an immediate address, a register or an indirect address as a parameter (note that most RISC processors only support a link register or short immediate displacement for jumping).

Also supported are several conditional jumps, including  (jump on zero),   (jump on non-zero),   (jump on greater than, signed),   (jump on less than, signed),   (jump on above/greater than, unsigned),   (jump on below/less than, unsigned). These conditional operations are based on the state of specific bits in the (E)FLAGS register. Many arithmetic and logic operations set, clear or complement these flags depending on their result. The comparison  (compare) and   instructions set the flags as if they had performed a subtraction or a bitwise AND operation, respectively, without altering the values of the operands. There are also instructions such as  (clear carry flag) and   (complement carry flag) which work on the flags directly. Floating point comparisons are performed via  or   instructions which eventually have to be converted to integer flags.

Each jump operation has three different forms, depending on the size of the operand. A short jump uses an 8-bit signed operand, which is a relative offset from the current instruction. A near jump is similar to a short jump but uses a 16-bit signed operand (in real or protected mode) or a 32-bit signed operand (in 32-bit protected mode only). A far jump is one that uses the full segment base:offset value as an absolute address. There are also indirect and indexed forms of each of these.

In addition to the simple jump operations, there are the  (call a subroutine) and   (return from subroutine) instructions. Before transferring control to the subroutine,  pushes the segment offset address of the instruction following the   onto the stack;   pops this value off the stack, and jumps to it, effectively returning the flow of control to that part of the program. In the case of a, the segment base is pushed following the offset;   pops the offset and then the segment base to return.

There are also two similar instructions,  (interrupt), which saves the current (E)FLAGS register value on the stack, then performs a , except that instead of an address, it uses an interrupt vector, an index into a table of interrupt handler addresses. Typically, the interrupt handler saves all other CPU registers it uses, unless they are used to return the result of an operation to the calling program (in software called interrupts). The matching return from interrupt instruction is, which restores the flags after returning. Soft Interrupts of the type described above are used by some operating systems for system calls, and can also be used in debugging hard interrupt handlers. Hard interrupts are triggered by external hardware events, and must preserve all register values as the state of the currently executing program is unknown. In Protected Mode, interrupts may be set up by the OS to trigger a task switch, which will automatically save all registers of the active task.

Examples
The following examples use the so-called Intel-syntax flavor as used by the assemblers Microsoft MASM, NASM and many others. (Note: There is also an alternative AT&T-syntax flavor where the order of source and destination operands are swapped, among many other differences.)

"Hello world!" program for MS-DOS in MASM-style assembly
Using the software interrupt 21h instruction to call the MS-DOS operating system for output to the display – other samples use libc's C printf routine to write to stdout. Note that the first example, is a 30-year-old example using 16-bit mode as on an Intel 8086. The second example is Intel 386 code in 32-bit mode. Modern code will be in 64-bit mode.

"Hello world!" program for Linux in NASM style assembly
For 64-bit long mode, "lea rcx, str" would be the address of the message, note 64-bit register rcx.

"Hello world!" program for 64-bit mode Linux in NASM style assembly
This example is in modern 64-bit mode.

Running it under strace verifies that no extra system calls are made in the process. The printf version would make many more system calls to initialize libc and do dynamic linking. But this is a static executable because we linked using ld without -pie or any shared libraries; the only instructions that run in user-space are the ones you provide.

Using the flags register
Flags are heavily used for comparisons in the x86 architecture. When a comparison is made between two data, the CPU sets the relevant flag or flags. Following this, conditional jump instructions can be used to check the flags and branch to code that should run, e.g.: Aside, from compare instructions, there are a great many arithmetic and other instructions that set bits in the flags register. Other examples are the instructions sub, test and add and there are many more. Common combinations such as cmp + conditional jump are internally ‘fused’ (‘macro fusion’) into one single micro-instruction (μ-op) and are fast provided the processor can guess which way the conditional jump will go, jump vs continue.

The flags register are also used in the x86 architecture to turn on and off certain features or execution modes. For example, to disable all maskable interrupts, you can use the instruction:

The flags register can also be directly accessed. The low 8 bits of the flag register can be loaded into  using the   instruction. The entire flags register can also be moved on and off the stack using the instructions,  ,   (including  ) and.

The x87 floating point maths subsystem also has its own independent ‘flags’-type register the fp status word. In the 1990s it was an awkward and slow procedure to access the flag bits in this register, but on modern processors there are ‘compare two floating point values’ instructions that can be used with the normal conditional jump/branch instructions directly without any intervening steps.

Using the instruction pointer register
The instruction pointer is called  in 16-bit mode,   in 32-bit mode, and   in 64-bit mode. The instruction pointer register points to the address of the next instruction that the processor will attempt to execute. It cannot be directly accessed in 16-bit or 32-bit mode, but a sequence like the following can be written to put the address of  into   (32-bit code):

Writing to the instruction pointer is simple — a  instruction stores the given target address into the instruction pointer to, so, for example, a sequence like the following will put the contents of   into   (64-bit code):

In 64-bit mode, instructions can reference data relative to the instruction pointer, so there is less need to copy the value of the instruction pointer to another register.

Manuals

 * Intel 64 and IA-32 Software Developer Manuals
 * AMD64 Architecture Programmer's Manual (Volume 1-5)