NOTE: The Intel 64 and IA-32 Architectures Software Developer's Manual
consists of five volumes: Basic Architecture, Order Number 253665;
Instruction Set Reference A-M, Order Number 253666; Instruction Set
Reference N-Z, Order Number 253667; System Programming Guide,
Part 1, Order Number 253668; System Programming Guide, Part 2,
Order Number 253669. Refer to all five volumes when evaluating your
design needs.
Order Number: 253666-024US
August 2007
INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL PRODUCTS. NO LICENSE,
EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERT Y RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN INTEL’S TERMS AND CONDITIONS OF SALE FOR SUCH
PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER, AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY, RELATING TO SALE AND/OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES
RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY
PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. INTEL PRODUCTS ARE NOT INTENDED
FOR USE IN MEDICAL, LIFE SAVING, OR LIFE SUSTAINING APPLICATIONS.
Intel may make changes to specifications and product descriptions at any time, without notice.
Developers must not rely on the absence or characteristics of any features or instructions marked “reserved”
or “undefined.” Improper use of reserved or undefined features or instructions may cause unpre dictab le be havior or failure in developer's software code when running on an Intel processor. Intel reserves these features or instructions for future definition and shall have no responsibility whatsoever for conflicts or
incompatibilities arising from their unauthorized use.
The Intel
acterized errata are available on request.
Hyper-Threading Technology requires a computer system with an Intel
Threading Technology and an HT Technology enabled chipset, BIOS and oper ating sys tem. Pe rformance will
vary depending on the specific hardware and software you use. For more information, see http://www.in-
tel.com/technology/hyperthread/index.htm; including details on which processors support HT Technology.
®
64 architecture processors ma y conta in de sign defects o r err ors kn own as err a ta. Curr ent c har -
®
processor supporting Hyper-
No computer system can provide absolute security under all conditions. Intel® Trusted Ex ecution Technology requires a computer system with Intel® Virtualization Technology, an Intel TXT-enabled processor,
chipset, BIOS, Authenti cate d Code Mo dule s and an Intel TXT-compatible measured launched environment
(MLE). The MLE could consist of a virtual machine monitor, an OS or an application. In addition, Intel TXT
requires the system to contain a TPM v1.2, as defined by the Trusted Computing Group, and specific software for some uses. For more information, see http://www.intel.com/technology/security
®
Virtualization T echnol ogy requires a computer syste m with an enabled Intel® processor , BIOS, virtual
Intel
machine monitor (VMM) and for some uses, certain platform software enabled for it. Functionality, performance or other benefits will
Technology-enabled BIOS and VMM applications are currently in development.
64-bit computing on Intel architecture requires a computer system with a processor, chipset, BIOS, operating system, device drivers and applications enabled for Intel
(including 32-bit operation) without an Intel
pending on your hardware and software configurations. Consult with your system vendor for more information.
vary depending on hardware and software configurations. Intel® Virtualization
®
®
64 architecture-enabled BIOS. Performance will vary de-
64 architecture. Processors will not operate
Enabling Execute Disable Bit functionality requires a PC with a processor with Execute Disable Bit capability
and a supporting operating system. Chec k with your PC manufacturer on whether your system delivers Execute Disable Bit functionality.
Intel, Pentium, Intel Xeon, Intel NetBurst, Intel Core Solo, Intel Core Duo, Intel Core 2 Duo, Intel Core 2
Extreme, Intel Pentium D, Itanium, Intel SpeedStep, MMX, and VTune are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.
*Other names and brands may be claimed as the property of others.
Contact your local Intel sales office or your distributor to obtain the latest specifications and befo re plac ing
your product order.
Copies of documents which have an ordering number and are referenced in this document, or other Intel
literature, may be obtained from:
Intel Corporation
P.O. Box 5937
Denver, CO 80217-9808
or call 1-800-548-4725
or visit Intel’s website a t http://www.intel.com
The Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volumes
2A & 2B: Instruction Set Reference (order numbers 253666 and 253667) are part of
a set that describes the architecture and programming environment of all Intel 64
and IA-32 architecture processors. Other volumes in this set are:
•The Intel
Basic Architecture (Order Number 253665).
•The Intel
3A & 3B: System Programming Guide (order numbers 253668 and 253669).
The Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1,
describes the basic architecture and programming environment of Intel 64 and IA-32
processors. The IntelVolumes 2A & 2B, describe the instruction set of the processor and the opcode structure. These volumes apply to application programmers and to programmers who
write operating system s or executiv es. The Intelware Developer’s Manual, Volumes 3A & 3B, describe the operating-system support
environment of Intel 64 and IA-32 processors. These volumes target operatingsystem and BIOS designers. In addition, the Intelware Developer’s Manual, Volume 3B, addresses the programming environment for
classes of software that host operating systems.
®
64 and IA-32 Architectures Software Developer’s Manual, Volume 1:
®
64 and IA-32 Architectures Software Developer’s Manual, Volumes
®
64 and IA-32 Architectures Software Developer’s Manual,
®
64 and IA-32 Architectures Soft-
®
64 and IA-32 Architectures Soft-
1.1 IA-32 PROCESSORS COVERED IN THIS MANUAL
This manual set includes information pertaining primarily to the most recent Intel 64
and IA-32 processors, which include:
•Pentium
®
processors
•P6 family processors
•Pentium
•Pentium
•Intel
•Pentium
•Pentium
•64-bit Intel
•Intel
•Intel
•Dual-Core Intel
®
4 processors
®
M processors
®
Xeon® processors
®
D processors
®
processor Extreme Editions
®
Xeon® processors
®
Core™ Duo processor
®
Core™ Solo processor
®
Xeon® processor LV
Vol. 2A 1-1
ABOUT THIS MANUAL
•Intel
•Intel
•Intel
•Intel
•Intel
•Intel
•Intel
•Intel
•Intel
P6 family processors are IA-32 processors based on the P6 family microarchitecture.
This includes the Pentium® Pro, Pentium® II, Pentium® III, and P entium® III Xeon®
processors.
The Pentium® 4, Pentium® D, and Pentium® processor Extreme Editions are based
on the Intel NetBurst® microarchitecture. Most early Intel® Xeon® processors are
based on the Intel NetBurst
series are based on the Intel NetBurst® microarchitecture.
The Intel® Core™ Duo, Intel® Core™ Solo and dual-core Intel® Xeon® processor LV
are based on an improved Pentium® M processor microarchitecture.
The Intel® Xeon® processor 3000, 3200, 5100, 5300, and 7300 series, Intel®
Pentium® dual-core, Intel® Core™2 Duo, Intel® Core™2 Quad, and Intel® Core™2
Extreme processors are based on Intel® Core™ microarchitecture.
P6 family , P entium® M, Intel® Core™ Solo, Intel® Core™ Duo processors, dual-core
Intel® Xeon® processor LV, and early generations of P entium 4 and Intel X eon
processors support IA-32 architecture.
The Intel® Xeon® processor 3000, 3200, 5000, 5100, 5300, 7100, 7300 series,
Intel
Pentium® D processors, Pentium® Dual-Core processor, newer generations of
Pentium 4 and Intel Xeon processor family support Intel
IA-32 architecture is the instruction set architecture and programming environment
for Intel's 32-bit microprocessors.
Intel® 64 architecture is the instruction set architecture and programming environment which is the superset of Intel’s 32-bit and 64-bit architectures. It is compatible
with the IA-32 architecture.
A description of Intel® 64 and IA-32 Architectures Software Developer’s Manual,
Volumes 2A & 2B, content follows:
1-2 Vol. 2A
ABOUT THIS MANUAL
Chapter 1 — About This Manual. Gives an overview of all five volumes of the
®
Intel
64 and IA-32 Architectures Software Developer’s Manual. It also describes the
notational conventions in these manuals and lists related Intel® manuals and documentation of interest to programmers and hardware designers.
Chapter 2 — Instruction Format. Describes the machine-level instruction format
used for all IA-32 instructions and gives the allowable encodings of prefixes, the
operand-identifier byte (ModR/M byte), the addressing-mode specifier byte (SIB
byte), and the displacement and immediate bytes.
Chapter 3 — Instruction Set Reference , A-M. Describes Intel 64 and IA-32
instructions in detail, including an algorithmic description of operations, the effect on
flags, the effect of operand- and address-size attributes, and the ex ceptions that
may be generated. The instructions are arranged in alphabetical order. Generalpurpose, x87 FPU, Intel MMX™ technology , SSE/SSE2/SSE3 extensions, and system
instructions are included.
Chapter 4 — Instruction Set Reference, N-Z. Continues the description of Intel
64 and IA-32 instructions started in Chapter 3. It provides the balance of the alphabetized list of instructions and starts Intel
®
64 and IA-32 Architectures Software
Developer’s Manual, Volume 2B.
Chapter 5 — VMX Instruction Reference. Describes the virtual-machine extensions (VMX). VMX is intended for a system executive to support virtualization of
processor hardware and a system software layer acting as a host to multiple guest
software environments.
Chapter 6— Safer Mode Extensions Reference. Describes the safer mode extensions (SMX). SMX is intended for a system executive to support launching a
measured environment in a platform where the identity of the software controlling
the platform hardware can be measured for the purpose of making trust decisions.
Appendix A — Opcode Map. Gives an opcode map for the IA-32 instruction set.
Appendix B — Instruction Formats and Encodings. Gives the binary encoding of
each form of each IA-32 instruction.
®
Appendix C — Intel
Lists the Intel
®
C/C++ compiler intrinsics and their assembly code equivalents for each
C/C++ Compiler Intrinsics and Functional Equivalents.
of the IA-32 MMX and SSE/SSE2/SSE3 instructions.
1.3 NOTATIONAL CONVENTIONS
This manual uses specific notation for data-structure formats, for symbolic representation of instructions, and for hexadecimal and binary numbers. A review of this
notation makes the manual easier to read.
Vol. 2A 1-3
ABOUT THIS MANUAL
1.3.1 Bit and Byte Order
In illustrations of data structures in memory , smaller addresses appear toward the
bottom of the figure; addresses increase toward the top. Bit positions are numbered
from right to left. The numerical value of a set bit is equal to two raised to the power
of the bit position. IA-32 processors are “little endian” machines; this means the
bytes of a word are numbered starting from the least significant byte. Figure 1-1
illustrates these conventions.
1-4 Vol. 2A
ABOUT THIS MANUAL
Highest
Address
31
Byte 3
24
23
Byte 2
Data Structure
15
16
Byte 1
8
7
Byte 0
Byte Offset
Bit offset
0
28
24
20
16
12
8
4
Lowest
0
Address
Figure 1-1. Bit and Byte Order
1.3.2 Reserved Bits and Software Compatibility
In many register and memory layout descriptions, certain bits are marked as
reserved. When bits are marked as reserved, it is essential for compatibility with
future processors that software treat these bits as having a future, though unkno wn,
effect. The behavior of reserved bits should be regarded as not only undefined, but
unpredictable. Software should follow these guidelines in dealing with reserved bits:
•Do not depend on the states of any reserved bits when testing the values of
registers which contain such bits. Mask out the reserved bits before testing.
•Do not depend on the states of any reserved bits when storing to memory or to a
register.
•Do not depend on the ability to retain information written into any reserved bits.
•When loading a register, always load the reserved bits with the values indicated
in the documentation, if any , or reload them with values previously read from the
same register.
NOTE
Avoid any softw are dependence upon the st ate of reserved bits in
IA-32 registers. Depending upon the values of reserved register bits
will make software dependent upon the unspecified manner in which
the processor handles these bits. Programs that depend upon
reserved values risk incompatibility with future processors.
Vol. 2A 1-5
ABOUT THIS MANUAL
1.3.3 Instruction Operands
When instructions are represented symbolically , a subset of the IA -32 assembly
language is used. In this subset, an instruction has the following format:
label: mnemonic argument1, argument2, argument3
where:
•A label is an identifier which is followed by a colon.
•A mnemonic is a reserved name for a class of instruction opcodes which have
the same function.
•The operands argument1, argument2, and argument3 are optional. Th ere may
be from zero to three operands, depending on the opcode. When present, they
take the form of either literals or identifiers for data items. Operand identifiers
are either reserved names of registers or are assumed to be assigned to data
items declared in another part of the program (which may not be shown in the
example).
When two operands are present in an arithmetic or logical instruction, the right
operand is the source and the left operand is the destination.
For example:
LOADREG: MOV EAX, SUBTOTAL
In this example, LOADREG is a label, MOV is the mnemonic identifier of an opcode,
EAX is the destination operand, and SUBT OTAL is the source operand. Some
assembly languages put the source and destination in reverse order.
1.3.4 Hexadecimal and Binary Numbers
Base 16 (hexadecimal) numbers are represented by a string of hexadecimal digits
followed by the character H (for example, F82EH). A hexadecimal digit is a character
from the following set: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F.
Base 2 (binary) numbers are represented by a string of 1s and 0s, sometimes
followed by the character B (for example, 1010B). The “B” designation is only used in
situations where confusion as to the type of number might arise.
1.3.5 Segmented Addressing
The processor uses byte addressing. This means memory is organized and accessed
as a sequence of bytes. Whether one or more bytes are being accessed, a byte
address is used to locate the byte or bytes in memory. The r ange of memory that can
be addressed is called an address space.
The processor also supports segmented addressing. This is a form of addressing
where a program may have many independent address spaces, called segments.
1-6 Vol. 2A
ABOUT THIS MANUAL
For example, a program can keep its code (instructions) and stack in separate
segments. Code addresses would always refer to the code space, and stack
addresses would always refer to the stack space. The following notation is used to
specify a byte address within a segment:
Segment-register:Byte-address
For example, the following segment address identifies the byte at address FF79H in
the segment pointed by the DS register:
DS:FF79H
The following segment address identifies an instruction address in the code segment.
The CS register points to the code segment and the EIP register contains the address
of the instruction.
CS:EIP
1.3.6 Exceptions
An exception is an event that typically occurs when an instruction causes an error.
For example, an attempt to divide by zero gener ates an exception. However, some
exceptions, such as breakpoints, occur under other conditions. Some types of exceptions may provide error codes. An error code reports additional information about the
error. An example of the notation used to show an exception and error code is shown
below:
#PF(fault code)
This example refers to a page-fault exception under conditions where an error code
naming a type of fault is reported. Under some conditions, exceptions which produce
error codes may not be able to report an accurate code. In this case, the error code
is zero, as shown below for a general-protection exception:
#GP(0)
1.3.7 A New Syntax for CPUID, CR, and MSR Values
Obtain feature flags, status, and system information by using the CPUID instruction,
by checking control register bits, and by reading model-specific registers. We are
moving toward a new syntax to represent this information. See Figure 1-2.
Some of the documents listed at this web site can be viewed on-line; others can be
ordered. The literature available is listed by Intel processor and then by the following
1-8 Vol. 2A
ABOUT THIS MANUAL
literature types: applications notes, data sheets, manuals, papers, and specification
updates.
See also:
•The data sheet for a particular Intel 64 or IA-32 processor
•The specification update for a particular Intel 64 or IA-32 processor
This chapter describes the instruction format for all Intel 64 and IA-32 processors.
The instruction format for protected mode, real-address mode and virtual-8086
mode is described in Section 2.1. Increments provided for IA-32e mode and its submodes are described in Section 2.2.
2.1 INSTRUCTION FORMAT FOR PROTECTED MODE,
REAL-ADDRESS MODE, AND VIRTUAL-8086 MODE
The Intel 64 and IA-32 architectures instruction encodings are subsets of the format
shown in Figure 2-1. Instructions consist of optional instruction prefixes (in any
order), primary opcode bytes (up to three bytes), an addressing-form specifier (if
required) consisting of the ModR/M byte and sometimes the SIB (Scale-Index-Base)
byte, a displacement (if required), and an immediate data field (if required).
Instruction
Prefixes
Up to four
prefixes of
1 byte each
(optional)
Opcode
1-, 2-, or 3-byte
opcode
7
65
Mod
Reg/
Opcode
ModR/M
1 byte
(if required)
2
3
R/M
1 byte
(if required)
0
SIBDisplacement
Address
displacement
of 1, 2, or 4
bytes or none
Index
27
Base
653
Scale
0
Immediate
Immediate
data of
1, 2, or 4
bytes or none
Figure 2-1. Intel 64 and IA-32 Architectures Instruction Format
2.1.1 Instruction Prefixes
Instruction prefixes are divided into four groups, each with a set of allowable prefix
codes. For each instruction, one prefix may be used from each of four groups (Groups
1, 2, 3, 4) and be placed in any order .
•Group 1
— Lock and repeat prefixes:
•F0H—LOCK
Vol. 2A 2-1
INSTRUCTION FORMAT
•F2H—REPNE/REPNZ (used only with string instructions; when used with
the escape opcode 0FH, this prefix is treated as a mandatory prefix for
some SIMD instructions)
•F3H—REP or REPE/REPZ (used only with string instructions; when used
with the escape opcode 0FH, this prefix is treated as an mandatory prefix
for some SIMD instructions)
•Group 2
— Segment override prefixes:
•2EH—CS segment override (use with any branch instruction is reserved)
•36H—SS segment override prefix (use with any branch instruction is
reserved)
•3EH—DS segment override prefix (use with any bran ch instruction is
reserved)
•26H—ES segment override prefix (use with any branch instruction is
reserved)
•64H—FS segment override prefix (use with any branch instruction is
reserved)
•65H—GS segment override prefix (use with any branch instruction is
reserved)
— Branch hints:
•2EH—Branch not taken (used only with Jcc instructions)
•3EH—Branch taken (used only with Jcc instructions)
•Group 3
•66H—Operand-size override prefix (when used with the es cape opcode
0FH, this is treated as a mandatory prefix for some SIMD instructions)
•Group 4
•67H—Address-size override prefix
The LOCK prefix (F0H) forces an operation that ensures exclusive use of shared
memory in a multiprocessor environment. See “LOCK — Assert LOCK# Sig nal Prefix”
in Chapter 3, “Instruction Set Reference, A-M,” for a description of this prefix.
Repeat prefixes (F2H, F3H) cause an instruction to be repeated for each element of a
string. Use these prefixes only with string instructions (MOVS, CMPS, SCAS, LODS,
STOS, INS, and OUTS). Their use, followed by 0FH, is treated as a mandatory prefix
by a number of SSE/SSE2/SSE3 instructions. Use of repeat prefixes and/or undefined opcodes with other Intel 64 or IA-32 instructions is reserved; such use may
cause unpredictable behavior.
Branch hint prefixes (2EH, 3EH) allow a progr am to give a hint to the processor about
the most likely code path for a branch. Use these prefixes only with conditional
branch instructions (Jcc). Other use of branch hint prefixes and/or other undefined
2-2 Vol. 2A
INSTRUCTION FORMAT
opcodes with Intel 64 or IA-32 instructions is reserved; such use may cause unpredictable behavior.
The operand-size override prefix allows a program to switch between 16- and 32-bit
operand sizes. Either size can be the default; use of the prefix selects the non-default
size. Use of 66H followed by 0FH is treated as a mandatory prefix by some
SSE/SSE2/SSE3 instructions. Other use of the 66H prefix with MMX/SSE/SSE2/SSE3
instructions is reserved; such use may cause unpredictable behavior.
The address-size override prefix (67H) allows programs to switch between 16- and
32-bit addressing. Either size can be the default; the prefix selects the non-default
size. Using this prefix and/or other undefined opcodes when operands for the instruction do not reside in memory is reserved; such use may cause unpredictable
behavior.
2.1.2 Opcodes
A primary opcode can be 1, 2, or 3 bytes in length. An additional 3-bit opcode field is
sometimes encoded in the ModR/M byte. Smaller fields can be defined within the
primary opcode. Such fields define the direction of operation, size of displacements,
register encoding, condition codes, or sign extension. Encoding fields used by an
opcode vary depending on the class of operation.
T wo-byte opcode formats for general-purpose and SIMD instructions consist of:
•An escape opcode byte 0FH as the primary opcode and a second opcode byte, or
•A mandatory prefix (66H, F2H, or F3H), an escape opcode byte, and a second
opcode byte (same as previous bullet)
For example, CVTDQ2PD consists of the following sequence: F3 0F E6. The first byte
is a mandatory prefix for SSE/SSE2/SSE3 instructions (it is not considered as a
repeat prefix).
Three-byte opcode formats for general-purpose and SIMD instructions consist of:
•An escape opcode byte 0FH as the primary opcode, plus two additional opcode
bytes, or
•A mandatory prefix (66H), an escape opcode byte, plus two additional opcode
bytes (same as previous bullet)
For example, PHADDW for XMM registers consists of the following sequence: 66 0F
38 01. The first byte is the mandatory prefix.
Valid opcode expressions are defined in Appendix A and Appendix B.
Vol. 2A 2-3
INSTRUCTION FORMAT
2.1.3 ModR/M and SIB Bytes
Many instructions that refer to an operand in memory have an addressing-form specifier byte (called the ModR/M byte) following the primary opcode. The ModR/M byte
contains three fields of information:
•The mod field combines with the r/m field to form 32 possible values: eight
registers and 24 addressing modes.
•The reg/opcode field specifies either a register number or three more bits of
opcode information. The purpose of the reg/opcode field is specified in the
primary opcode.
•The r/m field can specify a register as an oper and or it can be combined with the
mod field to encode an addressing mode. Sometimes, certain combinations of
the mod field and the r/m field is used to express opcode information for some
instructions.
Certain encodings of the ModR/M byte require a second addressing byte (the SIB
byte). The base-plus-index and scale-plus-index forms of 32-bit addressing require
the SIB byte. The SIB byte includes the following fields:
•The scale field specifies the scale factor.
•The index field specifies the register number of the index register .
•The base field specifies the register number of the base register.
See Section 2.1.5 for the encodings of the ModR/M and SIB bytes.
2.1.4 Displacement and Immediate Bytes
Some addressing forms include a displacement immediately following the ModR/M
byte (or the SIB byte if one is present). If a displacement is required; it be 1, 2, or 4
bytes.
If an instruction specifies an immediate operand, the operand always follows any
displacement bytes. An immediate operand can be 1, 2 or 4 bytes.
2.1.5 Addressing-Mode Encoding of ModR/M and SIB Bytes
The values and corresponding addressing forms of the ModR/M and SIB bytes are
shown in Table 2-1 through T able 2-3: 16-bit addressing forms specifie d by the
ModR/M byte are in T able 2-1 and 32-bit addressing forms are in T able 2-2. Table 2-3
shows 32-bit addressing forms specified by the SIB byte. In cases where the
reg/opcode field in the ModR/M byte represents an extended opcode, valid encodings
are shown in Appendix B.
In T able 2-1 and Table 2-2, the Effective Address column lists 32 effective addresses
that can be assigned to the first operand of an instruction by using the Mod and R/M
fields of the ModR/M byte. The first 24 options provide ways of specifying a memory
2-4 Vol. 2A
INSTRUCTION FORMAT
location; the last eight (Mod = 11B) provide ways of specifying general-purpose,
MMX technology and XMM registers.
The Mod and R/M columns in T able 2-1 and T able 2-2 give the binary encodings of the
Mod and R/M fields required to obtain the effective address listed in the first column.
For example: see the row indicated by Mod = 11B, R/M = 000B. The row identifies
the general-purpose registers EAX, AX or AL; MMX technology register MM0; or XMM
register XMM0. The register used is determined by the opcode byte and the operandsize attribute.
Now look at the seventh row in either table (labeled “REG =”). This row specifies the
use of the 3-bit Reg/Opcode field when the field is used to give the location of a
second operand. The second operand must be a gener al-purpose, MMX technology,
or XMM register. Rows one through five list the registers that may correspond to the
value in the table. Again, the reg ister used is determined by the opcode byte along
with the operand-size attribute.
If the instruction does not require a second operand, then the Reg/Opcode field may
be used as an opcode extension. This use is represented by the sixth row in the
tables (labeled “/digit (Opcode)”). Note that values in row six are represented in
decimal form.
The body of T able 2-1 and T able 2-2 (under the label “V alue of ModR/M Byte (in Hexadecimal)”) contains a 32 by 8 array that presents all of 256 values of the ModR/M
byte (in hexadecimal). Bits 3, 4 and 5 are specified by the column of the table in
which a byte resides. The row specifies bits 0, 1 and 2; and bits 6 and 7. The figure
below demonstrates interpretation of one table value.
Mod11
RM 000
/digit (Opcode);
REG = 001
C8H11001000
Figure 2-2. Table Interpretation of ModR/M Byte (C8H)
Vol. 2A 2-5
INSTRUCTION FORMAT
Table 2-1. 16-Bit Addressing Forms with the ModR/M Byte
CH
AH
BL
DL
CL
001
010
011
100
101
110
111
001
010
011
100
101
110
111
001
010
011
100
101
110
111
001
010
011
100
101
110
111
AL
AX
EAX
MM0
XMM0
0
000
00
01
02
03
04
05
06
07
40
41
42
43
44
45
46
47
80
81
82
83
84
85
86
87
C0
C1
C2
C3
C4
C5
C6
C7
CX
ECX
MM1
XMM1
1
001
08
09
0A
0B
0C
0D
0E
0F
48
49
4A
4B
4C
4D
4E
4F
88
89
8A
8B
8C
8D
8E
8F
C8
C9
CA
CB
CC
CD
CE
CF
DX
EDX
MM2
XMM2
2
010
10
11
12
13
14
15
16
17
50
51
52
53
54
55
56
57
90
91
92
93
94
95
96
97
D0
D1
D2
D3
D4
D5
D6
D7
BX
EBX
MM3
XMM3
3
011
18
19
1A
1B
1C
1D
1E
1F
58
59
5A
5B
5C
5D
5E
5F
98
99
9A
9B
9C
9D
9E
9F
D8
D9
DA
DB
DC
DD
DE
DF
SP
ESP
MM4
XMM4
4
100
20
21
22
23
24
25
26
27
60
61
62
63
64
65
66
67
A0
A1
A2
A3
A4
A5
A6
A7
E0
EQ
E2
E3
E4
E5
E6
E7
BP1
EBP
MM5
XMM5
5
101
28
29
2A
2B
2C
2D
2E
2F
68
69
6A
6B
6C
6D
6E
6F
A8
A9
AA
AB
AC
AD
AE
AF
E8
E9
EA
EB
EC
ED
EE
EF
r8(/r)
r16(/r)
r32(/r)
mm(/r)
xmm(/r)
(In decimal) /digit (Opcode)
(In binary) REG =
Effective AddressModR/MValue of ModR/M Byte (in Hexadecimal)
1. The [--][--] nomenclature means a SIB follows the ModR/M byte.
2. The disp32 nomenclature denotes a 32-bit displacement that follows the ModR/M byte (or the SIB
byte if one is present) and that is added to the index.
3. The disp8 nomenclature denotes an 8-bit displacement that follows the ModR/M byte (or the SIB
byte if one is present) and that is sign-extended and added to the index.
Table 2-3 is organized to give 256 possible values of the SIB byte (in hexadecimal).
General purpose registers used as a base are indicated across the top of the table,
along with corresponding values for the SIB byte’s base field. Table rows in the body
Vol. 2A 2-7
INSTRUCTION FORMAT
of the table indicate the register used as the index (SIB byte bits 3, 4 and 5) and the
scaling factor (determined by SIB byte bits 6 and 7).
Table 2-3. 32-Bit Addressing Forms with the SIB Byte
r32
(In decimal) Base =
(In binary) Base =
Scaled IndexSSIndexValue of SIB Byte (in Hexadecimal)
1. The [*] nomenclature means a disp32 with no base if the MOD is 00B. Otherwise, [*] means disp8
or disp32 + [EBP]. This provides the following address modes:
•Compatibility Mode. Enables a 64-bit operating system to run most legacy
protected mode software unmodified.
•64-Bit Mode. Enables a 64-bit operating system to run applications written to
access 64-bit address space.
2.2.1 REX Prefixes
REX prefixes are instruction-prefix bytes used in 64-bit mode. They do the following:
•Specify GPRs and SSE registers.
•Specify 64-bit operand size.
•Specify extended control registers.
Not all instructions require a REX prefix in 64-bit mode. A prefix is necessary only if
an instruction references one of the extended registers or uses a 64-bit operand. If a
REX prefix is used when it has no meaning, it is ignored.
Only one REX prefix is allowed per instruction. If used, the prefix must immediately
precede the opcode byte or the two-byte opcode escape prefix (if present). Other
placements are ignored. The instruction-size limit of 15 bytes still applies to instructions with a REX prefix. See Figure 2-3.
Legacy
Prefixes
Grp 1, Grp
2, Grp 3,
Grp 4
(optional)
REX
Prefix
(optional)
Opcode
1-, 2-, or
3-byte
opcode
ModR/M
1 byte
(if required)
SIBDisplacement
1 byte
(if required)
Address
displacement of
1, 2, or 4 bytes
Figure 2-3. Prefix Ordering in 64-bit Mode
Immediate
Immediate data
of 1, 2, or 4
bytes or none
Vol. 2A 2-9
INSTRUCTION FORMAT
2.2.1.1 Encoding
Intel 64 and IA-32 instruction formats specify up to three registers by using 3-bit
fields in the encoding, depending on the format:
•ModR/M: the reg and r/m fields of the ModR/M byte
•ModR/M with SIB: the reg field of the ModR/M byte, the base and index fields of
the SIB (scale, index, base) byte
•Instructions without ModR/M: the reg field of the opcode
In 64-bit mode, these formats do not change. Bits needed to define fields in the
64-bit context are provided by the addition of REX prefixes.
2.2.1.2 More on REX Prefix Fields
REX prefixes are a set of 16 opcodes that span one row of the opcode map and
occupy entries 40H to 4FH. These opcodes represent valid instructions (INC or DEC)
in IA-32 operating modes and in compatibility mode. In 64-bit mode, the same
opcodes represent the instruction prefix REX and are not treated as individual
instructions.
The single-byte-opcode form of INC/DEC in struction not available in 64-bit mode.
INC/DEC functionality is still available using ModR/M forms of the same instructions
(opcodes FF/0 and FF/1).
See T able 2-4 for a summary of the REX prefix format. Figure 2-4 though Figure 2-7
show examples of REX prefix fields in use. Some combinations of REX prefix fields are
invalid. In such cases, the prefix is ignored. Some additional information follows:
•Setting REX.W can be used to determine the operand size but does not solely
determine operand width. Like the 66H size prefix, 64-bit operand size override
has no effect on byte-specific operations.
•For non-byte operations: if a 66H prefix is used with prefix (REX.W = 1), 66H is
ignored.
•If a 66H override is used with REX and REX.W = 0, the operand size is 16 bits.
•REX.R modifies the ModR/M reg field when that field encodes a GPR, SSE, control
or debug register. REX.R is ignored when ModR/M specifies other registers or
defines an extended opcode.
•REX.X bit modifies the SIB index field.
•REX.B either modifies the base in the ModR/M r/m field or SIB base field; or it
modifies the opcode reg field used for accessing GPRs.
2-10 Vol. 2A
INSTRUCTION FORMAT
Table 2-4. REX Prefix Fields [BITS: 0100WRXB]
Field NameBit PositionDefinition
-7:40100
W30 = Operand size determined by CS.D
1 = 64 Bit Operand Size
R2Extension of the ModR/M reg field
X1Extension of the SIB index field
B0Extension of the ModR/M r/m field, SIB base field, or
Opcode reg field
0RG50%\WH
5(;35(),;
:5%
2SFRGH
PRG
UHJUP
UUUEEE
5UUU%EEE
20;ILJ
Figure 2-4. Memory Addressing Without an SIB Byte; REX.X Not Used
0RG50%\WH
5(;35(),;
:5%
2SFRGH
PRG
UHJUP
UUUEEE
5UUU%EEE
20;ILJ
Figure 2-5. Register-Register Addressing (No Memory Operand); REX.X Not Used
Vol. 2A 2-11
INSTRUCTION FORMAT
5(;35(),;
:5;%
0RG50%\WH
2SFRGH
PRG
UHJ
UUU
UP
VFDOH
VV
5UUU
Figure 2-6. Memory Addressing With a SIB Byte
5(;35(),;
:%
2SFRGH
UHJ
EEE
%EEE
20;ILJ
6,%%\WH
LQGH[
[[[
;[[[
EDVH
EEE
%EEE
20;ILJ
Figure 2-7. Register Operand Coded in Opcode Byte; REX.X & REX.R Not Used
In the IA-32 architecture, byte registers (AH, AL, BH, BL, CH, CL, DH, and DL) are
encoded in the ModR/M byte’s reg field, the r/m field or the opcode reg field as registers 0 through 7. REX prefixes provide an additional addressing capability for byteregisters that makes the least-significant byte of GPRs available for byte oper ations.
Certain combinations of the fields of the ModR/M byte and the SIB byte have special
meaning for register encodings. For some combinations, fields expanded by the REX
prefix are not decoded. Table 2-5 describes how each case behaves.
2-12 Vol. 2A
Table 2-5. Special Cases of REX Encodings
ModR/M or
SIB
ModR/M Byte mod != 11SIB byte present.SIB byte required
REX prefix adds a fourth
bit (b) which is not
decoded (don't care).
SIB byte also required for
R12-based addressing.
REX prefix adds a fourth
bit (b) which is not
decoded (don't care).
Using RBP or R13 without
displacement must be
done using mod = 01 with
a displacement of 0.
REX prefix adds a fourth
bit (b) which is decoded.
There are no additional
implications. The
expanded index field
allows distinguishing RSP
from R12, therefore R12
can be used as an index.
REX prefix adds a fourth
bit (b) which is not
decoded.
This requires explicit
displacement to be used
with EBP/RBP or R13.
2.2.1.3 Displacement
Addressing in 64-bit mode uses existing 32-bit ModR/M and SIB encodings. The
ModR/M and SIB displacement sizes do not change. They remain 8 bits or 32 bits and
are sign-extended to 64 bits.
2.2.1.4 Direct Memory-Offset MOVs
In 64-bit mode, direct memory-offset forms of the MOV instruction are extended to
specify a 64-bit immediate absolute address. This address is called a moffset. No
prefix is needed to specify this 64-bit memory offset. For these MOV instructions, the
Vol. 2A 2-13
INSTRUCTION FORMAT
size of the memory offset follows the address-size default (64 bits in 64-bit mode).
See Table 2-6.
Table 2-6. Direct Memory Offset Form of MOV
OpcodeInstruction
A0MOV AL, moffset
A1MOV EAX, moffset
A2MOV moffset, AL
A3MOV moffset, EAX
2.2.1.5 Immediates
In 64-bit mode, the typical size of immediate operands remains 32 bits. When the
operand size is 64 bits, the processor sign-extends all immediates to 64 bits prior to
their use.
Support for 64-bit immediate operands is accomplished by expanding the semantics
of the existing move (MOV reg, imm16/32) instructions. These instructions (opcodes
B8H – BFH) move 16-bits or 32-bits of immediate data (depending on the effective
operand size) into a GPR. When the effective operand size is 64 bits, these instructions can be used to load an immediate into a GPR. A REX prefix is needed to override
the 32-bit default operand size to a 64-bit operand size.
For example:
48 B8 8877665544332211 MOV RAX,1122334455667788H
2.2.1.6 RIP-Relative Addressing
A new addressing form, RIP-relative (relative instruction-pointer) addressing, is
implemented in 64-bit mode. An effective address is formed by adding displacement
to the 64-bit RIP of the next instruction.
In IA-32 architecture and compatibility mode, addressing relative to the instruction
pointer is available only with control-transfer instructions. In 64-bit mode, instructions that use ModR/M addressing can use RIP-relative addressing. Without RIP-relative addressing, all ModR/M instruction modes address memory relative to zero.
RIP-relative addressing allows specific ModR/M modes to address memory relative to
the 64-bit RIP using a signed 32-bit displacement. This provides an offset range of
±2GB from the RIP. Table 2-7 shows the ModR/M and SIB encodings for RIP- relative
addressing. Redundant forms of 32-bit displacement-addressing exist in the current
ModR/M and SIB encodings. There is one ModR/M encoding and there are several SIB
encodings. RIP-relative addressing is encoded using a redundant form.
In 64-bit mode, the ModR/M Disp32 (32-bit displacement) encoding is re-defined to
be RIP+Disp32 rather than disp lacement -only. See T able 2-7.
2-14 Vol. 2A
INSTRUCTION FORMAT
Table 2-7. RIP-Relative Addressing
ModR/M and SIB Sub-field
Encodings
ModR/M
Byte
SIB Bytebase == 101 (none) if mod = 00,
The ModR/M encoding for RIP-relative addressing does not depend on using prefix.
Specifically , the r/m bit field encoding of 101B (used to select RIP-relative
addressing) is not affected by the REX prefix. For example, selecting R13 (REX.B = 1,
r/m = 101B) with mod = 00B still results in RIP-relative addressing. The 4-bit r/m
field of REX.B combined with ModR/M is not fully decoded. In order to address R13
with no displacement, software must encode R13 + 0 using a 1-byte displacement of
zero.
RIP-relative addressing is enabled by 64-bit mode, not by a 64-bit address-size. The
use of the address-size prefix does not disable RIP-relative addressing. The effect of
the address-size prefix is to truncate and zero-extend the computed effective
address to 32 bits.
mod == 00Disp32RIP + Disp32Must use SIB form with
r/m == 101 (none)
index == 100
(none)
scale = 0, 1, 2, 4
Compatibility
Mode Operation
Disp32
64-bit Mode
Operation
Same as
legacy
Additional Implications
in 64-bit mode
normal (zero-based)
displacement addressing
None
2.2.1.7 Default 64-Bit Operand Size
In 64-bit mode, two groups of instructions have a default operand size of 64 bits (do
not need a REX prefix for this operand size). These are:
•Near branches
•All instructions, except far branches, that implicitly reference the RSP
2.2.2 Additional Encodings for Control and Debug Registers
In 64-bit mode, more encodings for control and debug registers are available. The
REX.R bit is used to modify the ModR/M reg field when that field encodes a control or
debug register (see T able 2-4). These encodings enable the processor to address
CR8-CR15 and DR8- DR15. An additional control register (CR8) is defined in 64-bit
mode. CR8 becomes the Task Priority Register (TPR).
In the first implementation of IA-32e mode, CR9-CR15 and DR8-DR15 are not implemented. Any attempt to access unimplemented registers results in an invalid-opcode
exception (#UD).
Vol. 2A 2-15
INSTRUCTION FORMAT
2-16 Vol. 2A
CHAPTER 3
INSTRUCTION SET REFERENCE, A-M
This chapter describes the instruction set for the Intel 64 and IA-32 architectures
(A-M) in IA-32e, protected, Virtual-8086, and real modes of operation. The set
includes general-purpose, x87 FPU, MMX, SSE/SSE2/SSE3/SSS E3, and system
instructions. See also Chapter 4, “Instruction Set Reference, N-Z,” in the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 2B.
For each instruction, each operand combination is described. A description of the
instruction and its operand, an operational description, a description of the effect of
the instructions on flags in the EFLAGS register, and a summary of exceptions that
can be generated are also provided.
3.1 INTERPRETING THE INSTRUCTION REFERENCE
PAGES
This section describes the format of information contained in the instruction reference pages in this chapter . It explains notational con ventions and abbreviations used
in these sections.
3.1.1 Instruction Format
The following is an example of the format used for each instruction description in this
chapter. The heading below introduces the example. The table below provides an
example summary table.
CMC—Complement Carry Flag [this is an example]
OpcodeInstruction64-bit ModeCompat/
Leg Mode
F5CMCValidValidComplement carry flag.
Description
Vol. 2A 3-1
INSTRUCTION SET REFERENCE, A-M
3.1.1.1 Opcode Column in the Instruction Summary Table
The “Opcode” column in the table above shows the object code produced for each
form of the instruction. When possible, codes are given as hexadecimal bytes in the
same order in which they appear in memory. Definitions of entries other than hexadecimal bytes are as follows:
•REX.W — Indicates the use of a REX prefix that affects operand size or
instruction semantics. The ordering of the REX prefix and other
optional/mandatory instruction prefixes are discussed Chapter 2. Note that REX
prefixes that promote legacy instructions to 64-bit behavior are not listed
explicitly in the opcode column.
•/digit — A digit between 0 and 7 indicates that the ModR/M byte of th e
instruction uses only the r/m (register or memory) operand. The reg field
contains the digit that provides an extension to the instruction's opcode.
•/r — Indicates that the ModR/M byte of the instruction contains a register
8-byte (co) or 10-byte (ct) value following the opcode. This value is used to
specify a code offset and possibly a new value for the code segment register .
•ib, iw, id, io — A 1-byte (ib), 2-byte (iw), 4-byte (id) or 8-byte (io) immediate
operand to the instruction that follows the opcode, ModR/M bytes or scaleindexing bytes. The opcode determines if the operand is a signed value. All
words, doublewords and quadwords are given with the low-order byte first.
•+rb, +rw, +rd, +ro — A register code, from 0 through 7, added to the
hexadecimal byte given at the left of the plus sign to form a single opcode byte.
See Table 3-1 for the codes. The +ro columns in the table are applicable only in
64-bit mode.
•+i — A number used in floating-point instructions when one of the operands is
ST(i) from the FPU register stack. The number i (which can range from 0 to 7) is
added to the hexadecimal byte given at the left of the plus sign to form a single
opcode byte.
Table 3-1. Register Codes Associated With +rb, +rw, +rd, +ro
Registers R8 - R15 (see below): Available in 64-Bit Mode Only
R8LYes0R8WYes0R8DYes0R8Yes0
R9LYes1R9WYes1R9DYes1R9Yes1
R10LYes2R10WYes2R10DYes2R10Yes2
R11LYes3R11WYes3R11DYes3R11Yes3
R12LYes4R12WYes4R12DYes4R12Yes4
R13LYes5R13WYes5R13DYes5R13Yes5
R14LYes6R14WYes6R14DYes6R14Yes6
R15LYes7R15WYes7R15DYes7R15Yes7
3.1.1.2 Instruction Column in the Opcode Summary Table
The “Instruction” column gives the syntax of the instruction statement as it would
appear in an ASM386 program. The following is a list of the symbols used to represent operands in the instruction statements:
•rel8 — A relative address in the range from 128 bytes before the end of the
instruction to 127 bytes after the end of the instruction.
•rel16, rel32, rel64 — A relative address within the same code segment as the
instruction assembled. The rel16 symbol applies to instructions with an operandsize attribute of 16 bits; the rel32 symbol applies to instructions with an
operand-size attribute of 32 bits; the rel64 symbol applies to instructions with an
operand-size attribute of 64 bits.
Vol. 2A 3-3
INSTRUCTION SET REFERENCE, A-M
•ptr16:16, ptr16:32 and ptr16:64 — A far pointer, typically to a code segment
different from that of the instruction. The notation 16:16 indicates that the value
of the pointer has two parts. The value to the left of the colon is a 16-bit selector
or value destined for the code segment register. The value to the right
corresponds to the offset within the destination segment. The ptr16:16 symbol is
used when the instruction's operand-size attribute is 16 bits; the ptr16:32
symbol is used when the operand-size attribute is 32 bits; the ptr16:64 symbol is
used when the operand-size attribute is 64 bits.
•r8 — One of the byte general-purpose registers: AL, CL, DL, BL, AH, CH , DH, BH,
BPL, SPL, DIL and SIL; or one of the byte registers (R8L - R15L) available when
using REX.R and 64-bit mode.
•r16 — One of the word general-purpose registers: AX, CX, DX, BX, SP , BP, SI, DI;
or one of the word registers (R8-R15) available when using REX.R and 64-bit
mode.
•r32 — One of the doubleword general-purpose registers: EAX, EC X, EDX, EBX,
ESP, EBP , ESI, EDI; or one of the doubleword registers (R8D - R15D) available
when using REX.R in 64-bit mode.
•r64 — One of the quadword general-purpos e registers: RAX, RBX, RCX, RDX,
RDI, RSI, RBP, RSP , R8–R15. These are available when using REX.R and 64-bit
mode.
•imm8 — An immediate byte value. The imm8 symbol is a signed number
between –128 and +127 inclusive. For instructions in which imm8 is combined
with a word or doubleword operand, the immediate value is sign-extended to
form a word or doubleword. The upper byte of the word is filled with the topmost
bit of the immediate value.
•imm16 — An immediate word value used for instructions whose operand-siz e
attribute is 16 bits. This is a number between –32,768 and +32,767 inclusive.
•imm32 — An immediate doubleword value used for instructions whose
operand-size attribute is 32 bits. It allows the use of a number between
+2,147,483,647 and –2,147,483,648 inclusive.
•imm64 — An immediate quadword value used for instructions whose
operand-size attribute is 64 bits. The value allows the use of a number
between +9,223,372,036,854,775,807 and –9,223,372,036,854,775,808
inclusive.
•r/m8 — A byte operand that is either the contents of a byte general-purpose
register (AL, CL, DL, BL, AH, CH, DH, BH, BPL, SPL, DIL and SIL) or a byte from
memory . Byte registers R8L - R15L are available using REX.R in 64-bit mode.
•r/m16 — A word general-purpose register or memory operand used for instruc-
tions whose operand-size attribute is 16 bits. The word general-purpose registers
are: AX, CX, DX, BX, SP, BP, SI, DI. The contents of memory are found at the
address provided by the effective address computation. Word registers R8W R15W are available using REX.R in 64-bit mode.
3-4 Vol. 2A
INSTRUCTION SET REFERENCE, A-M
•r/m32 — A doubleword general-purpose register or memory oper and used for
instructions whose operand-size attribute is 32 bits. The doubleword generalpurpose registers are: EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI. The contents of
memory are found at the address provided by the effective address computation.
Doubleword registers R8D - R15D are available when using REX.R in 64-bit
mode.
•r/m64 — A quadword general-purpose register or memory oper and used for
instructions whose operand-size attribute is 64 bits when using REX.W .
Quadword general-purpose registers are: RAX, RBX, RCX, RDX, RDI, RSI, RBP,
RSP, R8–R15; these are available only in 64-bit mode. The contents of memory
are found at the address provided by the effective address computation.
•m — A 16-, 32- or 64-bit operand in memory.
•m8 — A byte operand in memory , usually expressed as a v ariable or array name,
but pointed to by the DS:(E)SI or ES:(E)DI registers. In 64-bit mode, it is pointed
to by the RSI or RDI registers.
•m16 — A word oper and in memory, usually expressed as a variable or array
name, but pointed to by the DS:(E)SI or ES:(E)DI registers. This nomenclature is
used only with the string instructions.
•m32 — A doubleword operand in memory, usually expressed as a variable or
array name, but pointed to by the DS:(E)SI or ES:(E)DI registers. This nomenclature is used only with the string instructions.
•m64 — A memory quadword oper and in memory.
•m128 — A memory double quadword operand in memory. This nomenclature is
used only with SSE and SSE2 instructions.
•m16:16, m16:32 & m16:64 — A memory operand containing a far pointer
composed of two numbers. The number to the left of the colon corresponds to the
pointer's segment selector. The number to the right corresponds to its offset.
•m16&32, m16&16, m32&32, m16&64 — A memory operand consisting of
data item pairs whose sizes are indicated on the left and the right side of the
ampersand. All memory addressing modes are allowed. The m16&16 and
m32&32 operands are used by the BOUND instruction to provide an operand
containing an upper and lower bounds for array indices. The m16&32 operand is
used by LIDT and LGDT to provide a word with which to load the limit field, and a
doubleword with which to load the base field of the corresponding GDTR and
IDTR registers. The m16&64 operand is used by LIDT and LGDT in 64-bit mode to
provide a word with which to load the limit field, and a quadword with which to
load the base field of the corresponding GDTR and IDTR registers.
•moffs8, moffs16, moffs32, moffs64 — A simple memory variable (memory
offset) of type byte, word, or doubleword used by some variants of the MOV
instruction. The actual address is given by a simple offset relative to the segment
base. No ModR/M byte is used in the instruction. The number shown with moffs
indicates its size, which is determined by the address-size attribute of the
instruction.
Vol. 2A 3-5
INSTRUCTION SET REFERENCE, A-M
•Sreg — A segment register. The segment register bit assignments are ES = 0,
CS = 1, SS = 2, DS = 3, FS = 4, and GS = 5.
•m32fp, m64fp, m80fp — A single-precision, double-precision, and double
extended-precision (respectively) floating-point operand in memory . These
symbols designate floating-point values that are used as operands for x87 FPU
floating-point instructions.
•m16int, m32int, m64int — A word, doubleword, and quadword integer
(respectively) operand in memory . These symbols designate integers that are
used as operands for x87 FPU integer instructions.
•ST or ST(0) — The top element of the FPU register stack.
•ST(i) — The i
th
element from the top of the FPU register stack (i ← 0 through 7).
•mm — An MMX register. The 64-bit MMX registers are: MM0 through MM7.
•mm/m32 — The low order 32 bits of an MMX register or a 32-bit memory
operand. The 64-bit MMX registers are: MM0 through MM7. The contents of
memory are found at the address provided by the effective address computation.
•mm/m64 — An MMX register or a 64-bit memory operand. The 64-bit MMX
registers are: MM0 through MM7. The contents of memory are found at the
address provided by the effective address computation.
•xmm — An XMM register. The 128-bit XMM registers are: XMM0 through XMM7;
XMM8 through XMM15 are available using REX.R in 64-bit mode.
•xmm/m32— An XMM register or a 32-bit memory operand. The 128-bit XMM
registers are XMM0 through XMM7; XMM8 through XMM15 are available using
REX.R in 64-bit mode. The contents of memory are found at the address provided
by the effective address computation.
•xmm/m64 — An XMM register or a 64-bit memory operand. The 128-bit SIMD
floating-point registers are XMM0 through XMM7; XMM8 through XMM15 are
available using REX.R in 64-bit mode. The contents of memory are found at the
address provided by the effective address computation.
•xmm/m128 — An XMM register or a 128-bit memory operand. The 128-bit XMM
registers are XMM0 through XMM7; XMM8 through XMM15 are available using
REX.R in 64-bit mode. The contents of memory are found at the address provided
by the effective address computation.
3.1.1.3 64-bit Mode Column in the Instruction Summary Table
The “64-bit Mode” column indicates whether the opcode sequence is supported in
64-bit mode. The column uses the following notation:
•Valid — Supported.
•Invalid — Not supported.
•N.E. — Indicates an instruction syntax is not encodable in 64-bit mode (it may
represent part of a sequence of valid instructions in other modes).
3-6 Vol. 2A
INSTRUCTION SET REFERENCE, A-M
•N.P. — Indicates the REX prefix does not affect the legacy instruction in 64-bit
mode.
•N.I. — Indicates the opcode is treated as a new instruction in 64-bit mode.
•N.S. — Indicates an instruction syntax that requires an address override prefix in
64-bit mode and is not supported. Using an address override prefix in 64-bit
mode may result in model-specific execution behavior.
3.1.1.4 Compatibility/Legacy Mode Column in the Instruction Summary
Table
The “Compatibility/Legacy Mode” column provides information on the opcode
sequence in either the compatibility mode or other IA-32 modes. The column uses
the following notation:
•Valid — Supported.
•Invalid — Not supported.
•N.E. — Indicates an Intel 64 instruction mnemonics/syntax that is not
encodable; the opcode sequence is not applicable as an individual instruction in
compatibility mode or IA-32 mode. The opcode may represent a valid sequence
of legacy IA-32 instructions.
3.1.1.5 Description Column in the Instruction Summary Table
The “Description” column briefly explains forms of the instruction.
3.1.1.6 Description Section
Each instruction is then described by number of information sections. The “Description” section describes the purpose of the instructions and required operands in more
detail.
3.1.1.7 Operation Section
The “Operation” section contains an algorithm description (frequently written in
pseudo-code) for the instruction. Algorithms are composed of the following
elements:
•Comments are enclosed within the symbol pairs “(*” and “*)”.
•Compound statements are enclosed in keywords, such as: IF , THEN, ELSE and FI
for an if statement; DO and OD for a do statement; or CASE... OF for a case
statement.
•A register name implies the contents of the register . A register name enclosed in
brackets implies the contents of the location whose address is contained in that
register. For example, ES:[DI] indicates the contents of the location whose ES
segment relative address is in register DI. [SI] indicates the contents of the
Vol. 2A 3-7
INSTRUCTION SET REFERENCE, A-M
address contained in register SI relative to the SI register’s default segment (DS)
or the overridden segment.
•Parentheses around the “E” in a general-purpose register name, such as (E)SI,
indicates that the offset is read from the SI register if the address-size attribute
is 16, from the ESI register if the address-size attribute is 32. Parentheses
around the “R” in a gener al-purpose register name, (R)SI, in the presence of a
64-bit register definition such as (R)SI, indicates that the offset is read from the
64-bit RSI register if the address-size attribute is 64.
•Brackets are used for memory operands where they mean that the contents of
the memory location is a segment-relative offset. For example, [SRC] indicates
that the content of the source operand is a segment-relative offset.
•A ← B indicates that the value of B is assigned to A.
•The symbols =, ≠, >, <, ≥, and ≤ are relational operators used to compare two
values: meaning equal, not equal, greater or equal, less or equal, respectively . A
relational expression such as A ← B is TRUE if the value of A is equal to B;
otherwise it is FALSE.
•The expression “<< COUNT” and “>> COUNT” indicates that the destination
operand should be shifted left or right by the number of bits indicated by the
count operand.
The following identifiers are used in the algorithmic descriptions:
•OperandSize and AddressSize — The OperandSiz e identifier repre sents the
operand-size attribute of the instruction, which is 16, 32 or 64-bits. The
AddressSize identifier represents the addr ess-size attribute, which is 16, 32 or
64-bits. For example, the following pseudo-code indicates that the operand-size
attribute depends on the form of the MOV instruction used.
IF Instruction ← MOVW
THEN OperandSize ← 16;
ELSE
IF Instruction ← MOVD
THEN OperandSize ← 32;
ELSE
IF Instruction ← MOVQ
THEN OperandSize ← 64;
FI;
FI;
FI;
See “Operand-Size and Address-Size Attributes” in Chapter 3 of the Intel® 64
and IA-32 Architectures Software Developer’s Manual, Volume 1, for guidelines
on how these attributes are determined.
•StackAddrSize — Represents the stack address-size attribute associated with
the instruction, which has a value of 16, 32 or 64-bits. See “ Address-Siz e
3-8 Vol. 2A
INSTRUCTION SET REFERENCE, A-M
Attribute for Stack” in Chapter 6, “Proc edure Calls, Interrupts, and Exceptions, ” of
the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1.
•SRC — Represents the source operand.
•DEST — Represents the destination operand.
The following functions are used in the algorithmic descriptions:
•ZeroExtend(value) — Returns a v alue zero-extended to the operand-size
attribute of the instruction. For example, if the operand-size attribute is 32, zero
extending a byte value of –10 converts the byte from F6H to a doubleword value
of 000000F6H. If the value passed to the ZeroExtend function and the operandsize attribute are the same size, ZeroExtend returns the value unaltered.
•SignExtend(value) — Returns a value sign-extended to the operand-size
attribute of the instruction. For example, if the operand-size attribute is 32, sign
extending a byte containing the value –10 converts the byte from F6H to a
doubleword value of FFFFFFF6H. If the value passed to the SignExtend function
and the operand-size attribute are the same size, SignExtend returns the value
unaltered.
•SaturateSignedWordToSignedByte — Converts a signed 16-bit value to a
signed 8-bit value . If the signed 16- bit value is less than –128, it is represented
by the saturated value -128 (80H); if it is greater than 127, it is represented by
the saturated value 127 (7FH).
•SaturateSignedDwordToSignedWord — Converts a signed 32-bit v alue to a
signed 16-bit value. If the signed 32-bit value is less than –32768, it is
represented by the saturated value –32768 (8000H); if it is greater than 32767,
it is represented by the saturated value 32767 (7FFFH).
•SaturateSignedWordToUnsignedByte — Converts a signed 16-bit value to an
unsigned 8-bit value. If the signed 16-bit value is less than zero, it is represented
by the saturated value zero (00H); if it is greater than 255, it is represented by
the saturated value 255 (FFH).
•SaturateToSignedByte — Represents the result of an operation as a signed
8-bit value. If the result is less than –128, it is represented by the saturated value
–128 (80H); if it is greater than 127, it is represented by the saturated value 127
(7FH).
•SaturateToSignedWord — Represents the result of an operation as a signed
16-bit value. If the result is less than –32768, it is represented by the saturated
value –32768 (8000H); if it is greater than 32767, it is represented by the
saturated value 32767 (7FFFH).
•SaturateToUnsignedByte — Represents the result of an oper ation as a signed
8-bit value. If the result is less than zero it is represented by the saturated value
zero (00H); if it is greater than 255, it is represented by the saturated value 255
(FFH).
•SaturateToUnsignedWord — Represents the result of an operation as a signed
16-bit value. If the result is less than zero it is represented by the saturated value
Vol. 2A 3-9
INSTRUCTION SET REFERENCE, A-M
zero (00H); if it is greater than 65535, it is represented by the saturated value
65535 (FFFFH).
•LowOrderWord(DEST * SRC) — Multiplies a word operand by a word operand
and stores the least significant word of the doubleword result in the destination
operand.
•HighOrderWord(DEST * SRC) — Multiplies a word operand by a word oper and
and stores the most significant word of the doubleword result in the destination
operand.
•Push(value) — Pushes a value onto the stack. The number of bytes pushed is
determined by the operand-size attribute of the instruction. See the “Operation”
subsection of the “PUSH—Push Word, Doubleword or Quadword Onto the Stack”
section in Chapter 4 of the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 2B.
•Pop() removes the value from the top of the stack and returns it. The statement
EAX ← Pop(); assigns to EAX the 32-bit value from the top of the stack. P op will
return either a word, a doubleword or a quadword depending on the operand-size
attribute. See the “Operation” subsection in the “POP—Pop a V alue from the
Stack” section of Chapter 4 of the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 2B.
•PopRegisterStack — Marks the FPU ST(0) register as empty and increments
the FPU register stack pointer (TOP) by 1.
•Switch-Tasks — Performs a task switch.
•Bit(BitBase, BitOffset) — Returns the value of a bit within a bit string. The bit
string is a sequence of bits in memory or a register . Bits are numbered from loworder to high-order within registers and within memory bytes. If the BitBase is a
register, the BitOffset can be in the range 0 to [15, 31, 63] depending on the
mode and register size. See Figure 3-1: the function Bit[RAX, 21] is illustrated.
63
Bit Offset ← 21
Figure 3-1. Bit Offset for BIT[RAX, 21]
If BitBase is a memory address, the BitOffset can range has different ranges
depending on the operand size (see Table 3-2).
3-10 Vol. 2A
02131
INSTRUCTION SET REFERENCE, A-M
Table 3-2. Range of Bit Positions Specified by Bit Offset Operands
Operand SizeImmediate BitOffsetRegister BitOffset
160 to 15−2
320 to 31−2
640 to 63−2
The addressed bit is numbered (Offset MOD 8) within the byte at address
(BitBase + (BitOffset DIV 8)) where DIV is signed division with rounding towards
negative infinity and MOD returns a positive number (see Figure 3-2).
The Intel C/C++ compiler intrinsics equivalents are special C/C++ coding extensions that
allow using the syntax of C function calls and C variables instead of hardware registers. Using these intrinsics frees programmers from having to manage registers and
assembly programming. Further, the compiler optimizes the instruction scheduling
so that executable run faster.
The following sections discuss the intrinsics API and the MMX technology and SIMD
floating-point intrinsics. Each intrinsic equivalent is listed with the instruction
description. There may be additional intrinsics that do not have an instru ction equivalent. It is strongly recommended that the reader reference the compiler documentation for the complete list of supported intrinsics.
Vol. 2A 3-11
INSTRUCTION SET REFERENCE, A-M
See Appendix C, “InteL® C/C++ Compiler Intrinsics and Functional Equivalents,” in
the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 2B, for
more information on using intrinsics.
Intrinsics API
The benefit of coding with MMX technology intrinsics and the SSE/SSE2/SSE3 intrinsics is that you can use the syntax of C function calls and C variables instead of hardware registers. This frees you from managing registers and programming assembly.
Further, the compiler optimizes the instruction scheduling so that your executable
runs faster. For each computational and data manipulation instruction in the new
instruction set, there is a corresponding C intrinsic that implements it directly. The
intrinsics allow you to specify the underlying implementation (instruction selection)
of an algorithm yet leave instruction scheduling and register allocation to the
compiler.
MMX™ Technology Intrinsics
The MMX technology intrinsics are based on a __m64 data type that represents the
specific contents of an MMX technology register. You can specify values in bytes,
short integers, 32-bit values, or a 64-bit object. The __m64 data type, however, is
not a basic ANSI C data type, and therefore you must observe the following usage
restrictions:
•Use __m64 data only on the left-hand side of an assignment, as a return value,
or as a parameter. You cannot use it with other arithmetic expressions (“ +”, “>>”,
and so on).
•Use __m64 objects in aggregates, such as unions to access the byte elements
and structures; the address of an __m64 object may be taken.
•Use __m64 data only with the MMX technology intrinsics described in this manual
in the Intel® 64 and IA-32 Architectures Software Developer’s Manual,
Volume 2B, for more information on using intrinsics.
— SSE/SSE2/SSE3 Intrinsics
— SSE/SSE2/SSE3 intrinsics all make use of the XMM registers of the P entium
III, Pentium 4, and Intel Xeon processors. There are three data types
supported by these intrinsics: __m128, __m128d, and __m128i.
•The __m128 data type is used to represent the contents of an XMM register used
by an SSE intrinsic. This is either four packed single-precision floating-point
values or a scalar single-precision floating-point value.
•The __m128d data type holds two packed double-precision floating-point values
or a scalar double-precision floating-point value.
3-12 Vol. 2A
INSTRUCTION SET REFERENCE, A-M
•The __m128i data type can hold sixteen byte, eight word, or four doubleword, or
two quadword integer values.
The compiler aligns __m128, __m128d, and __m128i local and global data to
16-byte boundaries on the stack. To align integer , float, or double arrays, use the
declspec statement as described in Intel C/C++ compiler documentation. See
http://www.intel.com/support/performancetools/.
The __m128, __m128d, and __m128i data types are not basic ANSI C data types
and therefore some restrictions are placed on its usage:
•Use __m128, __m128d, and __m128i only on the left-hand side of an
assignment, as a return value, or as a parameter . Do not use it in other arithmetic
expressions such as “+” and “>>.”
•Do not initialize __m128, __m128d, and __m128i with literals; there is no way to
express 128-bit constants.
•Use __m128, __m128d, and __m128i objects in aggregates, such as unions (for
example, to access the float elements) and structures. The address of these
objects may be taken.
•Use __m128, __m128d, and __m128i data only with the intrinsics described in
this user’s guide. See Appendix C, “InteL® C/C++ Compiler Intrinsics and
Functional Equivalents,” in the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 2B, for more information on using intrinsics.
The compiler aligns __m128, __m128d, and __m128i local data to 16-byte boundaries on the stack. Global __m128 data is also aligned on 16-byte boundaries. (To
align float arrays, you can use the alignment declspec described in the following
section.) Because the new instruction set treats the SIMD floating-point registers in
the same way whether you are using packed or scalar data, there is no __m32 data
type to represent scalar data as you might expect. For scalar operations, you should
use the __m128 objects and the “scalar” forms of the intrinsics; the compiler and the
processor implement these operations with 32-bit memory references.
The suffixes ps and ss are used to denote “packed single” and “scalar single” precision operations. The packed floats are represented in right-to-left order, with the
lowest word (right-most) being used for scalar operations: [z, y, x, w]. T o explain
how memory storage reflects this, consider the following example.
Some intrinsics are “composites” because they require more than one instruction to
implement them. You should be familiar with the hardware features provided by the
SSE, SSE2, SSE3, and MMX technology when writing programs with the intrinsics.
Keep the following important issues in mind:
•Certain intrinsics, such as _mm_loadr_ps and _mm_cmpgt_ss, are not directly
supported by the instruction set. While these intrinsics are convenient
programming aids, be mindful of their implementation cost.
•Data loaded or stored as __m128 objects must generally be 16-byte-aligned.
•Some intrinsics require that their argument be immediates, that is, constant
integers (literals), due to the nature of the instruction.
•The result of arithmetic operations acting on two NaN (Not a Number) arguments
is undefined. Therefore, floating- point operations using NaN arguments may not
match the expected behavior of the corresponding assembly instructions.
For a more detailed description of each intrinsic and additional information related to
its usage, refer to Intel C/C++ compiler documentation. See:
in the Intel® 64 and IA-32 Architectures Software Developer’s Manual,
Volume 2B, for more information on using intrinsics.
3.1.1.9 Flags Affected Section
The “Flags Affected” section lists the flags in the EFLAGS register that are affected by
the instruction. When a flag is cleared, it is equal to 0; when it is set, it is equal to 1.
The arithmetic and logical instructions usually assign values to the status flags in a
uniform manner (see Appendix A, “Eflags Cross-Reference,” in the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1). Non-conventional
assignments are described in the “Operation” section. The values of flags listed as
undefined may be changed by the instruction in an indeterminate manner. Flags
that are not listed are unchanged by the instruction.
3.1.1.10 FPU Flags Affected Section
The floating-point instructions have an “FPU Flags Affected” section that describes
how each instruction can affect the four condition code flags of the FPU status word.
3.1.1.11 Protected Mode Exceptions Section
The “Protected Mode Exceptions” section lists the exceptions that can occur when the
instruction is executed in protected mode and the reasons for the exceptions. Each
exception is given a mnemonic that consists of a pound sign (#) followed by two
letters and an optional error code in parentheses. For example, #GP(0) denotes a
general protection exception with an error code of 0. Table 3-3 associates each two-
3-14 Vol. 2A
INSTRUCTION SET REFERENCE, A-M
letter mnemonic with the corresponding interrupt vector number and exception
name. See Chapter 5, “Interrupt and Exception Handling, ” in the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 3A, for a detailed description of
the exceptions.
Application programmers should consult the documentation provided with their operating systems to determine the actions taken when exceptions occur.
Table 3-3. Intel 64 and IA-32 General Exceptions
Vector
No.
NameSourceProtected
Mode
1
Real
Address
Mode
0#DE—Divide ErrorDIV and IDIV instructions.YesYesYes
1#DB—DebugAny code or data reference.YesYesYes
3#BP—BreakpointINT 3 instruction.YesYesYes
4#OF—OverflowINTO instruction.YesYesYes
5#BR—BOUND Range
BO U N D instr u c tion.YesYesYe s
Exceeded
6#UD—Invalid
Opcode (Undefined
UD2 instruction or reserved
opcode.
YesYesYe s
Opcode)
7#NM—Device Not
Available (No Math
Floating-point or WAIT/FWAIT
instruction.
YesYesYe s
Coprocessor)
8#DF—Double FaultAny instruction that can
YesYesYe s
generate an exception, an
NMI, or an INTR.
10#TS—Invalid TSSTask switch or TSS access.YesReservedYes
11#NP—Segment Not
Present
12#SS—Stack
Segment Fault
13#GP—General
Protection
2
Loading segment registers or
accessing system segments.
Table 3-3. Intel 64 and IA-32 General Exceptions (Contd.)
Vector
No.
NOTES:
1. Apply to protected mode, compatibility mode, and 64-bit mode.
2. In the real-address mode, vector 13 is the segment overrun exception.
NameSourceProtected
18#MC—Machine
Check
19#XM—SIMD
Floating-Point
Numeric Error
Model dependent machine
check errors.
SSE/SSE2/SSE3 floating-point
instructions.
1
Mode
YesYesYe s
YesYesYe s
Real
Address
Mode
Virtual
8086
Mode
3.1.1.12 Real-Address Mode Exceptions Section
The “Real-Address Mode Exceptions” section lists the exceptions that can occur when
the instruction is executed in real-address mode (see T able 3-3).
3.1.1.13 Virtual-8086 Mode Exceptions Section
The “Virtual-8086 Mode Exceptions” section lists the exceptions that can occur when
the instruction is executed in virtual-8086 mode (see T able 3-3).
3.1.1.14 Floating-Point Exceptions Section
The “Floating-Point Exceptions” section lists exceptions that can occur when an x87
FPU floating-point instruction is executed. All of these exception conditions result in
a floating-point error exception (#MF, vector number 16) being generated. T able 3-4
associates a one- or two-letter mnemonic with the corresponding exception name.
See “Floating-Point Exception Conditions” in Chapter 8 of the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1, for a detailed description of
these exceptions.
3-16 Vol. 2A
INSTRUCTION SET REFERENCE, A-M
Table 3-4. x87 FPU Floating-Point Exceptions
MnemonicNameSource
Floating-point invalid operation:
#IS
#IA
#ZFloating-point divide-by-zeroDivide-by-zero
#DFloating-point denormal operandSource operand that is a denormal number
#OFloating-point numeric overflowOverflow in result
#UFloating-point numeric underflowUnderflow in result
#PFloating-point inexact result
- Stack overflow or underflow
- Invalid arithmetic operation
(precision)
- x87 FPU stack overflow or underflow
- Invalid FPU arithmetic operation
Inexact result (precision)
3.1.1.15 SIMD Floating-Point Exceptions Section
The “SIMD Floating-Point Exceptions” section lists exceptions that can occur when an
SSE/SSE2/SSE3 floating-point instruction is executed. All of these exception conditions result in a SIMD floating-point error exception (#XM, vector number 19) being
generated. Table 3-5 associates a one-letter mnemonic with the corresponding
exception name. For a detailed description of these ex ceptions, refer to ”SSE and
SSE2 Exceptions”, in Chapter 11 of the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1.
Table 3-5. SIMD Floating-Point Exceptions
MnemonicNameSource
#IFloating-point invalid operationInvalid arithmetic operation or source operand
#ZFloating-point divide-by-zeroDivide-by-zero
#DFloating-point denormal operandSource operand that is a denormal number
#OFloating-point numeric overflowOverflow in result
#UFloating-point numeric underflow Underflow in result
#PFloating-point inexact resultInexact result (precision)
3.1.1.16 Compatibility Mode Exceptions Section
This section lists exception that occur within compatibility mode.
3.1.1.17 64-Bit Mode Exceptions Section
This section lists exception that occur within 64-bit mode.
Vol. 2A 3-17
INSTRUCTION SET REFERENCE, A-M
3.2 INSTRUCTIONS (A-M)
The remainder of this chapter provides descriptions of Intel 64 and IA-32 instructions
(A-M). See also: Chapter 4, “Instruction Set Reference, N-Z,” in the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 2B.
3-18 Vol. 2A
INSTRUCTION SET REFERENCE, A-M
AAA—ASCII Adjust After Addition
OpcodeInstruction64-Bit ModeCompat/
Leg Mode
37AAAInvalidValidASCII adjust AL after addition.
Description
Adjusts the sum of two unpacked BCD values to create an unpacked BCD result. The
AL register is the implied source and destination operand for this instruction. The AAA
instruction is only useful when it follows an ADD instruction that adds (binary addition) two unpacked BCD values and stores a byte result in the AL register. The AAA
instruction then adjusts the contents of the AL register to contain the correct 1-digit
unpacked BCD result.
If the addition produces a decimal carry , the AH register increments by 1, and the CF
and AF flags are set. If there was no decimal carry, the CF and AF flags are cleared
and the AH register is unchanged. In either case, bits 4 through 7 of the AL register
are set to 0.
This instruction executes as described in compatibility mode and legacy mode. It is
not valid in 64-bit mode.
Operation
Description
IF 64-Bit Mode
THEN
#UD;
ELSE
IF ((AL AND 0FH) > 9) or (AF
THEN
AL ← AL + 6;
AH ← AH + 1;
AF ← 1;
CF ← 1;
AL ← AL AND 0FH;
ELSE
AF ← 0;
CF ← 0;
AL ← AL AND 0FH;
FI;
FI;
= 1)
Flags Affected
The AF and CF flags are set to 1 if the adjustment results in a decimal carry; otherwise they are set to 0. The OF, SF , ZF, and PF flags are undefined.
AAA—ASCII Adjust After Addition
Vol. 2A 3-19
INSTRUCTION SET REFERENCE, A-M
Protected Mode Exceptions
#UDIf the LOCK prefix is used.
Real-Address Mode Exceptions
Same exceptions as protected mode.
Virtual-8086 Mode Exceptions
Same exceptions as protected mode.
Compatibility Mode Exceptions
Same exceptions as protected mode.
64-Bit Mode Exceptions
#UDIf in 64-bit mode.
3-20 Vol. 2AAAA—ASCII Adjust After Addition
INSTRUCTION SET REFERENCE, A-M
AAD—ASCII Adjust AX Before Division
OpcodeInstruction64-Bit Mode Compat/
Leg Mode
D5 0AAADInvalidValidASCII adjust AX before division.
D5 ib(No mnemonic)InvalidValidAdjust AX before division to
Description
Adjusts two unpacked BCD digits (the least-significant digit in the AL register and the
most-significant digit in the AH register) so that a division operation performed on
the result will yield a correct unpacked BCD value. The AAD instruction is only useful
when it precedes a DIV instruction that divides (binary division) the adjusted value in
the AX register by an unpacked BCD value.
The AAD instruction sets the value in the AL register to (AL + (10 * AH)), and then
clears the AH register to 00H. The value in the AX register is then equal to the binary
equivalent of the original unpacked two-digit (base 10) number in registers AH
and AL.
The generalized version of this instruction allows adjustment of two unpacked digits
of any number base (see the “Operation” section below), by setting the imm8 byte to
the selected number base (for example, 08H for octal, 0AH for decimal, or 0CH for
base 12 numbers). The AAD mnemonic is interpreted by all assemblers to mean
adjust ASCII (base 10) values. To adjust values in another number base, the instruction must be hand coded in machine code (D5 imm8).
This instruction executes as described in compatibility mode and legacy mode. It is
not valid in 64-bit mode.
Description
number base imm8.
Operation
IF 64-Bit Mode
THEN
#UD;
ELSE
tempAL ← AL;
tempAH ← AH;
AL ← (tempAL + (tempAH ∗ imm8)) AND FFH;
(* imm8 is set to 0AH for the AAD mnemonic.*)
AH ← 0;
FI;
The immediate value (imm8) is taken from the second byte of the instruction.
AAD—ASCII Adjust AX Before Division
Vol. 2A 3-21
INSTRUCTION SET REFERENCE, A-M
Flags Affected
The SF, ZF, and PF flags are set according to the resulting binary value in the AL
register; the OF, AF, and CF flags are undefined.
Protected Mode Exceptions
#UD If the LOCK prefix is used.
Real-Address Mode Exceptions
Same exceptions as protected mode.
Virtual-8086 Mode Exceptions
Same exceptions as protected mode.
Compatibility Mode Exceptions
Same exceptions as protected mode.
64-Bit Mode Exceptions
#UDIf in 64-bit mode.
3-22 Vol. 2AAAD—ASCII Adjust AX Before Division
INSTRUCTION SET REFERENCE, A-M
AAM—ASCII Adjust AX After Multiply
OpcodeInstruction64-Bit
Mode
D4 0AAAMInvalidValidASCII adjust AX after multiply.
D4 ib(No mnemonic)InvalidValidAdjust AX after multiply to number
Description
Adjusts the result of the multiplication of two unpacked BCD values to create a pair
of unpacked (base 10) BCD values. The AX register is the implied source and destination operand for this instruction. The AAM instruction is only useful when it follows
an MUL instruction that multiplies (binary multiplication) two unpacked BCD values
and stores a word result in the AX register . The AAM instruction then adjusts the
contents of the AX register to contain the correct 2-digit unpacked (base 10) BCD
result.
The generalized version of this instruction allows adjustment of the contents of the
AX to create two unpacked digits of any number base (see the “Operation” section
below). Here, the imm8 byte is set to the selected number base (for example, 08H
for octal, 0AH for decimal, or 0CH for base 12 numbers). The AAM mnemonic is interpreted by all assemblers to mean adjust to ASCII (base 10) values. To adjust to
values in another number base, the instruction must be hand coded in machine code
(D4 imm8).
This instruction executes as described in compatibility mode and legacy mode. It is
not valid in 64-bit mode.
Compat/
Leg Mode
Description
base imm8.
Operation
IF 64-Bit Mode
THEN
#UD;
ELSE
tempAL ← AL;
AH ← tempAL / imm8; (* imm8 is set to 0AH for the AAM mnemonic *)
AL ← tempAL MOD imm8;
FI;
The immediate value (imm8) is taken from the second byte of the instruction.
Flags Affected
The SF, ZF , and PF flags are set according to the resulting binary value in the AL
register. The OF, AF , and CF flags are undefine d.
AAM—ASCII Adjust AX After Multiply
Vol. 2A 3-23
INSTRUCTION SET REFERENCE, A-M
Protected Mode Exceptions
#DEIf an immediate value of 0 is used.
#UD If the LOCK prefix is used.
Real-Address Mode Exceptions
Same exceptions as protected mode.
Virtual-8086 Mode Exceptions
Same exceptions as protected mode.
Compatibility Mode Exceptions
Same exceptions as protected mode.
64-Bit Mode Exceptions
#UDIf in 64-bit mode.
3-24 Vol. 2AAAM—ASCII Adjust AX After Multiply
INSTRUCTION SET REFERENCE, A-M
AAS—ASCII Adjust AL After Subtraction
OpcodeInstruction64-Bit
Mode
3FAASInvalidValidASCII adjust AL after subtraction.
Description
Adjusts the result of the subtraction of two unpacked BCD values to create a
unpacked BCD result. The AL register is the implied source and destination operand
for this instruction. The AAS instruction is only useful when it follows a SUB instruction that subtracts (binary subtraction) one unpacked BCD value from another and
stores a byte result in the AL register. The AAA instruction then adjusts the contents
of the AL register to contain the correct 1-digit unpacked BCD result.
If the subtraction produced a decimal carry , the AH register decrements by 1, and the
CF and AF flags are set. If no decimal carry occurred, the CF and AF flags are cleared,
and the AH register is unchanged. In either case, the AL register is left with its top
nibble set to 0.
This instruction executes as described in compatibility mode and legacy mode. It is
not valid in 64-bit mode.
Operation
Compat/
Leg Mode
Description
IF 64-bit mode
THEN
#UD;
ELSE
IF ((AL AND 0FH) > 9) or (AF
THEN
AL ← AL – 6;
AH ← AH – 1;
AF ← 1;
CF ← 1;
AL ← AL AND 0FH;
ELSE
CF ← 0;
AF ← 0;
AL ← AL AND 0FH;
FI;
FI;
= 1)
Flags Affected
The AF and CF flags are set to 1 if there is a decimal borrow; otherwise, they are
cleared to 0. The OF, SF , ZF, and PF flags are undefined.
AAS—ASCII Adjust AL After Subtraction
Vol. 2A 3-25
INSTRUCTION SET REFERENCE, A-M
Protected Mode Exceptions
#UD If the LOCK prefix is used.
Real-Address Mode Exceptions
Same exceptions as protected mode.
Virtual-8086 Mode Exceptions
Same exceptions as protected mode.
Compatibility Mode Exceptions
Same exceptions as protected mode.
64-Bit Mode Exceptions
#UDIf in 64-bit mode.
3-26 Vol. 2AAAS—ASCII Adjust AL After Subtraction
INSTRUCTION SET REFERENCE, A-M
ADC—Add with Carry
OpcodeInstruction64-Bit
Mode
14 ibADC AL, imm8ValidValidAdd with carry imm8 to AL.
15 iwADC AX, imm16 ValidValidAdd with carry imm16 to AX.
15 idADC EAX,
ValidValidAdd with carry imm32 to EAX.
imm32
REX.W + 15 idADC RAX,
ValidN.E.Add with carry imm32 sign
imm32
80 /2 ibADC r/m8,
ValidValidAdd with carry imm8 to r/m8.
imm8
*
,
REX + 80 /2 ibADC r/m8
ValidN.E.Add with carry imm8 to r/m8.
imm8
81 /2 iwADC r/m16,
ValidValidAdd with carry imm16 to r/m16.
imm16
81 /2 idADC r/m32,
ValidValidAdd with CF imm32 to r/m32.
imm32
REX.W + 81 /2 idADC r/m64,
ValidN.E.Add with CF imm32 sign
imm32
83 /2 ibADC r/m16,
ValidValidAdd with CF sign-extended
imm8
83 /2 ibADC r/m32,
ValidValidAdd with CF sign-extended
imm8
REX.W + 83 /2 ibADC r/m64,
ValidN.E.Add with CF sign-extended
imm8
10 /rADC r/m8, r8ValidValidAdd with carry byte register to
*
REX + 10 /rADC r/m8
, r8*ValidN.E.Add with carry byte register to
11 /rADC r/m16, r16 ValidValidAdd with carry r16 to r/m16.
11 /rADC r/m32, r32 ValidValidAdd with CF r32 to r/m32.
REX.W + 11 /rADC r/m64, r64 ValidN.E.Add with CF r64 to r/m64.
12 /rADC r8, r/m8ValidValidAdd with carry r/m8 to byte
*
REX + 12 /rADC r8
, r/m8*ValidN.E.Add with carry r/m64 to byte
13 /rADC r16, r/m16 ValidValidAdd with carry r/m16 to r16.
Compat/
Leg Mode
Description
extended to 64-bits to RAX.
extended to 64-bits to r/m64.
imm8 to r/m16.
imm8 into r/m32.
imm8 into r/m64.
r/m8.
r/m64.
register.
register.
ADC—Add with Carry
Vol. 2A 3-27
INSTRUCTION SET REFERENCE, A-M
OpcodeInstruction64-Bit
Mode
13 /rADC r32, r/m32 ValidValidAdd with CF r/m32 to r32.
REX.W + 13 /rADC r64, r/m64 ValidN.E.Add with CF r/m64 to r64.
NOTES:
* In 64-bit mode, r/m8 can not be encoded to access the following byte registers if a REX prefix is
used: AH, BH, CH, DH.
Compat/
Leg Mode
Description
Description
Adds the destination operand (first operand), the source operand (second operand),
and the carry (CF) flag and stores the result in the destination operand. The destination operand can be a register or a memory location; the source operand can be an
immediate, a register, or a memory location. (However, two memory operands
cannot be used in one instruction.) The state of the CF flag represents a carry from a
previous addition. When an immediate value is used as an operand, it is signextended to the length of the destination operand format.
The ADC instruction does not distinguish between signed or unsigned oper ands.
Instead, the processor evaluates the result for both data types and sets the OF and
CF flags to indicate a carry in the signed or unsigned result, respectively . The SF flag
indicates the sign of the signed result.
The ADC instruction is usually executed as part of a multibyte or multiword addition
in which an ADD instruction is followed by an ADC instruction.
This instruction can be used with a LOCK prefix to allow the instruction to be
executed atomically .
In 64-bit mode, the instruction’s default operation size is 32 bits. Using a REX prefix
in the form of REX.R permits access to additional registers (R8-R15). Using a REX
prefix in the form of REX.W promotes operation to 64 bits. See the summary chart at
the beginning of this section for encoding data and limits.
Operation
DEST ← DEST + SRC + CF;
Flags Affected
The OF, SF , ZF, AF, CF, and PF flags are set according to the result.
Protected Mode Exceptions
#GP(0)If the destination is located in a non-writable segment.
If a memory operand effective address is outside the CS, DS,
ES, FS, or GS segment limit.
3-28 Vol. 2AADC—Add with Carry
INSTRUCTION SET REFERENCE, A-M
If the DS, ES, FS, or GS register is used to access memory and it
contains a NULL segment selector.
#SS(0)If a memory operand effective address is outside the SS
segment limit.
#PF(fault-code)If a page fault occurs.
#AC(0)If alignment checking is enabled and an unaligned memory
reference is made while the current privilege level is 3.
#UD If the LOCK prefix is used but the destination is not a memory
operand.
Real-Address Mode Exceptions
#GPIf a memory operand effective address is outside the CS, DS,
ES, FS, or GS segment limit.
#SSIf a memory operand effective address is outside the SS
segment limit.
#UD If the LOCK prefix is used but the destination is not a memory
operand.
Virtual-8086 Mode Exceptions
#GP(0)If a memory operand effective address is outside the CS, DS,
ES, FS, or GS segment limit.
#SS(0)If a memory operand effective address is outside the SS
segment limit.
#PF(fault-code)If a page fault occurs.
#AC(0)If alignment checking is enabled and an unaligned memory
reference is made.
#UD If the LOCK prefix is used but the destination is not a memory
operand.
Compatibility Mode Exceptions
Same exceptions as in protected mode.
64-Bit Mode Exceptions
#SS(0)If a memory address referencing the SS segment is in a non-
canonical form.
#GP(0)If the memory address is in a non-canonical form.
#PF(fault-code)If a page fault occurs.
#AC(0)If alignment checking is enabled and an unaligned memory
reference is made while the current privilege level is 3.
#UD If the LOCK prefix is used but the destination is not a memory
REX.W + 01 /rADD r/m64, r64ValidN.E.Add r64 to r/m64.
02 /rADD r8, r/m8ValidValidAdd r/m8 to r8.
REX + 02 /rADD r8
, r/m8
ValidN.E.Add r/m8 to r8.
*
*
03 /rADD r16, r/m16ValidValidAdd r/m16 to r16.
03 /rADD r32, r/m32ValidValidAdd r/m32 to r32.
REX.W + 03 /rADD r64, r/m64ValidN.E.Add r/m64 to r64.
NOTES:
* In 64-bit mode, r/m8 can not be encoded to access the following byte registers if a REX prefix is
used: AH, BH, CH, DH.
Description
extended to 64-bits
to RAX.
imm8 to r/m64.
extended to 64-bits
to r/m64.
imm8 to r/m16.
imm8 to r/m32.
imm8 to r/m64.
3-30 Vol. 2AADD—Add
INSTRUCTION SET REFERENCE, A-M
Description
Adds the destination operand (first operand) and the source operand (second
operand) and then stores the result in the destination operand. The destination
operand can be a register or a memory location; the source operand can be an immediate, a register, or a memory location. (However, two memory operands cannot be
used in one instruction.) When an immediate value is used as an operand, it is signextended to the length of the destination operand format.
The ADD instruction performs integer addition. It evaluates the result for both signed
and unsigned integer operands and sets the OF and CF flags to indicate a carry (ov erflow) in the signed or unsigned result, respectively . The SF flag indicates the sign of
the signed result.
This instruction can be used with a LOCK prefix to allow the instruction to be
executed atomically .
In 64-bit mode, the instruction’s default operation size is 32 bits. Using a REX prefix
in the form of REX.R permits access to additional registers (R8-R15). Using a REX a
REX prefix in the form of REX.W promotes operation to 64 bits. See the summary
chart at the beginning of this section for encoding data and limits.
Operation
DEST ← DEST + SRC;
Flags Affected
The OF, SF , ZF, AF, CF, and PF flags are set according to the result.
Protected Mode Exceptions
#GP(0)If the destination is located in a non-writable segment.
If a memory operand effective address is outside the CS, DS,
ES, FS, or GS segment limit.
If the DS, ES, FS, or GS register is used to access memory and it
contains a NULL segment selector.
#SS(0)If a memory operand effective address is outside the SS
segment limit.
#PF(fault-code)If a page fault occurs.
#AC(0)If alignment checking is enabled and an unaligned memory
reference is made while the current privilege level is 3.
#UD If the LOCK prefix is used but the destination is not a memory
operand.
Real-Address Mode Exceptions
#GPIf a memory operand effective address is outside the CS, DS,
ES, FS, or GS segment limit.
ADD—Add
Vol. 2A 3-31
INSTRUCTION SET REFERENCE, A-M
#SSIf a memory operand effective address is outside the SS
segment limit.
#UD If the LOCK prefix is used but the destination is not a memory
operand.
Virtual-8086 Mode Exceptions
#GP(0)If a memory operand effective address is outside th e CS, DS,
ES, FS, or GS segment limit.
#SS(0)If a memory operand effective address is outside the SS
segment limit.
#PF(fault-code)If a page fault occurs.
#AC(0)If alignment checking is enabled and an unaligned memory
reference is made.
#UD If the LOCK prefix is used but the destination is not a memory
operand.
Compatibility Mode Exceptions
Same exceptions as in protected mode.
64-Bit Mode Exceptions
#SS(0)If a memory address referencing the SS segment is in a non-
canonical form.
#GP(0)If the memory address is in a non-canonical form.
#PF(fault-code)If a page fault occurs.
#AC(0)If alignment checking is enabled and an unaligned memory
reference is made while the current privilege level is 3.
#UD If the LOCK prefix is used but the destination is not a memory
Performs a SIMD add of the two packed doub le-precision floating-point v alues from
the source operand (second operand) and the destination operand (first operand),
and stores the packed double-precision floating-point results in the destination
operand.
The source operand can be an XMM register or a 128-bit memory location. The destination operand is an XMM register. See Chapter 11 in the Intel® 64 and IA-32 Archi-tectures Software Developer’s Manual, Volume 1, for an overview of SIMD doubleprecision floating-point operation.
In 64-bit mode, using a REX prefix in the form of REX.R permits this instruction to
access additional registers (XMM8-XMM15).
#GP(0)For an illegal memory operand effective address in the CS, DS,
ES, FS or GS segments.
If a memory operand is not aligned on a 16-byte boundary ,
regardless of segment.
#SS(0) For an illegal address in the SS segment.
#PF(fault-code) For a page fault.
#NMIf CRO.TS[bit 3] = 1.
#XM If an unmasked SIMD floating-point exception and CR4.OSXM-
Performs a SIMD add of the four packed single-precision floating-point values from
the source operand (second operand) and the destination operand (first operand),
and stores the packed single-precision floating-point results in the destination
operand.
The source operand can be an XMM register or a 128-bit memory location. The destination operand is an XMM register. See Chapter 10 in the Intel® 64 and IA-32 Archi-tectures Software Developer’s Manual, Volume 1, for an ov erview of S IMD singleprecision floating-point operation.
In 64-bit mode, using a REX prefix in the form of REX.R permits this instruction to
access additional registers (XMM8-XMM15).
F2 0F 58 /r ADDSD xmm1, xmm2/m64ValidValidAdd the low double-
Description
Adds the low double-precision floating-point values from the source operand (second
operand) and the destination operand (first operand), and stor es the double-precision floating-point result in the destination operand.
The source operand can be an XMM register or a 64-bit memory location. The destination operand is an XMM register. The high quadword of the destination operand
remains unchanged. See Chapter 11 in the Intel® 64 and IA-32 Architectures Soft-ware Developer’s Manual, Volume 1, for an overview of a scalar double-precision
floating-point operation.
In 64-bit mode, using a REX prefix in the form of REX.R permits this instruction to
access additional registers (XMM8-XMM15).
Compat/
Leg Mode
Description
precision floating-point
value from xmm2/m64 to
xmm1.
#GP(0)For an illegal memory operand effective address in the CS, DS,
ES, FS or GS segments.
#SS(0) For an illegal address in the SS segment.
#PF(fault-code) For a page fault.
#NMIf CR0.TS[bit 3] = 1.
#XM If an unmasked SIMD floating-point exception and CR4.OSXM-
#UD If an unmasked SIMD floating-point exception and CR4.OSXM-
MEXCPT[bit 10] = 0.
If CR0.EM[bit 2] = 1.
If CR4.OSFXSR[bit 9] = 0.
If CPUID.01H:E DX.SSE 2[bit 26] = 0.
If the LOCK prefix is used.
#AC(0)If alignment checking is enabled and an unaligned memory
reference is made while the current privilege level is 3.
Real-Address Mode Exceptions
GP(0)If any part of the operand lies outside the effective address
space from 0 to FFFFH.
#NM If CR0.TS[bit 3] = 1.
#XM If an unmasked SIMD floating-point exception and CR4.OSXM-
MEXCPT[bit 10] = 1.
#UD If an unmasked SIMD floating-point exception and CR4.OSXM-
MEXCPT[bit 10] = 0.
If CR0.EM[bit 2] = 1.
If CR4.OSFXSR[bit 9] = 0.
If CPUID.01H:E DX.SSE 2[bit 26] = 0.
If the LOCK prefix is used.
Virtual-8086 Mode Exceptions
Same exceptions as in real address mode.
#PF(fault-code) For a page fault.
#AC(0)If alignment checking is enabled and an unaligned memory
reference is made.
Compatibility Mode Exceptions
Same exceptions as in protected mode.
64-Bit Mode Exceptions
#SS(0)If a memory address referencing the SS segment is in a non-
canonical form.
#GP(0)If the memory address is in a non-canonical form.
#PF(fault-code) For a page fault.
#NMIf CRO.TS[bit 3] = 1.
#XM If an unmasked SIMD floating-point exception and CR4.OSXM-
F3 0F 58 /rADDSS xmm1, xmm2/m32ValidValidAdd the low single-
Description
Adds the low single-precision floating-point values from the source operand (second
operand) and the destination operand (first operand), and stores the single-precision
floating-point result in the destination operand.
The source operand can be an XMM register or a 32-bit memory location. The destination operand is an XMM register. The three high-order doublewords of the destination operand remain unchanged. See Chapter 10 in the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1, for an overview of a scal ar
single-precision floating-point operation.
In 64-bit mode, using a REX prefix in the form of REX.R permits this instruction to
access additional registers (XMM8-XMM15).
Compat/
Leg Mode
Description
precision floating-point
value from xmm2/m32 to
xmm1.
#GP(0)For an illegal memory operand effective address in the CS, DS,
ES, FS or GS segments.
#SS(0) For an illegal address in the SS segment.
#PF(fault-code) For a page fault.
#NMIf CRO.TS[bit 3] = 1.
#XM If an unmasked SIMD floating-point exception and CR4.OSXM-
#UD If an unmasked SIMD floating-point exception and CR4.OSXM-
MEXCPT[bit 10] = 0.
If CR0.EM[bit 2] = 1.
If CR4.OSFXSR[bit 9] = 0.
If CPUID.01H:EDX.SSE[bit 25] = 0.
If the LOCK prefix is used.
#AC(0)If alignment checking is enabled and an unaligned memory
reference is made while the current privilege level is 3.
Real-Address Mode Exceptions
GP(0)If any part of the operand lies outside the effective address
space from 0 to FFFFH.
#NM If CRO.TS[bit 3] = 1.
#XM If an unmasked SIMD floating-point exception and CR4.OSXM-
MEXCPT[bit 10] = 1.
#UD If an unmasked SIMD floating-point exception and CR4.OSXM-
MEXCPT[bit 10] = 0.
If CR0.EM[bit 2] = 1.
If CR4.OSFXSR[bit 9] = 0.
If CPUID.01H:EDX.SSE[bit 25] = 0.
If the LOCK prefix is used.
Virtual-8086 Mode Exceptions
Same exceptions as in real address mode.
#PF(fault-code) For a page fault.
#AC(0)If alignment checking is enabled and an unaligned memory
reference is made.
Compatibility Mode Exceptions
Same exceptions as in protected mode.
64-Bit Mode Exceptions
#SS(0)If a memory address referencing the SS segment is in a non-
canonical form.
#GP(0)If the memory address is in a non-canonical form.
#PF(fault-code) For a page fault.
#NMIf CRO.TS[bit 3] = 1.
#XM If an unmasked SIMD floating-point exception and CR4.OSXM-
Adds the double-precision floating-point values in the high quadword of the source
and destination operands and stores the result in the high quadword of the destination operand.
Subtracts the double-precision floating-point value in the low quadword of the source
operand from the low quadword of the destination operand and stores the result in
the low quadword of the destination operand. See Figure 3-3.
The source operand can be a 128-bit memory location or an XMM register . The destination operand is an XMM register.
Compat/
Leg Mode
Description
double-precision
floating-point values
from xmm2/m128
to xmm1.
#GP(0)For an illegal memory operand effective address in the CS, DS,
ES, FS or GS segments.
If a memory operand is not aligned on a 16-byte boundary ,
regardless of segment.
#SS(0) For an illegal address in the SS segment.
#PF(fault-code) For a page fault.
#NM If CR0.TS[bit 3] = 1.
#XM For an unmasked Streaming SIMD Extensions numeric excep-
tion, CR4.OSXMMEXCPT[bit 10] = 1.
#UD If CR0.EM is 1.
For an unmasked Streaming SIMD Extensions numeric excep-
tion (CR4.OSXMMEXCPT[bit 10] = 0).
If CR4.OSFXSR[bit 9] = 0.
If CPUID.01H:ECX.SSE3[bit 0] = 0.
If the LOCK prefix is used.
Real Address Mode Exceptions
GP(0)If any part of the operand would lie outside of the effective
address space from 0 to 0FFFFH.
If a memory operand is not aligned on a 16-byte boundary ,
regardless of segment.
#NM If TS bit in CR0 is 1.
#XM For an unmasked Streaming SIMD Extensions numeric excep-
Adds odd-numbered single-precision floating-point values of the source operand
(second operand) with the corresponding single-precision floating-point values from
the destination operand (first operand); stores the result in the odd-numbered
values of the destina tion oper and.
Subtracts the even-numbered single-precision floating-point values in the source
operand from the corresponding single-precision floating values in the destination
operand; stores the result into the even-numbered values of the destination
operand.
The source operand can be a 128-bit memory location or an XMM register . The destination operand is an XMM register. See Figure 3-4.
When the source operand is a memory operand, the operand must be aligned on a
16-byte boundary or a general-protection exception (#GP) will be generated.
#GP(0) For an illegal memory operand effective address in the CS, DS,
ES, FS or GS segments.
If a memory operand is not aligned on a 16-byte boundary ,
regardless of segment.
#SS(0) For an illegal address in the SS segment.
#PF(fault-code) For a page fault.
#NM If CR0.TS[bit 3] = 1.
#XM For an unmasked Streaming SIMD Extensions numeric excep-
REX.W + 25 idAND RAX, imm32ValidN.E.RAX AND imm32 sign-
80 /4 ibAND r/m8, imm8ValidValidr/m8 AND imm8.
*
REX + 80 /4 ibAND r/m8
, imm8ValidN.E.r/m64 AND imm8 (sign-
81 /4 iwAND r/m16, imm16ValidValidr/m16 AND imm16.
81 /4 idAND r/m32, imm32ValidValidr/m32 AND imm32.
REX.W + 81 /4 idAND r/m64, imm32ValidN.E.r/m64 AND imm32 sign
83 /4 ibAND r/m16, imm8ValidValidr/m16 AND imm8 (sign-
83 /4 ibAND r/m32, imm8ValidValidr/m32 AND imm8 (sign-
REX.W + 83 /4 ibAND r/m64, imm8ValidN.E.r/m64 AND imm8 (sign-
20 /rAND r/m8, r8ValidValidr/m8 AND r8.
REX + 20 /rAND r/m8
, r8
ValidN.E.r/m64 AND r8 (sign-
*
*
21 /rAND r/m16, r16ValidValidr/m16 AND r16.
21 /rAND r/m32, r32ValidValidr/m32 AND r32.
REX.W + 21 /rAND r/m64, r64ValidN.E.r/m64 AND r32.
22 /rAND r8, r/m8ValidValidr8 AND r/m8.
REX + 22 /rAND r8
, r/m8
ValidN.E.r/m64 AND r8 (sign-
*
*
23 /rAND r16, r/m16ValidValidr16 AND r/m16.
23 /rAND r32, r/m32ValidValidr32 AND r/m32.
REX.W + 23 /rAND r64, r/m64ValidN.E.r64 AND r/m64.
NOTES:
* In 64-bit mode, r/m8 can not be encoded to access the following byte registers if a REX prefix is
used: AH, BH, CH, DH.
Comp/Leg
Mode
Description
extended to 64-bits.
extended).
extended to 64-bits.
extended).
extended).
extended).
extended).
extended).
AND—Logical AND
Vol. 2A 3-53
INSTRUCTION SET REFERENCE, A-M
Description
Performs a bitwise AND operation on the destination (first) and source (second)
operands and stores the result in the destination operand location. The source
operand can be an immediate, a register, or a memory location; the destination
operand can be a register or a memory location. (However, two memory operands
cannot be used in one instruction.) Each bit of the result is set to 1 if both corresponding bits of the first and second operands are 1; otherwise, it is set to 0.
This instruction can be used with a LOCK prefix to allow the it to be executed atomically.
In 64-bit mode, the instruction’s default operation size is 32 bits. Using a REX prefix
in the form of REX.R permits access to additional registers (R8-R15). Using a REX
prefix in the form of REX.W promotes operation to 64 bits. See the summary chart at
the beginning of this section for encoding data and limits.
Operation
DEST ← DEST AND SRC;
Flags Affected
The OF and CF flags are cleared; the SF, ZF , and PF flags are set according to the
result. The state of the AF flag is undefined.
Protected Mode Exceptions
#GP(0)If the destination operand points to a non-writable segment.
If a memory operand effective address is outside the CS, DS,
ES, FS, or GS segment limit.
If the DS, ES, FS, or GS register contains a NULL segment
selector.
#SS(0)If a memory operand effective address is outside the SS
segment limit.
#PF(fault-code)If a page fault occurs.
#AC(0)If alignment checking is enabled and an unaligned memory
reference is made while the current privilege level is 3.
#UD If the LOCK prefix is used but the destination is not a memory
operand.
Real-Address Mode Exceptions
#GPIf a memory operand effective address is outside the CS, DS,
ES, FS, or GS segment limit.
#SSIf a memory operand effective address is outside the SS
segment limit.
3-54 Vol. 2AAND—Logical AND
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.