Itanium2 Software Developer's Manual - V3
Itanium2 Software Developer's Manual - V3
Revision 2.2
January 2006
Figures
Part I: Intel® Itanium® Instruction Set Descriptions
2-1 Add Pointer............................................................................................................................. 3:15
2-2 Stack Frame ........................................................................................................................... 3:16
2-3 Operation of br.ctop and br.cexit ............................................................................................ 3:23
2-4 Operation of br.wtop and br.wexit .......................................................................................... 3:23
2-5 Deposit Example (merge_form) ............................................................................................. 3:48
2-6 Deposit Example (zero_form)................................................................................................. 3:48
2-7 Extract Example ..................................................................................................................... 3:51
2-8 Floating-point Merge Negative Sign Operation ...................................................................... 3:75
2-9 Floating-point Merge Sign Operation ..................................................................................... 3:75
2-10 Floating-point Merge Sign and Exponent Operation .............................................................. 3:75
2-11 Floating-point Mix Left ............................................................................................................ 3:78
2-12 Floating-point Mix Right.......................................................................................................... 3:78
2-13 Floating-point Mix Left-Right .................................................................................................. 3:78
2-14 Floating-point Pack................................................................................................................. 3:89
2-15 Floating-point Parallel Merge Negative Sign Operation ....................................................... 3:101
2-16 Floating-point Parallel Merge Sign Operation ...................................................................... 3:101
2-17 Floating-point Parallel Merge Sign and Exponent Operation ............................................... 3:102
Tables
Part I: Intel® Itanium® Instruction Set Descriptions
2-1 Instruction Page Description................................................................................................ 3:11
2-2 Instruction Page Font Conventions ..................................................................................... 3:11
2-3 Register File Notation .......................................................................................................... 3:12
2-4 C Syntax Differences........................................................................................................... 3:12
2-5 Pervasive Conditions Not Included in Instruction Description Code.................................... 3:12
2-6 Branch Types ...................................................................................................................... 3:20
2-7 Branch Whether Hint ........................................................................................................... 3:24
2-8 Sequential Prefetch Hint...................................................................................................... 3:24
2-9 Branch Cache Deallocation Hint.......................................................................................... 3:24
2-10 Long Branch Types ............................................................................................................. 3:29
2-11 IP-relative Branch Predict Whether Hint.............................................................................. 3:31
2-12 Indirect Branch Predict Whether Hint .................................................................................. 3:31
2-13 Importance Hint ................................................................................................................... 3:31
2-14 ALAT Clear Completer ........................................................................................................ 3:34
2-15 Comparison Types .............................................................................................................. 3:37
2-16 64-bit Comparison Relations for Normal and unc Compares .............................................. 3:38
2-17 64-bit Comparison Relations for Parallel Compares ........................................................... 3:38
2-18 Immediate Range for 32-bit Compares ............................................................................... 3:40
2-19 Memory Compare and Exchange Size................................................................................ 3:43
2-20 Compare and Exchange Semaphore Types ....................................................................... 3:43
2-21 Result Ranges for czx ......................................................................................................... 3:46
2-22 Specified pc Mnemonic Values ........................................................................................... 3:53
2-23 sf Mnemonic Values ............................................................................................................ 3:53
2-24 Floating-point Class Relations............................................................................................. 3:60
2-25 Floating-point Classes ......................................................................................................... 3:60
2-26 Floating-point Comparison Types........................................................................................ 3:63
2-27 Floating-point Comparison Relations .................................................................................. 3:63
2-28 Fetch and Add Semaphore Types....................................................................................... 3:70
2-29 Floating-point Parallel Comparison Results ........................................................................ 3:94
The Intel® Itanium® architecture is a unique combination of innovative features such as explicit
parallelism, predication, speculation and more. The architecture is designed to be highly scalable to
fill the ever increasing performance requirements of various server and workstation market
segments. The Itanium architecture features a revolutionary 64-bit instruction set architecture (ISA)
which applies a new processor architecture technology called EPIC, or Explicitly Parallel
Instruction Computing. A key feature of the Itanium architecture is IA-32 instruction set
compatibility.
Chapter 3, “Execution Environment” describes the Itanium register set used by applications and the
memory organization models.
Chapter 3, “Memory Reference” discusses features and optimizations related to control and data
speculation.
Chapter 4, “Predication, Control Flow, and Instruction Stream” describes optimization features
related to predication, control flow, and branch hints.
Chapter 5, “Software Pipelining and Loop Support” provides a detailed discussion on optimizing
loops through use of software pipelining.
Chapter 2, “Intel® Itanium® System Environment” introduces the environment designed to support
execution of Itanium architecture-based operating systems running IA-32 or Itanium
architecture-based applications.
Chapter 3, “System State and Programming Model” describes the Itanium architectural state which
is visible only to an operating system.
Chapter 4, “Addressing and Protection” defines the resources available to the operating system for
virtual to physical address translation, virtual aliasing, physical addressing, and memory ordering.
Chapter 5, “Interruptions” describes all interruptions that can be generated by a processor based on
the Itanium architecture.
Chapter 6, “Register Stack Engine” describes the architectural mechanism which automatically
saves and restores the stacked subset (GR32 – GR 127) of the general register file.
Chapter 9, “IA-32 Interruption Vector Descriptions” lists IA-32 exceptions, interrupts and
intercepts that can occur during IA-32 instruction set execution in the Itanium System
Environment.
Chapter 11, “Processor Abstraction Layer” describes the firmware layer which abstracts processor
implementation-dependent features.
Chapter 3, “Interruptions and Serialization” describes how the processor serializes execution
around interruptions and what state is preserved and made available to low-level system code when
interruptions are taken.
Chapter 4, “Context Management” describes how operating systems need to preserve Itanium
register contents and state. This chapter also describes system architecture mechanisms that allow
an operating system to reduce the number of registers that need to be spilled/filled on interruptions,
system calls, and context switches.
Chapter 6, “Runtime Support for Control and Data Speculation” describes the operating system
support that is required for control and data speculation.
Chapter 7, “Instruction Emulation and Other Fault Handlers” describes a variety of instruction
emulation handlers that Itanium architecture-based operating systems are expected to support.
Chapter 8, “Floating-point System Software” discusses how processors based on the Itanium
architecture handle floating-point numeric exceptions and how the software stack provides
complete IEEE-754 compliance.
Chapter 10, “External Interrupt Architecture” describes the external interrupt architecture with a
focus on how external asynchronous interrupt handling can be controlled by software.
Chapter 11, “I/O Architecture” describes the I/O architecture with a focus on platform issues and
support for the existing IA-32 I/O port space.
Chapter 12, “Performance Monitoring Support” describes the performance monitor architecture
with a focus on what kind of support is needed from Itanium architecture-based operating systems.
1.2.3 Appendices
Appendix A, “Code Examples” provides OS boot flow sample code.
Chapter 3, “Pseudo-Code Functions” provides a table of pseudo-code functions which are used to
define the behavior of the Itanium instructions.
Chapter 4, “Instruction Formats” describes the encoding and instruction format instructions.
Chapter 5, “Resource and Dependency Semantics” summarizes the dependency rules that are
applicable when generating code for processors based on the Itanium architecture.
Chapter 3, “IA-32 SSE Instruction Reference” provides a detailed description of all IA-32
Streaming SIMD Extension (SSE) instructions designed to increase performance of multimedia
intensive applications, and is organized in alphabetical order by assembly language mnemonic.
Instruction Set Architecture (ISA) – Defines application and system level resources. These
resources include instructions and registers.
Itanium Architecture – The new ISA with 64-bit instruction capabilities, new performance-
enhancing features, and support for the IA-32 instruction set.
IA-32 Architecture – The 32-bit and 16-bit Intel architecture as described in the IA-32 Intel®
Architecture Software Developer’s Manual.
Itanium System Environment – The operating system environment that supports the execution of
both IA-32 and Itanium architecture-based code.
IA-32 System Environment – The operating system privileged environment and resources as
defined by the IA-32 Intel® Architecture Software Developer’s Manual. Resources include virtual
paging, control registers, debugging, performance monitoring, machine checks, and the set of
privileged instructions.
Itanium® Architecture-based Firmware – The Processor Abstraction Layer (PAL) and System
Abstraction Layer (SAL).
Processor Abstraction Layer (PAL) – The firmware layer which abstracts processor features that
are implementation dependent.
System Abstraction Layer (SAL) – The firmware layer which abstracts system features that are
implementation dependent.
October 2002 2.1 Modified PAL_FREQ_RATIOS (Section 11.2.2, Part I, Vol. 2).
(continued) Modified PAL_VERSION (Section 11.9, Part I, Vol. 2).
Modified PAL_CACHE_INFO Store Hints (Section 11.9, Part I, Vol. 2).
Modified PAL_MC_RESUME (Sections 11.3.3 and 11.4, Part I, Vol. 2).
Modified IA_32_Exception (Debug) IIPA Description (Section 9.2, Part I,
Vol. 2).
Clarified Predicate Behavior of alloc Instruction (Section 4.1.2, Part I, Vol. 1
and Section 2.2, Part I, Vol. 3).
Clarified ITC clocking (Section 3.1.8.10, Part I, Vol. 1; Section 3.3.4.2, Part I,
Vol. 2; and Section 10.5.5, Part II, Vol. 2).
Clarified Interval Time Counter (ITC) Fault (Section 3.3.2, Part I, Vol. 2).
Clarified Interruption Control Registers (Section 3.3.5, Part I, Vol. 2).
Clarified Freeze Bit Functionality in Context Switching and Interrupt
Generation (Sections 7.2.1, 7.2.2, 7.2.4.1, and 7.2.4.2, Part I, Vol. 2).
Clarified PAL_BUS_GET/SET_FEATURES (Section 11.9.3, Part I, Vol. 2).
Clarified PAL_CACHE_FLUSH (Section 11.9, Part I, Vol. 2).
Clarified Cache State upon Recovery Check (Section 11.2, Part I, Vol. 2).
Clarified PALE_INIT Exit State (Section 11.4.2, Part I, Vol. 2).
Clarified Processor State Parameter (Section 11.4.2.1, Part I, Vol. 2).
Clarified Firmware Address Space at Reset (Section 11.1, Part I, Vol. 2).
Clarified PAL PMI, AR.ITC, and PMD Register Values (Sections 11.3, 11.5.1,
and 11.5.2, Part I, Vol. 2).
Clarified Invalid Arguments to PAL (Section 11.9.2.4, Part I, Vol. 2).
Clarified itr/itc Instructions (Section 2.2, Part I, Vol. 3).
December 2001 2.0 Volume 1:
Faults in ld.c that hits ALAT clarification (Section 4.4.5.3.1).
IA-32 related changes (Section 6.2.5.4, Section 6.2.3, Section 6.2.4, Section
6.2.5.3).
Load instructions change (Section 4.4.1).
Volume 2:
Class pr-writers-int clarification (Table A-5).
PAL_MC_DRAIN clarification (Section 4.4.6.1).
VHPT walk and forward progress change (Section 4.1.1.2).
IA-32 IBR/DBR match clarification (Section 7.1.1).
ISR figure changes (pp. 8-5, 8-26, 8-33 and 8-36).
PAL_CACHE_FLUSH return argument change - added new status return
argument (Section 11.8.3).
PAL self-test Control and PAL_A procedure requirement change - added new
arguments, figures, requirements (Section 11.2).
PAL_CACHE_FLUSH clarifications (Section 11).
Non-speculative reference clarification (Section 4.4.6).
RID and Preferred Page Size usage clarification (Section 4.1).
VHPT read atomicity clarification (Section 4.1).
IIP and WC flush clarification (Section 4.4.5).
Revised RSE and PMC typographical errors (Section 6.4).
Revised DV table (Section A.4).
December 2001 2.0 Memory attribute transitions - added new requirements (Section 4.4).
(continued) MCA for WC/UC aliasing change (Section 4.4.1).
Bus lock deprecation - changed behavior of DCR ‘lc’ bit (Section 3.3.4.1,
Section 10.6.8, Section 11.8.3).
PAL_PROC_GET/SET_FEATURES changes - extend calls to allow
implementation-specific feature control (Section 11.8.3).
Split PAL_A architecture changes (Section 11.1.6).
Simple barrier synchronization clarification (Section 13.4.2).
Limited speculation clarification - added hardware-generated speculative
references (Section 4.4.6).
PAL memory accesses and restrictions clarification (Section 11.9).
PSP validity on INITs from PAL_MC_ERROR_INFO clarification (Section
11.8.3).
Speculation attributes clarification (Section 4.4.6).
PAL_A FIT entry, PAL_VM_TR_READ, PSP, PAL_VERSION clarifications
(Sections 11.8.3 and 11.3.2.1).
TLB searching clarifications (Section 4.1).
IA-32 related changes (Section 10.3, Section 10.3.2, Section 10.3.2, Section
10.3.3.1, Section 10.10.1).
IPSR.ri and ISR.ei changes (Table 3-2, Section 3.3.5.1, Section 3.3.5.2,
Section 5.5, Section 8.3, and Section 2.2).
Volume 3:
IA-32 CPUID clarification (p. 5-71).
Revised figures for extract, deposit, and alloc instructions (Section 2.2).
RCPPS, RCPSS, RSQRTPS, and RSQRTSS clarification (Section 7.12).
IA-32 related changes (Section 5.3).
tak, tpa change (Section 2.2).
July 2000 1.1 Volume 1:
Processor Serial Number feature removed (Chapter 3).
Clarification on exceptions to instruction dependency (Section 3.4.3).
Volume 2:
Clarifications regarding “reserved” fields in ITIR (Chapter 3).
Instruction and Data translation must be enabled for executing IA-32
instructions (Chapters 3,4 and 10).
FCR/FDR mappings, and clarification to the value of PSR.ri after an RFI
(Chapters 3 and 4).
Clarification regarding ordering data dependency.
Out-of-order IPI delivery is now allowed (Chapters 4 and 5).
Content of EFLAG field changed in IIM (p. 9-24).
PAL_CHECK and PAL_INIT calls – exit state changes (Chapter 11).
PAL_CHECK processor state parameter changes (Chapter 11).
PAL_BUS_GET/SET_FEATURES calls – added two new bits (Chapter 11).
PAL_MC_ERROR_INFO call – Changes made to enhance and simplify the
call to provide more information regarding machine check (Chapter 11).
PAL_ENTER_IA_32_Env call changes – entry parameter represents the entry
order; SAL needs to initialize all the IA-32 registers properly before making
this call (Chapter 11).
PAL_CACHE_FLUSH – added a new cache_type argument (Chapter 11.
PAL_SHUTDOWN – removed from list of PAL calls (Chapter 11).
Clarified memory ordering changes (Chapter 13).
Clarification in dependence violation table (Appendix A).
Instruction Reference 2
This chapter describes the function of each Itanium instruction. The pages of this chapter are sorted
alphabetically by assembly language mnemonic.
In the Format section, register addresses are specified using the assembly mnemonic field names
given in the third column of Table 2-3. For instructions that are predicated, the Description section
assumes that the qualifying predicate is true (except for instructions that modify architectural state
when their qualifying predicate is false). The test of the qualifying predicate is included in the
Operation section (when applicable).
In the Operation section, registers are addressed using the notation reg[addr].field. The register file
being accessed is specified by reg, and has a value chosen from the second column of Table 2-3.
The addr field specifies a register address as an assembly language field name or a register
mnemonic. For the general, floating-point, and predicate register files which undergo register
renaming, addr is the register address prior to renaming and the renaming is not shown. The field
option specifies a named bit field within the register. If field is absent, then all fields of the register
are accessed. The only exception is when referencing the data field of the general registers (64-bits
not including the NaT bit) where the notation GR[addr] is used. The syntactical differences between
the code found in the Operation section and ANSI C is listed in Table 2-4.
The Operation section contains code that specifies only the execution semantics of each instruction
and does not include any behavior relating to instruction fetch (e.g., interrupts and faults caused
during fetch). The Interruptions section does not list any faults that may be caused by instruction
fetch or by mandatory RSE loads. The code to raise certain pervasive faults and actions is not
included in the code in the Operation section. These faults and actions are listed in Table 2-5. The
Single step trap applies to all instructions and is not listed in the Interruptions section.
add — Add
Format: (qp) add r1 = r2, r3 register_form A1
(qp) add r1 = r2, r3, 1 plus1_form, register_form A1
(qp) add r1 = imm, r3 pseudo-op
(qp) adds r1 = imm14, r3 imm14_form A4
(qp) addl r1 = imm22, r3 imm22_form A5
Description: The two source operands (and an optional constant 1) are added and the result placed in GR r1. In
the register form the first operand is GR r2; in the imm_14 form the first operand is taken from the
sign-extended imm14 encoding field; in the imm22_form the first operand is taken from the
sign-extended imm22 encoding field. In the imm22_form, GR r3 can specify only GRs 0, 1, 2 and 3.
The plus1_form is available only in the register_form (although the equivalent effect in the
immediate forms can be achieved by adjusting the immediate).
The immediate-form pseudo-op chooses the imm14_form or imm22_form based on the size of the
immediate operand and the value of r3.
Operation: if (PR[qp]) {
check_target_register(r1);
if (plus1_form)
GR[r1] = tmp_src + GR[r3] + 1;
else
GR[r1] = tmp_src + GR[r3];
Description: The two source operands are added. The upper 32 bits of the result are forced to zero, and then bits
{31:30} of GR r3 are copied to bits {62:61} of the result. This result is placed in GR r1. In the
register_form the first operand is GR r2; in the imm14_form the first operand is taken from the
sign-extended imm14 encoding field.
32 0 32 30 0
GR r2: GR r3:
GR r1: 0 0
63 61 32 0
Operation: if (PR[qp]) {
check_target_register(r1);
Description: A new stack frame is allocated on the general register stack, and the Previous Function State
register (PFS) is copied to GR r1. The change of frame size is immediate. The write of GR r1 and
subsequent instructions in the same instruction group use the new frame.
The four parameters, i (size of inputs), l (size of locals), o (size of outputs), and r (size of rotating)
specify the sizes of the regions of the stack frame.
GR32
Local Output
sof
sol
sor
The size of the frame (sof) is determined by i + l + o. Note that this instruction may grow or shrink
the size of the current register stack frame. The size of the local region (sol) is given by i + l. There
is no real distinction between inputs and locals. They are given as separate operands in the
instruction only as a hint to the assembler about how the local registers are to be used.
The rotating registers must fit within the stack frame and be a multiple of 8 in number. If this
instruction attempts to change the size of CFM.sor, and the register rename base registers
(CFM.rrb.gr, CFM.rrb.fr, CFM.rrb.pr) are not all zero, then the instruction will cause a Reserved
Register/Field fault.
Although the assembler does not allow illegal combinations of operands for alloc, illegal
combinations can be encoded in the instruction. Attempting to allocate a stack frame larger than 96
registers, or with the rotating region larger than the stack frame, or with the size of locals larger
than the stack frame, or specifying a qualifying predicate other than PR 0, will cause an Illegal
Operation fault.
This instruction must be the first instruction in an instruction group and must either be in
instruction slot 0 or in instruction slot 1 of a template having a stop after slot 0; otherwise, the
results are undefined.
If insufficient registers are available to allocate the desired frame alloc will stall the processor until
enough dirty registers are written to the backing store. Such mandatory RSE stores may cause the
data related faults listed below.
Operation: // tmp_sof, tmp_sol, tmp_sor are the fields encoded in the instruction
tmp_sof = i + l + o;
tmp_sol = i + l;
tmp_sor = r u>> 3;
check_target_register_sof(r1, tmp_sof);
if (tmp_sof u> 96 || r u> tmp_sof || tmp_sol u> tmp_sof || qp!= 0)
illegal_operation_fault();
if (tmp_sor!= CFM.sor &&
(CFM.rrb.gr!= 0 || CFM.rrb.fr!= 0 || CFM.rrb.pr!= 0))
reserved_register_field_fault();
GR[r1] = AR[PFS];
GR[r1].nat = 0;
Description: The two source operands are logically ANDed and the result placed in GR r1. In the register_form
the first operand is GR r2; in the imm8_form the first operand is taken from the imm8 encoding
field.
Operation: if (PR[qp]) {
check_target_register(r1);
Description: The first source operand is logically ANDed with the 1’s complement of the second source operand
and the result placed in GR r1. In the register_form the first operand is GR r2; in the imm8_form
the first operand is taken from the imm8 encoding field.
Operation: if (PR[qp]) {
check_target_register(r1);
br — Branch
Format: (qp) br.btype.bwh.ph.dh target25 ip_relative_form B1
(qp) br.btype.bwh.ph.dh b1 = target25 call_form, ip_relative_form B3
br.btype.bwh.ph.dh target25 counted_form, ip_relative_form B2
br.ph.dh target25 pseudo-op
(qp) br.btype.bwh.ph.dh b2 indirect_form B4
(qp) br.btype.bwh.ph.dh b1 = b2 call_form, indirect_form B5
br.ph.dh b2 pseudo-op
Description: A branch condition is evaluated, and either a branch is taken, or execution continues with the next
sequential instruction. The execution of a branch logically follows the execution of all previous
non-branch instructions in the same instruction group. On a taken branch, execution begins at slot
0.
Branches can be either IP-relative, or indirect. For IP-relative branches, the target25 operand, in
assembly, specifies a label to branch to. This is encoded in the branch instruction as a signed
immediate displacement (imm21) between the target bundle and the bundle containing this
instruction (imm21 = target25 - IP >> 4). For indirect branches, the target address is taken from BR
b2 .
There are two pseudo-ops for unconditional branches. These are encoded like a conditional branch
(btype = cond), with the qp field specifying PR 0, and with the bwh hint of sptk.
The branch type determines how the branch condition is calculated and whether the branch has
other effects (such as writing a link register). For the basic branch types, the branch condition is
simply the value of the specified predicate register. These basic branch types are:
• cond: If the qualifying predicate is 1, the branch is taken. Otherwise it is not taken.
• call: If the qualifying predicate is 1, the branch is taken and several other actions occur:
• The current values of the Current Frame Marker (CFM), the EC application register and
the current privilege level are saved in the Previous Function State application register.
• The caller’s stack frame is effectively saved and the callee is provided with a frame
containing only the caller’s output region.
• The rotation rename base registers in the CFM are reset to 0.
• A return link value is placed in BR b1.
• return: If the qualifying predicate is 1, the branch is taken and the following occurs:
• CFM, EC, and the current privilege level are restored from PFS. (The privilege level is
restored only if this does not increase privilege.)
• The caller’s stack frame is restored.
• If the return lowers the privilege, and PSR.lp is 1, then a Lower-Privilege Transfer trap is
taken.
• ia: The branch is taken unconditionally, if it is not intercepted by the OS. The effect of the
branch is to invoke the IA-32 instruction set (by setting PSR.is to 1) and begin processing
IA-32 instructions at the virtual linear target address contained in BR b2{31:0}. If the
qualifying predicate is not PR 0, an Illegal Operation fault is raised. If instruction set
transitions are disabled (PSR.di is 1), then a Disabled Instruction Set Transition fault is raised.
The IA-32 target effective address is calculated relative to the current code segment, i.e.
EIP{31:0} = BR b2{31:0} - CSD.base. The IA-32 instruction set can be entered at any
privilege level, provided PSR.di is 0. If PSR.dfh is 1, a Disabled FP Register fault is raised on
the target IA-32 instruction. No register bank switch nor change in privilege level occurs
during the instruction set transition.
Software must ensure the code segment descriptor (CSD) and selector (CS) are loaded before
issuing the branch. If the target EIP value exceeds the code segment limit or has a code
segment privilege violation, an IA_32_Exception(GPFault) is raised on the target IA-32
instruction. For entry into 16-bit IA-32 code, if BR b2 is not within 64K-bytes of CSD.base a
GPFault is raised on the target instruction. EFLAG.rf is unmodified until the successful
completion of the first IA-32 instruction. PSR.da, PSR.id, PSR.ia, PSR.dd, and PSR.ed are
cleared to zero after br.ia completes execution and before the first IA-32 instruction begins
execution. EFLAG.rf is not cleared until the target IA-32 instruction successfully completes.
Software must set PSR properly before branching to the IA-32 instruction set; otherwise
processor operation is undefined. See Table 3-2, “Processor Status Register Fields” on
page 2:21 for details.
Software must issue a mf instruction before the branch if memory ordering is required between
IA-32 processor consistent and Itanium unordered memory references. The processor does not
ensure Itanium-instruction-set-generated writes into the instruction stream are seen by
subsequent IA-32 instruction fetches. br.ia does not perform an instruction serialization
operation. The processor does ensure that prior writes (even in the same instruction group) to
GRs and FRs are observed by the first IA-32 instruction. Writes to ARs within the same
instruction group as br.ia are not allowed, since br.ia may implicitly reads all ARs. If an illegal
RAW dependency is present between an AR write and br.ia, the first IA-32 instruction fetch and
execution may or may not see the updated AR value.
IA-32 instruction set execution leaves the contents of the ALAT undefined. Software can not
rely on ALAT values being preserved across an instruction set transition. All registers left in
the current register stack frame are undefined across an instruction set transition. On entry to
IA-32 code, existing entries in the ALAT are ignored. If the register stack contains any dirty
registers, an Illegal Operation fault is raised on the br.ia instruction. The current register stack
frame is forced to zero. To flush the register file of dirty registers, the flushrs instruction must be
issued in an instruction group preceding the br.ia instruction. To enhance the performance of the
instruction set transition, software can start the register stack flush in parallel with starting the
IA-32 instruction set by 1) ensuring flushrs is exactly one instruction group before the br.ia, and
2) br.ia is in the first B-slot. br.ia should always be executed in the first B-slot with a hint of
“static-taken” (default), otherwise processor performance will be degraded.
If a br.ia causes any Itanium traps (e.g., Single Step trap, Taken Branch trap, or Unimplemented
Instruction Address trap), IIP will contain the original 64-bit target IP. (The value will not have
been zero extended from 32 bits.)
Another branch type is provided for simple counted loops. This branch type uses the Loop Count
application register (LC) to determine the branch condition, and does not use a qualifying
predicate:
• cloop: If the LC register is not equal to zero, it is decremented and the branch is taken.
In addition to these simple branch types, there are four types which are used for accelerating
modulo-scheduled loops (see also Section 4.5.1, “Modulo-scheduled Loop Support” on page 1:70).
Two of these are for counted loops (which use the LC register), and two for while loops (which use
the qualifying predicate). These loop types use register rotation to provide register renaming, and
they use predication to turn off instructions that correspond to empty pipeline stages.
The Epilog Count application register (EC) is used to count epilog stages and, for some while
loops, a portion of the prolog stages. In the epilog phase, EC is decremented each time around and,
for most loops, when EC is one, the pipeline has been drained, and the loop is exited. For certain
types of optimized, unrolled software-pipelined loops, the target of a br.cexit or br.wexit is set to the
next sequential bundle. In this case, the pipeline may not be fully drained when EC is one, and
continues to drain while EC is zero.
For these modulo-scheduled loop types, the calculation of whether the branch is taken or not
depends on the kernel branch condition (LC for counted types, and the qualifying predicate for
while types) and on the epilog condition (whether EC is greater than one or not).
These branch types are of two categories: top and exit. The top types (ctop and wtop) are used
when the loop decision is located at the bottom of the loop body and therefore a taken branch will
continue the loop while a fall through branch will exit the loop. The exit types (cexit and wexit) are
used when the loop decision is located somewhere other than the bottom of the loop and therefore a
fall though branch will continue the loop and a taken branch will exit the loop. The exit types are
also used at intermediate points in an unrolled pipelined loop. (For more details, see Section 4.5.1,
“Modulo-scheduled Loop Support” on page 1:70).
The modulo-scheduled loop types are:
• ctop and cexit: These branch types behave identically, except in the determination of whether
to branch or not. For br.ctop, the branch is taken if either LC is non-zero or EC is greater than
one. For br.cexit, the opposite is true. It is not taken if either LC is non-zero or EC is greater
than one and is taken otherwise.
These branch types also use LC and EC to control register rotation and predicate initialization.
During the prolog and kernel phase, when LC is non-zero, LC counts down. When br.ctop or
br.cexit is executed with LC equal to zero, the epilog phase is entered, and EC counts down.
When br.ctop or br.cexit is executed with LC equal to zero and EC equal to one, a final
decrement of EC and a final register rotation are done. If LC and EC are equal to zero, register
rotation stops. These other effects are the same for the two branch types, and are described in
Figure 2-3.
ctop, cexit
== 0 (Epilog) (Special
LC?
Unrolled
!= 0 >1 == 0 Loops)
(Prolog / EC?
Kernel)
== 1
LC-- LC = LC LC = LC LC = LC
EC = EC EC-- EC-- EC = EC
wtop and wexit: These branch types behave identically, except in the determination of whether
to branch or not. For br.wtop, the branch is taken if either the qualifying predicate is one or EC
is greater than one. For br.wexit, the opposite is true. It is not taken if either the qualifying
predicate is one or EC is greater than one, and is taken otherwise.
These branch types also use the qualifying predicate and EC to control register rotation and
predicate initialization. During the prolog phase, the qualifying predicate is either zero or one,
depending upon the scheme used to program the loop. During the kernel phase, the qualifying
predicate is one. During the epilog phase, the qualifying predicate is zero, and EC counts
down. When br.wtop or br.wexit is executed with the qualifying predicate equal to zero and EC
equal to one, a final decrement of EC and a final register rotation are done. If the qualifying
predicate and EC are zero, register rotation stops. These other effects are the same for the two
branch types, and are described in Figure 2-4.
wtop, wexit
>1 == 0 Loops)
(Prolog / == 1
EC?
Kernel) (Prolog /
Epilog) (Epilog) == 1
EC = EC EC-- EC-- EC = EC
The loop-type branches (br.cloop, br.ctop, br.cexit, br.wtop, and br.wexit) are only allowed in instruction
slot 2 within a bundle. Executing such an instruction in either slot 0 or 1 will cause an Illegal
Operation fault, whether the branch would have been taken or not.
Read after Write (RAW) and Write after Read (WAR) dependency requirements are slightly
different for branch instructions. Changes to BRs, PRs, and PFS by non-branch instructions are
visible to a subsequent branch instruction in the same instruction group (i.e., a limited RAW is
allowed for these resources). This allows for a low-latency compare-branch sequence, for example.
The normal RAW requirements apply to the LC and EC application registers, and the RRBs.
Within an instruction group, a WAR dependency on PR 63 is not allowed if both the reading and
writing instructions are branches. For example, a br.wtop or br.wexit may not use PR[63] as its
qualifying predicate and PR[63] cannot be the qualifying predicate for any branch preceding a
br.wtop or br.wexit in the same instruction group.
For dependency purposes, the loop-type branches effectively always write their associated
resources, whether they are taken or not. The cloop type effectively always writes LC. When LC is
0, a cloop branch leaves it unchanged, but hardware may implement this as a re-write of LC with
the same value. Similarly, br.ctop and br.cexit effectively always write LC, EC, the RRBs, and
PR[63]. br.wtop and br.wexit effectively always write EC, the RRBs, and PR[63].
Values for various branch hint completers are shown in the following tables. Whether Prediction
Strategy hints are shown in Table 2-7. Sequential Prefetch hints are shown in Table 2-8. Branch
Cache Deallocation hints are shown in Table 2-9. See Section 4.5.2, “Branch Prediction Hints” on
page 1:72.
lower_priv_transition = 0;
switch (btype) {
case ‘cond’: // simple conditional branch
tmp_taken = PR[qp];
break;
alat_frame_update(CFM.sol, 0);
rse_preserve_frame(CFM.sol);
CFM.sof -= CFM.sol; // new frame size is size of outs
CFM.sol = 0;
CFM.sor = 0;
CFM.rrb.gr = 0;
CFM.rrb.fr = 0;
CFM.rrb.pr = 0;
}
break;
rse_enable_current_frame_load();
AR[EC] = AR[PFS].pec;
if (PSR.cpl u< AR[PFS].ppl) { //... and restores privilege
PSR.cpl = AR[PFS].ppl;
lower_priv_transition = 1;
}
}
break;
illegal_operation_fault();
if (PSR.di)
disabled_instruction_set_transition_fault();
PSR.is = 1; // set IA-32 Instruction Set Mode
CFM.sof = 0; //force current stack frame
CFM.sol = 0; //to zero
CFM.sor = 0;
CFM.rrb.gr = 0;
CFM.rrb.fr = 0;
CFM.rrb.pr = 0;
rse_invalidate_non_current_regs();
//compute effective instruction pointer
EIP{31:0} = tmp_IP{31:0} - AR[CSD].Base;
case ‘ctop’:
case ‘cexit’: // SW pipelined counted loop
if (slot!= 2)
illegal_operation_fault();
if (btype == ‘ctop’) tmp_taken = ((AR[LC]!= 0) || (AR[EC] u> 1));
if (btype == ‘cexit’) tmp_taken =!((AR[LC]!= 0) || (AR[EC] u> 1));
if (AR[LC]!= 0) {
AR[LC]--;
AR[EC] = AR[EC];
PR[63] = 1;
rotate_regs();
} else if (AR[EC]!= 0) {
AR[LC] = AR[LC];
AR[EC]--;
PR[63] = 0;
rotate_regs();
} else {
AR[LC] = AR[LC];
AR[EC] = AR[EC];
PR[63] = 0;
CFM.rrb.gr = CFM.rrb.gr;
CFM.rrb.fr = CFM.rrb.fr;
CFM.rrb.pr = CFM.rrb.pr;
}
break;
case ‘wtop’:
case ‘wexit’: // SW pipelined while loop
if (slot!= 2)
illegal_operation_fault();
if (btype == ‘wtop’) tmp_taken = (PR[qp] || (AR[EC] u> 1));
if (btype == ‘wexit’) tmp_taken =!(PR[qp] || (AR[EC] u> 1));
if (PR[qp]) {
AR[EC] = AR[EC];
PR[63] = 0;
rotate_regs();
} else if (AR[EC]!= 0) {
AR[EC]--;
PR[63] = 0;
rotate_regs();
} else {
AR[EC] = AR[EC];
PR[63] = 0;
CFM.rrb.gr = CFM.rrb.gr;
CFM.rrb.fr = CFM.rrb.fr;
CFM.rrb.pr = CFM.rrb.pr;
}
break;
}
if (tmp_taken) {
taken_branch = 1;
IP = tmp_IP; // set the new value for IP
if (!impl_uia_fault_supported() &&
((PSR.it && unimplemented_virtual_address(tmp_IP, PSR.vm))
|| (!PSR.it && unimplemented_physical_address(tmp_IP))))
unimplemented_instruction_address_trap(lower_priv_transition,
tmp_IP);
if (lower_priv_transition && PSR.lp)
lower_privilege_transfer_trap();
if (PSR.tb)
taken_branch_trap();
}
break — Break
Format: (qp) break imm21 pseudo-op
(qp) break.i imm21 i_unit_form I19
(qp) break.b imm21 b_unit_form B9
(qp) break.m imm21 m_unit_form M37
(qp) break.f imm21 f_unit_form F15
(qp) break.x imm62 x_unit_form X1
Description: A Break Instruction fault is taken. For the i_unit_form, f_unit_form and m_unit_form, the value
specified by imm21 is zero-extended and placed in the Interruption Immediate control register
(IIM).
For the b_unit_form, imm21 is ignored and the value zero is placed in the Interruption Immediate
control register (IIM).
For the x_unit_form, the lower 21 bits of the value specified by imm62 is zero-extended and placed
in the Interruption Immediate control register (IIM). The L slot of the bundle contains the upper 41
bits of imm62.
A break.i instruction may be encoded in an MLI-template bundle, in which case the L slot of the
bundle is ignored.
This instruction has five forms, each of which can be executed only on a particular execution unit
type. The pseudo-op can be used if the unit type to execute on is unimportant.
Operation: if (PR[qp]) {
if (b_unit_form)
immediate = 0;
else if (x_unit_form)
immediate = zero_ext(imm62, 21);
else // i_unit_form || m_unit_form || f_unit_form
immediate = zero_ext(imm21, 21);
break_instruction_fault(immediate);
}
Description: A branch condition is evaluated, and either a branch is taken, or execution continues with the next
sequential instruction. The execution of a branch logically follows the execution of all previous
non-branch instructions in the same instruction group. On a taken branch, execution begins at slot
0.
Long branches are always IP-relative. The target64 operand, in assembly, specifies a label to branch
to. This is encoded in the long branch instruction as an immediate displacement (imm60) between
the target bundle and the bundle containing this instruction (imm60 = target64 - IP >> 4). The L slot
of the bundle contains 39 bits of imm60.
There is a pseudo-op for long unconditional branches, encoded like a conditional branch (btype =
cond), with the qp field specifying PR 0, and with the bwh hint of sptk.
The branch type determines how the branch condition is calculated and whether the branch has
other effects (such as writing a link register). For all long branch types, the branch condition is
simply the value of the specified predicate register:
• cond: If the qualifying predicate is 1, the branch is taken. Otherwise it is not taken.
• call: If the qualifying predicate is 1, the branch is taken and several other actions occur:
• The current values of the Current Frame Marker (CFM), the EC application register and
the current privilege level are saved in the Previous Function State application register.
• The caller’s stack frame is effectively saved and the callee is provided with a frame
containing only the caller’s output region.
• The rotation rename base registers in the CFM are reset to 0.
• A return link value is placed in BR b1.
Read after Write (RAW) and Write after Read (WAR) dependency requirements for long branch
instructions are slightly different than for other instructions but are the same as for branch
instructions. See page 3:24 for details.
This instruction must be immediately followed by a stop; otherwise its behavior is undefined.
Values for various branch hint completers are the same as for branch instructions. Whether
Prediction Strategy hints are shown in Table 2-7 on page 3:24, Sequential Prefetch hints are shown
in Table 2-8 on page 3:24, and Branch Cache Deallocation hints are shown in Table 2-9 on
page 3:24. See Section 4.5.2, “Branch Prediction Hints” on page 1:72.
This instruction is not implemented on the Itanium processor, which takes an Illegal Operation fault
whenever a long branch instruction is encountered, regardless of whether the branch is taken or not.
To support the Itanium processor, the operating system is required to provide an Illegal Operation
fault handler which emulates taken and not-taken long branches. Presence of this instruction is
indicated by a 1 in the lb bit of CPUID register 4. See Section 3.1.11, “Processor Identification
Registers” on page 1:31.
switch (btype) {
case ‘cond’: // simple conditional branch
tmp_taken = PR[qp];
break;
alat_frame_update(CFM.sol, 0);
rse_preserve_frame(CFM.sol);
CFM.sof -= CFM.sol; // new frame size is size of outs
CFM.sol = 0;
CFM.sor = 0;
CFM.rrb.gr = 0;
CFM.rrb.fr = 0;
CFM.rrb.pr = 0;
}
break;
}
if (tmp_taken) {
taken_branch = 1;
IP = tmp_IP; // set the new value for IP
if (!impl_uia_fault_supported() &&
((PSR.it && unimplemented_virtual_address(tmp_IP, PSR.vm))
|| (!PSR.it && unimplemented_physical_address(tmp_IP))))
unimplemented_instruction_address_trap(0,tmp_IP);
if (PSR.tb)
taken_branch_trap();
}
Description: This instruction can be used to provide to hardware early information about a future branch. It has
no effect on architectural machine state, and operates as a nop instruction except for its performance
effects.
The tag13 operand, in assembly, specifies the address of the branch instruction to which this
prediction information applies. This is encoded in the branch predict instruction as a signed
immediate displacement (timm9) between the bundle containing the presaged branch and the
bundle containing this instruction (timm9 = tag13 - IP >> 4).
The target25 operand, in assembly, specifies the label that the presaged branch will have as its
target. This is encoded in the branch predict instruction exactly as in branch instructions, with a
signed immediate displacement (imm21) between the target bundle and the bundle containing this
instruction (imm21 = target25 - IP >> 4). The indirect_form can be used to presage an indirect
branch. In the indirect_form, the target of the presaged branch is given by BR b2.
The return_form is used to indicate that the presaged branch will be a return.
Other hints can be given about the presaged branch. Values for various hint completers are shown
in the following tables. For more details, refer to Section 4.5.2, “Branch Prediction Hints” on
page 1:72.
The ipwh and indwh completers provide information about how best the branch condition should be
predicted, when the branch is reached.
The ih completer can be used to mark a small number of very important branches (e.g., an inner
loop branch). This can signal to hardware to use faster, smaller prediction structures for this
information.
Interruptions: None
Description: This instruction switches to the specified register bank. The zero_form specifies Bank 0 for GR16
to GR31. The one_form specifies Bank 1 for GR16 to GR31. After the bank switch the previous
register bank is no longer accessible but does retain its current state. If the new and old register
banks are the same, bsw is effectively a nop, although there may be a performance degradation.
A bsw instruction must be the last instruction in an instruction group; otherwise, operation is
undefined. Instructions in the same instruction group that access GR16 to GR31 reference the
previous register bank. Subsequent instruction groups reference the new register bank.
This instruction can only be executed at the most privileged level, and when PSR.vm is 0.
This instruction cannot be predicated.
Operation: if (!followed_by_stop())
undefined_behavior();
if (PSR.cpl!= 0)
privileged_operation_fault(0);
if (PSR.vm == 1)
virtualization_fault();
if (zero_form)
PSR.bn = 0;
else // one_form
PSR.bn = 1;
Serialization: This instruction does not require any additional instruction or data serialization operation. The bank
switch occurs synchronously with its execution.
Description: The result of a control- or data-speculative calculation is checked for success or failure. If the check
fails, a branch to target25 is taken.
In the control_form, success is determined by a NaT indication for the source register. If the NaT
bit corresponding to GR r2 is 1 (in the gr_form), or FR f2 contains a NaTVal (in the fr_form), the
check fails.
In the data_form, success is determined by the ALAT. The ALAT is queried using the general
register specifier r1 (in the gr_form), or the floating-point register specifier f1 (in the fr_form). If no
ALAT entry matches, the check fails. An implementation may optionally cause the check to fail
independent of whether an ALAT entry matches. A chk.a with general register specifier r0 or
floating-point register specifiers f0 or f1 always fails.
The target25 operand, in assembly, specifies a label to branch to. This is encoded in the instruction
as a signed immediate displacement (imm21) between the target bundle and the bundle containing
this instruction (imm21 = target25 - IP >> 4).
The branching behavior of this instruction can be optionally unimplemented. If the instruction
would have branched, and the branching behavior is not implemented, then a Speculative
Operation fault is taken and the value specified by imm21 is zero-extended and placed in the
Interruption Immediate control register (IIM). The fault handler emulates the branch by
sign-extending the IIM value, adding it to IIP and returning.
The control_form of this instruction for checking general registers can be encoded on either an
I-unit or an M-unit. The pseudo-op can be used if the unit type to execute on is unimportant.
For the data_form, if an ALAT entry matches, the matching ALAT entry can be optionally
invalidated, based on the value of the aclr completer (See Table 2-14).
Note that if the clr value of the aclr completer is used and the check succeeds, the matching ALAT
entry is invalidated. However, if the check fails (which may happen even if there is a matching
ALAT entry), any matching ALAT entry may optionally be invalidated, but this is not required.
Recovery code for data speculation, therefore, cannot rely on the absence of a matching ALAT
entry.
Operation: if (PR[qp]) {
if (control_form) {
if (fr_form && (tmp_isrcode = fp_reg_disabled(f2, 0, 0, 0)))
disabled_fp_register_fault(tmp_isrcode, 0);
check_type = gr_form? CHKS_GENERAL: CHKS_FLOAT;
fail = (gr_form && GR[r2].nat) || (fr_form && FR[f2] == NATVAL);
} else { // data_form
if (gr_form) {
reg_type = GENERAL;
check_type = CHKA_GENERAL;
alat_index = r1;
always_fail = (alat_index == 0);
} else { // fr_form
reg_type = FLOAT;
check_type = CHKA_FLOAT;
alat_index = f1;
always_fail = ((alat_index == 0) || (alat_index == 1));
}
fail = (always_fail || (!alat_cmp(reg_type, alat_index)));
}
if (fail) {
if (check_branch_implemented(check_type)) {
taken_branch = 1;
IP = IP + sign_ext((imm21 << 4), 25);
if (!impl_uia_fault_supported() &&
((PSR.it && unimplemented_virtual_address(IP, PSR.vm))
|| (!PSR.it && unimplemented_physical_address(IP))))
unimplemented_instruction_address_trap(0, IP);
if (PSR.tb)
taken_branch_trap();
} else
speculation_fault(check_type, zero_ext(imm21, 21));
} else if (data_form && (aclr == ‘clr’))
alat_inval_single_entry(reg_type, alat_index);
}
Description: In the all_form, the register rename base registers (CFM.rrb.gr, CFM.rrb.fr, and CFM.rrb.pr) are
cleared. In the pred_form, the single register rename base register for the predicates (CFM.rrb.pr) is
cleared.
This instruction must be the last instruction in an instruction group; otherwise, operation is
undefined.
This instruction cannot be predicated.
Operation: if (!followed_by_stop())
undefined_behavior();
if (all_form) {
CFM.rrb.gr = 0;
CFM.rrb.fr = 0;
CFM.rrb.pr = 0;
} else { // pred_form
CFM.rrb.pr = 0;
}
Interruptions: None
cmp — Compare
Format: (qp) cmp.crel.ctype p1, p2 = r2, r3 register_form A6
(qp) cmp.crel.ctype p1, p2 = imm8, r3 imm8_form A8
(qp) cmp.crel.ctype p1, p2 = r0, r3 parallel_inequality_form A7
(qp) cmp.crel.ctype p1, p2 = r3, r0 pseudo-op
Description: The two source operands are compared for one of ten relations specified by crel. This produces a
boolean result which is 1 if the comparison condition is true, and 0 otherwise. This result is written
to the two predicate register destinations, p1 and p2. The way the result is written to the destinations
is determined by the compare type specified by ctype.
The compare types describe how the predicate targets are updated based on the result of the
comparison. The normal type simply writes the compare result to one target, and the complement to
the other. The parallel types update the targets only for a particular comparison result. This allows
multiple simultaneous OR-type or multiple simultaneous AND-type compares to target the same
predicate register.
The unc type is special in that it first initializes both predicate targets to 0, independent of the
qualifying predicate. It then operates the same as the normal type. The behavior of the compare
types is described in Table 2-15. A blank entry indicates the predicate target is left unchanged.
In the register_form the first operand is GR r2; in the imm8_form the first operand is taken from the
sign-extended imm8 encoding field; and in the parallel_inequality_form the first operand must be
GR 0. The parallel_inequality_form is only used when the compare type is one of the parallel types,
and the relation is an inequality (>, >=, <, <=). See below.
If the two predicate register destinations are the same (p1 and p2 specify the same predicate
register), the instruction will take an Illegal Operation fault, if the qualifying predicate is 1, or if the
compare type is unc.
Of the ten relations, not all are directly implemented in hardware. Some are actually pseudo-ops.
For these, the assembler simply switches the source operand specifiers and/or switches the
predicate target specifiers and uses an implemented relation. For some of the pseudo-op compares
in the imm8_form, the assembler subtracts 1 from the immediate value, making the allowed
immediate range slightly different. Of the six parallel compare types, three of the types are actually
pseudo-ops. The assembler simply uses the negative relation with an implemented type. The
implemented relations and how the pseudo-ops map onto them are shown in Table 2-16 (for normal
and unc type compares), and Table 2-17 (for parallel type compares).
Table 2-16. 64-bit Comparison Relations for Normal and unc Compares
Compare Relation Register Form is a Immediate Form is a
crel Immediate Range
(a rel b) pseudo-op of pseudo-op of
eq a == b -128.. 127
ne a!= b eq p1 ´ p2 eq p1 ´ p2 -128.. 127
lt a<b signed -128.. 127
le a <= b lt a´b p1 ´ p2 lt a-1 -127.. 128
gt a>b lt a´b lt a-1 p1 ´ p2 -127.. 128
ge a >= b lt p1 ´ p2 lt p1 ´ p2 -128.. 127
ltu a<b unsigned 0.. 127,
264-128.. 264-1
leu a <= b ltu a´b p1 ´ p2 ltu a-1 1.. 128,
264-127.. 264
gtu a>b ltu a´b ltu a-1 p1 ´ p2 1.. 128,
264-127.. 264
geu a >= b ltu p1 ´ p2 ltu p1 ´ p2 0.. 127,
264-128.. 264-1
The parallel compare types can be used only with a restricted set of relations and operands. They
can be used with equal and not-equal comparisons between two registers or between a register and
an immediate, or they can be used with inequality comparisons between a register and GR 0.
Unsigned relations are not provided, since they are not of much use when one of the operands is
zero. For the parallel inequality comparisons, hardware only directly implements the ones where
the first operand (GR r2) is GR 0. Comparisons where the second operand is GR 0 are pseudo-ops
for which the assembler switches the register specifiers and uses the opposite relation.
Operation: if (PR[qp]) {
if (p1 == p2)
illegal_operation_fault();
switch (ctype) {
case ‘and’: // and-type compare
if (tmp_nat ||!tmp_rel) {
PR[p1] = 0;
PR[p2] = 0;
}
break;
case ‘or’: // or-type compare
if (!tmp_nat && tmp_rel) {
PR[p1] = 1;
PR[p2] = 1;
}
break;
case ‘or.andcm’: // or.andcm-type compare
if (!tmp_nat && tmp_rel) {
PR[p1] = 1;
PR[p2] = 0;
}
break;
case ‘unc’: // unc-type compare
default: // normal compare
if (tmp_nat) {
PR[p1] = 0;
PR[p2] = 0;
} else {
PR[p1] = tmp_rel;
PR[p2] =!tmp_rel;
}
break;
}
} else {
if (ctype == ‘unc’) {
if (p1 == p2)
illegal_operation_fault();
PR[p1] = 0;
PR[p2] = 0;
}
}
Description: The least significant 32 bits from each of two source operands are compared for one of ten relations
specified by crel. This produces a boolean result which is 1 if the comparison condition is true, and
0 otherwise. This result is written to the two predicate register destinations, p1 and p2. The way the
result is written to the destinations is determined by the compare type specified by ctype. See the
Compare instruction and Table 2-15 on page 3:37.
In the register_form the first operand is GR r2; in the imm8_form the first operand is taken from the
sign-extended imm8 encoding field; and in the parallel_inequality_form the first operand must be
GR 0. The parallel_inequality_form is only used when the compare type is one of the parallel types,
and the relation is an inequality (>, >=, <, <=). See the Compare instruction and Table 2-17 on
page 3:38.
If the two predicate register destinations are the same (p1 and p2 specify the same predicate
register), the instruction will take an Illegal Operation fault, if the qualifying predicate is 1, or if the
compare type is unc.
Of the ten relations, not all are directly implemented in hardware. Some are actually pseudo-ops.
See the Compare instruction and Table 2-16 and Table 2-17 on page 3:38. The range for
immediates is given below.
Operation: if (PR[qp]) {
if (p1 == p2)
illegal_operation_fault();
if (register_form)
tmp_src = GR[r2];
else if (imm8_form)
tmp_src = sign_ext(imm8, 8);
else // parallel_inequality_form
tmp_src = 0;
switch (ctype) {
case ‘and’: // and-type compare
if (tmp_nat ||!tmp_rel) {
PR[p1] = 0;
PR[p2] = 0;
}
break;
case ‘or’: // or-type compare
if (!tmp_nat && tmp_rel) {
PR[p1] = 1;
PR[p2] = 1;
}
break;
case ‘or.andcm’: // or.andcm-type compare
if (!tmp_nat && tmp_rel) {
PR[p1] = 1;
PR[p2] = 0;
}
break;
case ‘unc’: // unc-type compare
default: // normal compare
if (tmp_nat) {
PR[p1] = 0;
PR[p2] = 0;
} else {
PR[p1] = tmp_rel;
PR[p2] =!tmp_rel;
}
break;
}
} else {
if (ctype == ‘unc’) {
if (p1 == p2)
illegal_operation_fault();
PR[p1] = 0;
PR[p2] = 0;
}
}
Description: A value consisting of sz bytes (8 bytes for cmp8xchg16) is read from memory starting at the address
specified by the value in GR r3. The value is zero extended and compared with the contents of the
cmpxchg Compare Value application register (AR[CCV]). If the two are equal, then the least
significant sz bytes of the value in GR r2 are written to memory starting at the address specified by
the value in GR r3. For cmp8xchg16, if the two are equal, then 8-bytes from GR r2 are stored at the
specified address ignoring bit 3 (GR r3 & ~0x8), and 8 bytes from the Compare and Store Data
application register (AR[CSD]) are stored at that address + 8 ((GR r3 & ~0x8) + 8). The
zero-extended value read from memory is placed in GR r1 and the NaT bit corresponding to GR r1
is cleared.
The values of the sz completer are given in Table 2-19. The sem completer specifies the type of
semaphore operation. These operations are described in Table 2-20. See Section 4.4.7,
“Sequentiality Attribute and Ordering” on page 2:75 for details on memory ordering.
If the address specified by the value in GR r3 is not naturally aligned to the size of the value being
accessed in memory, an Unaligned Data Reference fault is taken independent of the state of the
User Mask alignment checking bit, UM.ac (PSR.ac in the Processor Status Register). For the
cmp8xchg16 instruction, the address specified must be 8-byte aligned.
The memory read and write are guaranteed to be atomic. For the cmp8xchg16 instruction, the 8-byte
memory read and the 16-byte memory write are guaranteed to be atomic.
Both read and write access privileges for the referenced page are required. The write access
privilege check is performed whether or not the memory write is performed.
This instruction is only supported to cacheable pages with write-back write policy. Accesses to
NaTPages cause a Data NaT Page Consumption fault. Accesses to pages with other memory
attributes cause an Unsupported Data Reference fault.
The value of the ldhint completer specifies the locality of the memory access. The values of the
ldhint completer are given in Table 2-34 on page 3:139. Locality hints do not affect program
functionality and may be ignored by the implementation. See Section 4.4.6, “Memory Hierarchy
Control and Consistency” on page 1:64 for details.
For cmp8xchg16, Illegal Operation fault is raised on processor models that do not support the
instruction. CPUID register 4 indicates the presence of the feature on the processor model. See
Section 3.1.11, “Processor Identification Registers” on page 1:31 for details.
Operation: if (PR[qp]) {
size = sixteen_byte_form? 16: sz;
if (sixteen_byte_form &&!instruction_implemented(CMP8XCHG16))
illegal_operation_fault();
check_target_register(r1);
if (GR[r3].nat || GR[r2].nat)
register_nat_consumption_fault(SEMAPHORE);
if (!ma_supports_semaphores(mattr))
unsupported_data_reference_fault(SEMAPHORE, GR[r3]);
if (sixteen_byte_form) {
if (sem == ‘acq’)
val = mem_xchg16_cond(AR[CCV], GR[r2], AR[CSD], paddr, UM.be,
mattr, ACQUIRE, ldhint);
else // ‘rel’
val = mem_xchg16_cond(AR[CCV], GR[r2], AR[CSD], paddr, UM.be,
mattr, RELEASE, ldhint);
} else {
if (sem == ‘acq’)
val = mem_xchg_cond(AR[CCV], GR[r2], paddr, size, UM.be, mattr,
ACQUIRE, ldhint);
else // ‘rel’
val = mem_xchg_cond(AR[CCV], GR[r2], paddr, size, UM.be, mattr,
RELEASE, ldhint);
val = zero_ext(val, size * 8);
}
if (AR[CCV] == val)
alat_inval_multiple_entries(paddr, size);
GR[r1] = val;
GR[r1].nat = 0;
}
Description: A new stack frame of zero size is allocated which does not include any registers from the previous
frame (as though all output registers in the previous frame had been locals). The register rename
base registers are reset. If interruption collection is disabled (PSR.ic is zero), then the old value of
the Current Frame Marker (CFM) is copied to the Interruption Function State register (IFS), and
IFS.v is set to one.
A cover instruction must be the last instruction in an instruction group; otherwise, operation is
undefined.
This instruction cannot be predicated.
Operation: if (!followed_by_stop())
undefined_behavior();
alat_frame_update(CFM.sof, 0);
rse_preserve_frame(CFM.sof);
if (PSR.ic == 0) {
CR[IFS].ifm = CFM;
CR[IFS].v = 1;
}
CFM.sof = 0;
CFM.sol = 0;
CFM.sor = 0;
CFM.rrb.gr = 0;
CFM.rrb.fr = 0;
CFM.rrb.pr = 0;
Description: GR r3 is scanned for a zero element. The element is either an 8-bit aligned byte (one_byte_form) or
a 16-bit aligned pair of bytes (two_byte_form). The index of the first zero element is placed in GR
r1. If there are no zero elements in GR r3, a default value is placed in GR r1. Table 2-21 gives the
possible result values. In the left_form, the source is scanned from most significant element to least
significant element, and in the right_form it is scanned from least significant element to most
significant element.
Operation: if (PR[qp]) {
check_target_register(r1);
if (one_byte_form) {
if (left_form) { // scan from most significant down
if ((GR[r3] & 0xff00000000000000) == 0) GR[r1] = 0;
else if ((GR[r3] & 0x00ff000000000000) == 0) GR[r1] = 1;
else if ((GR[r3] & 0x0000ff0000000000) == 0) GR[r1] = 2;
else if ((GR[r3] & 0x000000ff00000000) == 0) GR[r1] = 3;
else if ((GR[r3] & 0x00000000ff000000) == 0) GR[r1] = 4;
else if ((GR[r3] & 0x0000000000ff0000) == 0) GR[r1] = 5;
else if ((GR[r3] & 0x000000000000ff00) == 0) GR[r1] = 6;
else if ((GR[r3] & 0x00000000000000ff) == 0) GR[r1] = 7;
else GR[r1] = 8;
} else { // right_form scan from least significant up
if ((GR[r3] & 0x00000000000000ff) == 0) GR[r1] = 0;
else if ((GR[r3] & 0x000000000000ff00) == 0) GR[r1] = 1;
else if ((GR[r3] & 0x0000000000ff0000) == 0) GR[r1] = 2;
else if ((GR[r3] & 0x00000000ff000000) == 0) GR[r1] = 3;
else if ((GR[r3] & 0x000000ff00000000) == 0) GR[r1] = 4;
else if ((GR[r3] & 0x0000ff0000000000) == 0) GR[r1] = 5;
else if ((GR[r3] & 0x00ff000000000000) == 0) GR[r1] = 6;
else if ((GR[r3] & 0xff00000000000000) == 0) GR[r1] = 7;
else GR[r1] = 8;
}
} else { // two_byte_form
if (left_form) { // scan from most significant down
if ((GR[r3] & 0xffff000000000000) == 0) GR[r1] = 0;
else if ((GR[r3] & 0x0000ffff00000000) == 0) GR[r1] = 1;
else if ((GR[r3] & 0x00000000ffff0000) == 0) GR[r1] = 2;
else if ((GR[r3] & 0x000000000000ffff) == 0) GR[r1] = 3;
else GR[r1] = 4;
} else { // right_form scan from least significant up
if ((GR[r3] & 0x000000000000ffff) == 0) GR[r1] = 0;
else if ((GR[r3] & 0x00000000ffff0000) == 0) GR[r1] = 1;
else if ((GR[r3] & 0x0000ffff00000000) == 0) GR[r1] = 2;
else if ((GR[r3] & 0xffff000000000000) == 0) GR[r1] = 3;
else GR[r1] = 4;
}
}
GR[r1].nat = GR[r3].nat;
}
dep — Deposit
Format: (qp) dep r1 = r2, r3, pos6, len4 merge_form, register_form I15
(qp) dep r1 = imm1, r3, pos6, len6 merge_form, imm_form I14
(qp) dep.z r1 = r2, pos6, len6 zero_form, register_form I12
(qp) dep.z r1 = imm8, pos6, len6 zero_form, imm_form I13
Description: In the merge_form, a right justified bit field taken from the first source operand is deposited into the
value in GR r3 at an arbitrary bit position and the result is placed in GR r1. In the register_form the
first source operand is GR r2; and in the imm_form it is the sign-extended value specified by imm1
(either all ones or all zeroes). The deposited bit field begins at the bit position specified by the pos6
immediate and extends to the left (towards the most significant bit) a number of bits specified by
the len immediate. Note that len has a range of 1-16 in the register_form and 1-64 in the imm_form.
The pos6 immediate has a range of 0 to 63.
In the zero_form, a right justified bit field taken from either the value in GR r2 (in the
register_form) or the sign-extended value in imm8 (in the imm_form) is deposited into GR r1 and
all other bits in GR r1 are cleared to zero. The deposited bit field begins at the bit position specified
by the pos6 immediate and extends to the left (towards the most significant bit) a number of bits
specified by the len immediate. The len immediate has a range of 1-64 and the pos6 immediate has
a range of 0 to 63.
In the event that the deposited bit field extends beyond bit 63 of the target, i.e., len + pos6 > 64, the
most significant len + pos6 - 64 bits of the deposited bit field are truncated. The len immediate is
encoded as len minus 1 in the instruction.
The operation of dep r1 = r2, r3, 36, 16 is illustrated in Figure 2-5.
52 36 0 16 15 0
GR r3: GR r2:
GR r1:
52 36 0
16 15 0
GR r2:
GR r1: 0 0
52 36 0
Operation: if (PR[qp]) {
check_target_register(r1);
if (imm_form) {
tmp_src = (merge_form? sign_ext(imm1,1): sign_ext(imm8, 8));
tmp_nat = merge_form? GR[r3].nat: 0;
tmp_len = len6;
} else { // register_form
tmp_src = GR[r2];
tmp_nat = (merge_form? GR[r3].nat: 0) || GR[r2].nat;
tmp_len = merge_form? len4: len6;
}
if (pos6 + tmp_len u> 64)
tmp_len = 64 - pos6;
if (merge_form)
GR[r1] = GR[r3];
else // zero_form
GR[r1] = 0;
Description: This instruction increases the privilege level. The new privilege level is given by the TLB entry for
the page containing this instruction. This instruction can be used to implement calls to
higher-privileged routines without the overhead of an interruption.
Before increasing the privilege level, a check is performed. The PFS.ppl (previous privilege level)
is checked to ensure that it is not more privileged than the current privilege level. If this check fails,
the instruction takes an Illegal Operation fault.
If the check succeeds, then the privilege is increased as follows:
• If instruction address translation is enabled and the page containing the epc instruction has
execute-only page access rights and the privilege level assigned to the page is higher than
(numerically less than) the current privilege level, then the current privilege level is set to the
privilege level field in the translation for the page containing the epc instruction. This
instruction can promote but cannot demote, and the new privilege comes from the TLB entry.
If instruction address translation is disabled, then the current privilege level is set to 0 (most
privileged).
Instructions after the epc in the same instruction group may be executed at the old privilege
level or the new, higher privilege level. Instructions in subsequent instruction groups will be
executed at the new, higher privilege level.
• If the page containing the epc instruction has any other access rights besides execute-only, or if
the privilege level assigned to the page is lower or equal to (numerically greater than or equal
to) the current privilege level, then no action is taken (the current privilege level is unchanged).
Note that the ITLB is actually only read once, at instruction fetch. Information from the access
rights and privilege level fields from the translation is then used in executing this instruction.
This instruction cannot be predicated.
if (PSR.it)
PSR.cpl = tlb_enter_privileged_code();
else
PSR.cpl = 0;
extr — Extract
Format: (qp) extr r1 = r3, pos6, len6 signed_form I11
(qp) extr.u r1 = r3, pos6, len6 unsigned_form I11
Description: A field is extracted from GR r3, either zero extended or sign extended, and placed right-justified in
GR r1. The field begins at the bit position given by the second operand and extends len6 bits to the
left. The bit position where the field begins is specified by the pos6 immediate. The extracted field
is sign extended in the signed_form or zero extended in the unsigned_form. The sign is taken from
the most significant bit of the extracted field. If the specified field extends beyond the most
significant bit of GR r3, the sign is taken from the most significant bit of GR r3. The immediate
value len6 can be any number in the range 1 to 64, and is encoded as len6-1 in the instruction. The
immediate value pos6 can be any value in the range 0 to 63.
The operation of extr r1 = r3, 7, 50 is illustrated in Figure 2-7.
63 56 7 0
GR r3:
GR r1: Sign
63 49 0
Operation: if (PR[qp]) {
check_target_register(r1);
tmp_len = len6;
if (unsigned_form)
GR[r1] = zero_ext(shift_right_unsigned(GR[r3], pos6), tmp_len);
else // signed_form
GR[r1] = sign_ext(shift_right_unsigned(GR[r3], pos6), tmp_len);
GR[r1].nat = GR[r3].nat;
}
Description: The absolute value of the value in FR f3 is computed and placed in FR f1.
If FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
Description: FR f3 and FR f2 are added (computed to infinite precision), rounded to the precision indicated by pc
(and possibly FPSR.sf.pc and FPSR.sf.wre) using the rounding mode specified by FPSR.sf.rc, and
placed in FR f1. If either FR f3 or FR f2 is a NaTVal, FR f1 is set to NaTVal instead of the computed
result.
The mnemonic values for the opcode’s pc are given in Table 2-22. The mnemonic values for sf are
given in Table 2-23. For the encodings and interpretation of the status field’s pc, wre, and rc, refer
to Table 5-5 and Table 5-6 on page 1:86.
Description: The operand with the larger absolute value is placed in FR f1. If the magnitude of FR f2 equals the
magnitude of FR f3, FR f1 gets FR f3.
If either FR f2 or FR f3 is a NaN, FR f1 gets FR f3.
If either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
This operation does not propagate NaNs the same way as other arithmetic floating-point
instructions. The Invalid Operation is signaled in the same manner as the fcmp.lt operation.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
fminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
tmp_right = fp_reg_read(FR[f2]);
tmp_left = fp_reg_read(FR[f3]);
tmp_right.sign = FP_SIGN_POSITIVE;
tmp_left.sign = FP_SIGN_POSITIVE;
tmp_bool_res = fp_less_than(tmp_left, tmp_right);
FR[f1] = tmp_bool_res? FR[f2]: FR[f3];
fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
}
Description: The operand with the smaller absolute value is placed in FR f1. If the magnitude of FR f2 equals the
magnitude of FR f3, FR f1 gets FR f3.
If either FR f2 or FR f3 is a NaN, FR f1 gets FR f3.
If either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
This operation does not propagate NaNs the same way as other arithmetic floating-point
instructions. The Invalid Operation is signaled in the same manner as the fcmp.lt operation.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
fminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
tmp_left = fp_reg_read(FR[f2]);
tmp_right = fp_reg_read(FR[f3]);
tmp_left.sign = FP_SIGN_POSITIVE;
tmp_right.sign = FP_SIGN_POSITIVE;
tmp_bool_res = fp_less_than(tmp_left, tmp_right);
FR[f1] = tmp_bool_res? FR[f2]: FR[f3];
fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
}
Description: The bit-wise logical AND of the significand fields of FR f2 and FR f3 is computed. The resulting
value is stored in the significand field of FR f1. The exponent field of FR f1 is set to the biased
exponent for 2.063 (0x1003E) and the sign field of FR f1 is set to positive (0).
If either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
FR[f1].significand = FR[f2].significand & FR[f3].significand;
FR[f1].exponent = FP_INTEGER_EXP;
FR[f1].sign = FP_SIGN_POSITIVE;
}
fp_update_psr(f1);
}
FP Exceptions: None
Description: The bit-wise logical AND of the significand field of FR f2 with the bit-wise complemented
significand field of FR f3 is computed. The resulting value is stored in the significand field of FR f1.
The exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the sign field of
FR f1 is set to positive (0).
If either FR f2 or FR f2 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
FR[f1].significand = FR[f2].significand & ~FR[f3].significand;
FR[f1].exponent = FP_INTEGER_EXP;
FR[f1].sign = FP_SIGN_POSITIVE;
}
fp_update_psr(f1);
}
FP Exceptions: None
fc — Flush Cache
Format: (qp) fc r3 invalidate_line_form M28
(qp) fc.i r3 instruction_cache_coherent_form M28
Description: In the invalidate_line form, the cache line associated with the address specified by the value of GR
r3 is invalidated from all levels of the processor cache hierarchy. The invalidation is broadcast
throughout the coherence domain. If, at any level of the cache hierarchy, the line is inconsistent
with memory it is written to memory before invalidation. The line size affected is at least 32-bytes
(aligned on a 32-byte boundary). An implementation may flush a larger region.
In the instruction_cache_coherent form, the cache line specified by GR r3 is flushed in an
implementation-specific manner that ensures that the instruction caches are coherent with the data
caches. The fc.i instruction is not required to invalidate the targeted cache line nor write the targeted
cache line back to memory if it is inconsistent with memory, but may do so if this is required to
make the instruction caches coherent with the data caches. The fc.i instruction is broadcast
throughout the coherence domain if necessary to make all instruction caches coherent. The line size
affected is at least 32-bytes (aligned on a 32-byte boundary). An implementation may flush a larger
region.
When executed at privilege level 0, fc and fc.i perform no access rights or protection key checks. At
other privilege levels, fc and fc.i perform access rights checks as if they were 1-byte reads, but do
not perform any protection key checks (regardless of PSR.pk).
The memory attribute of the page containing the affected line has no effect on the behavior of these
instructions. The fc instruction can be used to remove a range of addresses from the cache by first
changing the memory attribute to non-cacheable and then flushing the range.
These instructions follow data dependency ordering rules; they are ordered only with respect to
previous load, store or semaphore instructions to the same line. fc and fc.i have data dependencies in
the sense that any prior stores by this processor will be included in the flush operation. Subsequent
memory operations to the same line need not wait for prior fc or fc.i completion before being
globally visible. fc and fc.i are unordered operations, and are not affected by a memory fence (mf)
instruction. These instructions are ordered with respect to the sync.i instruction.
Operation: if (PR[qp]) {
itype = NON_ACCESS|FC|READ;
if (GR[r3].nat)
register_nat_consumption_fault(itype);
tmp_paddr = tlb_translate_nonaccess(GR[r3], itype);
if (invalidate_line_form)
mem_flush(tmp_paddr);
else // instruction_cache_coherent_form
make_icache_coherent(tmp_paddr);
}
Description: The flags in FPSR.sf.flags are compared with FPSR.s0.flags and FPSR.traps. If any flags set in
FPSR.sf.flags correspond to FPSR.traps which are enabled, or if any flags set in FPSR.sf.flags are
not set in FPSR.s0.flags, then a branch to target25 is taken.
The target25 operand, specifies a label to branch to. This is encoded in the instruction as a signed
immediate displacement (imm21) between the target bundle and the bundle containing this
instruction (imm21 = target25 - IP >> 4).
The branching behavior of this instruction can be optionally unimplemented. If the instruction
would have branched, and the branching behavior is not implemented, then a Speculative
Operation fault is taken and the value specified by imm21 is zero-extended and placed in the
Interruption Immediate control register (IIM). The fault handler emulates the branch by
sign-extending the IIM value, adding it to IIP and returning.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
Operation: if (PR[qp]) {
switch (sf) {
case ‘s0’:
tmp_flags = AR[FPSR].sf0.flags;
break;
case ‘s1’:
tmp_flags = AR[FPSR].sf1.flags;
break;
case ‘s2’:
tmp_flags = AR[FPSR].sf2.flags;
break;
case ‘s3’:
tmp_flags = AR[FPSR].sf3.flags;
break;
}
if ((tmp_flags & ~AR[FPSR].traps) || (tmp_flags & ~AR[FPSR].sf0.flags)) {
if (check_branch_implemented(FCHKF)) {
taken_branch = 1;
IP = IP + sign_ext((imm21 << 4), 25);
if (!impl_uia_fault_supported() &&
((PSR.it && unimplemented_virtual_address(IP, PSR.vm))
|| (!PSR.it && unimplemented_physical_address(IP)))
unimplemented_instruction_address_trap(0, IP);
if (PSR.tb)
taken_branch_trap();
} else
speculation_fault(FCHKF, zero_ext(imm21, 21));
}
}
FP Exceptions: None
Description: The contents of FR f2 are classified according to the fclass9 completer as shown in Table 2-25. This
produces a boolean result based on whether the contents of FR f2 agrees with the floating-point
number format specified by fclass9, as specified by the fcrel completer. This result is written to the
two predicate register destinations, p1 and p2. The result written to the destinations is determined by
the compare type specified by fctype.
The allowed types are Normal (or none) and unc. See Table 2-26 on page 3:63. The assembly
syntax allows the specification of membership or non-membership and the assembler swaps the
target predicates to achieve the desired effect.
Operation: if (PR[qp]) {
if (p1 == p2)
illegal_operation_fault();
if (tmp_nat) {
PR[p1] = 0;
PR[p2] = 0;
} else {
PR[p1] = tmp_rel;
PR[p2] =!tmp_rel;
}
} else {
if (fctype == ‘unc’) {
if (p1 == p2)
illegal_operation_fault();
PR[p1] = 0;
PR[p2] = 0;
}
}
FP Exceptions: None
Operation: if (PR[qp]) {
fp_set_sf_flags(sf, 0);
}
FP Exceptions: None
Interruptions: None
Description: The two source operands are compared for one of twelve relations specified by frel. This produces
a boolean result which is 1 if the comparison condition is true, and 0 otherwise. This result is
written to the two predicate register destinations, p1 and p2. The way the result is written to the
destinations is determined by the compare type specified by fctype. The allowed types are Normal
(or none) and unc.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
The relations are defined for each of the comparison types in Table 2-27. Of the twelve relations,
not all are directly implemented in hardware. Some are actually pseudo-ops. For these, the
assembler simply switches the source operand specifiers and/or switches the predicate target
specifiers and uses an implemented relation.
Operation: if (PR[qp]) {
if (p1 == p2)
illegal_operation_fault();
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
PR[p1] = 0;
PR[p2] = 0;
} else {
fcmp_exception_fault_check(f2, f3, frel, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
tmp_fr2 = fp_reg_read(FR[f2]);
tmp_fr3 = fp_reg_read(FR[f3]);
PR[p1] = tmp_rel;
PR[p2] =!tmp_rel;
fp_update_fpsr(sf, tmp_fp_env);
}
} else {
if (fctype == ‘unc’) {
if (p1 == p2)
illegal_operation_fault();
PR[p1] = 0;
PR[p2] = 0;
}
}
Description: FR f2 is treated as a register format floating-point value and converted to a signed (signed_form) or
unsigned integer (unsigned_form) using either the rounding mode specified in the FPSR.sf.rc, or
using Round-to-Zero if the trunc_form of the instruction is used. The result is placed in the 64-bit
significand field of FR f1. The exponent field of FR f1 is set to the biased exponent for 2.063
(0x1003E) and the sign field of FR f1 is set to positive (0). If the result of the conversion cannot be
represented as a 64-bit integer, the 64-bit integer indefinite value 0x8000000000000000 is used as
the result, if the IEEE Invalid Operation Floating-point Exception fault is disabled.
If FR f2 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, 0, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2])) {
FR[f1] = NATVAL;
fp_update_psr(f1);
} else {
tmp_default_result = fcvt_exception_fault_check(f2, signed_form,
trunc_form, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
if (fp_is_nan(tmp_default_result)) {
FR[f1].significand = INTEGER_INDEFINITE;
FR[f1].exponent = FP_INTEGER_EXP;
FR[f1].sign = FP_SIGN_POSITIVE;
} else {
tmp_res = fp_ieee_rnd_to_int(fp_reg_read(FR[f2]), &tmp_fp_env);
if (tmp_res.exponent)
tmp_res.significand = fp_U64_rsh(
tmp_res.significand, (FP_INTEGER_EXP - tmp_res.exponent));
if (signed_form && tmp_res.sign)
tmp_res.significand = (~tmp_res.significand) + 1;
FR[f1].significand = tmp_res.significand;
FR[f1].exponent = FP_INTEGER_EXP;
FR[f1].sign = FP_SIGN_POSITIVE;
}
fp_update_fpsr(sf, tmp_fp_env);
fp_update_psr(f1);
if (fp_raise_traps(tmp_fp_env))
fp_exception_trap(fp_decode_trap(tmp_fp_env));
}
}
Description: The 64-bit significand of FR f2 is treated as a signed integer and its register file precision
floating-point representation is placed in FR f1.
If FR f2 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
This operation is always exact and is unaffected by the rounding mode.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, 0, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2])) {
FR[f1] = NATVAL;
} else {
tmp_res = FR[f2];
if (tmp_res.significand{63}) {
tmp_res.significand = (~tmp_res.significand) + 1;
tmp_res.sign = 1;
} else
tmp_res.sign = 0;
tmp_res.exponent = FP_INTEGER_EXP;
tmp_res = fp_normalize(tmp_res);
FR[f1].significand = tmp_res.significand;
FR[f1].exponent = tmp_res.exponent;
FR[f1].sign = tmp_res.sign;
}
fp_update_psr(f1);
}
FP Exceptions: None
Description: FR f3 is multiplied with FR 1, rounded to the precision indicated by pc (and possibly FPSR.sf.pc
and FPSR.sf.wre) using the rounding mode specified by FPSR.sf.rc, and placed in FR f1.
Note: Multiplying FR f3 with FR 1 (a 1.0) normalizes the canonical representation of an integer
in the floating-point register file producing a normal floating-point value.
If FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
The mnemonic values for the opcode’s pc are given in Table 2-22 on page 3:53. The mnemonic
values for sf are given in Table 2-23 on page 3:53. For the encodings and interpretation of the status
field’s pc, wre, and rc, refer to Table 5-5 and Table 5-6 on page 1:86.
Description: A value consisting of four or eight bytes is read from memory starting at the address specified by
the value in GR r3. The value is zero extended and added to the sign-extended immediate value
specified by inc3. The values that may be specified by inc3 are: -16, -8, -4, -1, 1, 4, 8, 16. The least
significant four or eight bytes of the sum are then written to memory starting at the address
specified by the value in GR r3. The zero-extended value read from memory is placed in GR r1 and
the NaT bit corresponding to GR r1 is cleared.
The sem completer specifies the type of semaphore operation. These operations are described in
Table 2-28. See Section 4.4.7, “Sequentiality Attribute and Ordering” on page 2:75 for details on
memory ordering.
The memory read and write are guaranteed to be atomic for accesses to pages with cacheable,
writeback memory attribute. For accesses to other memory types, atomicity is platform dependent.
Details on memory attributes are described in Section 4.4, “Memory Attributes” on page 2:69.
If the address specified by the value in GR r3 is not naturally aligned to the size of the value being
accessed in memory, an Unaligned Data Reference fault is taken independent of the state of the
User Mask alignment checking bit, UM.ac (PSR.ac in the Processor Status Register).
Both read and write access privileges for the referenced page are required. The write access
privilege check is performed whether or not the memory write is performed.
Only accesses to UCE pages or cacheable pages with write-back write policy are permitted.
Accesses to NaTPages result in a Data NaT Page Consumption fault. Accesses to pages with other
memory attributes cause an Unsupported Data Reference fault.
On a processor model that supports exported fetchadd, a fetchadd to a UCE page causes the
fetch-and-add operation to be exported outside of the processor; if the platform does not support
exported fetchadd, the operation is undefined. On a processor model that does not support exported
fetchadd, a fetchadd to a UCE page causes an Unsupported Data Reference fault. See Section 4.4.9,
“Effects of Memory Attributes on Memory Reference Instructions” on page 2:79.
The value of the ldhint completer specifies the locality of the memory access. The values of the
ldhint completer are given in Table 2-34 on page 3:139. Locality hints do not affect program
functionality and may be ignored by the implementation. See Section 4.4.6, “Memory Hierarchy
Control and Consistency” on page 1:64 for details.
Operation: if (PR[qp]) {
check_target_register(r1);
if (GR[r3].nat)
register_nat_consumption_fault(SEMAPHORE);
size = four_byte_form? 4: 8;
if (sem == ‘acq’)
val = mem_xchg_add(inc3, paddr, size, UM.be, mattr, ACQUIRE, ldhint);
else // ‘rel’
val = mem_xchg_add(inc3, paddr, size, UM.be, mattr, RELEASE, ldhint);
alat_inval_multiple_entries(paddr, size);
Description: All stacked general registers in the dirty partition of the register stack are written to the backing
store before execution continues. The dirty partition contains registers from previous procedure
frames that have not yet been saved to the backing store. For a description of the register stack
partitions, refer to Chapter 6, “Register Stack Engine” in Volume 2. A pending external interrupt
can interrupt the RSE store loop when enabled.
After this instruction completes execution BSPSTORE is equal to BSP.
This instruction must be the first instruction in an instruction group and must either be in
instruction slot 0 or in instruction slot 1 of a template having a stop after slot 0; otherwise, the
results are undefined. This instruction cannot be predicated.
Description: The product of FR f3 and FR f4 is computed to infinite precision and then FR f2 is added to this
product, again in infinite precision. The resulting value is then rounded to the precision indicated
by pc (and possibly FPSR.sf.pc and FPSR.sf.wre) using the rounding mode specified by FPSR.sf.rc.
The rounded result is placed in FR f1.
If any of FR f3, FR f4, or FR f2 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
If f2 is f0, an IEEE multiply operation is performed instead of a multiply and add. See “fmpy —
Floating-point Multiply” on page 3:80.
The mnemonic values for the opcode’s pc are given in Table 2-22 on page 3:53. The mnemonic
values for sf are given in Table 2-23 on page 3:53. For the encodings and interpretation of the status
field’s pc, wre, and rc, refer to Table 5-5 and Table 5-6 on page 1:86.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, f4))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) ||
fp_is_natval(FR[f4])) {
FR[f1] = NATVAL;
fp_update_psr(f1);
} else {
tmp_default_result = fma_exception_fault_check(f2, f3, f4,
pc, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
if (fp_is_nan_or_inf(tmp_default_result)) {
FR[f1] = tmp_default_result;
} else {
tmp_res = fp_mul(fp_reg_read(FR[f3]), fp_reg_read(FR[f4]));
if (f2!= 0)
tmp_res = fp_add(tmp_res, fp_reg_read(FR[f2]), tmp_fp_env);
FR[f1] = fp_ieee_round(tmp_res, &tmp_fp_env);
}
fp_update_fpsr(sf, tmp_fp_env);
fp_update_psr(f1);
if (fp_raise_traps(tmp_fp_env))
fp_exception_trap(fp_decode_trap(tmp_fp_env));
}
}
Description: The operand with the larger value is placed in FR f1. If FR f2 equals FR f3, FR f1 gets FR f3.
If either FR f2 or FR f3 is a NaN, FR f1 gets FR f3.
If either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
This operation does not propagate NaNs the same way as other arithmetic floating-point
instructions. The Invalid Operation is signaled in the same manner as the fcmp.lt operation.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
fminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
tmp_bool_res = fp_less_than(fp_reg_read(FR[f3]),
fp_reg_read(FR[f2]));
FR[f1] = (tmp_bool_res? FR[f2]: FR[f3]);
fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
}
Description: Sign, exponent and significand fields are extracted from FR f2 and FR f3, combined, and the result
is placed in FR f1.
For the neg_sign_form, the sign of FR f2 is negated and concatenated with the exponent and the
significand of FR f3. This form can be used to negate a floating-point number by using the same
register for FR f2 and FR f3.
For the sign_form, the sign of FR f2 is concatenated with the exponent and the significand of FR f3.
For the sign_exp_form, the sign and exponent of FR f2 is concatenated with the significand of FR
f3.
For all forms, if either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed
result.
81 80 64 63 0 81 80 64 63 0
FR f2 FR f3
Negated 81 80 64 63 0
Sign Bit FR f1
81 80 64 63 0 81 80 64 63 0
FR f2 FR f3
81 80 64 63 0
FR f1
81 80 64 63 0 81 80 64 63 0
FR f2 FR f3
81 80 64 63 0
FR f1
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
FR[f1].significand = FR[f3].significand;
if (neg_sign_form) {
FR[f1].exponent = FR[f3].exponent;
FR[f1].sign =!FR[f2].sign;
} else if (sign_form) {
FR[f1].exponent = FR[f3].exponent;
FR[f1].sign = FR[f2].sign;
} else { // sign_exp_form
FR[f1].exponent = FR[f2].exponent;
FR[f1].sign = FR[f2].sign;
}
}
fp_update_psr(f1);
}
FP Exceptions: None
Description: The operand with the smaller value is placed in FR f1. If FR f2 equals FR f3, FR f1 gets FR f3.
If either FR f2 or FR f3 is a NaN, FR f1 gets FR f3.
If either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
This operation does not propagate NaNs the same way as other arithmetic floating-point
instructions. The Invalid Operation is signaled in the same manner as the fcmp.lt operation.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
fminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
tmp_bool_res = fp_less_than(fp_reg_read(FR[f2]),
fp_reg_read(FR[f3]));
FR[f1] = tmp_bool_res? FR[f2]: FR[f3];
fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
}
Description: For the mix_l_form (mix_r_form), the left (right) single precision value in FR f2 is concatenated
with the left (right) single precision value in FR f3. For the mix_lr_form, the left single precision
value in FR f2 is concatenated with the right single precision value in FR f3.
For all forms, the exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the
sign field of FR f1 is set to positive (0).
For all forms, if either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed
result.
81 80 64 63 32 31 0 81 80 64 63 32 31 0
FR f2 FR f3
81 80 64 63 32 31 0
FR f1 0 1003E
81 80 64 63 32 31 0 81 80 64 63 32 31 0
FR f2 FR f3
81 80 64 63 32 31 0
FR f1 0 1003E
81 80 64 63 32 31 0 81 80 64 63 32 31 0
FR f2 FR f3
81 80 64 63 32 31 0
FR f1 0 1003E
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
if (mix_l_form) {
tmp_res_hi = FR[f2].significand{63:32};
tmp_res_lo = FR[f3].significand{63:32};
} else if (mix_r_form) {
tmp_res_hi = FR[f2].significand{31:0};
tmp_res_lo = FR[f3].significand{31:0};
} else { // mix_lr_form
tmp_res_hi = FR[f2].significand{63:32};
tmp_res_lo = FR[f3].significand{31:0};
}
FR[f1].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);
FR[f1].exponent = FP_INTEGER_EXP;
FR[f1].sign = FP_SIGN_POSITIVE;
}
fp_update_psr(f1);
}
FP Exceptions: None
Description: The product FR f3 and FR f4 is computed to infinite precision. The resulting value is then rounded
to the precision indicated by pc (and possibly FPSR.sf.pc and FPSR.sf.wre) using the rounding
mode specified by FPSR.sf.rc. The rounded result is placed in FR f1.
If either FR f3 or FR f4 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
The mnemonic values for the opcode’s pc are given in Table 2-22 on page 3:53. The mnemonic
values for sf are given in Table 2-23 on page 3:53. For the encodings and interpretation of the status
field’s pc, wre, and rc, refer to Table 5-5 and Table 5-6 on page 1:86.
Description: The product of FR f3 and FR f4 is computed to infinite precision and then FR f2 is subtracted from
this product, again in infinite precision. The resulting value is then rounded to the precision
indicated by pc (and possibly FPSR.sf.pc and FPSR.sf.wre) using the rounding mode specified by
FPSR.sf.rc. The rounded result is placed in FR f1.
If any of FR f3, FR f4, or FR f2 is a NaTVal, a NaTVal is placed in FR f1 instead of the computed
result.
If f2 is f0, an IEEE multiply operation is performed instead of a multiply and subtract. See “fmpy —
Floating-point Multiply” on page 3:80.
The mnemonic values for the opcode’s pc are given in Table 2-22 on page 3:53. The mnemonic
values for sf are given in Table 2-23 on page 3:53. For the encodings and interpretation of the status
field’s pc, wre, and rc, refer to Table 5-5 and Table 5-6 on page 1:86.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, f4))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) ||
fp_is_natval(FR[f4])) {
FR[f1] = NATVAL;
fp_update_psr(f1);
} else {
tmp_default_result = fms_fnma_exception_fault_check(f2, f3, f4,
pc, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
if (fp_is_nan_or_inf(tmp_default_result)) {
FR[f1] = tmp_default_result;
} else {
tmp_res = fp_mul(fp_reg_read(FR[f3]), fp_reg_read(FR[f4]));
tmp_fr2 = fp_reg_read(FR[f2]);
tmp_fr2.sign =!tmp_fr2.sign;
if (f2!= 0)
tmp_res = fp_add(tmp_res, tmp_fr2, tmp_fp_env);
FR[f1] = fp_ieee_round(tmp_res, &tmp_fp_env);
}
fp_update_fpsr(sf, tmp_fp_env);
fp_update_psr(f1);
if (fp_raise_traps(tmp_fp_env))
fp_exception_trap(fp_decode_trap(tmp_fp_env));
}
}
Description: The absolute value of the value in FR f3 is computed, negated, and placed in FR f1.
If FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
Description: The product of FR f3 and FR f4 is computed to infinite precision, negated, and then FR f2 is added
to this product, again in infinite precision. The resulting value is then rounded to the precision
indicated by pc (and possibly FPSR.sf.pc and FPSR.sf.wre) using the rounding mode specified by
FPSR.sf.rc. The rounded result is placed in FR f1.
If any of FR f3, FR f4, or FR f2 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
If f2 is f0, an IEEE multiply operation is performed, followed by negation of the product. See
“fnmpy — Floating-point Negative Multiply” on page 3:85.
The mnemonic values for the opcode’s pc are given in Table 2-22 on page 3:53. The mnemonic
values for sf are given in Table 2-23 on page 3:53. For the encodings and interpretation of the status
field’s pc, wre, and rc, refer to Table 5-5 and Table 5-6 on page 1:86.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, f4))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) ||
fp_is_natval(FR[f4])) {
FR[f1] = NATVAL;
fp_update_psr(f1);
} else {
tmp_default_result = fms_fnma_exception_fault_check(f2, f3, f4,
pc, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
if (fp_is_nan_or_inf(tmp_default_result)) {
FR[f1] = tmp_default_result;
} else {
tmp_res = fp_mul(fp_reg_read(FR[f3]), fp_reg_read(FR[f4]));
tmp_res.sign =!tmp_res.sign;
if (f2!= 0)
tmp_res = fp_add(tmp_res, fp_reg_read(FR[f2]), tmp_fp_env);
FR[f1] = fp_ieee_round(tmp_res, &tmp_fp_env);
}
fp_update_fpsr(sf, tmp_fp_env);
fp_update_psr(f1);
if (fp_raise_traps(tmp_fp_env))
fp_exception_trap(fp_decode_trap(tmp_fp_env));
}
}
Description: The product FR f3 and FR f4 is computed to infinite precision and then negated. The resulting value
is then rounded to the precision indicated by pc (and possibly FPSR.sf.pc and FPSR.sf.wre) using
the rounding mode specified by FPSR.sf.rc. The rounded result is placed in FR f1.
If either FR f3 or FR f4 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
The mnemonic values for the opcode’s pc are given in Table 2-22 on page 3:53. The mnemonic
values for sf are given in Table 2-23 on page 3:53. For the encodings and interpretation of the status
field’s pc, wre, and rc, refer to Table 5-5 and Table 5-6 on page 1:86.
Description: FR f3 is normalized and rounded to the precision indicated by pc (and possibly FPSR.sf.pc and
FPSR.sf.wre) using the rounding mode specified by FPSR.sf.rc, and placed in FR f1.
If FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
The mnemonic values for the opcode’s pc are given in Table 2-22 on page 3:53. The mnemonic
values for sf are given in Table 2-23 on page 3:53. For the encodings and interpretation of the status
field’s pc, wre, and rc, refer to Table 5-5 and Table 5-6 on page 1:86.
Description: The bit-wise logical OR of the significand fields of FR f2 and FR f3 is computed. The resulting
value is stored in the significand field of FR f1. The exponent field of FR f1 is set to the biased
exponent for 2.063 (0x1003E) and the sign field of FR f1 is set to positive (0).
If either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
FR[f1].significand = FR[f2].significand | FR[f3].significand;
FR[f1].exponent = FP_INTEGER_EXP;
FR[f1].sign = FP_SIGN_POSITIVE;
}
fp_update_psr(f1);
}
FP Exceptions: None
Description: The absolute values of the pair of single precision values in the significand field of FR f3 are
computed and stored in the significand field of FR f1. The exponent field of FR f1 is set to the
biased exponent for 2.063 (0x1003E) and the sign field of FR f1 is set to positive (0).
If FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
Description: The register format numbers in FR f2 and FR f3 are converted to single precision memory format.
These two single precision numbers are concatenated and stored in the significand field of FR f1.
The exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the sign field of
FR f1 is set to positive (0).
If either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
81 80 64 63 0 81 80 64 63 0
FR f2 FR f3
82-bit FR to Single Mem Format Conversions
81 80 64 63 32 31 0
FR f1 0 1003E
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
tmp_res_hi = fp_single(FR[f2]);
tmp_res_lo = fp_single(FR[f3]);
FP Exceptions: None
Description: The paired single precision values in the significands of FR f2 and FR f3 are compared. The
operands with the larger absolute value are returned in the significand field of FR f1.
If the magnitude of high (low) FR f3 is less than the magnitude of high (low) FR f2, high (low) FR
f1 gets high (low) FR f2. Otherwise high (low) FR f1 gets high (low) FR f3.
If high (low) FR f2 or high (low) FR f3 is a NaN, and neither FR f2 or FR f3 is a NaTVal, high (low)
FR f1 gets high (low) FR f3.
The exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the sign field of
FR f1 is set to positive (0).
If either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
This operation does not propagate NaNs the same way as other arithmetic floating-point
instructions. The Invalid Operation is signaled in the same manner as for the fpcmp.lt operation.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
fpminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
}
Description: The paired single precision values in the significands of FR f2 or FR f3 are compared. The operands
with the smaller absolute value is returned in the significand of FR f1.
If the magnitude of high (low) FR f2 is less than the magnitude of high (low) FR f3, high (low) FR
f1 gets high (low) FR f2. Otherwise high (low) FR f1 gets high (low) FR f3.
If high (low) FR f2 or high (low) FR f3 is a NaN, and neither FR f2 or FR f3 is a NaTVal, high (low)
FR f1 gets high (low) FR f3.
The exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the sign field of
FR f1 is set to positive (0).
If either FR f2 or FR f3 is NaTVal, FR f1 is set to NaTVal instead of the computed result.
This operation does not propagate NaNs the same way as other arithmetic floating-point
instructions. The Invalid Operation is signaled in the same manner as for the fpcmp.lt operation.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
fpminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
}
Description: The two pairs of single precision source operands in the significand fields of FR f2 and FR f3 are
compared for one of twelve relations specified by frel. This produces a boolean result which is a
mask of 32 1’s if the comparison condition is true, and a mask of 32 0’s otherwise. This result is
written to a pair of 32-bit integers in the significand field of FR f1. The exponent field of FR f1 is set
to the biased exponent for 2.063 (0x1003E) and the sign field of FR f1 is set to positive (0).
The mnemonic values for sf are given in Table 2-23 on page 3:53.
The relations are defined for each of the comparison types in Table 2-29. Of the twelve relations,
not all are directly implemented in hardware. Some are actually pseudo-ops. For these, the
assembler simply switches the source operand specifiers and/or switches the predicate type
specifiers and uses an implemented relation.
If either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
fpcmp_exception_fault_check(f2, f3, frel, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
tmp_fr2 = fp_reg_read_hi(f2);
tmp_fr3 = fp_reg_read_hi(f3);
tmp_fr2 = fp_reg_read_lo(f2);
tmp_fr3 = fp_reg_read_lo(f3);
fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
}
Description: The pair of single precision values in the significand field of FR f2 is converted to a pair of 32-bit
signed integers (signed_form) or unsigned integers (unsigned_form) using either the rounding
mode specified in the FPSR.sf.rc, or using Round-to-Zero if the trunc_form of the instruction is
used. The result is written as a pair of 32-bit integers into the significand field of FR f1. The
exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the sign field of FR f1
is set to positive (0). If the result of the conversion cannot be represented as a 32-bit integer, the
32-bit integer indefinite value 0x80000000 is used as the result, if the IEEE Invalid Operation
Floating-point Exception fault is disabled.
If FR f2 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, 0, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2])) {
FR[f1] = NATVAL;
fp_update_psr(f1);
} else {
tmp_default_result_pair = fpcvt_exception_fault_check(f2,
signed_form, trunc_form, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
if (fp_is_nan(tmp_default_result_pair.hi)) {
tmp_res_hi = INTEGER_INDEFINITE_32_BIT;
} else {
tmp_res = fp_ieee_rnd_to_int_sp(fp_reg_read_hi(f2), HIGH,
&tmp_fp_env);
if (tmp_res.exponent)
tmp_res.significand = fp_U64_rsh(
tmp_res.significand, (FP_INTEGER_EXP - tmp_res.exponent));
if (signed_form && tmp_res.sign)
tmp_res.significand = (~tmp_res.significand) + 1;
tmp_res_hi = tmp_res.significand{31:0};
}
if (fp_is_nan(tmp_default_result_pair.lo)) {
tmp_res_lo = INTEGER_INDEFINITE_32_BIT;
} else {
tmp_res = fp_ieee_rnd_to_int_sp(fp_reg_read_lo(f2), LOW,
&tmp_fp_env);
if (tmp_res.exponent)
tmp_res.significand = fp_U64_rsh(
tmp_res.significand, (FP_INTEGER_EXP - tmp_res.exponent));
if (signed_form && tmp_res.sign)
tmp_res.significand = (~tmp_res.significand) + 1;
tmp_res_lo = tmp_res.significand{31:0};
}
fp_update_fpsr(sf, tmp_fp_env);
fp_update_psr(f1);
if (fp_raise_traps(tmp_fp_env))
fp_exception_trap(fp_decode_trap(tmp_fp_env));
}
}
Description: The pair of products of the pairs of single precision values in the significand fields of FR f3 and FR
f4 are computed to infinite precision and then the pair of single precision values in the significand
field of FR f2 is added to these products, again in infinite precision. The resulting values are then
rounded to single precision using the rounding mode specified by FPSR.sf.rc. The pair of rounded
results are stored in the significand field of FR f1. The exponent field of FR f1 is set to the biased
exponent for 2.063 (0x1003E) and the sign field of FR f1 is set to positive (0).
If any of FR f3, FR f4, or FR f2 is a NaTVal, FR f1 is set to NaTVal instead of the computed results.
Note: If f2 is f0 in the fpma instruction, just the IEEE multiply operation is performed. (See
“fpmpy — Floating-point Parallel Multiply” on page 3:104.) FR f1, as an operand, is not a
packed pair of 1.0 values, it is just the register file format’s 1.0 value.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
The encodings and interpretation for the status field’s rc are given in Table 5-6 on page 1:86.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, f4))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) ||
fp_is_natval(FR[f4])) {
FR[f1] = NATVAL;
fp_update_psr(f1);
} else {
tmp_default_result_pair = fpma_exception_fault_check(f2,
f3, f4, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
if (fp_is_nan_or_inf(tmp_default_result_pair.hi)) {
tmp_res_hi = fp_single(tmp_default_result_pair.hi);
} else {
tmp_res = fp_mul(fp_reg_read_hi(f3), fp_reg_read_hi(f4));
if (f2!= 0)
tmp_res = fp_add(tmp_res, fp_reg_read_hi(f2), tmp_fp_env);
tmp_res_hi = fp_ieee_round_sp(tmp_res, HIGH, &tmp_fp_env);
}
if (fp_is_nan_or_inf(tmp_default_result_pair.lo)) {
tmp_res_lo = fp_single(tmp_default_result_pair.lo);
} else {
tmp_res = fp_mul(fp_reg_read_lo(f3), fp_reg_read_lo(f4));
if (f2!= 0)
tmp_res = fp_add(tmp_res, fp_reg_read_lo(f2), tmp_fp_env);
tmp_res_lo = fp_ieee_round_sp(tmp_res, LOW, &tmp_fp_env);
}
fp_update_fpsr(sf, tmp_fp_env);
fp_update_psr(f1);
if (fp_raise_traps(tmp_fp_env))
fp_exception_trap(fp_decode_trap(tmp_fp_env));
}
}
Description: The paired single precision values in the significands of FR f2 or FR f3 are compared. The operands
with the larger value is returned in the significand of FR f1.
If the value of high (low) FR f3 is less than the value of high (low) FR f2, high (low) FR f1 gets high
(low) FR f2. Otherwise high (low) FR f1 gets high (low) FR f3.
If high (low) FR f2 or high (low) FR f3 is a NaN, high (low) FR f1 gets high (low) FR f3.
The exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the sign field of
FR f1 is set to positive (0).
If either FR f2 or FR f3 is NaTVal, FR f1 is set to NaTVal instead of the computed result.
This operation does not propagate NaNs the same way as other arithmetic floating-point
instructions. The Invalid Operation is signaled in the same manner as for the fpcmp.lt operation.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
fpminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
}
Description: For the neg_sign_form, the signs of the pair of single precision values in the significand field of FR
f2 are negated and concatenated with the exponents and the significands of the pair of single
precision values in the significand field of FR f3 and stored in the significand field of FR f1. This
form can be used to negate a pair of single precision floating-point numbers by using the same
register for f2 and f3.
For the sign_form, the signs of the pair of single precision values in the significand field of FR f2
are concatenated with the exponents and the significands of the pair of single precision values in
the significand field of FR f3 and stored in FR f1.
For the sign_exp_form, the signs and exponents of the pair of single precision values in the
significand field of FR f2 are concatenated with the pair of single precision significands in the
significand field of FR f3 and stored in the significand field of FR f1.
For all forms, the exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the
sign field of FR f1 is set to positive (0).
For all forms, if either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed
result.
81 80 64 63 62 32 31 30 0 81 80 64 63 62 32 31 30 0
FR f2 FR f3
Negated
Sign Bits
81 80 64 63 62 32 31 30 0
FR f1 0 1003E
81 80 64 63 62 32 31 30 0 81 80 64 63 62 32 31 30 0
FR f2 FR f3
81 80 64 63 62 32 31 30 0
FR f1 0 1003E
81 80 64 63 55 54 32 31 23 22 0 81 80 64 63 55 54 32 31 23 22 0
FR f2 FR f3
81 80 64 63 55 54 32 31 23 22 0
FR f1 0 1003E
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
if (neg_sign_form) {
tmp_res_hi = (!FR[f2].significand{63} << 31)
| (FR[f3].significand{62:32});
tmp_res_lo = (!FR[f2].significand{31} << 31)
| (FR[f3].significand{30:0});
} else if (sign_form) {
tmp_res_hi = (FR[f2].significand{63} << 31)
| (FR[f3].significand{62:32});
tmp_res_lo = (FR[f2].significand{31} << 31)
| (FR[f3].significand{30:0});
} else { // sign_exp_form
tmp_res_hi = (FR[f2].significand{63:55} << 23)
| (FR[f3].significand{54:32});
tmp_res_lo = (FR[f2].significand{31:23} << 23)
| (FR[f3].significand{22:0});
}
fp_update_psr(f1);
}
FP Exceptions: None
Description: The paired single precision values in the significands of FR f2 or FR f3 are compared. The operands
with the smaller value is returned in significand of FR f1.
If the value of high (low) FR f2 is less than the value of high (low) FR f3, high (low) FR f1 gets high
(low) FR f2. Otherwise high (low) FR f1 gets high (low) FR f3.
If high (low) FR f2 or high (low) FR f3 is a NaN, high (low) FR f1 gets high (low) FR f3.
The exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the sign field of
FR f1 is set to positive (0).
If either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
This operation does not propagate NaNs the same way as other arithmetic floating-point
instructions. The Invalid Operation is signaled in the same manner as for the fpcmp.lt operation.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
fpminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
}
Description: The pair of products of the pairs of single precision values in the significand fields of FR f3 and FR
f4 are computed to infinite precision. The resulting values are then rounded to single precision
using the rounding mode specified by FPSR.sf.rc. The pair of rounded results are stored in the
significand field of FR f1. The exponent field of FR f1 is set to the biased exponent for 2.063
(0x1003E) and the sign field of FR f1 is set to positive (0).
If either FR f3, or FR f4 is a NaTVal, FR f1 is set to NaTVal instead of the computed results.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
The encodings and interpretation for the status field’s rc are given in Table 5-6 on page 1:86.
Description: The pair of products of the pairs of single precision values in the significand fields of FR f3 and FR
f4 are computed to infinite precision and then the pair of single precision values in the significand
field of FR f2 is subtracted from these products, again in infinite precision. The resulting values are
then rounded to single precision using the rounding mode specified by FPSR.sf.rc. The pair of
rounded results are stored in the significand field of FR f1. The exponent field of FR f1 is set to the
biased exponent for 2.063 (0x1003E) and the sign field of FR f1 is set to positive (0).
Note: If any of FR f3, FR f4, or FR f2 is a NaTVal, FR f1 is set to NaTVal instead of the computed
results.
Mapping: If f2 is f0 in the fpms instruction, just the IEEE multiply operation is performed.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
The encodings and interpretation for the status field’s rc are given in Table 5-6 on page 1:86.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, f4))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) ||
fp_is_natval(FR[f4])) {
FR[f1] = NATVAL;
fp_update_psr(f1);
} else {
tmp_default_result_pair = fpms_fpnma_exception_fault_check(f2, f3,
f4, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
if (fp_is_nan_or_inf(tmp_default_result_pair.hi)) {
tmp_res_hi = fp_single(tmp_default_result_pair.hi);
} else {
tmp_res = fp_mul(fp_reg_read_hi(f3), fp_reg_read_hi(f4));
if (f2!= 0) {
tmp_sub = fp_reg_read_hi(f2);
tmp_sub.sign =!tmp_sub.sign;
tmp_res = fp_add(tmp_res, tmp_sub, tmp_fp_env);
}
tmp_res_hi = fp_ieee_round_sp(tmp_res, HIGH, &tmp_fp_env);
}
if (fp_is_nan_or_inf(tmp_default_result_pair.lo)) {
tmp_res_lo = fp_single(tmp_default_result_pair.lo);
} else {
tmp_res = fp_mul(fp_reg_read_lo(f3), fp_reg_read_lo(f4));
if (f2!= 0) {
tmp_sub = fp_reg_read_lo(f2);
tmp_sub.sign =!tmp_sub.sign;
tmp_res = fp_add(tmp_res, tmp_sub, tmp_fp_env);
}
tmp_res_lo = fp_ieee_round_sp(tmp_res, LOW, &tmp_fp_env);
}
FR[f1].sign = FP_SIGN_POSITIVE;
fp_update_fpsr(sf, tmp_fp_env);
fp_update_psr(f1);
if (fp_raise_traps(tmp_fp_env))
fp_exception_trap(fp_decode_trap(tmp_fp_env));
}
}
Description: The pair of single precision values in the significand field of FR f3 are negated and stored in the
significand field of FR f1. The exponent field of FR f1 is set to the biased exponent for 2.063
(0x1003E) and the sign field of FR f1 is set to positive (0).
If FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
Description: The absolute values of the pair of single precision values in the significand field of FR f3 are
computed, negated and stored in the significand field of FR f1. The exponent field of FR f1 is set to
the biased exponent for 2.063 (0x1003E) and the sign field of FR f1 is set to positive (0).
If FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
Description: The pair of products of the pairs of single precision values in the significand fields of FR f3 and FR
f4 are computed to infinite precision, negated, and then the pair of single precision values in the
significand field of FR f2 are added to these (negated) products, again in infinite precision. The
resulting values are then rounded to single precision using the rounding mode specified by
FPSR.sf.rc. The pair of rounded results are stored in the significand field of FR f1. The exponent
field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the sign field of FR f1 is set to
positive (0).
If any of FR f3, FR f4, or FR f2 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
Note: If f2 is f0 in the fpnma instruction, just the IEEE multiply operation (with the product
being negated before rounding) is performed.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
The encodings and interpretation for the status field’s rc are given in Table 5-6 on page 1:86.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, f4))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) ||
fp_is_natval(FR[f4])) {
FR[f1] = NATVAL;
fp_update_psr(f1);
} else {
tmp_default_result_pair = fpms_fpnma_exception_fault_check(f2, f3,
f4, sf, &tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
if (fp_is_nan_or_inf(tmp_default_result_pair.hi)) {
tmp_res_hi = fp_single(tmp_default_result_pair.hi);
} else {
tmp_res = fp_mul(fp_reg_read_hi(f3), fp_reg_read_hi(f4));
tmp_res.sign =!tmp_res.sign;
if (f2!= 0)
tmp_res = fp_add(tmp_res, fp_reg_read_hi(f2), tmp_fp_env);
tmp_res_hi = fp_ieee_round_sp(tmp_res, HIGH, &tmp_fp_env);
}
if (fp_is_nan_or_inf(tmp_default_result_pair.lo)) {
tmp_res_lo = fp_single(tmp_default_result_pair.lo);
} else {
tmp_res = fp_mul(fp_reg_read_lo(f3), fp_reg_read_lo(f4));
tmp_res.sign =!tmp_res.sign;
if (f2!= 0)
tmp_res = fp_add(tmp_res, fp_reg_read_lo(f2), tmp_fp_env);
tmp_res_lo = fp_ieee_round_sp(tmp_res, LOW, &tmp_fp_env);
}
fp_update_fpsr(sf, tmp_fp_env);
fp_update_psr(f1);
if (fp_raise_traps(tmp_fp_env))
fp_exception_trap(fp_decode_trap(tmp_fp_env));
}
}
Description: The pair of products of the pairs of single precision values in the significand fields of FR f3 and FR
f4 are computed to infinite precision and then negated. The resulting values are then rounded to
single precision using the rounding mode specified by FPSR.sf.rc. The pair of rounded results are
stored in the significand field of FR f1. The exponent field of FR f1 is set to the biased exponent for
2.063 (0x1003E) and the sign field of FR f1 is set to positive (0).
If either FR f3 or FR f4 is a NaTVal, FR f1 is set to NaTVal instead of the computed results.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
The encodings and interpretation for the status field’s rc are given in Table 5-6 on page 1:86.
Operation: See “fpnma — Floating-point Parallel Negative Multiply Add” on page 3:109.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
PR[p2] = 0;
} else {
tmp_default_result_pair = fprcpa_exception_fault_check(f2, f3, sf,
&tmp_fp_env, &limits_check);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
if (fp_is_nan_or_inf(tmp_default_result_pair.hi) ||
limits_check.hi_fr3) {
tmp_res_hi = fp_single(tmp_default_result_pair.hi);
tmp_pred_hi = 0;
} else {
num = fp_normalize(fp_reg_read_hi(f2));
den = fp_normalize(fp_reg_read_hi(f3));
if (fp_is_inf(num) && fp_is_finite(den)) {
tmp_res = FP_INFINITY;
tmp_res.sign = num.sign ^ den.sign;
tmp_pred_hi = 0;
} else if (fp_is_finite(num) && fp_is_inf(den)) {
tmp_res = FP_ZERO;
tmp_res.sign = num.sign ^ den.sign;
tmp_pred_hi = 0;
} else if (fp_is_zero(num) && fp_is_finite(den)) {
tmp_res = FP_ZERO;
tmp_res.sign = num.sign ^ den.sign;
tmp_pred_hi = 0;
} else {
tmp_res = fp_ieee_recip(den);
if (limits_check.hi_fr2_or_quot)
tmp_pred_hi = 0;
else
tmp_pred_hi = 1;
}
tmp_res_hi = fp_single(tmp_res);
}
if (fp_is_nan_or_inf(tmp_default_result_pair.lo) ||
limits_check.lo_fr3) {
tmp_res_lo = fp_single(tmp_default_result_pair.lo);
tmp_pred_lo = 0;
} else {
num = fp_normalize(fp_reg_read_lo(f2));
den = fp_normalize(fp_reg_read_lo(f3));
if (fp_is_inf(num) && fp_is_finite(den)) {
tmp_res = FP_INFINITY;
tmp_res.sign = num.sign ^ den.sign;
tmp_pred_lo = 0;
} else if (fp_is_finite(num) && fp_is_inf(den)) {
tmp_res = FP_ZERO;
tmp_res.sign = num.sign ^ den.sign;
tmp_pred_lo = 0;
} else if (fp_is_zero(num) && fp_is_finite(den)) {
tmp_res = FP_ZERO;
tmp_res.sign = num.sign ^ den.sign;
tmp_pred_lo = 0;
} else {
tmp_res = fp_ieee_recip(den);
if (limits_check.lo_fr2_or_quot)
tmp_pred_lo = 0;
else
tmp_pred_lo = 1;
}
tmp_res_lo = fp_single(tmp_res);
}
fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
} else {
PR[p2] = 0;
}
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f3, 0, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
PR[p2] = 0;
} else {
tmp_default_result_pair = fprsqrta_exception_fault_check(f3, sf,
&tmp_fp_env, &limits_check);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
if (fp_is_nan(tmp_default_result_pair.hi)) {
tmp_res_hi = fp_single(tmp_default_result_pair.hi);
tmp_pred_hi = 0;
} else {
tmp_fr3 = fp_normalize(fp_reg_read_hi(f3));
if (fp_is_zero(tmp_fr3)) {
tmp_res = FP_INFINITY;
tmp_res.sign = tmp_fr3.sign;
tmp_pred_hi = 0;
} else if (fp_is_pos_inf(tmp_fr3)) {
tmp_res = FP_ZERO;
tmp_pred_hi = 0;
} else {
tmp_res = fp_ieee_recip_sqrt(tmp_fr3);
if (limits_check.hi)
tmp_pred_hi = 0;
else
tmp_pred_hi = 1;
}
tmp_res_hi = fp_single(tmp_res);
}
if (fp_is_nan(tmp_default_result_pair.lo)) {
tmp_res_lo = fp_single(tmp_default_result_pair.lo);
tmp_pred_lo = 0;
} else {
tmp_fr3 = fp_normalize(fp_reg_read_lo(f3));
if (fp_is_zero(tmp_fr3)) {
tmp_res = FP_INFINITY;
tmp_res.sign = tmp_fr3.sign;
tmp_pred_lo = 0;
} else if (fp_is_pos_inf(tmp_fr3)) {
tmp_res = FP_ZERO;
tmp_pred_lo = 0;
} else {
tmp_res = fp_ieee_recip_sqrt(tmp_fr3);
if (limits_check.lo)
tmp_pred_lo = 0;
else
tmp_pred_lo = 1;
}
tmp_res_lo = fp_single(tmp_res);
}
fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
} else {
PR[p2] = 0;
}
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
PR[p2] = 0;
} else {
tmp_default_result = frcpa_exception_fault_check(f2, f3, sf,
&tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
if (fp_is_nan_or_inf(tmp_default_result)) {
FR[f1] = tmp_default_result;
PR[p2] = 0;
} else {
num = fp_normalize(fp_reg_read(FR[f2]));
den = fp_normalize(fp_reg_read(FR[f3]));
if (fp_is_inf(num) && fp_is_finite(den)) {
FR[f1] = FP_INFINITY;
FR[f1].sign = num.sign ^ den.sign;
PR[p2] = 0;
} else if (fp_is_finite(num) && fp_is_inf(den)) {
FR[f1] = FP_ZERO;
FR[f1].sign = num.sign ^ den.sign;
PR[p2] = 0;
} else if (fp_is_zero(num) && fp_is_finite(den)) {
FR[f1] = FP_ZERO;
FR[f1].sign = num.sign ^ den.sign;
PR[p2] = 0;
} else {
FR[f1] = fp_ieee_recip(den);
PR[p2] = 1;
}
}
fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
} else {
PR[p2] = 0;
}
// fp_ieee_recip()
fp_ieee_recip(den)
{
RECIP_TABLE[256] = {
0x3fc, 0x3f4, 0x3ec, 0x3e4, 0x3dd, 0x3d5, 0x3cd, 0x3c6,
0x3be, 0x3b7, 0x3af, 0x3a8, 0x3a1, 0x399, 0x392, 0x38b,
0x384, 0x37d, 0x376, 0x36f, 0x368, 0x361, 0x35b, 0x354,
0x34d, 0x346, 0x340, 0x339, 0x333, 0x32c, 0x326, 0x320,
0x319, 0x313, 0x30d, 0x307, 0x300, 0x2fa, 0x2f4, 0x2ee,
0x2e8, 0x2e2, 0x2dc, 0x2d7, 0x2d1, 0x2cb, 0x2c5, 0x2bf,
0x2ba, 0x2b4, 0x2af, 0x2a9, 0x2a3, 0x29e, 0x299, 0x293,
0x28e, 0x288, 0x283, 0x27e, 0x279, 0x273, 0x26e, 0x269,
0x264, 0x25f, 0x25a, 0x255, 0x250, 0x24b, 0x246, 0x241,
0x23c, 0x237, 0x232, 0x22e, 0x229, 0x224, 0x21f, 0x21b,
0x216, 0x211, 0x20d, 0x208, 0x204, 0x1ff, 0x1fb, 0x1f6,
0x1f2, 0x1ed, 0x1e9, 0x1e5, 0x1e0, 0x1dc, 0x1d8, 0x1d4,
0x1cf, 0x1cb, 0x1c7, 0x1c3, 0x1bf, 0x1bb, 0x1b6, 0x1b2,
0x1ae, 0x1aa, 0x1a6, 0x1a2, 0x19e, 0x19a, 0x197, 0x193,
0x18f, 0x18b, 0x187, 0x183, 0x17f, 0x17c, 0x178, 0x174,
0x171, 0x16d, 0x169, 0x166, 0x162, 0x15e, 0x15b, 0x157,
0x154, 0x150, 0x14d, 0x149, 0x146, 0x142, 0x13f, 0x13b,
0x138, 0x134, 0x131, 0x12e, 0x12a, 0x127, 0x124, 0x120,
0x11d, 0x11a, 0x117, 0x113, 0x110, 0x10d, 0x10a, 0x107,
0x103, 0x100, 0x0fd, 0x0fa, 0x0f7, 0x0f4, 0x0f1, 0x0ee,
0x0eb, 0x0e8, 0x0e5, 0x0e2, 0x0df, 0x0dc, 0x0d9, 0x0d6,
0x0d3, 0x0d0, 0x0cd, 0x0ca, 0x0c8, 0x0c5, 0x0c2, 0x0bf,
0x0bc, 0x0b9, 0x0b7, 0x0b4, 0x0b1, 0x0ae, 0x0ac, 0x0a9,
0x0a6, 0x0a4, 0x0a1, 0x09e, 0x09c, 0x099, 0x096, 0x094,
0x091, 0x08e, 0x08c, 0x089, 0x087, 0x084, 0x082, 0x07f,
0x07c, 0x07a, 0x077, 0x075, 0x073, 0x070, 0x06e, 0x06b,
0x069, 0x066, 0x064, 0x061, 0x05f, 0x05d, 0x05a, 0x058,
0x056, 0x053, 0x051, 0x04f, 0x04c, 0x04a, 0x048, 0x045,
0x043, 0x041, 0x03f, 0x03c, 0x03a, 0x038, 0x036, 0x033,
0x031, 0x02f, 0x02d, 0x02b, 0x029, 0x026, 0x024, 0x022,
0x020, 0x01e, 0x01c, 0x01a, 0x018, 0x015, 0x013, 0x011,
0x00f, 0x00d, 0x00b, 0x009, 0x007, 0x005, 0x003, 0x001,
};
tmp_index = den.significand{62:55};
tmp_res.significand = (1 << 63) | (RECIP_TABLE[tmp_index] << 53);
tmp_res.exponent = FP_REG_EXP_ONES - 2 - den.exponent;
tmp_res.sign = den.sign;
return (tmp_res);
}
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f3, 0, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
PR[p2] = 0;
} else {
tmp_default_result = frsqrta_exception_fault_check(f3, sf,
&tmp_fp_env);
if (fp_raise_fault(tmp_fp_env))
fp_exception_fault(fp_decode_fault(tmp_fp_env));
if (fp_is_nan(tmp_default_result)) {
FR[f1] = tmp_default_result;
PR[p2] = 0;
} else {
tmp_fr3 = fp_normalize(fp_reg_read(FR[f3]));
if (fp_is_zero(tmp_fr3)) {
FR[f1] = tmp_fr3;
PR[p2] = 0;
} else if (fp_is_pos_inf(tmp_fr3)) {
FR[f1] = tmp_fr3;
PR[p2] = 0;
} else {
FR[f1] = fp_ieee_recip_sqrt(tmp_fr3);
PR[p2] = 1;
}
}
fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
} else {
PR[p2] = 0;
// fp_ieee_recip_sqrt()
fp_ieee_recip_sqrt(root)
{
RECIP_SQRT_TABLE[256] = {
0x1a5, 0x1a0, 0x19a, 0x195, 0x18f, 0x18a, 0x185, 0x180,
0x17a, 0x175, 0x170, 0x16b, 0x166, 0x161, 0x15d, 0x158,
0x153, 0x14e, 0x14a, 0x145, 0x140, 0x13c, 0x138, 0x133,
0x12f, 0x12a, 0x126, 0x122, 0x11e, 0x11a, 0x115, 0x111,
0x10d, 0x109, 0x105, 0x101, 0x0fd, 0x0fa, 0x0f6, 0x0f2,
0x0ee, 0x0ea, 0x0e7, 0x0e3, 0x0df, 0x0dc, 0x0d8, 0x0d5,
0x0d1, 0x0ce, 0x0ca, 0x0c7, 0x0c3, 0x0c0, 0x0bd, 0x0b9,
0x0b6, 0x0b3, 0x0b0, 0x0ad, 0x0a9, 0x0a6, 0x0a3, 0x0a0,
0x09d, 0x09a, 0x097, 0x094, 0x091, 0x08e, 0x08b, 0x088,
0x085, 0x082, 0x07f, 0x07d, 0x07a, 0x077, 0x074, 0x071,
0x06f, 0x06c, 0x069, 0x067, 0x064, 0x061, 0x05f, 0x05c,
0x05a, 0x057, 0x054, 0x052, 0x04f, 0x04d, 0x04a, 0x048,
0x045, 0x043, 0x041, 0x03e, 0x03c, 0x03a, 0x037, 0x035,
0x033, 0x030, 0x02e, 0x02c, 0x029, 0x027, 0x025, 0x023,
0x020, 0x01e, 0x01c, 0x01a, 0x018, 0x016, 0x014, 0x011,
0x00f, 0x00d, 0x00b, 0x009, 0x007, 0x005, 0x003, 0x001,
0x3fc, 0x3f4, 0x3ec, 0x3e5, 0x3dd, 0x3d5, 0x3ce, 0x3c7,
0x3bf, 0x3b8, 0x3b1, 0x3aa, 0x3a3, 0x39c, 0x395, 0x38e,
0x388, 0x381, 0x37a, 0x374, 0x36d, 0x367, 0x361, 0x35a,
0x354, 0x34e, 0x348, 0x342, 0x33c, 0x336, 0x330, 0x32b,
0x325, 0x31f, 0x31a, 0x314, 0x30f, 0x309, 0x304, 0x2fe,
0x2f9, 0x2f4, 0x2ee, 0x2e9, 0x2e4, 0x2df, 0x2da, 0x2d5,
0x2d0, 0x2cb, 0x2c6, 0x2c1, 0x2bd, 0x2b8, 0x2b3, 0x2ae,
0x2aa, 0x2a5, 0x2a1, 0x29c, 0x298, 0x293, 0x28f, 0x28a,
0x286, 0x282, 0x27d, 0x279, 0x275, 0x271, 0x26d, 0x268,
0x264, 0x260, 0x25c, 0x258, 0x254, 0x250, 0x24c, 0x249,
0x245, 0x241, 0x23d, 0x239, 0x235, 0x232, 0x22e, 0x22a,
0x227, 0x223, 0x220, 0x21c, 0x218, 0x215, 0x211, 0x20e,
0x20a, 0x207, 0x204, 0x200, 0x1fd, 0x1f9, 0x1f6, 0x1f3,
0x1f0, 0x1ec, 0x1e9, 0x1e6, 0x1e3, 0x1df, 0x1dc, 0x1d9,
0x1d6, 0x1d3, 0x1d0, 0x1cd, 0x1ca, 0x1c7, 0x1c4, 0x1c1,
0x1be, 0x1bb, 0x1b8, 0x1b5, 0x1b2, 0x1af, 0x1ac, 0x1aa,
};
Description: The significand field of FR f3 is logically AND-ed with the significand field of FR f2 and the
significand field of FR f4 is logically AND-ed with the one’s complement of the significand field of
FR f2. The two results are logically OR-ed together. The result is placed in the significand field of
FR f1.
The exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E). The sign bit field of
FR f1 is set to positive (0).
If any of FR f3, FR f4, or FR f2 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, f4))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) ||
fp_is_natval(FR[f4])) {
FR[f1] = NATVAL;
} else {
FR[f1].significand = (FR[f3].significand & FR[f2].significand)
| (FR[f4].significand & ~FR[f2].significand);
FR[f1].exponent = FP_INTEGER_EXP;
FR[f1].sign = FP_SIGN_POSITIVE;
}
fp_update_psr(f1);
}
FP Exceptions: None
Description: The status field’s control bits are initialized to the value obtained by logically AND-ing the
sf0.controls and amask7 immediate field and logically OR-ing the omask7 immediate field.
The mnemonic values for sf are given in Table 2-23 on page 3:53.
Operation: if (PR[qp]) {
tmp_controls = (AR[FPSR].sf0.controls & amask7) | omask7;
if (is_reserved_field(FSETC, sf, tmp_controls))
reserved_register_field_fault();
fp_set_sf_controls(sf, tmp_controls);
}
FP Exceptions: None
Description: FR f2 is subtracted from FR f3 (computed to infinite precision), rounded to the precision indicated
by pc (and possibly FPSR.sf.pc and FPSR.sf.wre) using the rounding mode specified by FPSR.sf.rc,
and placed in FR f1.
If either FR f3 or FR f2 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
The mnemonic values for the opcode’s pc are given in Table 2-22 on page 3:53. The mnemonic
values for sf are given in Table 2-23 on page 3:53. For the encodings and interpretation of the status
field’s pc, wre, and rc, refer to Table 5-5 and Table 5-6 on page 1:86.
Description: For the swap_form, the left single precision value in FR f2 is concatenated with the right single
precision value in FR f3. The concatenated pair is then swapped.
For the swap_nl_form, the left single precision value in FR f2 is concatenated with the right single
precision value in FR f3. The concatenated pair is then swapped, and the left single precision value
is negated.
For the swap_nr_form, the left single precision value in FR f2 is concatenated with the right single
precision value in FR f3. The concatenated pair is then swapped, and the right single precision value
is negated.
For all forms, the exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the
sign field of FR f1 is set to positive (0).
For all forms, if either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed
result.
81 80 64 63 32 31 0 81 80 64 63 32 31 0
FR f2 FR f3
81 80 64 63 32 31 0
FR f1 0 1003E
81 80 64 63 32 31 0 81 80 64 63 32 31 30 0
FR f2 FR f3
Negated Sign Bit
81 80 64 63 62 32 31 0
FR f1 0 1003E
81 80 64 63 62 32 31 0 81 80 64 63 32 31 0
FR f2 FR f3
81 80 64 63 32 31 30 0
FR f1 0 1003E
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
if (swap_form) {
tmp_res_hi = FR[f3].significand{31:0};
tmp_res_lo = FR[f2].significand{63:32};
} else if (swap_nl_form) {
tmp_res_hi = (!FR[f3].significand{31} << 31)
| (FR[f3].significand{30:0});
tmp_res_lo = FR[f2].significand{63:32};
} else { // swap_nr_form
tmp_res_hi = FR[f3].significand{31:0};
tmp_res_lo = (!FR[f2].significand{63} << 31)
| (FR[f2].significand{62:32});
}
fp_update_psr(f1);
}
FP Exceptions: None
Description: For the sxt_l_form (sxt_r_form), the sign of the left (right) single precision value in FR f2 is
extended to 32-bits and is concatenated with the left (right) single precision value in FR f3.
For all forms, the exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the
sign field of FR f1 is set to positive (0).
For all forms, if either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed
result.
81 80 64 63 62 32 31 0 81 80 64 63 32 31 0
FR f2 FR f3
Extended
81 80 64 63 32 31 0
FR f1 0 1003E
81 80 64 63 32 31 30 0 81 80 64 63 32 31 0
FR f2 FR f3
Extended
81 80 64 63 32 31 0
FR f1 0 1003E
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
if (sxt_l_form) {
tmp_res_hi = (FR[f2].significand{63}? 0xFFFFFFFF: 0x00000000);
tmp_res_lo = FR[f3].significand{63:32};
} else { // sxt_r_form
tmp_res_hi = (FR[f2].significand{31}? 0xFFFFFFFF: 0x00000000);
tmp_res_lo = FR[f3].significand{31:0};
}
fp_update_psr(f1);
}
FP Exceptions: None
Description: The processor is instructed to expedite flushing of any pending stores held in write or coalescing
buffers. Since this operation is a hint, the processor may or may not take any action and actually
flush any outstanding stores. The processor gives no indication when flushing of any prior stores is
completed. An fwb instruction does not ensure ordering of stores, since later stores may be flushed
before prior stores.
To ensure prior coalesced stores are made visible before later stores, software must issue a release
operation between stores (see Table 4-14 on page 2:76 for a list of release operations).
This instruction can be used to help ensure stores held in write or coalescing buffers are not delayed
for long periods or to expedite high priority stores out of the processors.
Operation: if (PR[qp]) {
mem_flush_pending_stores();
}
Interruptions: None
Description: The bit-wise logical exclusive-OR of the significand fields of FR f2 and FR f3 is computed. The
resulting value is stored in the significand field of FR f1. The exponent field of FR f1 is set to the
biased exponent for 2.063 (0x1003E) and the sign field of FR f1 is set to positive (0).
If either of FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
FR[f1] = NATVAL;
} else {
FR[f1].significand = FR[f2].significand ^ FR[f3].significand;
FR[f1].exponent = FP_INTEGER_EXP;
FR[f1].sign = FP_SIGN_POSITIVE;
}
fp_update_psr(f1);
}
FP Exceptions: None
Description: In the single and double forms, the value in FR f2 is converted into a single precision (single_form)
or double precision (double_form) memory representation and placed in GR r1, as shown in
Figure 5-7 and Figure 5-8 on page 1:91, respectively. In the single_form, the most-significant 32
bits of GR r1 are set to 0.
In the exponent_form, the exponent field of FR f2 is copied to bits 16:0 of GR r1 and the sign bit of
the value in FR f2 is copied to bit 17 of GR r1. The most-significant 46-bits of GR r1 are set to zero.
FR f2 s exponent significand
63 18 16 0
GR r1 0
46 1 17
FR f2 s exponent significand
63 0
GR r1
64
For all forms, if FR f2 contains a NaTVal, then the NaT bit corresponding to GR r1 is set to 1.
Operation: if (PR[qp]) {
check_target_register(r1);
if (tmp_isrcode = fp_reg_disabled(f2, 0, 0, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (single_form) {
GR[r1]{31:0} = fp_fr_to_mem_format(FR[f2], 4, 0);
GR[r1]{63:32} = 0;
} else if (double_form) {
GR[r1] = fp_fr_to_mem_format(FR[f2], 8, 0);
} else if (exponent_form) {
GR[r1]{63:18} = 0;
GR[r1]{16:0} = FR[f2].exponent;
GR[r1]{17} = FR[f2].sign;
} else // significand_form
GR[r1] = FR[f2].significand;
if (fp_is_natval(FR[f2]))
GR[r1].nat = 1;
else
GR[r1].nat = 0;
}
Description: Provides a performance hint to the processor about the program being executed. It has no effect on
architectural machine state, and operates as a nop instruction except for its performance effects.
The immediate, imm21 or imm62, specifies the hint. For the x_unit_form, the L slot of the bundle
contains the upper 41 bits of imm62.
This instruction has five forms, each of which can be executed only on a particular execution unit
type. The pseudo-op can be used if the unit type to execute on is unimportant.
Operation: if (PR[qp]) {
if (x_unit_form)
hint = imm62;
else // i_unit_form || b_unit_form || m_unit_form || f_unit_form
hint = imm21;
if (is_supported_hint(hint))
execute_hint(hint);
}
Interruptions: None
Operation: if (PR[qp]) {
if (complete_form)
alat_inval();
else { // entry_form
if (gr_form)
alat_inval_single_entry(GENERAL, r1);
else // fr_form
alat_inval_single_entry(FLOAT, f1);
}
}
Interruptions: None
Description: An entry is inserted into the instruction or data translation cache. GR r2 specifies the physical
address portion of the translation. ITIR specifies the protection key, page size and additional
information. The virtual address is specified by the IFA register and the region register is selected
by IFA{63:61}. The processor determines which entry to replace based on an
implementation-specific replacement algorithm.
The visibility of the itc instruction to externally generated purges (ptc.g, ptc.ga) must occur before
subsequent memory operations. From a software perspective, this is similar to acquire semantics.
Serialization is still required to observe the side-effects of a translation being present.
itc must be the last instruction in an instruction group; otherwise, its behavior (including its
ordering semantics) is undefined.
The TLB is first purged of any overlapping entries as specified by Table 4-1 on page 2:47.
This instruction can only be executed at the most privileged level, and when PSR.ic and PSR.vm
are both 0.
To ensure forward progress, software must ensure that PSR.ic remains 0 until rfi-ing to the
instruction that requires the translation.
Operation: if (PR[qp]) {
if (!followed_by_stop())
undefined_behavior();
if (PSR.ic)
illegal_operation_fault();
if (PSR.cpl!= 0)
privileged_operation_fault(0);
if (GR[r2].nat)
register_nat_consumption_fault(0);
tmp_size = CR[ITIR].ps;
tmp_va = CR[IFA]{60:0};
tmp_rid = RR[CR[IFA]{63:61}].rid;
tmp_va = align_to_size_boundary(tmp_va, tmp_size);
if (instruction_form) {
tlb_must_purge_itc_entries(tmp_rid, tmp_va, tmp_size);
tlb_may_purge_dtc_entries(tmp_rid, tmp_va, tmp_size);
slot = tlb_replacement_algorithm(ITC_TYPE);
tlb_insert_inst(slot, GR[r2], CR[ITIR], CR[IFA], tmp_rid, TC);
} else { // data_form
tlb_must_purge_dtc_entries(tmp_rid, tmp_va, tmp_size);
tlb_may_purge_itc_entries(tmp_rid, tmp_va, tmp_size);
slot = tlb_replacement_algorithm(DTC_TYPE);
tlb_insert_data(slot, GR[r2], CR[ITIR], CR[IFA], tmp_rid, TC);
}
}
Serialization: For the instruction_form, software must issue an instruction serialization operation before a
dependent instruction fetch access. For the data_form, software must issue a data serialization
operation before issuing a data access or non-access reference dependent on the new translation.
Description: A translation is inserted into the instruction or data translation register specified by the contents of
GR r3. GR r2 specifies the physical address portion of the translation. ITIR specifies the protection
key, page size and additional information. The virtual address is specified by the IFA register and
the region register is selected by IFA{63:61}.
As described in Table 4-1, “Purge Behavior of TLB Inserts and Purges” on page 2:47, the TLB is
first purged of any entries that overlap with the newly inserted translation. The translation
previously contained in the TR slot specified by GR r3 is not necessarily purged from the
processor's TLBs and may remain as a TC entry. To ensure that the previous TR translation is
purged, software must use explicit ptr instructions before inserting the new TR entry.
This instruction can only be executed at the most privileged level, and when PSR.ic and PSR.vm
are both 0.
Operation: if (PR[qp]) {
if (PSR.ic)
illegal_operation_fault();
if (PSR.cpl!= 0)
privileged_operation_fault(0);
if (GR[r3].nat || GR[r2].nat)
register_nat_consumption_fault(0);
slot = GR[r3]{7:0};
tmp_size = CR[ITIR].ps;
tmp_va = CR[IFA]{60:0};
tmp_rid = RR[CR[IFA]{63:61}].rid;
tmp_va = align_to_size_boundary(tmp_va, tmp_size);
if (is_reserved_reg(tmp_tr_type, slot))
reserved_register_field_fault();
if (is_reserved_field(TLB_TYPE, GR[r2], CR[ITIR]))
reserved_register_field_fault();
if (!impl_check_mov_ifa() &&
unimplemented_virtual_address(CR[IFA], PSR.vm))
unimplemented_data_address_fault(0);
if (PSR.vm == 1)
virtualization_fault();
if (instruction_form) {
tlb_must_purge_itc_entries(tmp_rid, tmp_va, tmp_size);
tlb_may_purge_dtc_entries(tmp_rid, tmp_va, tmp_size);
tlb_insert_inst(slot, GR[r2], CR[ITIR], CR[IFA], tmp_rid, TR);
} else { // data_form
tlb_must_purge_dtc_entries(tmp_rid, tmp_va, tmp_size);
tlb_may_purge_itc_entries(tmp_rid, tmp_va, tmp_size);
tlb_insert_data(slot, GR[r2], CR[ITIR], CR[IFA], tmp_rid, TR);
}
}
Serialization: For the instruction_form, software must issue an instruction serialization operation before a
dependent instruction fetch access. For the data_form, software must issue a data serialization
operation before issuing a data access or non-access reference dependent on the new translation.
Notes: The processor may use invalid translation registers for translation cache entries. Performance can
be improved on some processor models by ensuring translation registers are allocated beginning at
translation register zero and continuing contiguously upwards.
ld — Load
Format: (qp) ldsz.ldtype.ldhint r1 = [r3] no_base_update_form M1
(qp) ldsz.ldtype.ldhint r1 = [r3], r2 reg_base_update_form M2
(qp) ldsz.ldtype.ldhint r1 = [r3], imm9 imm_base_update_form M3
(qp) ld16.ldhint r1, ar.csd = [r3] sixteen_byte_form, no_base_update_form M1
(qp) ld16.acq.ldhint r1, ar.csd = [r3] sixteen_byte_form, acquire_form, no_base_update_form M1
(qp) ld8.fill.ldhint r1 = [r3] fill_form, no_base_update_form M1
(qp) ld8.fill.ldhint r1 = [r3], r2 fill_form, reg_base_update_form M2
(qp) ld8.fill.ldhint r1 = [r3], imm9 fill_form, imm_base_update_form M3
Description: A value consisting of sz bytes is read from memory starting at the address specified by the value in
GR r3. The value is then zero extended and placed in GR r1. The values of the sz completer are
given in Table 2-32. The NaT bit corresponding to GR r1 is cleared, except as described below for
speculative loads. The ldtype completer specifies special load operations, which are described in
Table 2-33.
For the sixteen_byte_form, two 8-byte values are loaded as a single, 16-byte memory read. The
value at the lowest address is placed in GR r1, and the value at the highest address is placed in the
Compare and Store Data application register (AR[CSD]). The only load types supported for this
sixteen_byte_form are none and acq.
For the fill_form, an 8-byte value is loaded, and a bit in the UNAT application register is copied
into the target register NaT bit. This instruction is used for reloading a spilled register/NaT pair. See
Section 4.4.4, “Control Speculation” on page 1:56 for details.
In the base update forms, the value in GR r3 is added to either a signed immediate value (imm9) or
a value from GR r2, and the result is placed back in GR r3. This base register update is done after
the load, and does not affect the load address. In the reg_base_update_form, if the NaT bit
corresponding to GR r2 is set, then the NaT bit corresponding to GR r3 is set and no fault is raised.
Base register update is not supported for the ld16 instruction.
For more details on ordered, biased, speculative, advanced and check loads see Section 4.4.4,
“Control Speculation” on page 1:56 and Section 4.4.5, “Data Speculation” on page 1:59. For more
details on ordered loads see Section 4.4.7, “Memory Access Ordering” on page 1:68. See
Section 4.4.6, “Memory Hierarchy Control and Consistency” on page 1:64 for details on biased
loads. Details on memory attributes are described in Section 4.4, “Memory Attributes” on
page 2:69.
For the non-speculative load types, if NaT bit associated with GR r3 is 1, a Register NaT
Consumption fault is taken. For speculative and speculative advanced loads, no fault is raised, and
the exception is deferred. For the base-update calculation, if the NaT bit associated with GR r2 is 1,
the NaT bit associated with GR r3 is set to 1 and no fault is raised.
The value of the ldhint completer specifies the locality of the memory access. The values of the
ldhint completer are given in Table 2-34. A prefetch hint is implied in the base update forms. The
address specified by the value in GR r3 after the base update acts as a hint to prefetch the indicated
cache line. This prefetch uses the locality hints specified by ldhint. Prefetch and locality hints do
not affect program functionality and may be ignored by the implementation. See Section 4.4.6,
“Memory Hierarchy Control and Consistency” on page 1:64 for details.
In the no_base_update form, the value in GR r3 is not modified and no prefetch hint is implied.
For the base update forms, specifying the same register address in r1 and r3 will cause an Illegal
Operation fault.
Hardware support for ld16 instructions that reference a page that is neither a cacheable page with
write-back policy nor a NaTPage is optional. On processor models that do not support such ld16
accesses, an Unsupported Data Reference fault is raised when an unsupported reference is
attempted.
For the sixteen_byte_form, Illegal Operation fault is raised on processor models that do not support
the instruction. CPUID register 4 indicates the presence of the feature on the processor model. See
Section 3.1.11, “Processor Identification Registers” on page 1:31 for details.
Operation: if (PR[qp]) {
size = fill_form? 8: (sixteen_byte_form? 16: sz);
itype = READ;
if (speculative) itype |= SPEC;
if (advanced) itype |= ADVANCE;
if (size == 16) itype |= UNCACHE_OPT;
if (sixteen_byte_form &&!instruction_implemented(LD16))
illegal_operation_fault();
if ((reg_base_update_form || imm_base_update_form) && (r1 == r3))
illegal_operation_fault();
check_target_register(r1);
if (reg_base_update_form || imm_base_update_form)
check_target_register(r3);
if (reg_base_update_form) {
tmp_r2 = GR[r2];
tmp_r2nat = GR[r2].nat;
}
Description: A value consisting of fsz bytes is read from memory starting at the address specified by the value in
GR r3. The value is then converted into the floating-point register format and placed in FR f1. See
Section 5.1, “Data Types and Formats” on page 1:81 for details on conversion to floating-point
register format. The values of the fsz completer are given in Table 2-35. The fldtype completer
specifies special load operations, which are described in Table 2-36.
For the integer_form, an 8-byte value is loaded and placed in the significand field of FR f1 without
conversion. The exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the
sign field of FR f1 is set to positive (0).
For the fill_form, a 16-byte value is loaded, and the appropriate fields are placed in FR f1 without
conversion. This instruction is used for reloading a spilled register. See Section 4.4.4, “Control
Speculation” on page 1:56 for details.
In the base update forms, the value in GR r3 is added to either a signed immediate value (imm9) or
a value from GR r2, and the result is placed back in GR r3. This base register update is done after
the load, and does not affect the load address. In the reg_base_update_form, if the NaT bit
corresponding to GR r2 is set, then the NaT bit corresponding to GR r3 is set and no fault is raised.
For more details on speculative, advanced and check loads see Section 4.4.4, “Control Speculation”
on page 1:56 and Section 4.4.5, “Data Speculation” on page 1:59. Details on memory attributes are
described in Section 4.4, “Memory Attributes” on page 2:69.
For the non-speculative load types, if NaT bit associated with GR r3 is 1, a Register NaT
Consumption fault is taken. For speculative and speculative advanced loads, no fault is raised, and
the exception is deferred. For the base-update calculation, if the NaT bit associated with GR r2 is 1,
the NaT bit associated with GR r3 is set to 1 and no fault is raised.
The value of the ldhint modifier specifies the locality of the memory access. The mnemonic values
of ldhint are given in Table 2-34 on page 3:139. A prefetch hint is implied in the base update forms.
The address specified by the value in GR r3 after the base update acts as a hint to prefetch the
indicated cache line. This prefetch uses the locality hints specified by ldhint. Prefetch and locality
hints do not affect program functionality and may be ignored by the implementation. See
Section 4.4.6, “Memory Hierarchy Control and Consistency” on page 1:64 for details.
In the no_base_update form, the value in GR r3 is not modified and no prefetch hint is implied.
The PSR.mfl and PSR.mfh bits are updated to reflect the modification of FR f1.
Hardware support for ldfe (10-byte) instructions that reference a page that is neither a cacheable
page with write-back policy nor a NaTPage is optional. On processor models that do not support
such ldfe accesses, an Unsupported Data Reference fault is raised when an unsupported reference is
attempted. The fault is delivered only on the normal, advanced, and check load flavors.
Control-speculative flavors of ldfe always defer the Unsupported Data Reference fault.
Operation: if (PR[qp]) {
size = (fill_form? 16: (integer_form? 8: fsz));
speculative = (fldtype == ‘s’ || fldtype == ‘sa’);
advanced = (fldtype == ‘a’ || fldtype == ‘sa’);
check_clear = (fldtype == ‘c.clr’);
check_no_clear = (fldtype == ‘c.nc’);
check = check_clear || check_no_clear;
translate_address = 1;
read_memory = 1;
itype = READ;
if (speculative) itype |= SPEC;
if (advanced) itype |= ADVANCE;
if (size == 10) itype |= UNCACHE_OPT;
if (reg_base_update_form || imm_base_update_form)
check_target_register(r3);
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, 0, 0, 0))
disabled_fp_register_fault(tmp_isrcode, itype);
if (!translate_address) {
if (check_clear || advanced) // remove any old ALAT entry
alat_inval_single_entry(FLOAT, f1);
} else {
if (!defer) {
paddr = tlb_translate(GR[r3], size, itype, PSR.cpl, &mattr,
&defer);
spontaneous_deferral(paddr, size, UM.be, mattr, UNORDERED,
ldhint, &defer);
if (!defer && read_memory)
val = mem_read(paddr, size, UM.be, mattr, UNORDERED, ldhint);
}
if (check_clear || advanced) // remove any old ALAT entry
alat_inval_single_entry(FLOAT, f1);
if (speculative && defer) {
FR[f1] = NATVAL;
} else if (advanced &&!speculative && defer) {
FR[f1] = (integer_form? FP_INT_ZERO: FP_ZERO);
} else { // execute load normally
FR[f1] = fp_mem_to_fr_format(val, size, integer_form);
fp_update_psr(f1);
}
Description: Eight (single_form) or sixteen (double_form/integer_form) bytes are read from memory starting at
the address specified by the value in GR r3. The value read is treated as a contiguous pair of
floating-point numbers for the single_form/double_form and as integer/Parallel FP data for the
integer_form. Each number is converted into the floating-point register format. The value at the
lowest address is placed in FR f1, and the value at the highest address is placed in FR f2. See
Section 5.1, “Data Types and Formats” on page 1:81 for details on conversion to floating-point
register format. The fldtype completer specifies special load operations, which are described in
Table 2-36 on page 3:143.
For more details on speculative, advanced and check loads see Section 4.4.4, “Control Speculation”
on page 1:56 and Section 4.4.5, “Data Speculation” on page 1:59.
For the non-speculative load types, if NaT bit associated with GR r3 is 1, a Register NaT
Consumption fault is taken. For speculative and speculative advanced loads, no fault is raised, and
the exception is deferred.
In the base_update_form, the value in GR r3 is added to an implied immediate value (equal to
double the data size) and the result is placed back in GR r3. This base register update is done after
the load, and does not affect the load address.
The value of the ldhint modifier specifies the locality of the memory access. The mnemonic values
of ldhint are given in Table 2-34 on page 3:139. A prefetch hint is implied in the base update form.
The address specified by the value in GR r3 after the base update acts as a hint to prefetch the
indicated cache line. This prefetch uses the locality hints specified by ldhint. Prefetch and locality
hints do not affect program functionality and may be ignored by the implementation. See
Section 4.4.6, “Memory Hierarchy Control and Consistency” on page 1:64 for details.
In the no_base_update form, the value in GR r3 is not modified and no prefetch hint is implied.
The PSR.mfl and PSR.mfh bits are updated to reflect the modification of FR f1 and FR f2.
There is a restriction on the choice of target registers. Register specifiers f1 and f2 must specify one
odd-numbered physical FR and one even-numbered physical FR. Specifying two odd or two even
registers will cause an Illegal Operation fault to be raised. The restriction is on physical register
numbers after register rotation. This means that if f1 and f2 both specify static registers or both
specify rotating registers, then f1 and f2 must be odd/even or even/odd. If f1 and f2 specify one static
and one rotating register, the restriction depends on CFM.rrb.fr. If CFM.rrb.fr is even, the
restriction is the same; f1 and f2 must be odd/even or even/odd. If CFM.rrb.fr is odd, then f1 and f2
must be even/even or odd/odd. Specifying one static and one rotating register should only be done
when CFM.rrb.fr will have a predictable value (such as 0).
Operation: if (PR[qp]) {
size = single_form? 8: 16;
itype = READ;
if (speculative) itype |= SPEC;
if (advanced) itype |= ADVANCE;
if (fp_reg_bank_conflict(f1, f2))
illegal_operation_fault();
if (base_update_form)
check_target_register(r3);
fp_check_target_register(f1);
fp_check_target_register(f2);
if (tmp_isrcode = fp_reg_disabled(f1, f2, 0, 0))
disabled_fp_register_fault(tmp_isrcode, itype);
if (!translate_address) {
if (check_clear || advanced) // remove any old ALAT entry
alat_inval_single_entry(FLOAT, f1);
} else {
if (!defer) {
paddr = tlb_translate(GR[r3], size, itype, PSR.cpl, &mattr,
&defer);
spontaneous_deferral(paddr, size, UM.be, mattr, UNORDERED,
ldhint, &defer);
if (!defer && read_memory)
mem_read_pair(&f1_val, &f2_val, paddr, size, UM.be,
mattr, UNORDERED, ldhint);
}
if (check_clear || advanced) // remove any old ALAT entry
alat_inval_single_entry(FLOAT, f1);
if (speculative && defer) {
FR[f1] = NATVAL;
FR[f2] = NATVAL;
} else if (advanced &&!speculative && defer) {
FR[f1] = (integer_form? FP_INT_ZERO: FP_ZERO);
FR[f2] = (integer_form? FP_INT_ZERO: FP_ZERO);
} else { // execute load normally
FR[f1] = fp_mem_to_fr_format(f1_val, size/2, integer_form);
FR[f2] = fp_mem_to_fr_format(f2_val, size/2, integer_form);
fp_update_psr(f1);
fp_update_psr(f2);
}
Description: The line containing the address specified by the value in GR r3 is moved to the highest level of the
data memory hierarchy. The value of the lfhint modifier specifies the locality of the memory access;
see Section 4.4, “Memory Access Instructions” on page 1:53 for details. The mnemonic values of
lfhint are given in Table 2-38.
The behavior of the memory read is also determined by the memory attribute associated with the
accessed page. See Chapter 4, “Addressing and Protection” in Volume 2. Line size is
implementation dependent but must be a power of two greater than or equal to 32 bytes. In the
exclusive form, the cache line is allowed to be marked in an exclusive state. This qualifier is used
when the program expects soon to modify a location in that line. If the memory attribute for the
page containing the line is not cacheable, then no reference is made.
The completer, lftype, specifies whether or not the instruction raises faults normally associated with
a regular load. Table 2-37 defines these two options.
In the base update forms, after being used to address memory, the value in GR r3 is incremented by
either the sign-extended value in imm9 (in the imm_base_update_form) or the value in GR r2 (in
the reg_base_update_form). In the reg_base_update_form, if the NaT bit corresponding to GR r2 is
set, then the NaT bit corresponding to GR r3 is set – no fault is raised.
In the reg_base_update_form and the imm_base_update_form, if the NaT bit corresponding to GR
r3 is clear, then the address specified by the value in GR r3 after the post-increment acts as a hint to
implicitly prefetch the indicated cache line. This implicit prefetch uses the locality hints specified
by lfhint. The implicit prefetch does not affect program functionality, does not raise any faults, and
may be ignored by the implementation.
In the no_base_update_form, the value in GR r3 is not modified and no implicit prefetch hint is
implied.
If the NaT bit corresponding to GR r3 is set then the state of memory is not affected. In the
reg_base_update_form and imm_base_update_form, the post increment of GR r3 is performed and
prefetch is hinted as described above.
lfetch instructions, like hardware prefetches, are not orderable operations, i.e., they have no order
with respect to prior or subsequent memory operations.
Operation: if (PR[qp]) {
itype = READ|NON_ACCESS;
itype |= (lftype == ‘fault’)? LFETCH_FAULT: LFETCH;
if (reg_base_update_form || imm_base_update_form)
check_target_register(r3);
if (imm_base_update_form) {
GR[r3] = GR[r3] + sign_ext(imm9, 9);
GR[r3].nat = GR[r3].nat;
} else if (reg_base_update_form) {
GR[r3] = GR[r3] + GR[r2];
Description: This instruction ensures that a specified number of bytes (registers values and/or NaT collections)
below the current BSP have been loaded from the backing store into the stacked general registers.
The loaded registers are placed into the dirty partition of the register stack. All other stacked
general registers are marked as invalid, without being saved to the backing store.
The number of bytes to be loaded is specified in a sub-field of the RSC application register
(RSC.loadrs). Backing store addresses are always 8-byte aligned, and therefore the low order 3 bits
of the loadrs field (RSC.loadrs{2:0}) are ignored. This instruction can be used to invalidate all
stacked registers outside the current frame, by setting RSC.loadrs to zero.
This instruction will fault with an Illegal Operation fault under any of the following conditions:
• the RSE is not in enforced lazy mode (RSC.mode is non-zero).
• CFM.sof and RSC.loadrs are both non-zero.
• an attempt is made to load up more registers than are available in the physical stacked register
file.
This instruction must be the first instruction in an instruction group and must either be in
instruction slot 0 or in instruction slot 1 of a template having a stop after slot 0; otherwise, the
results are undefined. This instruction cannot be predicated.
Operation: if (AR[RSC].mode!= 0)
illegal_operation_fault();
mf — Memory Fence
Format: (qp) mf ordering_form M24
(qp) mf.a acceptance_form M24
Description: This instruction forces ordering between prior and subsequent memory accesses. The
ordering_form ensures all prior data memory accesses are made visible prior to any subsequent
data memory accesses being made visible. It does not ensure prior data memory references have
been accepted by the external platform, nor that prior data memory references are visible.
The acceptance_form prevents any subsequent data memory accesses by the processor from
initiating transactions to the external platform until:
• all prior loads to sequential pages have returned data, and
• all prior stores to sequential pages have been accepted by the external platform.
The definition of “acceptance” is platform dependent. The acceptance_form is typically used to
ensure the processor has “waited” until a memory-mapped I/O transaction has been “accepted”
before initiating additional external transactions. The acceptance_form does not ensure ordering, or
acceptance to memory areas other than sequential pages.
Operation: if (PR[qp]){
if (acceptance_form)
acceptance_fence();
else // ordering_form
ordering_fence();
}
Interruptions: None
mix — Mix
Format: (qp) mix1.l r1 = r2, r3 one_byte_form, left_form I2
(qp) mix2.l r1 = r2, r3 two_byte_form, left_form I2
(qp) mix4.l r1 = r2, r3 four_byte_form, left_form I2
(qp) mix1.r r1 = r2, r3 one_byte_form, right_form I2
(qp) mix2.r r1 = r2, r3 two_byte_form, right_form I2
(qp) mix4.r r1 = r2, r3 four_byte_form, right_form I2
Description: The data elements of GR r2 and r3 are mixed as shown in Figure 2-25, and the result placed in GR
r1. The data elements in the source registers are grouped in pairs, and one element from each pair is
selected for the result. In the left_form, the result is formed from the leftmost elements from each of
the pairs. In the right_form, the result is formed from the rightmost elements. Elements are selected
alternately from the two source registers.
GR r2: GR r3:
mix1.l GR r1:
GR r2: GR r3:
mix1.r GR r1:
GR r2: GR r3:
mix2.l GR r1:
GR r2: GR r3:
mix2.r GR r1:
GR r2: GR r3:
mix4.l GR r1:
GR r2: GR r3:
mix4.r GR r1:
Operation: if (PR[qp]) {
check_target_register(r1);
if (left_form)
GR[r1] = concatenate8( x[7], y[7], x[5], y[5],
x[3], y[3], x[1], y[1]);
else // right_form
GR[r1] = concatenate8( x[6], y[6], x[4], y[4],
x[2], y[2], x[0], y[0]);
if (left_form)
GR[r1] = concatenate4(x[3], y[3], x[1], y[1]);
else // right_form
GR[r1] = concatenate4(x[2], y[2], x[0], y[0]);
if (left_form)
GR[r1] = concatenate2(x[1], y[1]);
else // right_form
GR[r1] = concatenate2(x[0], y[0]);
}
GR[r1].nat = GR[r2].nat || GR[r3].nat;
}
Operation: if (PR[qp]) {
tmp_type = (i_form? AR_I_TYPE: AR_M_TYPE);
if (is_reserved_reg(tmp_type, ar3))
illegal_operation_fault();
if (from_form) {
check_target_register(r1);
if (((ar3 == BSPSTORE) || (ar3 == RNAT)) && (AR[RSC].mode!= 0))
illegal_operation_fault();
if (is_read_only_register(AR_TYPE, ar3) ||
(((ar3 == BSPSTORE) || (ar3 == RNAT)) && (AR[RSC].mode!= 0)))
illegal_operation_fault();
if (!is_ignored_reg(ar3)) {
tmp_val = ignored_field_mask(AR_TYPE, ar3, tmp_val);
// check for illegal promotion
if (ar3 == RSC && tmp_val{3:2} u< PSR.cpl)
tmp_val{3:2} = PSR.cpl;
AR[ar3] = tmp_val;
if (ar3 == BSPSTORE) {
AR[BSP] = rse_update_internal_stack_pointers(tmp_val);
AR[RNAT] = undefined();
}
}
}
}
A pseudo-op is provided for copying a general register into a branch register when there is no hint
information to be specified. This is encoded with a value of 0 for tag13 and values corresponding to
none for the hint completers.
Operation: if (PR[qp]) {
if (from_form) {
check_target_register(r1);
GR[r1] = BR[b2];
GR[r1].nat = 0;
} else { // to_form
tmp_tag = IP + sign_ext((timm9 << 4), 13);
if (GR[r2].nat)
register_nat_consumption_fault(0);
BR[b1] = GR[r2];
branch_predict(mwh, ih, return_form, GR[r2], tmp_tag);
}
}
Operation: if (PR[qp]) {
if (is_reserved_reg(CR_TYPE, cr3)
|| to_form && is_read_only_reg(CR_TYPE, cr3)
|| PSR.ic && is_interruption_cr(cr3))
{
illegal_operation_fault();
}
if (from_form)
check_target_register(r1);
if (PSR.cpl!= 0)
privileged_operation_fault(0);
if (from_form) {
if (PSR.vm == 1)
virtualization_fault();
if (cr3 == IVR)
check_interrupt_request();
if (cr3 == ITIR)
GR[r1] = impl_itir_cwi_mask(CR[ITIR]);
else
GR[r1] = CR[cr3];
GR[r1].nat = 0;
} else { // to_form
if (GR[r2].nat)
register_nat_consumption_fault(0);
Serialization: Reads of control registers reflect the results of all prior instruction groups and interruptions.
In general, writes to control registers do not immediately affect subsequent instructions. Software
must issue a serialize operation before a dependent instruction uses a modified resource.
Control register writes are not implicitly synchronized with a corresponding control register read
and requires data serialization.
Description: The immediate value, imm22, is sign extended to 64 bits and placed in GR r1.
For all register files other than the region registers, bits {7:0} of GR r3 are used as the index. For
region registers, bits {63:61} are used. The remainder of the bits are ignored.
Instruction and data breakpoint, performance monitor configuration, protection key, and region
registers can only be accessed at the most privileged level. Performance monitor data registers can
only be written at the most privileged level.
The CPU identification registers can only be read. There is no to_form of this instruction.
For move to protection key register, the processor ensures uniqueness of protection keys by
checking new valid protection keys against all protection key registers. If any matching keys are
found, duplicate protection keys are invalidated.
Apart from the PMC and PMD register files, access of a non-existent register results in a Reserved
Register/Field fault. All accesses to the implementation-dependent portion of PMC and PMD
register files result in implementation dependent behavior but do not fault.
Modifying a region register or a protection key register which is being used to translate:
• the executing instruction stream when PSR.it == 1, or
• the data space for an eager RSE reference when PSR.rt == 1
is an undefined operation.
Operation: if (PR[qp]) {
if (ireg == RR_TYPE)
tmp_index = GR[r3]{63:61};
else // all other register types
tmp_index = GR[r3]{7:0};
if (from_form) {
check_target_register(r1);
if (GR[r3].nat)
register_nat_consumption_fault(0);
if (is_reserved_reg(ireg, tmp_index))
reserved_register_field_fault();
if (ireg == PMD_TYPE) {
if ((PSR.cpl!= 0) && ((PSR.sp == 1) ||
(tmp_index > 3 &&
tmp_index <= IMPL_MAXGENERIC_PMCPMD &&
PMC[tmp_index].pm == 1)))
GR[r1] = 0;
else
GR[r1] = pmd_read(tmp_index);
} else
switch (ireg) {
case CPUID_TYPE: GR[r1] = CPUID[tmp_index]; break;
case DBR_TYPE: GR[r1] = DBR[tmp_index]; break;
case IBR_TYPE: GR[r1] = IBR[tmp_index]; break;
case PKR_TYPE: GR[r1] = PKR[tmp_index]; break;
case PMC_TYPE: GR[r1] = pmc_read(tmp_index); break;
case RR_TYPE: GR[r1] = RR[tmp_index]; break;
}
GR[r1].nat = 0;
} else { // to_form
if (PSR.cpl!= 0)
privileged_operation_fault(0);
if (GR[r2].nat || GR[r3].nat)
register_nat_consumption_fault(0);
if (is_reserved_reg(ireg, tmp_index)
|| is_reserved_field(ireg, tmp_index, GR[r2]))
reserved_register_field_fault();
if (PSR.vm == 1)
virtualization_fault();
if (ireg == PKR_TYPE && GR[r2]{0} == 1) { // writing valid prot key
if ((tmp_slot = tlb_search_pkr(GR[r2]{31:8}))!= NOT_FOUND)
PKR[tmp_slot].v = 0; // clear valid bit of matching key reg
}
tmp_val = ignored_field_mask(ireg, tmp_index, GR[r2]);
switch (ireg) {
case DBR_TYPE: DBR[tmp_index] = tmp_val; break;
case IBR_TYPE: IBR[tmp_index] = tmp_val; break;
case PKR_TYPE: PKR[tmp_index] = tmp_val; break;
case PMC_TYPE: pmc_write(tmp_index, tmp_val); break;
case PMD_TYPE: pmd_write(tmp_index, tmp_val); break;
Serialization: For move to data breakpoint registers, software must issue a data serialize operation before issuing
a memory reference dependent on the modified register.
For move to instruction breakpoint registers, software must issue an instruction serialize operation
before fetching an instruction dependent on the modified register.
For move to protection key, region, performance monitor configuration, and performance monitor
data registers, software must issue an instruction or data serialize operation to ensure the changes
are observed before issuing any dependent instruction.
To obtain improved accuracy, software can issue an instruction or data serialize operation before
reading the performance monitors.
Description: The Instruction Pointer (IP) for the bundle containing this instruction is copied into GR r1.
Operation: if (PR[qp]) {
check_target_register(r1);
GR[r1] = IP;
GR[r1].nat = 0;
}
Operation: if (PR[qp]) {
if (from_form) {
check_target_register(r1);
GR[r1] = 1; // PR[0] is always 1
for (i = 1; i <= 63; i++) {
GR[r1]{i} = PR[pr_phys_to_virt(i)];
}
GR[r1].nat = 0;
} else if (to_form) {
if (GR[r2].nat)
register_nat_consumption_fault(0);
tmp_src = sign_ext(mask17, 17);
for (i = 1; i <= 63; i++) {
if (tmp_src{i})
PR[pr_phys_to_virt(i)] = GR[r2]{i};
}
} else { // to_rotate_form
tmp_src = sign_ext(imm44, 44);
for (i = 16; i <= 63; i++) {
PR[pr_phys_to_virt(i)] = tmp_src{i};
}
}
}
Description: The source operand is copied to the destination register. See Section 3.3.2, “Processor Status
Register (PSR)” on page 2:20.
For move from processor status register, PSR bits {36:35} and {31:0} are read, and copied into GR
r1. All other bits of the PSR read as zero.
For move to processor status register, GR r2 is read, bits {31:0} copied into PSR{31:0} and bits
{45:32} are ignored. All bits of GR r2 corresponding to reserved fields of the PSR must be 0 or a
Reserved Register/Field fault will result.
Moves to and from the PSR can only be performed at the most privileged level, and when PSR.vm
is 0.
The contents of the interruption resources (that are overwritten when the PSR.ic bit is 1) are
undefined if an interruption occurs between the enabling of the PSR.ic bit and a subsequent
instruction serialize operation.
Operation: if (PR[qp]) {
if (from_form)
check_target_register(r1);
if (PSR.cpl!= 0)
privileged_operation_fault(0);
if (from_form) {
if (PSR.vm == 1)
virtualization_fault();
tmp_val = zero_ext(PSR{31:0}, 32); // read lower 32 bits
tmp_val |= PSR{36:35} << 35; // read mc and it bits
GR[r1] = tmp_val; // other bits read as zero
GR[r1].nat = 0;
} else { // to_form
if (GR[r2].nat)
register_nat_consumption_fault(0);
if (PSR.vm == 1)
virtualization_fault();
PSR{31:0} = GR[r2]{31:0};
}
}
Serialization: Software must issue an instruction or data serialize operation before issuing instructions dependent
upon the altered PSR bits. Unlike with the rsm instruction, the PSR.i bit is not treated specially
when cleared.
Operation: if (PR[qp]) {
if (from_form) {
check_target_register(r1);
PSR{1:0} = GR[r2]{1:0};
PSR{5:3} = GR[r2]{5:3};
}
}
Serialization: All user mask modifications are observed by the next instruction group.
Description: The immediate value imm64 is copied to GR r1. The L slot of the bundle contains 41 bits of imm64.
Operation: if (PR[qp]) {
check_target_register(r1);
GR[r1] = imm64;
GR[r1].nat = 0;
}
mux — Mux
Format: (qp) mux1 r1 = r2, mbtype4 one_byte_form I3
(qp) mux2 r1 = r2, mhtype8 two_byte_form I4
Description: A permutation is performed on the packed elements in a single source register, GR r2, and the result
is placed in GR r1. For 8-bit elements, only some of all possible permutations can be specified. The
five possible permutations are given in Table 2-41 and shown in Figure 2-26.
GR r2: GR r2:
GR r1: GR r1:
GR r2: GR r2:
GR r1: GR r1:
GR r2:
GR r1:
For 16-bit elements, all possible permutations, with and without repetitions can be specified. They
are expressed with an 8-bit mhtype8 field, which encodes the indices of the four 16-bit data
elements. The indexed 16-bit elements of GR r2 are copied to corresponding 16-bit positions in the
target register GR r1. The indices are encoded in little-endian order. (The 8 bits of mhtype8[7:0] are
grouped in pairs of bits and named mhtype8[3], mhtype8[2], mhtype8[1], mhtype8[0] in the
Operation section).
GR r2: GR r2:
GR r1: GR r1:
mux2 r1 = r2, 0x8d (shuffle 10 00 11 01) mux2 r1 = r2, 0x1b (reverse 00 01 10 11)
GR r2: GR r2:
GR r1: GR r1:
mux2 r1 = r2, 0xd8 (alternate 11 01 10 00) mux2 r1 = r2, 0xaa (broadcast 10 10 10 10)
Operation: if (PR[qp]) {
check_target_register(r1);
if (one_byte_form) {
x[0] = GR[r2]{7:0};
x[1] = GR[r2]{15:8};
x[2] = GR[r2]{23:16};
x[3] = GR[r2]{31:24};
x[4] = GR[r2]{39:32};
x[5] = GR[r2]{47:40};
x[6] = GR[r2]{55:48};
x[7] = GR[r2]{63:56};
switch (mbtype) {
case ‘@rev’:
GR[r1] = concatenate8( x[0], x[1], x[2], x[3],
x[4], x[5], x[6], x[7]);
break;
case ‘@mix’:
GR[r1] = concatenate8( x[7], x[3], x[5], x[1],
x[6], x[2], x[4], x[0]);
break;
case ‘@shuf’:
GR[r1] = concatenate8( x[7], x[3], x[6], x[2],
x[5], x[1], x[4], x[0]);
break;
case ‘@alt’:
GR[r1] = concatenate8( x[7], x[5], x[3], x[1],
x[6], x[4], x[2], x[0]);
break;
case ‘@brcst’:
GR[r1] = concatenate8( x[0], x[0], x[0], x[0],
x[0], x[0], x[0], x[0]);
break;
}
} else { // two_byte_form
x[0] = GR[r2]{15:0};
x[1] = GR[r2]{31:16};
x[2] = GR[r2]{47:32};
x[3] = GR[r2]{63:48};
res[0] = x[mhtype8{1:0}];
res[1] = x[mhtype8{3:2}];
res[2] = x[mhtype8{5:4}];
res[3] = x[mhtype8{7:6}];
nop — No Operation
Format: (qp) nop imm21 pseudo-op
(qp) nop.i imm21 i_unit_form I18
(qp) nop.b imm21 b_unit_form B9
(qp) nop.m imm21 m_unit_form M48
(qp) nop.f imm21 f_unit_form F16
(qp) nop.x imm62 x_unit_form X5
Operation: if (PR[qp]) {
; // no operation
}
Interruptions: None
or — Logical Or
Format: (qp) or r1 = r2, r3 register_form A1
(qp) or r1 = imm8, r3 imm8_form A3
Description: The two source operands are logically ORed and the result placed in GR r1. In the register form the
first operand is GR r2; in the immediate form the first operand is taken from the imm8 encoding
field.
Operation: if (PR[qp]) {
check_target_register(r1);
pack — Pack
Format: (qp) pack2.sss r1 = r2, r3 two_byte_form, signed_saturation_form I2
(qp) pack2.uss r1 = r2, r3 two_byte_form, unsigned_saturation_form I2
(qp) pack4.sss r1 = r2, r3 four_byte_form, signed_saturation_form I2
Description: 32-bit or 16-bit elements from GR r2 and GR r3 are converted into 16-bit or 8-bit elements
respectively, and the results are placed GR r1. The source elements are treated as signed values. If a
source element cannot be represented in the result element, then saturation clipping is performed.
The saturation can either be signed or unsigned. If an element is larger than the upper limit value,
the result is the upper limit value. If it is smaller than the lower limit value, the result is the lower
limit value. The saturation limits are given in Table 2-42.
GR r3: GR r2:
GR r1:
pack4
GR r3: GR r2:
GR r1:
pack2
Operation: if (PR[qp]) {
check_target_register(r1);
if (two_byte_form) {
if (signed_saturation_form) {
max = sign_ext(0x7f, 8);
min = sign_ext(0x80, 8);
} else { // unsigned_saturation_form
max = 0xff;
min = 0x00;
}
temp[0] = sign_ext(GR[r2]{15:0}, 16);
temp[1] = sign_ext(GR[r2]{31:16}, 16);
temp[2] = sign_ext(GR[r2]{47:32}, 16);
temp[3] = sign_ext(GR[r2]{63:48}, 16);
temp[4] = sign_ext(GR[r3]{15:0}, 16);
temp[5] = sign_ext(GR[r3]{31:16}, 16);
temp[6] = sign_ext(GR[r3]{47:32}, 16);
temp[7] = sign_ext(GR[r3]{63:48}, 16);
} else { // four_byte_form
max = sign_ext(0x7fff, 16); // signed_saturation_form
min = sign_ext(0x8000, 16);
temp[0] = sign_ext(GR[r2]{31:0}, 32);
temp[1] = sign_ext(GR[r2]{63:32}, 32);
temp[2] = sign_ext(GR[r3]{31:0}, 32);
temp[3] = sign_ext(GR[r3]{63:32}, 32);
Description: The sets of elements from the two source operands are added, and the results placed in GR r1.
If a sum of two elements cannot be represented in the result element and a saturation completer is
specified, then saturation clipping is performed. The saturation can either be signed or unsigned, as
given in Table 2-43. If the sum of two elements is larger than the upper limit value, the result is the
upper limit value. If it is smaller than the lower limit value, the result is the lower limit value. The
saturation limits are given in Table 2-44.
GR r3: GR r3:
GR r2: GR r2:
+ + + + + + + + + + + +
GR r1: GR r1:
padd1 padd2
Operation: if (PR[qp]) {
check_target_register(r1);
if (sss_saturation_form) {
max = sign_ext(0x7f, 8);
min = sign_ext(0x80, 8);
if (sss_saturation_form || uus_saturation_form ||
uuu_saturation_form) {
for (i = 0; i < 8; i++) {
if (temp[i] > max)
temp[i] = max;
if (sss_saturation_form) {
max = sign_ext(0x7fff, 16);
min = sign_ext(0x8000, 16);
if (sss_saturation_form || uus_saturation_form ||
uuu_saturation_form) {
for (i = 0; i < 4; i++) {
if (temp[i] > max)
temp[i] = max;
Description: The unsigned data elements of GR r2 are added to the unsigned data elements of GR r3. The results
of the add are then each independently shifted to the right by one bit position. The high-order bits
of each element are filled with the carry bits of the sums. To prevent cumulative round-off errors,
an averaging is performed. The unsigned results are placed in GR r1.
The averaging operation works as follows. In the normal_form, the low-order bit of each result is
set to 1 if at least one of the two least significant bits of the corresponding sum is 1. In the raz_form,
the average rounds away from zero by adding 1 to each of the sums.
GR r3:
GR r2:
Shift Right
1 Bit or
GR r1:
pavg2
Figure 2-31. Parallel Average with Round Away from Zero Example
GR r3:
GR r2:
1 1 1 1
+ + + +
Shift Right 1 Bit
16-bit Sum
Plus
Carry Carry
Bit Sum Bits
Shift Right
1 Bit
GR r1:
pavg2.raz
Operation: if (PR[qp]) {
check_target_register(r1);
if (one_byte_form) {
x[0] = GR[r2]{7:0}; y[0] = GR[r3]{7:0};
x[1] = GR[r2]{15:8}; y[1] = GR[r3]{15:8};
x[2] = GR[r2]{23:16}; y[2] = GR[r3]{23:16};
x[3] = GR[r2]{31:24}; y[3] = GR[r3]{31:24};
x[4] = GR[r2]{39:32}; y[4] = GR[r3]{39:32};
x[5] = GR[r2]{47:40}; y[5] = GR[r3]{47:40};
x[6] = GR[r2]{55:48}; y[6] = GR[r3]{55:48};
x[7] = GR[r2]{63:56}; y[7] = GR[r3]{63:56};
if (raz_form) {
for (i = 0; i < 8; i++) {
temp[i] = zero_ext(x[i], 8) + zero_ext(y[i], 8) + 1;
res[i] = shift_right_unsigned(temp[i], 1);
}
} else { // normal form
for (i = 0; i < 8; i++) {
temp[i] = zero_ext(x[i], 8) + zero_ext(y[i], 8);
res[i] = shift_right_unsigned(temp[i], 1) | (temp[i]{0});
}
}
GR[r1] = concatenate8(res[7], res[6], res[5], res[4],
res[3], res[2], res[1], res[0]);
} else { // two_byte_form
x[0] = GR[r2]{15:0}; y[0] = GR[r3]{15:0};
x[1] = GR[r2]{31:16}; y[1] = GR[r3]{31:16};
x[2] = GR[r2]{47:32}; y[2] = GR[r3]{47:32};
x[3] = GR[r2]{63:48}; y[3] = GR[r3]{63:48};
if (raz_form) {
for (i = 0; i < 4; i++) {
temp[i] = zero_ext(x[i], 16) + zero_ext(y[i], 16) + 1;
res[i] = shift_right_unsigned(temp[i], 1);
}
} else { // normal form
for (i = 0; i < 4; i++) {
temp[i] = zero_ext(x[i], 16) + zero_ext(y[i], 16);
res[i] = shift_right_unsigned(temp[i], 1) | (temp[i]{0});
}
}
GR[r1] = concatenate4(res[3], res[2], res[1], res[0]);
}
GR[r1].nat = GR[r2].nat || GR[r3].nat;
}
Description: The unsigned data elements of GR r3 are subtracted from the unsigned data elements of GR r2. The
results of the subtraction are then each independently shifted to the right by one bit position. The
high-order bits of each element are filled with the borrow bits of the subtraction (the complements
of the ALU carries). To prevent cumulative round-off errors, an averaging is performed. The
low-order bit of each result is set to 1 if at least one of the two least significant bits of the
corresponding difference is 1. The signed results are placed in GR r1.
GR r3:
GR r2:
Shift Right or
1 Bit
GR r1:
pavgsub2
Operation: if (PR[qp]) {
check_target_register(r1);
if (one_byte_form) {
x[0] = GR[r2]{7:0}; y[0] = GR[r3]{7:0};
x[1] = GR[r2]{15:8}; y[1] = GR[r3]{15:8};
x[2] = GR[r2]{23:16}; y[2] = GR[r3]{23:16};
x[3] = GR[r2]{31:24}; y[3] = GR[r3]{31:24};
x[4] = GR[r2]{39:32}; y[4] = GR[r3]{39:32};
x[5] = GR[r2]{47:40}; y[5] = GR[r3]{47:40};
x[6] = GR[r2]{55:48}; y[6] = GR[r3]{55:48};
x[7] = GR[r2]{63:56}; y[7] = GR[r3]{63:56};
} else { // two_byte_form
x[0] = GR[r2]{15:0}; y[0] = GR[r3]{15:0};
x[1] = GR[r2]{31:16}; y[1] = GR[r3]{31:16};
x[2] = GR[r2]{47:32}; y[2] = GR[r3]{47:32};
x[3] = GR[r2]{63:48}; y[3] = GR[r3]{63:48};
Description: The two source operands are compared for one of the two relations shown in Table 2-45. If the
comparison condition is true for corresponding data elements of GR r2 and GR r3, then the
corresponding data element in GR r1 is set to all ones. If the comparison condition is false, then the
corresponding data element in GR r1 is set to all zeros. For the ‘>’ relation, both operands are
interpreted as signed.
GR r3: GR r3:
GR r2: GR r2:
pcmp1.gt pcmp2.eq
GR r3:
GR r2:
= =
True False
pcmp4.eq
Operation: if (PR[qp]) {
check_target_register(r1);
if (tmp_rel)
res[i] = 0xff;
else
res[i] = 0x00;
}
GR[r1] = concatenate8(res[7], res[6], res[5], res[4],
res[3], res[2], res[1], res[0]);
} else if (two_byte_form) { // two-byte elements
x[0] = GR[r2]{15:0}; y[0] = GR[r3]{15:0};
x[1] = GR[r2]{31:16}; y[1] = GR[r3]{31:16};
x[2] = GR[r2]{47:32}; y[2] = GR[r3]{47:32};
x[3] = GR[r2]{63:48}; y[3] = GR[r3]{63:48};
for (i = 0; i < 4; i++) {
if (prel == ‘eq’)
tmp_rel = x[i] == y[i];
else // ‘gt’
tmp_rel = greater_signed(sign_ext(x[i], 16),
sign_ext(y[i], 16));
if (tmp_rel)
res[i] = 0xffff;
else
res[i] = 0x0000;
}
GR[r1] = concatenate4(res[3], res[2], res[1], res[0]);
} else { // four-byte elements
x[0] = GR[r2]{31:0}; y[0] = GR[r3]{31:0};
x[1] = GR[r2]{63:32}; y[1] = GR[r3]{63:32};
for (i = 0; i < 2; i++) {
if (prel == ‘eq’)
tmp_rel = x[i] == y[i];
else // ‘gt’
tmp_rel = greater_signed(sign_ext(x[i], 32),
sign_ext(y[i], 32));
if (tmp_rel)
res[i] = 0xffffffff;
else
res[i] = 0x00000000;
}
GR[r1] = concatenate2(res[1], res[0]);
}
GR[r1].nat = GR[r2].nat || GR[r3].nat;
}
Description: The maximum of the two source operands is placed in the result register. In the one_byte_form,
each unsigned 8-bit element of GR r2 is compared with the corresponding unsigned 8-bit element
of GR r3 and the greater of the two is placed in the corresponding 8-bit element of GR r1. In the
two_byte_form, each signed 16-bit element of GR r2 is compared with the corresponding signed
16-bit element of GR r3 and the greater of the two is placed in the corresponding 16-bit element of
GR r1.
GR r3: GR r3:
GR r2: GR r2:
< < < < < < < < < < < <
GR r1: GR r1:
pmax1.u pmax2
Operation: if (PR[qp]) {
check_target_register(r1);
Description: The minimum of the two source operands is placed in the result register. In the one_byte_form,
each unsigned 8-bit element of GR r2 is compared with the corresponding unsigned 8-bit element
of GR r3 and the smaller of the two is placed in the corresponding 8-bit element of GR r1. In the
two_byte_form, each signed 16-bit element of GR r2 is compared with the corresponding signed
16-bit element of GR r3 and the smaller of the two is placed in the corresponding 16-bit element of
GR r1.
GR r3: GR r3:
GR r2: GR r2:
< < < < < < < < < < < <
GR r1: GR r1:
pmin1.u pmin2
Operation: if (PR[qp]) {
check_target_register(r1);
Description: Two signed 16-bit data elements of GR r2 are multiplied by the corresponding two signed 16-bit
data elements of GR r3 as shown in Figure 2-36. The two 32-bit results are placed in GR r1.
GR r3: GR r3:
GR r2: GR r2:
* * * *
GR r1: GR r1:
pmpy2.l pmpy2.r
Operation: if (PR[qp]) {
check_target_register(r1);
if (right_form) {
GR[r1]{31:0} = sign_ext(GR[r2]{15:0}, 16) *
sign_ext(GR[r3]{15:0}, 16);
GR[r1]{63:32} = sign_ext(GR[r2]{47:32}, 16) *
sign_ext(GR[r3]{47:32}, 16);
} else { // left_form
GR[r1]{31:0} = sign_ext(GR[r2]{31:16}, 16) *
sign_ext(GR[r3]{31:16}, 16);
GR[r1]{63:32} = sign_ext(GR[r2]{63:48}, 16) *
sign_ext(GR[r3]{63:48}, 16);
}
Description: The four 16-bit data elements of GR r2 are multiplied by the corresponding four 16-bit data
elements of GR r3 as shown in Figure 2-37. This multiplication can either be signed (pmpyshr2), or
unsigned (pmpyshr2.u). Each product is then shifted to the right count2 bits, and the
least-significant 16-bits of each shifted product form 4 16-bit results, which are placed in GR r1. A
count2 of 0 gives the 16 low bits of the results, a count2 of 16 gives the 16 high bits of the results.
The allowed values for count2 are given in Table 2-46.
GR r3:
16-bit
Source
GR r2: Elements
* * * *
32-bit
Products
Shift Right
count2 Bits
16-bit
GR r1: Result
Elements
pmpyshr2
Operation: if (PR[qp]) {
check_target_register(r1);
x[0] = GR[r2]{15:0}; y[0] = GR[r3]{15:0};
x[1] = GR[r2]{31:16}; y[1] = GR[r3]{31:16};
x[2] = GR[r2]{47:32}; y[2] = GR[r3]{47:32};
x[3] = GR[r2]{63:48}; y[3] = GR[r3]{63:48};
for (i = 0; i < 4; i++) {
if (unsigned_form) // unsigned multiplication
temp[i] = zero_ext(x[i], 16) * zero_ext(y[i], 16);
else // signed multiplication
temp[i] = sign_ext(x[i], 16) * sign_ext(y[i], 16);
Description: The number of bits in GR r3 having the value 1 is counted, and the resulting sum is placed in GR r1.
Operation: if (PR[qp]) {
check_target_register(r1);
res = 0;
// Count up all the one bits
for (i = 0; i < 64; i++) {
res += GR[r3]{i};
}
GR[r1] = res;
GR[r1].nat = GR[r3].nat;
}
Description: This instruction determines whether read or write access, with a specified privilege level, to a given
virtual address is permitted. GR r1 is set to 1 if the specified access is allowed and to 0 otherwise. In
the fault_form, if the specified access is allowed this instruction does nothing; if the specified
access is not allowed, a fault is taken.
When PSR.dt is 1, the DTLB and the VHPT are queried for present translations to determine if
access to the virtual address specified by GR r3 bits {60:0} and the region register indexed by GR
r3 bits {63:61}, is permitted at the privilege level given by either GR r2 bits{1:0} or imm2. If
PSR.pk is 1, protection key checks are also performed. The read or write form specifies whether the
instruction checks for read or write access, or both.
When PSR.dt is 0, a non-faulting probe uses its address operand as a virtual address to query the
DTLB only, because the VHPT walker is disabled. If the probed address is found in the DTLB, the
non-faulting probe returns the appropriate value, if not an Alternate Data TLB fault is raised.
When PSR.dt is 0, a faulting probe treats its address operand as a physical address, and takes no
TLB related faults.
A non-faulting probe to an unimplemented virtual address returns 0. A faulting probe to an
unimplemented virtual address (when PSR.dt is 1) or unimplemented physical address (when
PSR.dt is 0) takes an Unimplemented Data Address fault.
If this instruction faults, then it will set the non-access bit in the ISR and set the ISR read or write
bits depending on the completer. The following faults are taken by the faulting form of the probe
instruction only (the non-faulting form of the instruction does not take them): Unimplemented Data
Address fault, Data Key Permissions fault, Data Access Rights fault, Data Dirty Bit fault, Data
Access Bit fault, and Data Debug fault.
This instruction can only probe with equal or lower privilege levels. If the specified privilege level
is higher (lower number), then the probe is performed with the current privilege level.
Operation: if (PR[qp]) {
itype = NON_ACCESS;
itype |= (read_write_form)? READ|WRITE: ((write_form)? WRITE: READ);
itype |= (fault_form)? PROBE_FAULT: PROBE;
if (!fault_form)
check_target_register(r1);
if (fault_form) {
tlb_translate(GR[r3], 1, itype, tmp_pl, &mattr, &defer);
} else {
GR[r1] = tlb_grant_permission(GR[r3], itype, tmp_pl);
GR[r1].nat = 0;
}
}
Description: The unsigned 8-bit elements of GR r2 are subtracted from the unsigned 8-bit elements of GR r3.
The absolute value of each difference is accumulated across the elements and placed in GR r1.
GR r3:
GR r2:
- - - - - - - -
+ + + +
+ +
GR r1:
psad1
Operation: if (PR[qp]) {
check_target_register(r1);
GR[r1] = 0;
for (i = 0; i < 8; i++) {
temp[i] = zero_ext(x[i], 8) - zero_ext(y[i], 8);
if (temp[i] < 0)
temp[i] = -temp[i];
GR[r1] += temp[i];
}
Description: The data elements of GR r2 are each independently shifted to the left by the scalar shift count in GR
r3, or in the immediate field count5. The low-order bits of each element are filled with zeros. The
shift count is interpreted as unsigned. Shift counts greater than 15 (for 16-bit quantities) or 31 (for
32-bit quantities) yield all zero results. The results are placed in GR r1.
GR r2: GR r2:
Shift Left
0 0 0
0 0 0
GR r1: 0 0 0 0 GR r1: 0 0
pshl2 pshl4
Operation: if (PR[qp]) {
check_target_register(r1);
if (two_byte_form) { // two_byte_form
if (shift_count u> 16)
shift_count = 16;
GR[r1]{15:0} = GR[r2]{15:0} << shift_count;
GR[r1]{31:16} = GR[r2]{31:16} << shift_count;
GR[r1]{47:32} = GR[r2]{47:32} << shift_count;
GR[r1]{63:48} = GR[r2]{63:48} << shift_count;
} else { // four_byte_form
if (shift_count u> 32)
shift_count = 32;
GR[r1]{31:0} = GR[r2]{31:0} << shift_count;
GR[r1]{63:32} = GR[r2]{63:32} << shift_count;
}
Description: The four signed 16-bit data elements of GR r2 are each independently shifted to the left by count2
bits (shifting zeros into the low-order bits), and added to the four signed 16-bit data elements of GR
r3. Both the left shift and the add operations are saturating: if the result of either the shift or the add
is not representable as a signed 16-bit value, the final result is saturated. The four signed 16-bit
results are placed in GR r1. The first operand can be shifted by 1, 2 or 3 bits.
Operation: if (PR[qp]) {
check_target_register(r1);
Description: The data elements of GR r3 are each independently shifted to the right by the scalar shift count in
GR r2, or in the immediate field count5. The high-order bits of each element are filled with either
the initial value of the sign bits of the data elements in GR r3 (arithmetic shift) or zeros (logical
shift). The shift count is interpreted as unsigned. Shift counts greater than 15 (for 16-bit quantities)
or 31 (for 32-bit quantities) yield all zero or all one results depending on the initial values of the
sign bits of the data elements in GR r3 and whether a signed or unsigned shift is done. The results
are placed in GR r1.
Operation: if (PR[qp]) {
check_target_register(r1);
if (two_byte_form) { // two_byte_form
if (shift_count u> 16)
shift_count = 16;
if (unsigned_form) { // unsigned shift
GR[r1]{15:0} = shift_right_unsigned(zero_ext(GR[r3]{15:0}, 16),
shift_count);
GR[r1]{31:16} = shift_right_unsigned(zero_ext(GR[r3]{31:16}, 16),
shift_count);
GR[r1]{47:32} = shift_right_unsigned(zero_ext(GR[r3]{47:32}, 16),
shift_count);
GR[r1]{63:48} = shift_right_unsigned(zero_ext(GR[r3]{63:48}, 16),
shift_count);
} else { // signed shift
GR[r1]{15:0} = shift_right_signed(sign_ext(GR[r3]{15:0}, 16),
shift_count);
GR[r1]{31:16} = shift_right_signed(sign_ext(GR[r3]{31:16}, 16),
shift_count);
GR[r1]{47:32} = shift_right_signed(sign_ext(GR[r3]{47:32}, 16),
shift_count);
GR[r1]{63:48} = shift_right_signed(sign_ext(GR[r3]{63:48}, 16),
shift_count);
}
} else { // four_byte_form
if (shift_count > 32)
shift_count = 32;
if (unsigned_form) { // unsigned shift
GR[r1]{31:0} = shift_right_unsigned(zero_ext(GR[r3]{31:0}, 32),
shift_count);
GR[r1]{63:32} = shift_right_unsigned(zero_ext(GR[r3]{63:32}, 32),
shift_count);
} else { // signed shift
GR[r1]{31:0} = shift_right_signed(sign_ext(GR[r3]{31:0}, 32),
shift_count);
GR[r1]{63:32} = shift_right_signed(sign_ext(GR[r3]{63:32}, 32),
shift_count);
}
}
Description: The four signed 16-bit data elements of GR r2 are each independently shifted to the right by count2
bits, and added to the four signed 16-bit data elements of GR r3. The right shift operation fills the
high-order bits of each element with the initial value of the sign bits of the data elements in GR r2.
The add operation is performed with signed saturation. The four signed 16-bit results of the add are
placed in GR r1. The first operand can be shifted by 1, 2 or 3 bits.
Operation: if (PR[qp]) {
check_target_register(r1);
Description: The sets of elements from the two source operands are subtracted, and the results placed in GR r1.
If the difference between two elements cannot be represented in the result element and a saturation
completer is specified, then saturation clipping is performed. The saturation can either be signed or
unsigned, as given in Table 2-47. If the difference of two elements is larger than the upper limit
value, the result is the upper limit value. If it is smaller than the lower limit value, the result is the
lower limit value. The saturation limits are given in Table 2-48.
GR r3: GR r3:
GR r2: GR r2:
- - - - - - - - - - - -
GR r1: GR r1:
psub1 psub2
Operation: if (PR[qp]) {
check_target_register(r1);
if (sss_saturation_form) { // sss_saturation_form
max = sign_ext(0x7f, 8);
min = sign_ext(0x80, 8);
for (i = 0; i < 8; i++) {
temp[i] = sign_ext(x[i], 8) - sign_ext(y[i], 8);
}
} else if (uus_saturation_form) { // uus_saturation_form
max = 0xff;
min = 0x00;
for (i = 0; i < 8; i++) {
temp[i] = zero_ext(x[i], 8) - sign_ext(y[i], 8);
}
} else if (uuu_saturation_form) { // uuu_saturation_form
max = 0xff;
min = 0x00;
for (i = 0; i < 8; i++) {
temp[i] = zero_ext(x[i], 8) - zero_ext(y[i], 8);
}
} else { // modulo_form
for (i = 0; i < 8; i++) {
temp[i] = zero_ext(x[i], 8) - zero_ext(y[i], 8);
}
}
if (sss_saturation_form || uus_saturation_form ||
uuu_saturation_form) {
for (i = 0; i < 8; i++) {
if (temp[i] > max)
temp[i] = max;
if (temp[i] < min)
temp[i] = min;
}
}
if (sss_saturation_form) { // sss_saturation_form
max = sign_ext(0x7fff, 16);
min = sign_ext(0x8000, 16);
for (i = 0; i < 4; i++) {
temp[i] = sign_ext(x[i], 16) - sign_ext(y[i], 16);
}
} else if (uus_saturation_form) { // uus_saturation_form
max = 0xffff;
min = 0x0000;
for (i = 0; i < 4; i++) {
temp[i] = zero_ext(x[i], 16) - sign_ext(y[i], 16);
}
} else if (uuu_saturation_form) { // uuu_saturation_form
max = 0xffff;
min = 0x0000;
for (i = 0; i < 4; i++) {
temp[i] = zero_ext(x[i], 16) - zero_ext(y[i], 16);
}
} else { // modulo_form
for (i = 0; i < 4; i++) {
temp[i] = zero_ext(x[i], 16) - zero_ext(y[i], 16);
}
}
if (sss_saturation_form || uus_saturation_form ||
uuu_saturation_form) {
for (i = 0; i < 4; i++) {
if (temp[i] > max)
temp[i] = max;
if (temp[i] < min)
temp[i] = min;
}
}
Description: One or more translation entries are purged from the local processor’s instruction and data
translation cache. Translation Registers and the VHPT are not modified.
The number of translation cache entries purged is implementation specific. Some implementations
may purge all levels of the translation cache hierarchy with one iteration of PTC.e, while other
implementations may require several iterations to flush all levels, sets and associativities of both
instruction and data translation caches. GR r3 specifies an implementation-specific parameter
associated with each iteration.
The following loop is defined to flush the entire translation cache for all processor models.
Software can acquire parameters through a processor dependent layer that is accessed through a
procedural interface. The selected region registers must remain unchanged during the loop.
disable_interrupts();
addr = base;
for (i = 0; i < count1; i++) {
for (j = 0; j < count2; j++) {
ptc.e(addr);
addr += stride2;
}
addr += stride1;
}
enable_interrupts();
This instruction can only be executed at the most privileged level, and when PSR.vm is 0.
Operation: if (PR[qp]) {
if (PSR.cpl!= 0)
privileged_operation_fault(0);
if (GR[r3].nat)
register_nat_consumption_fault(0);
if (PSR.vm == 1)
virtualization_fault();
tlb_purge_translation_cache(GR[r3]);
}
Serialization: Software must issue a data serialization operation to ensure the purge is complete before issuing a
data access or non-access reference dependent upon the purge. Software must issue instruction
serialize operation before fetching an instruction dependent upon the purge.
Description: The instruction and data translation cache for each processor in the local TLB coherence domain
are searched for all entries whose virtual address and page size partially or completely overlap the
specified purge virtual address and purge address range. These entries are removed.
The purge virtual address is specified by GR r3 bits{60:0} and the purge region identifier is
selected by GR r3 bits {63:61}. GR r2 specifies the address range of the purge as 1<<GR[r2]{7:2}
bytes in size.
Based on the processor model, the translation cache may be also purged of more translations than
specified by the purge parameters up to and including removal of all entries within the translation
cache.
ptc.g has release semantics and is guaranteed to be made visible after all previous data memory
accesses are made visible. The memory fence instruction forces all processors to complete the
purge prior to any subsequent memory operations. Serialization is still required to observe the
side-effects of a translation being removed.
ptc.g must be the last instruction in an instruction group; otherwise, its behavior (including its
ordering semantics) is undefined.
The behavior of the ptc.ga instruction is similar to ptc.g. In addition to the behavior specified for ptc.g
the ptc.ga instruction encodes an extra bit of information in the broadcast transaction. This
information specifies the purge is due to a page remapping as opposed to a protection change or
page tear down. The remote processors within the coherence domain will then take what ever
additional action is necessary to make their ALAT consistent. The local ALAT is not purged.
This instruction can only be executed at the most privileged level, and when PSR.vm is 0.
Unless specifically supported by the processors and platform, only one global purge transaction
may be issued at a time by all processors, the operation is undefined otherwise. Software is
responsible for enforcing this restriction. Implementations may optionally support multiple
concurrent global purge transactions. The firmware returns if implementations support this optional
behavior. It also returns the maximum number of simultaneous outstanding purges allowed.
Propagation of ptc.g between multiple local TLB coherence domains is platform dependent, and
must be handled by software. It is expected that the local TLB coherence domain covers at least the
processors on the same local bus.
Operation: if (PR[qp]) {
if (!followed_by_stop())
undefined_behavior();
if (PSR.cpl!= 0)
privileged_operation_fault(0);
if (GR[r3].nat || GR[r2].nat)
register_nat_consumption_fault(0);
if (unimplemented_virtual_address(GR[r3], PSR.vm))
unimplemented_data_address_fault(0);
if (PSR.vm == 1)
virtualization_fault();
tmp_rid = RR[GR[r3]{63:61}].rid;
tmp_va = GR[r3]{60:0};
tmp_size = GR[r2]{7:2};
tmp_va = align_to_size_boundary(tmp_va, tmp_size);
tlb_must_purge_dtc_entries(tmp_rid, tmp_va, tmp_size);
Serialization: The broadcast purge TC is not synchronized with the instruction stream on a remote processor.
Software cannot depend on any such synchronization with the instruction stream. Hardware on the
remote machine cannot reload an instruction from memory or cache after acknowledging a
broadcast purge TC without first retranslating the I-side access in the TLB. Hardware may continue
to use a valid private copy of the instruction stream data (possibly in an I-buffer) obtained prior to
acknowledging a broadcast purge TC to a page containing the i-stream data. Hardware must
retranslate access to an instruction page upon an interruption or any explicit or implicit instruction
serialization event (e.g., srlz.i, rfi).
Software must issue the appropriate data and/or instruction serialization operation to ensure the
purge is completed before a local data access, non-access reference, or local instruction fetch access
dependent upon the purge.
Description: The instruction and data translation cache of the local processor is searched for all entries whose
virtual address and page size partially or completely overlap the specified purge virtual address and
purge address range. All these entries are removed.
The purge virtual address is specified by GR r3 bits{60:0} and the purge region identifier is
selected by GR r3 bits {63:61}. GR r2 specifies the address range of the purge as 1<<GR[r2]{7:2}
bytes in size.
The processor ensures that all entries matching the purging parameters are removed. However,
based on the processor model, the translation cache may be also purged of more translations than
specified by the purge parameters up to and including removal of all entries within the translation
cache.
This instruction can only be executed at the most privileged level, and when PSR.vm is 0.
This is a local operation, no purge broadcast to other processors occurs in a multiprocessor system.
This instruction ensures that all prior stores are made locally visible before the actual purge
operation is performed.
Operation: if (PR[qp]) {
if (PSR.cpl!= 0)
privileged_operation_fault(0);
if (GR[r3].nat || GR[r2].nat)
register_nat_consumption_fault(0);
if (unimplemented_virtual_address(GR[r3], PSR.vm))
unimplemented_data_address_fault(0);
if (PSR.vm == 1)
virtualization_fault();
tmp_rid = RR[GR[r3]{63:61}].rid;
tmp_va = GR[r3]{60:0};
tmp_size = GR[r2]{7:2};
tmp_va = align_to_size_boundary(tmp_va, tmp_size);
tlb_must_purge_dtc_entries(tmp_rid, tmp_va, tmp_size);
tlb_must_purge_itc_entries(tmp_rid, tmp_va, tmp_size);
}
Serialization: Software must issue the appropriate data and/or instruction serialization operation to ensure the
purge is completed before a data access, non-access reference, or instruction fetch access dependent
upon the purge.
Description: In the data form of this instruction, the data translation registers and caches are searched for all
entries whose virtual address and page size partially or completely overlap the specified purge
virtual address and purge address range. All these entries are removed. Entries in the instruction
translation registers are unaffected by the data form of the purge.
In the instruction form, the instruction translation registers and caches are searched for all entries
whose virtual address and page size partially or completely overlap the specified purge virtual
address and purge address range. All these entries are removed. Entries in the data translation
registers are unaffected by the instruction form of the purge.
In addition, in both forms, the instruction and data translation cache may be purged of more
translations than specified by the purge parameters up to and including removal of all entries within
the translation cache.
The purge virtual address is specified by GR r3 bits{60:0} and the purge region identifier is
selected by GR r3 bits {63:61}. GR r2 specifies the address range of the purge as 1<<GR[r2]{7:2}
bytes in size.
This instruction can only be executed at the most privileged level, and when PSR.vm is 0.
This is a local operation, no purge broadcast to other processors occurs in a multiprocessor system.
As described in Section 4.1.1.2, “Translation Cache (TC)” on page 2:45, the processor may use the
translation caches to cache virtual address mappings held by translation registers. The ptr.i and ptr.d
instructions purge the processor’s translation registers as well as cached translation register copies
that may be contained in the respective translation caches.
Operation: if (PR[qp]) {
if (PSR.cpl!= 0)
privileged_operation_fault(0);
if (GR[r3].nat || GR[r2].nat)
register_nat_consumption_fault(0);
if (unimplemented_virtual_address(GR[r3], PSR.vm))
unimplemented_data_address_fault(0);
if (PSR.vm == 1)
virtualization_fault();
tmp_rid = RR[GR[r3]{63:61}].rid;
tmp_va = GR[r3]{60:0};
tmp_size = GR[r2]{7:2};
tmp_va = align_to_size_boundary(tmp_va, tmp_size);
if (data_form) {
tlb_must_purge_dtr_entries(tmp_rid, tmp_va, tmp_size);
tlb_must_purge_dtc_entries(tmp_rid, tmp_va, tmp_size);
tlb_may_purge_itc_entries(tmp_rid, tmp_va, tmp_size);
} else { // instruction_form
tlb_must_purge_itr_entries(tmp_rid, tmp_va, tmp_size);
tlb_must_purge_itc_entries(tmp_rid, tmp_va, tmp_size);
tlb_may_purge_dtc_entries(tmp_rid, tmp_va, tmp_size);
}
}
Serialization: For the data form, software must issue a data serialization operation to ensure the purge is
completed before issuing an instruction dependent upon the purge. For the instruction form,
software must issue an instruction serialization operation to ensure the purge is completed before
fetching an instruction dependent on that purge.
Description: The machine context prior to an interruption is restored. PSR is restored from IPSR, IPSR is
unmodified, and IP is restored from IIP. Execution continues at the bundle address loaded into the
IP, and the instruction slot loaded into PSR.ri.
This instruction must be immediately followed by a stop; otherwise, operation is undefined. This
instruction switches to the register bank specified by IPSR.bn. Instructions in the same instruction
group that access GR16 to GR31 reference the previous register bank. Subsequent instruction
groups reference the new register bank.
This instruction performs instruction serialization, which ensures:
• prior modifications to processor register resources that affect fetching of subsequent
instruction groups are observed.
• prior modifications to processor register resources that affect subsequent execution or data
memory accesses are observed.
• prior memory synchronization (sync.i) operations have taken effect on the local processor
instruction cache.
• subsequent instruction group fetches (including the target instruction group) are re-initiated
after rfi completes.
The rfi instruction must be in an instruction group after the instruction group containing the
operation that is to be serialized.
This instruction can only be executed at the most privileged level, and when PSR.vm is 0. This
instruction can not be predicated.
Execution of this instruction is undefined if PSR.ic or PSR.i are 1. Software must ensure that an
interruption cannot occur that could modify IIP, IPSR, or IFS between when they are written and
the subsequent rfi.
Execution of this instruction is undefined if IPSR.ic is 0 and the current register stack frame is
incomplete.
This instruction does not take Lower Privilege Transfer, Taken Branch or Single Step traps.
If this instruction sets PSR.ri to 2 and the target is an MLX bundle, then an Illegal Operation fault
will be taken on the target bundle.
If IPSR.is is 1, control is resumed in the IA-32 instruction set at the virtual linear address specified
by IIP{31:0}. PSR.di does not inhibit instruction set transitions for this instruction. If PSR.dfh is 1
after rfi completes execution, a Disabled FP Register fault is raised on the target IA-32 instruction.
If IPSR.is is 1 and an Unimplemented Instruction Address trap is taken, IIP will contain the original
64-bit target IP. (The value will not have been zero extended from 32 bits.)
When entering the IA-32 instruction set, the size of the current stack frame is set to zero, and all
stacked general registers are left in an undefined state. Software can not rely on the value of these
registers across an instruction set transition. Software must ensure that BSPSTORE==BSP on entry
to the IA-32 instruction set, otherwise undefined behavior may result.
If IPSR.is is 1, software must set other IPSR fields properly for IA-32 instruction set execution;
otherwise processor operation is undefined. See Table 3-2, “Processor Status Register Fields” on
page 2:21 for details.
Software must issue a mf instruction before this instruction if memory ordering is required between
IA-32 processor-consistent and Itanium unordered memory references. The processor does not
ensure Itanium-instruction-set-generated writes into the instruction stream are seen by subsequent
IA-32 instructions.
Software must ensure the code segment descriptor and selector are loaded before issuing this
instruction. If the target EIP value exceeds the code segment limit or has a code segment privilege
violation, an IA_32_Exception(GPFault) exception is raised on the target IA-32 instruction. For
entry into 16-bit IA-32 code, if IIP is not within 64K-bytes of CSD.base a GPFault is raised on the
target instruction.
EFLAG.rf and PSR.id are unmodified until the successful completion of the target IA-32
instruction. PSR.da, PSR.dd, PSR.ia and PSR.ed are cleared to zero before the target IA-32
instruction begins execution.
IA-32 instruction set execution leaves the contents of the ALAT undefined. Software can not rely
on ALAT state across an instruction set transition. On entry to IA-32 code, existing entries in the
ALAT are ignored.
Operation: if (!followed_by_stop())
undefined_behavior();
unimplemented_address = 0;
if (PSR.cpl!= 0)
privileged_operation_fault(0);
if (PSR.vm == 1)
virtualization_fault();
taken_rfi = 1;
PSR = CR[IPSR];
if (CR[IPSR].is == 1) { //resume IA-32 instruction set
if (CR[IPSR].ic == 0 || CR[IPSR].dt == 0 ||
CR[IPSR].mc == 1 || CR[IPSR].it == 0)
undefined_behavior();
tmp_IP = CR[IIP];
if (!impl_uia_fault_supported() &&
((CR[IPSR].it && unimplemented_virtual_address(tmp_IP, IPSR.vm))
|| (!CR[IPSR].it && unimplemented_physical_address(tmp_IP))))
unimplemented_address = 1;
//compute effective instruction pointer
EIP{31:0} = CR[IIP]{31:0} - AR[CSD].Base;
//force zero-sized restored frame
rse_restore_frame(0, 0, CFM.sof);
CFM.sof = 0;
CFM.sol = 0;
CFM.sor = 0;
CFM.rrb.gr = 0;
CFM.rrb.fr = 0;
CFM.rrb.pr = 0;
rse_invalidate_non_current_regs();
//The register stack engine is disabled during IA-32
//instruction set execution.
} else { //return to Itanium instruction set
tmp_IP = CR[IIP] & ~0xf;
slot = CR[IPSR].ri;
if ((CR[IPSR].it && unimplemented_virtual_address(tmp_IP, IPSR.vm))
|| (!CR[IPSR].it && unimplemented_physical_address(tmp_IP)))
unimplemented_address = 1;
if (CR[IFS].v) {
tmp_growth = -CFM.sof;
alat_frame_update(-CR[IFS].ifm.sof, 0);
rse_restore_frame(CR[IFS].ifm.sof, tmp_growth, CFM.sof);
CFM = CR[IFS].ifm;
}
rse_enable_current_frame_load();
}
IP = tmp_IP;
instruction_serialize();
if (unimplemented_address)
unimplemented_instruction_address_trap(0, tmp_IP);
Description: The complement of the imm24 operand is ANDed with the system mask (PSR{23:0}) and the result
is placed in the system mask. See Section 3.3.2, “Processor Status Register (PSR)” on page 2:20.
The PSR system mask can only be written at the most privileged level, and when PSR.vm is 0.
When the current privilege level is zero (PSR.cpl is 0), an rsm instruction whose mask includes
PSR.i may cause external interrupts to be disabled for an implementation-dependent number of
instructions, even if the qualifying predicate for the rsm instruction is false. Architecturally, the
extents of this external interrupt disabling “window” are defined as follows:
• External interrupts may be disabled for any instructions in the same instruction group as the
rsm, including those that precede the rsm in sequential program order, regardless of the value of
the qualifying predicate of the rsm instruction.
• If the qualifying predicate of the rsm is true, then external interrupts are disabled immediately
following the rsm instruction.
• If the qualifying predicate of the rsm is false, then external interrupts may be disabled until the
next data serialization operation that follows the rsm instruction.
The external interrupt disable window is guaranteed to be no larger than defined by the above
criteria, but it may be smaller, depending on the processor implementation.
When the current privilege level is non-zero (PSR.cpl is not 0), an rsm instruction whose mask
includes PSR.i may briefly disable external interrupts, regardless of the value of the qualifying
predicate of the rsm instruction. However, processor implementations guarantee that non-privileged
code cannot lock out external interrupts indefinitely (e.g., via an arbitrarily long sequence of rsm
instructions with zero-valued qualifying predicates).
Operation: if (PR[qp]) {
if (PSR.cpl!= 0)
privileged_operation_fault(0);
if (PSR.vm == 1)
virtualization_fault();
Serialization: Software must use a data serialize or instruction serialize operation before issuing instructions
dependent upon the altered PSR bits – except the PSR.i bit. The PSR.i bit is implicitly serialized
and the processor ensures that external interrupts are masked by the time the next instruction
executes.
Description: The complement of the imm24 operand is ANDed with the user mask (PSR{5:0}) and the result is
placed in the user mask. See Section 3.3.2, “Processor Status Register (PSR)” on page 2:20.
PSR.up is only cleared if the secure performance monitor bit (PSR.sp) is zero. Otherwise PSR.up is
not modified.
Operation: if (PR[qp]) {
if (is_reserved_field(PSR_TYPE, PSR_UM, imm24))
reserved_register_field_fault();
Serialization: All user mask modifications are observed by the next instruction group.
Description: In the single and double forms, GR r2 is treated as a single precision (in the single_form) or double
precision (in the double_form) memory representation, converted into floating-point register
format, and placed in FR f1, as shown in Figure 5-4 and Figure 5-5 on page 1:89, respectively.
In the exponent_form, bits 16:0 of GR r2 are copied to the exponent field of FR f1 and bit 17 of GR
r2 is copied to the sign bit of FR f1. The significand field of FR f1 is set to one (0x800...000).
63 18 17 0
GR r1
63 0
GR r1
FR f1 0 0x1003E significand
For all forms, if the NaT bit corresponding to r2 is equal to 1, FR f1 is set to NaTVal instead of the
computed result.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, 0, 0, 0))
disabled_fp_register_fault(tmp_isrcode, 0);
if (!GR[r2].nat) {
if (single_form)
FR[f1] = fp_mem_to_fr_format(GR[r2], 4, 0);
else if (double_form)
FR[f1] = fp_mem_to_fr_format(GR[r2], 8, 0);
else if (significand_form) {
FR[f1].significand = GR[r2];
FR[f1].exponent = FP_INTEGER_EXP;
FR[f1].sign = 0;
} else { // exponent_form
FR[f1].significand = 0x8000000000000000;
FR[f1].exp = GR[r2]{16:0};
FR[f1].sign = GR[r2]{17};
}
} else
FR[f1] = NATVAL;
fp_update_psr(f1);
}
Description: The value in GR r2 is shifted to the left, with the vacated bit positions filled with zeroes, and placed
in GR r1. The number of bit positions to shift is specified by the value in GR r3 or by an immediate
value count6. The shift count is interpreted as an unsigned number. If the value in GR r3 is greater
than 63, then the result is all zeroes.
See “dep — Deposit” on page 3:48 for the immediate form.
Operation: if (PR[qp]) {
check_target_register(r1);
count = GR[r3];
GR[r1] = (count > 63)? 0: GR[r2] << count;
Description: The first source operand is shifted to the left by count2 bits and then added to the second source
operand and the result placed in GR r1. The first operand can be shifted by 1, 2, 3, or 4 bits.
Operation: if (PR[qp]) {
check_target_register(r1);
Description: The first source operand is shifted to the left by count2 bits and then is added to the second source
operand. The upper 32 bits of the result are forced to zero, and then bits {31:30} of GR r3 are
copied to bits {62:61} of the result. This result is placed in GR r1. The first operand can be shifted
by 1, 2, 3, or 4 bits.
GR r2: GR r3:
GR r1: 0 0
Operation: if (PR[qp]) {
check_target_register(r1);
Description: The value in GR r3 is shifted to the right and placed in GR r1. In the signed_form the vacated bit
positions are filled with bit 63 of GR r3; in the unsigned_form the vacated bit positions are filled
with zeroes. The number of bit positions to shift is specified by the value in GR r2 or by an
immediate value count6. The shift count is interpreted as an unsigned number. If the value in GR r2
is greater than 63, then the result is all zeroes (for the unsigned_form, or if bit 63 of GR r3 was 0) or
all ones (for the signed_form if bit 63 of GR r3 was 1).
If the.u completer is specified, the shift is unsigned (logical), otherwise it is signed (arithmetic).
See “extr — Extract” on page 3:51 for the immediate forms.
Operation: if (PR[qp]) {
check_target_register(r1);
if (signed_form) {
count = (GR[r2] > 63)? 63: GR[r2];
GR[r1] = shift_right_signed(GR[r3], count);
} else {
count = GR[r2];
GR[r1] = (count > 63)? 0: shift_right_unsigned(GR[r3], count);
}
Description: The two source operands, GR r2 and GR r3, are concatenated to form a 128-bit value and shifted to
the right count6 bits. The least-significant 64 bits of the result are placed in GR r1.
The immediate value count6 can be any number in the range 0 to 63.
GR r2: GR r3:
GR r1:
Operation: if (PR[qp]) {
check_target_register(r1);
srlz — Serialize
Format: (qp) srlz.i instruction_form M24
(qp) srlz.d data_form M24
Operation: if (PR[qp]) {
if (instruction_form)
instruction_serialize();
else // data_form
data_serialize();
}
Interruptions: None
Description: The imm24 operand is ORed with the system mask (PSR{23:0}) and the result is placed in the
system mask. See Section 3.3.2, “Processor Status Register (PSR)” on page 2:20.
The PSR system mask can only be written at the most privileged level, and when PSR.vm is 0.
The contents of the interruption resources (that are overwritten when the PSR.ic bit is 1), are
undefined if an interruption occurs between the enabling of the PSR.ic bit and a subsequent
instruction serialize operation.
Operation: if (PR[qp]) {
if (PSR.cpl!= 0)
privileged_operation_fault(0);
if (PSR.vm == 1)
virtualization_fault();
Serialization: Software must issue a data serialize or instruction serialize operation before issuing instructions
dependent upon the altered PSR bits from the ssm instruction. Unlike with the rsm instruction,
setting the PSR.i bit is not treated specially. Refer to Section 3.2, “Serialization” on page 2:15 for a
description of serialization.
st — Store
Format: (qp) stsz.sttype.sthint [r3] = r2 normal_form, no_base_update_form M4
(qp) stsz.sttype.sthint [r3] = r2, imm9 normal_form, imm_base_update_form M5
(qp) st16.sttype.sthint [r3] = r2, ar.csd sixteen_byte_form, no_base_update_form M4
(qp) st8.spill.sthint [r3] = r2 spill_form, no_base_update_form M4
(qp) st8.spill.sthint [r3] = r2, imm9 spill_form, imm_base_update_form M5
Description: A value consisting of the least significant sz bytes of the value in GR r2 is written to memory
starting at the address specified by the value in GR r3. The values of the sz completer are given in
Table 2-32 on page 3:138. The sttype completer specifies special store operations, which are
described in Table 2-49. If the NaT bit corresponding to GR r3 is 1, or in sixteen_byte_form or
normal_form, if the NaT bit corresponding to GR r2 is 1, a Register NaT Consumption fault is
taken.
In the sixteen_byte_form, two 8-byte values are stored as a single, 16-byte atomic memory write.
The value in GR r2 is written to memory starting at the address specified by the value in GR r3. The
value in the Compare and Store Data application register (AR[CSD]) is written to memory starting
at the address specified by the value in GR r3 plus 8.
In the spill_form, an 8-byte value is stored, and the NaT bit corresponding to GR r2 is copied to a
bit in the UNAT application register. This instruction is used for spilling a register/NaT pair. See
Section 4.4.4, “Control Speculation” on page 1:56 for details.
In the imm_base_update form, the value in GR r3 is added to a signed immediate value (imm9) and
the result is placed back in GR r3. This base register update is done after the store, and does not
affect the store address, nor the value stored (for the case where r2 and r3 specify the same register).
Base register update is not supported for the st16 instruction.
For more details on ordered stores see Section 4.4.7, “Memory Access Ordering” on page 1:68.
The ALAT is queried using the physical memory address and the access size, and all overlapping
entries are invalidated.
The value of the sthint completer specifies the locality of the memory access. The values of the
sthint completer are given in Table 2-50. A prefetch hint is implied in the base update forms. The
address specified by the value in GR r3 after the base update acts as a hint to prefetch the indicated
cache line. This prefetch uses the locality hints specified by sthint. See Section 4.4.6, “Memory
Hierarchy Control and Consistency” on page 1:64.
Hardware support for st16 instructions that reference a page that is neither a cacheable page with
write-back policy nor a NaTPage is optional. On processor models that do not support such st16
accesses, an Unsupported Data Reference fault is raised when an unsupported reference is
attempted.
For the sixteen_byte_form, Illegal Operation fault is raised on processor models that do not support
the instruction. CPUID register 4 indicates the presence of the feature on the processor model. See
Section 3.1.11, “Processor Identification Registers” on page 1:31 for details.
Operation: if (PR[qp]) {
size = spill_form? 8: (sixteen_byte_form? 16: sz);
itype = WRITE;
if (size == 16) itype |= UNCACHE_OPT;
otype = (sttype == ‘rel’)? RELEASE: UNORDERED;
if (sixteen_byte_form &&!instruction_implemented(ST16))
illegal_operation_fault();
if (imm_base_update_form)
check_target_register(r3);
if (GR[r3].nat || ((sixteen_byte_form || normal_form) && GR[r2].nat))
register_nat_consumption_fault(WRITE);
if (spill_form) {
bit_pos = GR[r3]{8:3};
AR[UNAT]{bit_pos} = GR[r2].nat;
}
alat_inval_multiple_entries(paddr, size);
if (imm_base_update_form) {
GR[r3] = GR[r3] + sign_ext(imm9, 9);
GR[r3].nat = 0;
mem_implicit_prefetch(GR[r3], sthint, WRITE);
}
}
Description: A value, consisting of fsz bytes, is generated from the value in FR f2 and written to memory starting
at the address specified by the value in GR r3. In the normal_form, the value in FR f2 is converted
to the memory format and then stored. In the integer_form, the significand of FR f2 is stored. The
values of the fsz completer are given in Table 2-35 on page 3:143. In the normal_form or the
integer_form, if the NaT bit corresponding to GR r3 is 1 or if FR f2 contains NaTVal, a Register
NaT Consumption fault is taken. See Section 5.1, “Data Types and Formats” on page 1:81 for
details on conversion from floating-point register format.
In the spill_form, a 16-byte value from FR f2 is stored without conversion. This instruction is used
for spilling a register. See Section 4.4.4, “Control Speculation” on page 1:56 for details.
In the imm_base_update form, the value in GR r3 is added to a signed immediate value (imm9) and
the result is placed back in GR r3. This base register update is done after the store, and does not
affect the store address.
The ALAT is queried using the physical memory address and the access size, and all overlapping
entries are invalidated.
The value of the sthint completer specifies the locality of the memory access. The values of the
sthint completer are given in Table 2-50 on page 3:230. A prefetch hint is implied in the base
update forms. The address specified by the value in GR r3 after the base update acts as a hint to
prefetch the indicated cache line. This prefetch uses the locality hints specified by sthint. See
Section 4.4.6, “Memory Hierarchy Control and Consistency” on page 1:64.
Hardware support for stfe (10-byte) instructions that reference a page that is neither a cacheable
page with write-back policy nor a NaTPage is optional. On processor models that do not support
such stfe accesses, an Unsupported Data Reference fault is raised when an unsupported reference is
attempted.
Operation: if (PR[qp]) {
if (imm_base_update_form)
check_target_register(r3);
if (tmp_isrcode = fp_reg_disabled(f2, 0, 0, 0))
disabled_fp_register_fault(tmp_isrcode, WRITE);
alat_inval_multiple_entries(paddr, size);
if (imm_base_update_form) {
GR[r3] = GR[r3] + sign_ext(imm9, 9);
GR[r3].nat = 0;
mem_implicit_prefetch(GR[r3], sthint, WRITE);
}
}
sub — Subtract
Format: (qp) sub r1 = r2, r3 register_form A1
(qp) sub r1 = r2, r3, 1 minus1_form, register_form A1
(qp) sub r1 = imm8, r3 imm8_form A3
Description: The second source operand (and an optional constant 1) are subtracted from the first operand and
the result placed in GR r1. In the register form the first operand is GR r2; in the immediate form the
first operand is taken from the sign-extended imm8 encoding field.
The minus1_form is available only in the register_form (although the equivalent effect can be
achieved by adjusting the immediate).
Operation: if (PR[qp]) {
check_target_register(r1);
if (minus1_form)
GR[r1] = tmp_src - GR[r3] - 1;
else
GR[r1] = tmp_src - GR[r3];
Description: The imm24 operand is ORed with the user mask (PSR{5:0}) and the result is placed in the user
mask. See Section 3.3.2, “Processor Status Register (PSR)” on page 2:20.
PSR.up can only be set if the secure performance monitor bit (PSR.sp) is zero. Otherwise PSR.up is
not modified.
Operation: if (PR[qp]) {
if (is_reserved_field(PSR_TYPE, PSR_UM, imm24))
reserved_register_field_fault();
Serialization: All user mask modifications are observed by the next instruction group.
Description: The value in GR r3 is sign extended from the bit position specified by xsz and the result is placed in
GR r1. The mnemonic values for xsz are given in Table 2-51.
Operation: if (PR[qp]) {
check_target_register(r1);
Description: sync.i ensures that when previously initiated Flush Cache (fc, fc.i) operations issued by the local
processor become visible to local data memory references, prior Flush Cache operations are also
observed by the local processor instruction fetch stream. sync.i also ensures that at the time
previously initiated Flush Cache (fc, fc.i) operations are observed on a remote processor by data
memory references they are also observed by instruction memory references on the remote
processor. sync.i is ordered with respect to all cache flush operations as observed by another
processor. A sync.i and a previous fc must be in separate instruction groups. If semantically
required, the programmer must explicitly insert ordered data references (acquire, release or fence
type) to appropriately constrain sync.i (and hence fc and fc.i) visibility to the data stream on other
processors.
sync.i is used to maintain an ordering relationship between instruction and data caches on local and
remote processors. An instruction serialize operation must be used to ensure synchronization
initiated by sync.i on the local processor has been observed by a given point in program execution.
An example of self-modifying code (local processor):
Operation: if (PR[qp]) {
instruction_synchronize();
}
Interruptions: None
Description: The protection key for a given virtual address is obtained and placed in GR r1.
When PSR.dt is 1, the DTLB and the VHPT are searched for the virtual address specified by GR r3
and the region register indexed by GR r3 bits {63:61}. If a matching present translation is found,
the protection key of the translation is placed in bits 31:8 of GR r1. If a matching present translation
is not found or if an unimplemented virtual address is specified by GR r3, the value 1 is returned.
When PSR.dt is 0, only the DTLB is searched, because the VHPT walker is disabled. If no
matching present translation is found in the DTLB, the value 1 is returned.
A translation with the NaTPage attribute is not treated differently and returns its key field.
This instruction can only be executed at the most privileged level, and when PSR.vm is 0.
Operation: if (PR[qp]) {
itype = NON_ACCESS|TAK;
check_target_register(r1);
if (PSR.cpl!= 0)
privileged_operation_fault(itype);
if (GR[r3].nat)
register_nat_consumption_fault(itype);
if (PSR.vm == 1)
virtualization_fault();
Description: The bit specified by the pos6 immediate is selected from GR r3. The selected bit forms a single bit
result either complemented or not depending on the trel completer. This result is written to the two
predicate register destinations p1 and p2. The way the result is written to the destinations is
determined by the compare type specified by ctype. See the Compare instruction and Table 2-15 on
page 3:37.
The trel completer values.nz and.z indicate non-zero and zero sense of the test. For normal and unc
types, only the.z value is directly implemented in hardware; the.nz value is actually a pseudo-op.
For it, the assembler simply switches the predicate target specifiers and uses the implemented
relation. For the parallel types, both relations are implemented in hardware.
Table 2-52. Test Bit Relations for Normal and unc tbits
trel Test Relation Pseudo-op of
nz selected bit == 1 z p1 ´ p2
z selected bit == 0
If the two predicate register destinations are the same (p1 and p2 specify the same predicate
register), the instruction will take an Illegal Operation fault, if the qualifying predicate is set, or if
the compare type is unc.
Operation: if (PR[qp]) {
if (p1 == p2)
illegal_operation_fault();
switch (ctype) {
case ‘and’: // and-type compare
if (GR[r3].nat ||!tmp_rel) {
PR[p1] = 0;
PR[p2] = 0;
}
break;
case ‘or’: // or-type compare
if (!GR[r3].nat && tmp_rel) {
PR[p1] = 1;
PR[p2] = 1;
}
break;
case ‘or.andcm’: // or.andcm-type compare
if (!GR[r3].nat && tmp_rel) {
PR[p1] = 1;
PR[p2] = 0;
}
break;
case ‘unc’: // unc-type compare
default: // normal compare
if (GR[r3].nat) {
PR[p1] = 0;
PR[p2] = 0;
} else {
PR[p1] = tmp_rel;
PR[p2] =!tmp_rel;
}
break;
}
} else {
if (ctype == ‘unc’) {
if (p1 == p2)
illegal_operation_fault();
PR[p1] = 0;
PR[p2] = 0;
}
}
tf — Test Feature
Format: (qp) tf.trel.ctype p1, p2 = imm5 I30
Description: The imm5 value (in the range of 32-63) selects the feature bit defined in Table 2-56 to be tested
from the features vector in CPUID[4]. See Section 3.1.11, “Processor Identification Registers” on
page 1:31 for details on CPUID registers. The selected bit forms a single-bit result either
complemented or not depending on the trel completer. This result is written to the two predicate
register destinations p1 and p2. The way the result is written to the destinations is determined by the
compare type specified by ctype. See the Compare instruction and Table 2-15 on page 3:37.
The trel completer values.nz and.z indicate non-zero and zero sense of the test. For normal and unc
types, only the.z value is directly implemented in hardware; the.nz value is actually a pseudo-op.
For it, the assembler simply switches the predicate target specifiers and uses the implemented
relation. For the parallel types, both relations are implemented in hardware.
If the two predicate register destinations are the same (p1 and p2 specify the same predicate
register), the instruction will take an Illegal Operation fault, if the qualifying predicate is set or the
compare type is unc.
Operation: if (PR[qp]) {
if (p1 == p2)
illegal_operation_fault();
if (PSR.vm == 1 && vm_tf_disabled())
virtualization_fault();
tmp_rel = cpuid[4]{imm5};
switch (ctype) {
case ‘and’: // and-type compare
if (!tmp_rel) {
PR[p1] = 0;
PR[p2] = 0;
}
break;
case ‘or’: // or-type compare
if (tmp_rel) {
PR[p1] = 1;
PR[p2] = 1;
}
break;
case ‘or.andcm’: // or.andcm-type compare
if (tmp_rel) {
PR[p1] = 1;
PR[p2] = 0;
}
break;
case ‘unc’: // unc-type compare
default: // normal compare
PR[p1] = tmp_rel;
PR[p2] =!tmp_rel;
break;
}
} else {
if (ctype == ‘unc’) {
if (p1 == p2)
illegal_operation_fault();
if (PSR.vm == 1 && vm_tf_disabled())
virtualization_fault();
PR[p1] = 0;
PR[p2] = 0;
}
}
Description: A Virtual Hashed Page Table (VHPT) entry address is generated based on the specified virtual
address and the result is placed in GR r1. The virtual address is specified by GR r3 and the region
register selected by GR r3 bits {63:61}.
If thash is given a NaT input argument or an unimplemented virtual address as an input, the
resulting target register value is undefined, and its NaT bit is set to one.
When the processor is configured to use the region-based short format VHPT (PTA.vf=0), the value
returned by thash is defined by the architected short format hash function. See Section 4.1.5.3,
“Region-based VHPT Short Format” on page 2:58.
When the processor is configured to use the long format VHPT (PTA.vf=1), thash performs an
implementation-specific long format hash function on the virtual address to generate a hash index
into the long format VHPT.
In the long format, a translation in the VHPT must be uniquely identified by its hash index
generated by this instruction and the hash tag produced from the ttag instruction.
The hash function must use all implemented region bits and only virtual address bits {60:0} to
determine the offset into the VHPT. Virtual address bits {63:61} are used only by the short format
hash to determine the region of the VHPT.
This instruction must be implemented on all processor models, even processor models that do not
implement a VHPT walker.
This instruction can only be executed when PSR.vm is 0.
Operation: if (PR[qp]) {
check_target_register(r1);
if (PSR.vm == 1)
virtualization_fault();
Description: The NaT bit from GR r3 forms a single bit result, either complemented or not depending on the trel
completer. This result is written to the two predicate register destinations, p1 and p2. The way the
result is written to the destinations is determined by the compare type specified by ctype. See the
Compare instruction and Table 2-15 on page 3:37.
The trel completer values.nz and.z indicate non-zero and zero sense of the test. For normal and unc
types, only the.z value is directly implemented in hardware; the.nz value is actually a pseudo-op.
For it, the assembler simply switches the predicate target specifiers and uses the implemented
relation. For the parallel types, both relations are implemented in hardware.
Table 2-57. Test NaT Relations for Normal and unc tnats
trel Test Relation Pseudo-op of
nz selected bit == 1 z p1 ´ p2
z selected bit == 0
If the two predicate register destinations are the same (p1 and p2 specify the same predicate
register), the instruction will take an Illegal Operation fault, if the qualifying predicate is set, or if
the compare type is unc.
Operation: if (PR[qp]) {
if (p1 == p2)
illegal_operation_fault();
switch (ctype) {
case ‘and’: // and-type compare
if (!tmp_rel) {
PR[p1] = 0;
PR[p2] = 0;
}
break;
case ‘or’: // or-type compare
if (tmp_rel) {
PR[p1] = 1;
PR[p2] = 1;
}
break;
case ‘or.andcm’: // or.andcm-type compare
if (tmp_rel) {
PR[p1] = 1;
PR[p2] = 0;
}
break;
case ‘unc’: // unc-type compare
default: // normal compare
PR[p1] = tmp_rel;
PR[p2] =!tmp_rel;
break;
}
} else {
if (ctype == ‘unc’) {
if (p1 == p2)
illegal_operation_fault();
PR[p1] = 0;
PR[p2] = 0;
}
}
Description: The physical address for the virtual address specified by GR r3 is obtained and placed in GR r1.
When PSR.dt is 1, the DTLB and the VHPT are searched for the virtual address specified by GR r3
and the region register indexed by GR r3 bits {63:61}. If a matching present translation is found the
physical address of the translation is placed in GR r1. If a matching present translation is not found
the appropriate TLB fault is taken.
When PSR.dt is 0, only the DTLB is searched, because the VHPT walker is disabled. If no
matching present translation is found in the DTLB, an Alternate Data TLB fault is raised if psr.ic is
one or a Data Nested TLB fault is raised if psr.ic is zero.
If this instruction faults, then it will set the non-access bit in the ISR. The ISR read and write bits
are not set.
This instruction can only be executed at the most privileged level, and when PSR.vm is 0.
Operation: if (PR[qp]) {
itype = NON_ACCESS|TPA;
check_target_register(r1);
if (PSR.cpl!= 0)
privileged_operation_fault(itype);
if (GR[r3].nat)
register_nat_consumption_fault(itype);
Description: A tag used for matching during searches of the long format Virtual Hashed Page Table (VHPT) is
generated and placed in GR r1. The virtual address is specified by GR r3 and the region register
selected by GR r3 bits {63:61}.
If ttag is given a NaT input argument or an unimplemented virtual address as an input, the resulting
target register value is undefined, and its NaT bit is set to one.
The tag generation function generates an implementation-specific long format VHPT tag. The tag
generation function must use all implemented region bits and only virtual address bits {60:0}.
PTA.vf is ignored by this instruction.
A translation in the long format VHPT must be uniquely identified by its hash index generated by
the thash instruction and the tag produced from this instruction.
This instruction must be implemented on all processor models, even processor models that do not
implement a VHPT walker.
This instruction can only be executed when PSR.vm is 0.
Operation: if (PR[qp]) {
check_target_register(r1);
if (PSR.vm == 1)
virtualization_fault();
unpack — Unpack
Format: (qp) unpack1.h r1 = r2, r3 one_byte_form, high_form I2
(qp) unpack2.h r1 = r2, r3 two_byte_form, high_form I2
(qp) unpack4.h r1 = r2, r3 four_byte_form, high_form I2
(qp) unpack1.l r1 = r2, r3 one_byte_form, low_form I2
(qp) unpack2.l r1 = r2, r3 two_byte_form, low_form I2
(qp) unpack4.l r1 = r2, r3 four_byte_form, low_form I2
Description: The data elements of GR r2 and r3 are unpacked, and the result placed in GR r1. In the high_form,
the most significant elements of each source register are selected, while in the low_form the least
significant elements of each source register are selected. Elements are selected alternately from the
source registers.
GR r2: GR r3:
unpack1.h GR r1:
GR r2: GR r3:
unpack1.l GR r1:
GR r2: GR r3:
unpack2.h GR r1:
GR r2: GR r3:
unpack2.l GR r1:
GR r2: GR r3:
unpack4.h GR r1:
GR r2: GR r3:
unpack4.l GR r1:
Operation: if (PR[qp]) {
check_target_register(r1);
if (high_form)
GR[r1] = concatenate8( x[7], y[7], x[6], y[6],
x[5], y[5], x[4], y[4]);
else // low_form
GR[r1] = concatenate8( x[3], y[3], x[2], y[2],
x[1], y[1], x[0], y[0]);
} else if (two_byte_form) { // two-byte elements
x[0] = GR[r2]{15:0}; y[0] = GR[r3]{15:0};
x[1] = GR[r2]{31:16}; y[1] = GR[r3]{31:16};
x[2] = GR[r2]{47:32}; y[2] = GR[r3]{47:32};
x[3] = GR[r2]{63:48}; y[3] = GR[r3]{63:48};
if (high_form)
GR[r1] = concatenate4(x[3], y[3], x[2], y[2]);
else // low_form
GR[r1] = concatenate4(x[1], y[1], x[0], y[0]);
} else { // four-byte elements
x[0] = GR[r2]{31:0}; y[0] = GR[r3]{31:0};
x[1] = GR[r2]{63:32}; y[1] = GR[r3]{63:32};
if (high_form)
GR[r1] = concatenate2(x[1], y[1]);
else // low_form
GR[r1] = concatenate2(x[0], y[0]);
}
GR[r1].nat = GR[r2].nat || GR[r3].nat;
}
Description: This instruction sets the PSR.vm bit to the specified value. This instruction can be used to
implement transitions to/from virtual machine mode without the overhead of an interruption.
If instruction address translation is enabled and the page containing the vmsw instruction has access
rights equal to 7, then the new value is written to the PSR.vm bit. In the zero_form, PSR.vm is set
to 0, and in the one_form, PSR.vm is set to 1.
Instructions after the vmsw instruction in the same instruction group may be executed with the old
or new value of PSR.vm. Instructions in subsequent instruction groups will be executed with
PSR.vm equal to the new value.
If the above conditions are not met, this instruction takes a Virtualization fault.
This instruction can only be executed at the most privileged level. This instruction cannot be
predicated.
Implementation of PSR.vm is optional. If it is not implemented, this instruction takes Illegal
Operation fault. If it is implemented but is disabled, this instruction takes Virtualization fault when
executed at the most privileged level. See Section 3.4, “Processor Virtualization” on page 2:38 and
PAL_PROC_GET_FEATURES on page 2:429 for details.
Operation: if (!implemented_vm())
illegal_operation fault();
if (PSR.cpl!= 0)
privileged_operation_fault(0);
if (zero_form) {
PSR.vm = 0;
}
else {
PSR.vm = 1;
}
xchg — Exchange
Format: (qp) xchgsz.ldhint r1 = [r3], r2 M16
Description: A value consisting of sz bytes is read from memory starting at the address specified by the value in
GR r3. The least significant sz bytes of the value in GR r2 are written to memory starting at the
address specified by the value in GR r3. The value read from memory is then zero extended and
placed in GR r1 and the NaT bit corresponding to GR r1 is cleared. The values of the sz completer
are given in Table 2-59.
If the address specified by the value in GR r3 is not naturally aligned to the size of the value being
accessed in memory, an Unaligned Data Reference fault is taken independent of the state of the
User Mask alignment checking bit, UM.ac (PSR.ac in the Processor Status Register).
Both read and write access privileges for the referenced page are required.
The exchange is performed with acquire semantics, i.e., the memory read/write is made visible
prior to all subsequent data memory accesses. See Section 4.4.7, “Sequentiality Attribute and
Ordering” on page 2:75 for details on memory ordering.
The memory read and write are guaranteed to be atomic.
This instruction is only supported to cacheable pages with write-back write policy. Accesses to
NaTPages cause a Data NaT Page Consumption fault. Accesses to pages with other memory
attributes cause an Unsupported Data Reference fault.
The value of the ldhint completer specifies the locality of the memory access. The values of the
ldhint completer are given in Table 2-34 on page 3:139. Locality hints do not affect program
functionality and may be ignored by the implementation. See Section 4.4.6, “Memory Hierarchy
Control and Consistency” on page 1:64 for details.
Operation: if (PR[qp]) {
check_target_register(r1);
if (GR[r3].nat || GR[r2].nat)
register_nat_consumption_fault(SEMAPHORE);
if (!ma_supports_semaphores(mattr))
unsupported_data_reference_fault(SEMAPHORE, GR[r3]);
alat_inval_multiple_entries(paddr, sz);
Description: Two source operands (FR f3 and FR f4) are treated as either signed or unsigned integers and
multiplied. The third source operand (FR f2) is zero extended and added to the product. The upper
or lower 64 bits of the resultant sum are selected and placed in FR f1.
In the high_unsigned_form, the significand fields of FR f3 and FR f4 are treated as unsigned
integers and multiplied to produce a full 128-bit unsigned result. The significand field of FR f2 is
zero extended and added to the product. The most significant 64-bits of the resultant sum are placed
in the significand field of FR f1.
In the high_form, the significand fields of FR f3 and FR f4 are treated as signed integers and
multiplied to produce a full 128-bit signed result. The significand field of FR f2 is zero extended
and added to the product. The most significant 64-bits of the resultant sum are placed in the
significand field of FR f1.
In the other forms, the significand fields of FR f3 and FR f4 are treated as signed integers and
multiplied to produce a full 128-bit signed result. The significand field of FR f2 is zero extended
and added to the product. The least significant 64-bits of the resultant sum are placed in the
significand field of FR f1.
In all forms, the exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the
sign field of FR f1 is set to positive (0).
Note: f1 as an operand is not an integer 1; it is just the register file format’s 1.0 value.
In all forms, if any of FR f3, FR f4, or FR f2 is a NaTVal, FR f1 is set to NaTVal instead of the
computed result.
Operation: if (PR[qp]) {
fp_check_target_register(f1);
if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, f4))
disabled_fp_register_fault(tmp_isrcode, 0);
if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) ||
fp_is_natval(FR[f4])) {
FR[f1] = NATVAL;
} else {
if (low_form || high_form)
tmp_res_128 =
fp_I64_x_I64_to_I128(FR[f3].significand, FR[f4].significand);
else // high_unsigned_form
tmp_res_128 =
fp_U64_x_U64_to_U128(FR[f3].significand, FR[f4].significand);
tmp_res_128 =
fp_U128_add(tmp_res_128, fp_U64_to_U128(FR[f2].significand));
if (high_form || high_unsigned_form)
FR[f1].significand = tmp_res_128.hi;
else // low_form
FR[f1].significand = tmp_res_128.lo;
FR[f1].exponent = FP_INTEGER_EXP;
FR[f1].sign = FP_SIGN_POSITIVE;
}
fp_update_psr(f1);
}
Description: Two source operands (FR f3 and FR f4) are treated as either signed or unsigned integers and
multiplied. The upper or lower 64 bits of the resultant product are selected and placed in FR f1.
In the high_unsigned_form, the significand fields of FR f3 and FR f4 are treated as unsigned
integers and multiplied to produce a full 128-bit unsigned result. The most significant 64-bits of the
resultant product are placed in the significand field of FR f1.
In the high_form, the significand fields of FR f3 and FR f4 are treated as signed integers and
multiplied to produce a full 128-bit signed result. The most significant 64-bits of the resultant
product are placed in the significand field of FR f1.
In the other forms, the significand fields of FR f3 and FR f4 are treated as signed integers and
multiplied to produce a full 128-bit signed result. The least significant 64-bits of the resultant
product are placed in the significand field of FR f1.
In all forms, the exponent field of FR f1 is set to the biased exponent for 2.063 (0x1003E) and the
sign field of FR f1 is set to positive (0). Note: f1 as an operand is not an integer 1; it is just the
register file format’s 1.0 value.
xor — Exclusive Or
Format: (qp) xor r1 = r2, r3 register_form A1
(qp) xor r1 = imm8, r3 imm8_form A3
Description: The two source operands are logically XORed and the result placed in GR r1. In the register_form
the first operand is GR r2; in the imm8_form the first operand is taken from the imm8 encoding
field.
Operation: if (PR[qp]) {
check_target_register(r1);
Description: The value in GR r3 is zero extended above the bit position specified by xsz and the result is placed
in GR r1. The mnemonic values for xsz are given in Table 2-51 on page 3:235.
Operation: if (PR[qp]) {
check_target_register(r1);
Pseudo-Code Functions 3
This chapter contains a table of all pseudo-code functions used on the Itanium instruction pages.
Instruction Formats 4
Each Itanium instruction is categorized into one of six types; each instruction type may be executed
on one or more execution unit types. Table 4-1 lists the instruction types and the execution unit type
on which they are executed:
Table 4-1. Relationship between Instruction Type and Execution Unit Type
Instruction
Description Execution Unit Type
Type
A Integer ALU I-unit or M-unit
I Non-ALU integer I-unit
M Memory M-unit
F Floating-point F-unit
B Branch B-unit
L+X Extended I-unit/B-unita
a. L+X Major Opcodes 0 - 7 execute on an I-unit. L+X Major Opcodes 8 - F execute on a B-unit.
Three instructions are grouped together into 128-bit sized and aligned containers called bundles.
Each bundle contains three 41-bit instruction slots and a 5-bit template field. The format of a
bundle is depicted in Figure 4-1.
The template field specifies two properties: stops within the current bundle, and the mapping of
instruction slots to execution unit types. Not all combinations of these two properties are allowed -
Table 4-2 indicates the defined combinations. The three rightmost columns correspond to the three
instruction slots in a bundle; listed within each column is the execution unit type controlled by that
instruction slot for each encoding of the template field. A double line to the right of an instruction
slot indicates that a stop occurs at that point within the current bundle. See “Instruction Encoding
Overview” on page 1:34 for the definition of a stop. Within a bundle, execution order proceeds
from slot 0 to slot 2. Unused template values (appearing as empty rows in Table 4-2) are reserved
and cause an Illegal Operation fault.
Extended instructions, used for long immediate integer and long branch instructions, occupy two
instruction slots. Depending on the major opcode, extended instructions execute on a B-unit (long
branch/call) or an I-unit (all other L+X instructions).
Unused major ops (appearing as blank entries in Table 4-3) behave in one of four ways:
Table 4-4 on page 3:274 summarizes all the instruction formats. The instruction fields are
color-coded for ease of identification, as described in Table 4-5 on page 3:276. A color version of
this chapter is available for those heavily involved in working with the instruction encodings.
The instruction field names, used throughout this chapter, are described in Table 4-6 on page 3:276.
The set of special notations (such as whether an instruction is privileged) are listed in Table 4-7 on
page 3:277. These notations appear in the “Instruction” column of the opcode tables.
Most instruction containing immediates encode those immediates in more than one instruction
field. For example, the 14-bit immediate in the Add Imm14 instruction (format A4) is formed from
the imm7b, imm6d, and s fields. Table 4-74 on page 3:349 shows how the immediates are formed
from the instruction fields for each instruction which has an immediate.
The remaining sections of this chapter present the detailed encodings of all instructions. The
“A-Unit Instruction encodings” are presented first, followed by the “I-Unit Instruction Encodings”
on page 3:288, “M-Unit Instruction Encodings” on page 3:302, “B-Unit Instruction Encodings” on
page 3:330, “F-Unit Instruction Encodings” on page 3:337, and “X-Unit Instruction Encodings” on
page 3:346.
Within each section, the instructions are grouped by function, and appear with their instruction
format in the same order as in Table 4-4, “Instruction Format Summary” on page 3:274. The
opcode extension fields are briefly described and tables present the opcode extension assignments.
Unused instruction encodings (appearing as blank entries in the opcode extensions tables) behave
in one of four ways:
• Ignored instructions (white color entries in the tables) execute as nop instructions.
• Reserved instructions (light gray color in the gray scale version of the tables, brown color in
the color version) cause an Illegal Operation fault.
• Reserved if PR[qp] is 1 instructions (dark gray in the gray scale version of the tables, purple in
the color version) cause an Illegal Operation fault if the predicate register specified by the qp
field of the instruction (bits 5:0) is 1 and execute as a nop instruction if 0.
• Reserved if PR[qp] is 1 B-unit instructions (medium gray in the gray scale version of the
tables, cyan in the color version) cause an Illegal Operation fault if the predicate register
Some processors may implement the Reserved if PR[qp] is 1 (purple) and Reserved if PR[qp] is 1
B-unit (cyan) encodings in the L+X opcode space as Reserved (brown). These encodings appear in
the L+X column of Table 4-3 on page 3:273, and in Table 4-69 on page 3:347, Table 4-70 on
page 3:347, Table 4-71 on page 3:348, and Table 4-72 on page 3:348. On processors which
implement these encodings as Reserved (brown), the operating system is required to provide an
Illegal Operation fault handler which emulates them as Reserved if PR[qp] is 1 (cyan/purple) by
decoding the reserved opcodes, checking the qualifying predicate, and returning to the next
instruction if PR[qp] is 0.
Constant 0 fields in instructions must be 0 or undefined operation results. The undefined operation
may include checking that the constant field is 0 and causing an Illegal Operation fault if it is not. If
an instruction having a constant 0 field also has a qualifying predicate (qp field), the fault or other
undefined operation must not occur if PR[qp] is 0. For constant 0 fields in instruction bits 5:0
(normally used for qp), the fault or other undefined operation may or may not depend on the PR
addressed by those bits.
Ignored (white space) fields in instructions should be coded as 0. Although ignored in this revision
of the architecture, future architecture revisions may define these fields as hint extensions. These
hint extensions will be defined such that the 0 value in each field corresponds to the default hint. It
is expected that assemblers will automatically set these fields to zero by default.
Unused opcode hint extension values (white color entries in Hint Completer tables) should not be
used by software. Processors must perform the architected functional behavior of the instruction
independent of the hint extension value (whether defined or unused), but different processor
models may interpret unused opcode hint extension values in different ways, resulting in
undesirable performance effects.
Opcode x2a ve
Bits Bits Bit 33
40:37 35:34 0 1
0 Integer ALU 4-bit+2-bit Ext (Table 4-9)
1 Multimedia ALU 1-bit+2-bit Ext (Table 4-12)
8
2 adds – imm14 A4
3 addp4 – imm14 A4
A1 8 x2a ve x4 x2b r3 r2 r1 qp
4 1 2 1 4 2 7 7 7 6
Extension
Instruction Operands Opcode
x2a ve x4 x2b
r1 = r2, r3 0
add 0
r1 = r2, r3, 1 1
r1 = r2, r3 1
sub 1
r1 = r2, r3, 1 0
addp4 8 0 0 2 0
and 0
andcm r1 = r2, r3 1
3
or 2
xor 3
A2 8 x2a ve x4 ct2d r3 r2 r1 qp
4 1 2 1 4 2 7 7 7 6
Extension
Instruction Operands Opcode
x2a ve x4
shladd 4
r1 = r2, count2, r3 8 0 0
shladdp4 6
Extension
Instruction Operands Opcode
x2a ve x4 x2b
sub 9 1
and 0
andcm r1 = imm8, r3 8 0 0 1
B
or 2
xor 3
Extension
Instruction Operands Opcode
x2a ve
adds 2
r1 = imm14, r3 8 0
addp4 3
x2 tb ta c Opcode
Bits Bit Bit Bit Bits 40:37
35:34 36 33 12 C D E
0 cmp.lt A6 cmp.ltu A6 cmp.eq A6
0
1 cmp.lt.unc A6 cmp.ltu.unc A6 cmp.eq.unc A6
0
0 cmp.eq.and A6 cmp.eq.or A6 cmp.eq.or.andcm A6
1
1 cmp.ne.and A6 cmp.ne.or A6 cmp.ne.or.andcm A6
0
0 cmp.gt.and A7 cmp.gt.or A7 cmp.gt.or.andcm A7
0
1 cmp.le.and A7 cmp.le.or A7 cmp.le.or.andcm A7
1
0 cmp.ge.and A7 cmp.ge.or A7 cmp.ge.or.andcm A7
1
1 cmp.lt.and A7 cmp.lt.or A7 cmp.lt.or.andcm A7
0 cmp4.lt A6 cmp4.ltu A6 cmp4.eq A6
0
1 cmp4.lt.unc A6 cmp4.ltu.unc A6 cmp4.eq.unc A6
0
0 cmp4.eq.and A6 cmp4.eq.or A6 cmp4.eq.or.andcm A6
1
1 cmp4.ne.and A6 cmp4.ne.or A6 cmp4.ne.or.andcm A6
1
0 cmp4.gt.and A7 cmp4.gt.or A7 cmp4.gt.or.andcm A7
0
1 cmp4.le.and A7 cmp4.le.or A7 cmp4.le.or.andcm A7
1
0 cmp4.ge.and A7 cmp4.ge.or A7 cmp4.ge.or.andcm A7
1
1 cmp4.lt.and A7 cmp4.lt.or A7 cmp4.lt.or.andcm A7
x2 ta c Opcode
Bits Bit Bit Bits 40:37
35:34 33 12 C D E
0 cmp.lt – imm8 A8 cmp.ltu – imm8 A8 cmp.eq – imm8 A8
0
1 cmp.lt.unc – imm8 A8 cmp.ltu.unc – imm8 A8 cmp.eq.unc – imm8 A8
2
0 cmp.eq.and – imm8 A8 cmp.eq.or – imm8 A8 cmp.eq.or.andcm – imm8 A8
1
1 cmp.ne.and – imm8 A8 cmp.ne.or – imm8 A8 cmp.ne.or.andcm – imm8 A8
0 cmp4.lt – imm8 A8 cmp4.ltu – imm8 A8 cmp4.eq – imm8 A8
0
1 cmp4.lt.unc – imm8 A8 cmp4.ltu.unc – imm8 A8 cmp4.eq.unc – imm8 A8
A6 C-E tb x2 ta p2 r3 r2 c p1 qp
4 1 2 1 6 7 7 1 6 6
Extension
Instruction Operands Opcode
x2 tb ta c
cmp.lt C
cmp.ltu D 0
cmp.eq E
0
cmp.lt.unc C
cmp.ltu.unc D 1
cmp.eq.unc E
0 0
cmp.eq.and C
cmp.eq.or D 0
cmp.eq.or.andcm E
1
cmp.ne.and C
cmp.ne.or D 1
cmp.ne.or.andcm E
p1, p2 = r2, r3
cmp4.lt C
cmp4.ltu D 0
cmp4.eq E
0
cmp4.lt.unc C
cmp4.ltu.unc D 1
cmp4.eq.unc E
1 0
cmp4.eq.and C
cmp4.eq.or D 0
cmp4.eq.or.andcm E
1
cmp4.ne.and C
cmp4.ne.or D 1
cmp4.ne.or.andcm E
A7 C-E tb x2 ta p2 r3 0 c p1 qp
4 1 2 1 6 7 7 1 6 6
Extension
Instruction Operands Opcode
x2 tb ta c
cmp.gt.and C
cmp.gt.or D 0
cmp.gt.or.andcm E
0
cmp.le.and C
cmp.le.or D 1
cmp.le.or.andcm E
0
cmp.ge.and C
cmp.ge.or D 0
cmp.ge.or.andcm E
1
cmp.lt.and C
cmp.lt.or D 1
cmp.lt.or.andcm E
p1, p2 = r0, r3 1
cmp4.gt.and C
cmp4.gt.or D 0
cmp4.gt.or.andcm E
0
cmp4.le.and C
cmp4.le.or D 1
cmp4.le.or.andcm E
1
cmp4.ge.and C
cmp4.ge.or D 0
cmp4.ge.or.andcm E
1
cmp4.lt.and C
cmp4.lt.or D 1
cmp4.lt.or.andcm E
A8 C-E s x2 ta p2 r3 imm7b c p1 qp
4 1 2 1 6 7 7 1 6 6
Extension
Instruction Operands Opcode
x2 ta c
cmp.lt C
cmp.ltu D 0
cmp.eq E
0
cmp.lt.unc C
cmp.ltu.unc D 1
cmp.eq.unc E
2
cmp.eq.and C
cmp.eq.or D 0
cmp.eq.or.andcm E
1
cmp.ne.and C
cmp.ne.or D 1
cmp.ne.or.andcm E
p1, p2 = imm8, r3
cmp4.lt C
cmp4.ltu D 0
cmp4.eq E
0
cmp4.lt.unc C
cmp4.ltu.unc D 1
cmp4.eq.unc E
3
cmp4.eq.and C
cmp4.eq.or D 0
cmp4.eq.or.andcm E
1
cmp4.ne.and C
cmp4.ne.or D 1
cmp4.ne.or.andcm E
4.2.3 Multimedia
All multimedia ALU instructions are encoded within major opcode 8 using two 1-bit opcode
extension fields in bits 36 (za) and 33 (zb) and a 2-bit opcode extension field in bits 35:34 (x2a) as
shown in Table 4-12. The multimedia ALU instructions also have a 4-bit opcode extension field in
bits 32:29 (x4), and a 2-bit opcode extension field in bits 28:27 (x2b) as shown in Table 4-13 on
page 3:285.
A9 8 za x2a zb x4 x2b r3 r2 r1 qp
4 1 2 1 4 2 7 7 7 6
Extension
Instruction Operands Opcode
x2a za zb x4 x2b
padd1 0
0
padd2 1 0
padd4 1 0
padd1.sss 0
0 1
padd2.sss 1 0
padd1.uuu 0
0 2
padd2.uuu 1
padd1.uus 0
0 3
padd2.uus 1
psub1 0
0
psub2 1 0
psub4 1 0
psub1.sss 0
0 1
psub2.sss 1 1
psub1.uuu 0
r1 = r2, r3 8 1 0 2
psub2.uuu 1
psub1.uus 0
0 3
psub2.uus 1
pavg1 0
0 2
pavg2 1
2
pavg1.raz 0
0 3
pavg2.raz 1
pavgsub1 0
0 3 2
pavgsub2 1
pcmp1.eq 0
0
pcmp2.eq 1 0
pcmp4.eq 1 0
9
pcmp1.gt 0
0
pcmp2.gt 1 1
pcmp4.gt 1 0
Extension
Instruction Operands Opcode
x2a za zb x4
pshladd2 4
r1 = r2, count2, r3 8 1 0 1
pshradd2 6
Opcode za zb ve
Bits Bit Bit Bit 32
40:37 36 33 0 1
0 Multimedia Size 1 (Table 4-17)
0
1 Multimedia Size 2 (Table 4-18)
7
0 Multimedia Size 4 (Table 4-19)
1
1 Variable Shift (Table 4-20)
Extension
Instruction Operands Opcode
za zb ve x2a x2b
pmpyshr2 3
r1 = r2, r3, count2 7 0 1 0 0
pmpyshr2.u 1
Extension
Instruction Operands Opcode
za zb ve x2a x2b x2c
pmpy2.r 1
0 1 3
pmpy2.l 3
mix1.r 0 0
mix2.r 0 1 0
mix4.r 1 0
2
mix1.l 0 0
mix2.l 0 1 2
mix4.l 1 0
pack2.uss 0 1 0
pack2.sss 0 1 0
2
pack4.sss 1 0
r1 = r2, r3 7 0 2
unpack1.h 0 0
unpack2.h 0 1 0
unpack4.h 1 0
1
unpack1.l 0 0
unpack2.l 0 1 2
unpack4.l 1 0
pmin1.u 0
0 0 1
pmax1.u 1
pmin2 0
0 1 3
pmax2 1
psad1 0 0 3 2
Extension
Instruction Operands Opcode
za zb ve x2a x2b x2c
mux1 r1 = r2, mbtype4 7 0 0 0 3 2 2
Extension
Instruction Operands Opcode
za zb ve x2a x2b x2c
mux2 r1 = r2, mhtype8 7 0 1 0 3 2 2
Extension
Instruction Operands Opcode
za zb ve x2a x2b x2c
pshr2 0 1
pshr4 1 0 2
shr 1 1
r1 = r3, r2 7 0 0 0
pshr2.u 0 1
pshr4.u 1 0 0
shr.u 1 1
Extension
Instruction Operands Opcode
za zb ve x2a x2b x2c
pshr2 0 1
3
pshr4 1 0
r1 = r3, count5 7 0 1 0
pshr2.u 0 1
1
pshr4.u 1 0
Extension
Instruction Operands Opcode
za zb ve x2a x2b x2c
pshl2 0 1
pshl4 r1 = r2, r3 7 1 0 0 0 0 1
shl 1 1
Extension
Instruction Operands Opcode
za zb ve x2a x2b x2c
pshl2 0 1
r1 = r2, count5 7 0 3 1 1
pshl4 1 0
Extension
Instruction Operands Opcode
za zb ve x2a x2b x2c
popcnt r1 = r3 7 0 1 0 1 1 2
Most deposit instructions also have a 1-bit opcode extension field in bit 26 (y). Table 4-22 shows
these assignments.
I10 5 x2 x count6d r3 r2 r1 qp
4 1 2 1 6 7 7 7 6
Extension
Instruction Operands Opcode
x2 x
shrp r1 = r2, r3, count6 5 3 0
Extension
Instruction Operands Opcode
x2 x y
extr.u 0
r1 = r3, pos6, len6 5 1 0
extr 1
Extension
Instruction Operands Opcode
x2 x y
dep.z r1 = r2, pos6, len6 5 1 1 0
Extension
Instruction Operands Opcode
x2 x y
dep.z r1 = imm8, pos6, len6 5 1 1 1
Extension
Instruction Operands Opcode
x2 x
dep r1 = imm1, r3, pos6, len6 5 3 1
4.3.2.6 Deposit
40 37 36 31 30 27 26 20 19 13 12 6 5 0
x2 x
Opcode ta tb c y Bit 19
Bits
Bits 40:37 Bit 33 Bit 36 Bit 12 Bit 13
35:34 0 1
0 tbit.z I16
0
1 tnat.z I17 tf.z I30
0
0 tbit.z.unc I16
1
1 tnat.z.unc I17 tf.z.unc I30
0
0 tbit.z.and I16
0
1 tnat.z.and I17 tf.z.and I30
1
0 tbit.nz.and I16
1
1 tnat.nz.and I17 tf.nz.and I30
5 0
0 tbit.z.or I16
0
1 tnat.z.or I17 tf.z.or I30
0
0 tbit.nz.or I16
1
1 tnat.nz.or I17 tf.nz.or I30
1
0 tbit.z.or.andcm I16
0
1 tnat.z.or.andcm I17 tf.z.or.andcm I30
1
0 tbit.nz.or.andcm I16
1
1 tnat.nz.or.andcm I17 tf.nz.or.andcm I30
I16 5 tb x2 ta p2 r3 pos6b y c p1 qp
4 1 2 1 6 7 6 1 1 6 6
Extension
Instruction Operands Opcode
x2 ta tb y c
tbit.z 0
0
tbit.z.unc 1
0
tbit.z.and 0
1
tbit.nz.and 1
p1, p2 = r3, pos6 5 0 0
tbit.z.or 0
0
tbit.nz.or 1
1
tbit.z.or.andcm 0
1
tbit.nz.or.andcm 1
I17 5 tb x2 ta p2 r3 x y c p1 qp
4 1 2 1 6 7 1 5 1 1 6 6
Extension
Instruction Operands Opcode
x2 ta tb y x c
tnat.z 0
0
tnat.z.unc 1
0
tnat.z.and 0
1
tnat.nz.and 1
p1, p2 = r3 5 0 1 0
tnat.z.or 0
0
tnat.nz.or 1
1
tnat.z.or.andcm 0
1
tnat.nz.or.andcm 1
Opcode x3 x6
Bits Bits Bits Bits 32:31
40:37 35:33 30:27 0 1 2 3
0 break.i I19 zxt1 I29 mov from ip I25
1 1-bit Ext (Table 4-26) zxt2 I29 mov from b I22
2 zxt4 I29 mov.i from ar I28
3 mov from pr I25
4 sxt1 I29
5 sxt2 I29
6 sxt4 I29
7
0 0
8 czx1.l I29
9 czx2.l I29
A mov.i to ar – imm8 I27 mov.i to ar I26
B
C czx1.r I29
D czx2.r I29
E
F
I-unit nop and hint instructions are encoded within major opcode 0 using a 3-bit opcode extension
field in bits 35:33 (x3), a 6-bit opcode extension field in bits 32:27 (x6), and a 1-bit opcode
extension field in bit 26 (y), as shown in Table 4-26.
I18 0 i x3 x6 y imm20a qp
4 1 3 6 1 20 6
Extension
Instruction Operands Opcode
x3 x6 y
i
nop.i 0
imm21 0 0 01
hint.i 1
I19 0 i x3 x6 imm20a qp
4 1 3 6 1 20 6
Extension
Instruction Operands Opcode
x3 x6
break.i i imm21 0 0 00
Extension
Instruction Operands Opcode
x3
chk.s.i r2, target25 0 1
The mov to BR instruction also uses a 1-bit opcode extension field (x) in bit 22 to distinguish the
return form from the normal form, and a 1-bit hint extension in bit 23 (ih) (see Table 4-56 on
page 3:335).
4.3.5.1 Move to BR
40 37 36 35 33 32 24 23 22 21 20 19 13 12 9 8 6 5 0
I21 0 x3 timm9c ih x wh r2 b1 qp
4 1 3 9 1 1 2 7 4 3 6
Extension
Instruction Operands Opcode
x3 x ih wh
mov.mwh.ih 0 See Table 4-56 See Table 4-27
b1 = r2, tag13 0 7
on page 3:335 on page 3:299
mov.ret.mwh.ih 1
I22 0 x3 x6 b2 r1 qp
4 1 3 6 11 3 7 6
Extension
Instruction Operands Opcode
x3 x6
mov r1 = b 2 0 0 31
Extension
Instruction Operands Opcode
x3
mov pr = r2, mask17 0 3
I24 0 s x3 imm27a qp
4 1 3 27 6
Extension
Instruction Operands Opcode
x3
mov pr.rot = imm44 0 2
I25 0 x3 x6 r1 qp
4 1 3 6 14 7 6
Extension
Instruction Operands Opcode
x3 x6
r1 = ip 30
mov 0 0
r1 = pr 33
I26 0 x3 x6 ar3 r2 qp
4 1 3 6 7 7 7 6
Extension
Instruction Operands Opcode
x3 x6
mov.i ar3 = r2 0 0 2A
Extension
Instruction Operands Opcode
x3 x6
mov.i ar3 = imm8 0 0 0A
I28 0 x3 x6 ar3 r1 qp
4 1 3 6 7 7 7 6
Extension
Instruction Operands Opcode
x3 x6
mov.i r1 = ar3 0 0 32
I29 0 x3 x6 r3 r1 qp
4 1 3 6 7 7 7 6
Extension
Instruction Operands Opcode
x3 x6
zxt1 10
zxt2 11
zxt4 12
sxt1 14
sxt2 15
r1 = r3 0 0
sxt4 16
czx1.l 18
czx2.l 19
czx1.r 1C
czx2.r 1D
I30 5 tb x2 ta p2 0 x imm5b y c p1 qp
4 1 2 1 6 7 1 5 1 1 6 6
Extension
Instruction Operands Opcode
x2 ta tb y x c
tf.z 0
0
tf.z.unc 1
0
tf.z.and 0
1
tf.nz.and 1
p1, p2 = imm5 5 0 1 1
tf.z.or 0
0
tf.nz.or 1
1
tf.z.or.andcm 0
1
tf.nz.or.andcm 1
The integer load/store opcode extensions are summarized in Table 4-30 on page 3:303, Table 4-31
on page 3:303, and Table 4-32 on page 3:304, and the semaphore and get FR opcode extensions in
Table 4-33 on page 3:304. The floating-point load/store opcode extensions are summarized in
Opcode x6
Bits Bits Bits 31:30
40:37 35:32 0 1 2 3
0 ld1 M3 ld2 M3 ld4 M3 ld8 M3
1 ld1.s M3 ld2.s M3 ld4.s M3 ld8.s M3
2 ld1.a M3 ld2.a M3 ld4.a M3 ld8.a M3
3 ld1.sa M3 ld2.sa M3 ld4.sa M3 ld8.sa M3
4 ld1.bias M3 ld2.bias M3 ld4.bias M3 ld8.bias M3
5 ld1.acq M3 ld2.acq M3 ld4.acq M3 ld8.acq M3
6 ld8.fill M3
7
5
8 ld1.c.clr M3 ld2.c.clr M3 ld4.c.clr M3 ld8.c.clr M3
9 ld1.c.nc M3 ld2.c.nc M3 ld4.c.nc M3 ld8.c.nc M3
A ld1.c.clr.acq M3 ld2.c.clr.acq M3 ld4.c.clr.acq M3 ld8.c.clr.acq M3
B
C st1 M5 st2 M5 st4 M5 st8 M5
D st1.rel M5 st2.rel M5 st4.rel M5 st8.rel M5
E st8.spill M5
F
Opcode m x x6
Bits Bit Bit Bits Bits 31:30
40:37 36 27 35:32 0 1 2 3
0 ldfe M6 ldf8 M6 ldfs M6 ldfd M6
1 ldfe.s M6 ldf8.s M6 ldfs.s M6 ldfd.s M6
2 ldfe.a M6 ldf8.a M6 ldfs.a M6 ldfd.a M6
3 ldfe.sa M6 ldf8.sa M6 ldfs.sa M6 ldfd.sa M6
4
5
6 ldf.fill M6
7
6 0 0
8 ldfe.c.clr M6 ldf8.c.clr M6 ldfs.c.clr M6 ldfd.c.clr M6
9 ldfe.c.nc M6 ldf8.c.nc M6 ldfs.c.nc M6 ldfd.c.nc M6
A
B lfetch M13 lfetch.excl M13 lfetch.fault M13 lfetch.fault.excl M13
C stfe M9 stf8 M9 stfs M9 stfd M9
D
E stf.spill M9
F
Opcode x6
Bits Bits Bits 31:30
40:37 35:32 0 1 2 3
0 ldfe M8 ldf8 M8 ldfs M8 ldfd M8
1 ldfe.s M8 ldf8.s M8 ldfs.s M8 ldfd.s M8
2 ldfe.a M8 ldf8.a M8 ldfs.a M8 ldfd.a M8
3 ldfe.sa M8 ldf8.sa M8 ldfs.sa M8 ldfd.sa M8
4
5
6 ldf.fill M8
7
7
8 ldfe.c.clr M8 ldf8.c.clr M8 ldfs.c.clr M8 ldfd.c.clr M8
9 ldfe.c.nc M8 ldf8.c.nc M8 ldfs.c.nc M8 ldfd.c.nc M8
A
B lfetch M15 lfetch.excl M15 lfetch.fault M15 lfetch.fault.excl M15
C stfe M10 stf8 M10 stfs M10 stfd M10
D
E stf.spill M10
F
Opcode m x x6
Bits Bit Bit Bits Bits 31:30
40:37 36 27 35:32 0 1 2 3
0 ldfp8 M12 ldfps M12 ldfpd M12
1 ldfp8.s M12 ldfps.s M12 ldfpd.s M12
2 ldfp8.a M12 ldfps.a M12 ldfpd.a M12
3 ldfp8.sa M12 ldfps.sa M12 ldfpd.sa M12
4
5
6
7
6 1 1
8 ldfp8.c.clr M12 ldfps.c.clr M12 ldfpd.c.clr M12
9 ldfp8.c.nc M12 ldfps.c.nc M12 ldfpd.c.nc M12
A
B
C
D
E
F
The load and store instructions all have a 2-bit cache locality opcode hint extension field in bits
29:28 (hint). Table 4-39 and Table 4-40 summarize these assignments.
M1 4 m x6 hint x r3 r1 qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
m x x6 hint
ld1.ldhint 00
ld2.ldhint 01
ld4.ldhint 02
ld8.ldhint 03
ld1.s.ldhint 04
ld2.s.ldhint 05
ld4.s.ldhint 06
ld8.s.ldhint 07
ld1.a.ldhint 08
ld2.a.ldhint 09
ld4.a.ldhint 0A
ld8.a.ldhint 0B
ld1.sa.ldhint 0C
ld2.sa.ldhint 0D
ld4.sa.ldhint 0E
ld8.sa.ldhint 0F
ld1.bias.ldhint 10
ld2.bias.ldhint 11
ld4.bias.ldhint r1 = [r3] 0 0 12
See Table 4-39
ld8.bias.ldhint 4 13
on page 3:307
ld1.acq.ldhint 14
ld2.acq.ldhint 15
ld4.acq.ldhint 16
ld8.acq.ldhint 17
ld8.fill.ldhint 1B
ld1.c.clr.ldhint 20
ld2.c.clr.ldhint 21
ld4.c.clr.ldhint 22
ld8.c.clr.ldhint 23
ld1.c.nc.ldhint 24
ld2.c.nc.ldhint 25
ld4.c.nc.ldhint 26
ld8.c.nc.ldhint 27
ld1.c.clr.acq.ldhint 28
ld2.c.clr.acq.ldhint 29
ld4.c.clr.acq.ldhint 2A
ld8.c.clr.acq.ldhint 2B
ld16.ldhint 28
r1, ar.csd = [r3] 0 1
ld16.acq.ldhint 2C
M2 4 m x6 hint x r3 r2 r1 qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
m x x6 hint
ld1.ldhint 00
ld2.ldhint 01
ld4.ldhint 02
ld8.ldhint 03
ld1.s.ldhint 04
ld2.s.ldhint 05
ld4.s.ldhint 06
ld8.s.ldhint 07
ld1.a.ldhint 08
ld2.a.ldhint 09
ld4.a.ldhint 0A
ld8.a.ldhint 0B
ld1.sa.ldhint 0C
ld2.sa.ldhint 0D
ld4.sa.ldhint 0E
ld8.sa.ldhint 0F
ld1.bias.ldhint 10
ld2.bias.ldhint 11
See Table 4-39
ld4.bias.ldhint r1 = [r3], r2 4 1 0 12
on page 3:307
ld8.bias.ldhint 13
ld1.acq.ldhint 14
ld2.acq.ldhint 15
ld4.acq.ldhint 16
ld8.acq.ldhint 17
ld8.fill.ldhint 1B
ld1.c.clr.ldhint 20
ld2.c.clr.ldhint 21
ld4.c.clr.ldhint 22
ld8.c.clr.ldhint 23
ld1.c.nc.ldhint 24
ld2.c.nc.ldhint 25
ld4.c.nc.ldhint 26
ld8.c.nc.ldhint 27
ld1.c.clr.acq.ldhint 28
ld2.c.clr.acq.ldhint 29
ld4.c.clr.acq.ldhint 2A
ld8.c.clr.acq.ldhint 2B
M3 5 s x6 hint i r3 imm7b r1 qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
x6 hint
ld1.ldhint 00
ld2.ldhint 01
ld4.ldhint 02
ld8.ldhint 03
ld1.s.ldhint 04
ld2.s.ldhint 05
ld4.s.ldhint 06
ld8.s.ldhint 07
ld1.a.ldhint 08
ld2.a.ldhint 09
ld4.a.ldhint 0A
ld8.a.ldhint 0B
ld1.sa.ldhint 0C
ld2.sa.ldhint 0D
ld4.sa.ldhint 0E
ld8.sa.ldhint 0F
ld1.bias.ldhint 10
ld2.bias.ldhint 11
See Table 4-39 on
ld4.bias.ldhint r1 = [r3], imm9 5 12
page 3:307
ld8.bias.ldhint 13
ld1.acq.ldhint 14
ld2.acq.ldhint 15
ld4.acq.ldhint 16
ld8.acq.ldhint 17
ld8.fill.ldhint 1B
ld1.c.clr.ldhint 20
ld2.c.clr.ldhint 21
ld4.c.clr.ldhint 22
ld8.c.clr.ldhint 23
ld1.c.nc.ldhint 24
ld2.c.nc.ldhint 25
ld4.c.nc.ldhint 26
ld8.c.nc.ldhint 27
ld1.c.clr.acq.ldhint 28
ld2.c.clr.acq.ldhint 29
ld4.c.clr.acq.ldhint 2A
ld8.c.clr.acq.ldhint 2B
M4 4 m x6 hint x r3 r2 qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
m x x6 hint
st1.sthint 30
st2.sthint 31
st4.sthint 32
st8.sthint 33
st1.rel.sthint [r3] = r2 0 0 34
See Table 4-40
st2.rel.sthint 4 35
on page 3:307
st4.rel.sthint 36
st8.rel.sthint 37
st8.spill.sthint 3B
st16.sthint 30
[r3] = r2, ar.csd 0 1
st16.rel.sthint 34
M5 5 s x6 hint i r3 r2 imm7a qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
x6 hint
st1.sthint 30
st2.sthint 31
st4.sthint 32
st8.sthint 33
See Table 4-40 on
st1.rel.sthint [r3] = r2, imm9 5 34
page 3:307
st2.rel.sthint 35
st4.rel.sthint 36
st8.rel.sthint 37
st8.spill.sthint 3B
M6 6 m x6 hint x r3 f1 qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
m x x6 hint
ldfs.ldhint 02
ldfd.ldhint 03
ldf8.ldhint 01
ldfe.ldhint 00
ldfs.s.ldhint 06
ldfd.s.ldhint 07
ldf8.s.ldhint 05
ldfe.s.ldhint 04
ldfs.a.ldhint 0A
ldfd.a.ldhint 0B
ldf8.a.ldhint 09
ldfe.a.ldhint 08
See Table 4-39
ldfs.sa.ldhint f1 = [r3] 6 0 0 0E
on page 3:307
ldfd.sa.ldhint 0F
ldf8.sa.ldhint 0D
ldfe.sa.ldhint 0C
ldf.fill.ldhint 1B
ldfs.c.clr.ldhint 22
ldfd.c.clr.ldhint 23
ldf8.c.clr.ldhint 21
ldfe.c.clr.ldhint 20
ldfs.c.nc.ldhint 26
ldfd.c.nc.ldhint 27
ldf8.c.nc.ldhint 25
ldfe.c.nc.ldhint 24
M7 6 m x6 hint x r3 r2 f1 qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
m x x6 hint
ldfs.ldhint 02
ldfd.ldhint 03
ldf8.ldhint 01
ldfe.ldhint 00
ldfs.s.ldhint 06
ldfd.s.ldhint 07
ldf8.s.ldhint 05
ldfe.s.ldhint 04
ldfs.a.ldhint 0A
ldfd.a.ldhint 0B
ldf8.a.ldhint 09
ldfe.a.ldhint 08
See Table 4-39 on
ldfs.sa.ldhint f1 = [r3], r2 6 1 0 0E
page 3:307
ldfd.sa.ldhint 0F
ldf8.sa.ldhint 0D
ldfe.sa.ldhint 0C
ldf.fill.ldhint 1B
ldfs.c.clr.ldhint 22
ldfd.c.clr.ldhint 23
ldf8.c.clr.ldhint 21
ldfe.c.clr.ldhint 20
ldfs.c.nc.ldhint 26
ldfd.c.nc.ldhint 27
ldf8.c.nc.ldhint 25
ldfe.c.nc.ldhint 24
M8 7 s x6 hint i r3 imm7b f1 qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
x6 hint
ldfs.ldhint 02
ldfd.ldhint 03
ldf8.ldhint 01
ldfe.ldhint 00
ldfs.s.ldhint 06
ldfd.s.ldhint 07
ldf8.s.ldhint 05
ldfe.s.ldhint 04
ldfs.a.ldhint 0A
ldfd.a.ldhint 0B
ldf8.a.ldhint 09
ldfe.a.ldhint 08
See Table 4-39 on
ldfs.sa.ldhint f1 = [r3], imm9 7 0E
page 3:307
ldfd.sa.ldhint 0F
ldf8.sa.ldhint 0D
ldfe.sa.ldhint 0C
ldf.fill.ldhint 1B
ldfs.c.clr.ldhint 22
ldfd.c.clr.ldhint 23
ldf8.c.clr.ldhint 21
ldfe.c.clr.ldhint 20
ldfs.c.nc.ldhint 26
ldfd.c.nc.ldhint 27
ldf8.c.nc.ldhint 25
ldfe.c.nc.ldhint 24
M9 6 m x6 hint x r3 f2 qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
m x x6 hint
stfs.sthint 32
stfd.sthint 33
See Table 4-40 on
stf8.sthint [r3] = f2 6 0 0 31
page 3:307
stfe.sthint 30
stf.spill.sthint 3B
Extension
Instruction Operands Opcode
x6 hint
stfs.sthint 32
stfd.sthint 33
See Table 4-40 on
stf8.sthint [r3] = f2, imm9 7 31
page 3:307
stfe.sthint 30
stf.spill.sthint 3B
M11 6 m x6 hint x r3 f2 f1 qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
m x x6 hint
ldfps.ldhint 02
ldfpd.ldhint 03
ldfp8.ldhint 01
ldfps.s.ldhint 06
ldfpd.s.ldhint 07
ldfp8.s.ldhint 05
ldfps.a.ldhint 0A
ldfpd.a.ldhint 0B
ldfp8.a.ldhint 09 See Table 4-39
f1, f2 = [r3] 6 0 1
on page 3:307
ldfps.sa.ldhint 0E
ldfpd.sa.ldhint 0F
ldfp8.sa.ldhint 0D
ldfps.c.clr.ldhint 22
ldfpd.c.clr.ldhint 23
ldfp8.c.clr.ldhint 21
ldfps.c.nc.ldhint 26
ldfpd.c.nc.ldhint 27
ldfp8.c.nc.ldhint 25
M12 6 m x6 hint x r3 f2 f1 qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
m x x6 hint
ldfps.ldhint f1, f2 = [r3], 8 02
ldfpd.ldhint 03
f1, f2 = [r3], 16
ldfp8.ldhint 01
ldfps.s.ldhint f1, f2 = [r3], 8 06
ldfpd.s.ldhint 07
f1, f2 = [r3], 16
ldfp8.s.ldhint 05
ldfps.a.ldhint f1, f2 = [r3], 8 0A
ldfpd.a.ldhint 0B
f1, f2 = [r3], 16
ldfp8.a.ldhint 09 See Table 4-39
6 1 1
ldfps.sa.ldhint f1, f2 = [r3], 8 0E on page 3:307
ldfpd.sa.ldhint 0F
f1, f2 = [r3], 16
ldfp8.sa.ldhint 0D
ldfps.c.clr.ldhint f1, f2 = [r3], 8 22
ldfpd.c.clr.ldhint 23
f1, f2 = [r3], 16
ldfp8.c.clr.ldhint 21
ldfps.c.nc.ldhint f1, f2 = [r3], 8 26
ldfpd.c.nc.ldhint 27
f1, f2 = [r3], 16
ldfp8.c.nc.ldhint 25
The line prefetch instructions all have a 2-bit cache locality opcode hint extension field in bits
29:28 (hint) as shown in Table 4-41.
M13 6 m x6 hint x r3 qp
4 1 6 2 1 7 14 6
Extension
Instruction Operands Opcode
m x x6 hint
lfetch.lfhint 2C
lfetch.excl.lfhint 2D See Table 4-41 on
[r 3 ] 6 0 0
lfetch.fault.lfhint 2E page 3:316
lfetch.fault.excl.lfhint 2F
M14 6 m x6 hint x r3 r2 qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
m x x6 hint
lfetch.lfhint 2C
lfetch.excl.lfhint 2D See Table 4-41 on
[r3], r2 6 1 0
lfetch.fault.lfhint 2E page 3:316
lfetch.fault.excl.lfhint 2F
Extension
Instruction Operands Opcode
x6 hint
lfetch.lfhint 2C
lfetch.excl.lfhint 2D See Table 4-41 on
[r3], imm9 7
lfetch.fault.lfhint 2E page 3:316
lfetch.fault.excl.lfhint 2F
M16 4 m x6 hint x r3 r2 r1 qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
m x x6 hint
cmpxchg1.acq.ldhint 00
cmpxchg2.acq.ldhint 01
cmpxchg4.acq.ldhint 02
cmpxchg8.acq.ldhint 03
r1 = [r3], r2, ar.ccv
cmpxchg1.rel.ldhint 04
cmpxchg2.rel.ldhint 05
cmpxchg4.rel.ldhint 06 See
4 0 1 Table 4-39 on
cmpxchg8.rel.ldhint 07 page 3:307
cmp8xchg16.acq.ldhint 20
r1 = [r3], r2, ar.csd, ar.ccv
cmp8xchg16.rel.ldhint 24
xchg1.ldhint 08
xchg2.ldhint 09
r1 = [r3], r2
xchg4.ldhint 0A
xchg8.ldhint 0B
Extension
Instruction Operands Opcode
m x x6 hint
fetchadd4.acq.ldhint 12
fetchadd8.acq.ldhint 13 See Table 4-39
r1 = [r3], inc3 4 0 1
fetchadd4.rel.ldhint 16 on page 3:307
fetchadd8.rel.ldhint 17
4.4.4.1 Set FR
40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0
M18 6 m x6 x r2 f1 qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
m x x6
setf.sig 1C
setf.exp 1D
f1 = r2 6 0 1
setf.s 1E
setf.d 1F
4.4.4.2 Get FR
40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0
M19 4 m x6 x f2 r1 qp
4 1 6 2 1 7 7 7 6
Extension
Instruction Operands Opcode
m x x6
getf.sig 1C
getf.exp 1D
r1 = f 2 4 0 1
getf.s 1E
getf.d 1F
Extension
Instruction Operands Opcode
x3
chk.s.m r2, target25 1 1
Extension
Instruction Operands Opcode
x3
chk.s f2, target25 1 3
M22 0 s x3 imm20b r1 qp
4 1 3 20 7 6
Extension
Instruction Operands Opcode
x3
chk.a.nc 4
r1, target25 0
chk.a.clr 5
M23 0 s x3 imm20b f1 qp
4 1 3 20 7 6
Extension
Instruction Operands Opcode
x3
chk.a.nc 6
f1, target25 0
chk.a.clr 7
M24 0 x3 x2 x4 qp
4 1 3 2 4 21 6
Extension
Instruction Opcode
x3 x4 x2
invala 0 1
fwb 0
mf 2 2
mf.a 0 0 3
srlz.d 0
srlz.i 1 3
sync.i 3
M25 0 x3 x2 x4 0
4 1 3 2 4 21 6
Extension
Instruction Opcode
x3 x4 x2
flushrs f C
0 0 0
loadrs f A
M26 0 x3 x2 x4 r1 qp
4 1 3 2 4 14 7 6
Extension
Instruction Operands Opcode
x3 x4 x2
invala.e r1 0 0 2 1
M27 0 x3 x2 x4 f1 qp
4 1 3 2 4 14 7 6
Extension
Instruction Operands Opcode
x3 x4 x2
invala.e f1 0 0 3 1
M28 1 x x3 x6 r3 qp
4 1 3 6 7 14 6
Extension
Instruction Operands Opcode
x3 x6 x
fc 0
r3 1 0 30
fc.i 1
M29 1 x3 x6 ar3 r2 qp
4 1 3 6 7 7 7 6
Extension
Instruction Operands Opcode
x3 x6
mov.m ar3 = r2 1 0 2A
Extension
Instruction Operands Opcode
x3 x4 x2
mov.m ar3 = imm8 0 0 8 2
M31 1 x3 x6 ar3 r1 qp
4 1 3 6 7 7 7 6
Extension
Instruction Operands Opcode
x3 x6
mov.m r1 = ar3 1 0 22
4.4.8.1 Move to CR
40 37 36 35 33 32 27 26 20 19 13 12 6 5 0
M32 1 x3 x6 cr3 r2 qp
4 1 3 6 7 7 7 6
Extension
Instruction Operands Opcode
x3 x6
p
mov cr3 = r2 1 0 2C
M33 1 x3 x6 cr3 r1 qp
4 1 3 6 7 7 7 6
Extension
Instruction Operands Opcode
x3 x6
mov p r1 = cr3 1 0 24
Extension
Instruction Operands Opcode
x3
alloc f r1 = ar.pfs, i, l, o, r 1 6
Note: The three immediates in the instruction encoding are formed from the operands as fol-
lows:
sof = i + l + o
sol = i + l
sor = r >> 3
M35 1 x3 x6 r2 qp
4 1 3 6 7 7 7 6
Extension
Instruction Operands Opcode
x3 x6
mov p psr.l = r2 2D
1 0
mov psr.um = r2 29
M36 1 x3 x6 r1 qp
4 1 3 6 14 7 6
Extension
Instruction Operands Opcode
x3 x6
mov p r1 = psr 25
1 0
mov r1 = psr.um 21
M37 0 i x3 x2 x4 imm20a qp
4 1 3 2 4 1 20 6
Extension
Instruction Operands Opcode
x3 x4 x2
break.m imm21 0 0 0 0
Opcode x3 x4 x2
Bits Bits Bits Bits 32:31
40:37 35:33 30:27 0 1 2 3
0 break.m M37 invala M24 fwb M24 srlz.d M24
1-bit Ext srlz.i M24
1
(Table 4-46)
2 invala.e – int M26 mf M24
3 invala.e – fp M27 mf.a M24 sync.i M24
4 sum M44
5 rum M44
6 ssm M44
0 0 7 rsm M44
8 mov.m to ar – imm8 M30
9
A loadrs M25
B
C flushrs M25
D
E
F
Opcode x3 x6
Bits Bits Bits Bits 32:31
40:37 35:33 30:27 0 1 2 3
0 mov to rr M42 mov from rr M43 fc M28
mov to dbr M42 mov from dbr M43 mov from psr.um probe.rw.fault –
1
M36 imm2 M40
mov to ibr M42 mov from ibr M43 mov.m from ar M31 probe.r.fault –
2
imm2 M40
mov to pkr M42 mov from pkr M43 probe.w.fault –
3
imm2 M40
4 mov to pmc M42 mov from pmc M43 mov from cr M33 ptc.e M47
5 mov to pmd M42 mov from pmd M43 mov from psr M36
6
1 0
7 mov from cpuid M43
8 probe.r – imm2 M39 probe.r M38
9 ptc.l M45 probe.w – imm2 M39 mov to psr.um M35 probe.w M38
A ptc.g M45 thash M46 mov.m to ar M29
B ptc.ga M45 ttag M46
C ptr.d M45 mov to cr M32
D ptr.i M45 mov to psr.l M35
E itr.d M42 tpa M46 itc.d M41
F itr.i M42 tak M46 itc.i M41
M38 1 x3 x6 r3 r2 r1 qp
4 1 3 6 7 7 7 6
Extension
Instruction Operands Opcode
x3 x6
probe.r 38
r1 = r3, r2 1 0
probe.w 39
M39 1 x3 x6 r3 i2b r1 qp
4 1 3 6 7 5 2 7 6
Extension
Instruction Operands Opcode
x3 x6
probe.r 18
r1 = r3, imm2 1 0
probe.w 19
M40 1 x3 x6 r3 i2b qp
4 1 3 6 7 5 2 7 6
Extension
Instruction Operands Opcode
x3 x6
probe.rw.fault 31
probe.r.fault r3, imm2 1 0 32
probe.w.fault 33
M41 1 x3 x6 r2 qp
4 1 3 6 7 7 7 6
Extension
Instruction Operands Opcode
x3 x6
lp
itc.d 2E
r2 1 0
itc.i l p 2F
M42 1 x3 x6 r3 r2 qp
4 1 3 6 7 7 7 6
Extension
Instruction Operands Opcode
x3 x6
rr[r3] = r2 00
dbr[r3] = r2 01
ibr[r3] = r2 02
mov p pkr[r3] = r2 03
pmc[r3] = r2 1 0 04
pmd[r3] = r2 05
itr.d p dtr[r3] = r2 0E
itr.i p itr[r3] = r2 0F
M43 1 x3 x6 r3 r1 qp
4 1 3 6 7 7 7 6
Extension
Instruction Operands Opcode
x3 x6
r1 = rr[r3] 10
r1 = dbr[r3] 11
r1 = ibr[r3] 12
mov p
r1 = pkr[r3] 13
1 0
r1 = pmc[r3] 14
r1 = pmd[r3] 15
mov
r1 = cpuid[r3] 17
Extension
Instruction Operands Opcode
x3 x4
sum 4
rum 5
imm24 0 0
ssm p 6
rsm p 7
M45 1 x3 x6 r3 r2 qp
4 1 3 6 7 7 7 6
Extension
Instruction Operands Opcode
x3 x6
ptc.l p 09
ptc.g l p 0A
ptc.ga l p r3, r2 1 0 0B
p
ptr.d 0C
ptr.i p 0D
M46 1 x3 x6 r3 r1 qp
4 1 3 6 7 7 7 6
Extension
Instruction Operands Opcode
x3 x6
thash 1A
ttag 1B
r1 = r3 1 0
tpa p 1E
tak p 1F
M47 1 x3 x6 r3 qp
4 1 3 6 7 14 6
Extension
Instruction Operands Opcode
x3 x6
ptc.e p r3 1 0 34
M48 0 i x3 x2 x4 y imm20a qp
4 1 3 2 4 1 20 6
Extension
Instruction Operands Opcode
x3 x4 x2 y
nop.m 0
imm21 0 0 1 0
hint.m 1
The IP-relative branch instructions encoded within major opcode 4 use a 3-bit opcode extension
field in bits 8:6 (btype) to distinguish the branch types as shown in Table 4-47.
The indirect branch, indirect return, and miscellaneous branch-unit instructions are encoded within
major opcode 0 using a 6-bit opcode extension field in bits 32:27 (x6). Table 4-48 summarizes these
assignments.
3 e e e e
e e e
4 clrrrb B8
5 clrrrb.pr B8 e e e
e e e e
6
0 7 e e e e
8 rfi B8 vmsw.0 B8 e e
e e
9 vmsw.1 B8
e e e e
A
B e e e e
e e e
C bsw.0 B8
e e e
D bsw.1 B8
E e e e e
e e e e
F
The indirect branch instructions encoded within major opcodes 0 use a 3-bit opcode extension field
in bits 8:6 (btype) to distinguish the branch types as shown in Table 4-49.
6 e
e
7
The indirect return branch instructions encoded within major opcodes 0 use a 3-bit opcode
extension field in bits 8:6 (btype) to distinguish the branch types as shown in Table 4-50.
All of the branch instructions have a 1-bit sequential prefetch opcode hint extension field, p, in bit
12. Table 4-51 summarizes these assignments.
The IP-relative and indirect branch instructions all have a 2-bit branch prediction “whether” opcode
hint extension field in bits 34:33 (wh) as shown in Table 4-52. Indirect call instructions have a 3-bit
“whether” opcode hint extension field in bits 34:32 (wh) as shown in Table 4-53.
The branch instructions also have a 1-bit branch cache deallocation opcode hint extension field in
bit 35 (d) as shown in Table 4-54.
B1 4 s d wh imm20b p btype qp
4 1 1 2 20 1 3 3 6
Extension
Instruction Operands Opcode
btype p wh d
br.cond.bwh.ph.dh e 0 See See See
br.wexit.bwh.ph.dh e t target25 4 2 Table 4-51 on Table 4-52 on Table 4-54 on
br.wtop.bwh.ph.dh e t 3 page 3:332 page 3:332 page 3:333
B2 4 s d wh imm20b p btype 0
4 1 1 2 20 1 3 3 6
Extension
Instruction Operands Opcode
btype p wh d
br.cloop.bwh.ph.dh e t 5 See See See
br.cexit.bwh.ph.dh e t target25 4 6 Table 4-51 on Table 4-52 on Table 4-54 on
br.ctop.bwh.ph.dh e t 7 page 3:332 page 3:332 page 3:333
B3 5 s d wh imm20b p b1 qp
4 1 1 2 20 1 3 3 6
Extension
Instruction Operands Opcode
p wh d
See Table 4-51 See Table 4-52 See Table 4-54
br.call.bwh.ph.dh e b1 = target25 5
on page 3:332 on page 3:332 on page 3:333
B4 0 d wh x6 b2 p btype qp
4 1 1 2 6 11 3 1 3 3 6
Extension
Instruction Operands Opcode
x6 btype p wh d
B5 1 d wh b2 p b1 qp
4 1 1 3 16 3 1 3 3 6
Extension
Instruction Operands Opcode
p wh d
See Table 4-51 See Table 4-53 See Table 4-54
br.call.bwh.ph.dh e b1 = b2 1
on page 3:332 on page 3:333 on page 3:333
Opcode x6
Bits Bits Bits 32:31
40:37 30:27 0 1 2 3
0 nop.b B9 brp B7
1 hint.b B9 brp.ret B7
2
3
4
5
6
7
2
8
9
A
B
C
D
E
F
The branch predict instructions all have a 1-bit branch importance opcode hint extension field in bit
35 (ih). The mov to BR instruction (page 3:299) also has this hint in bit 23. Table 4-56 shows these
assignments.
The IP-relative branch predict instructions have a 2-bit branch prediction “whether” opcode hint
extension field in bits 4:3 (wh) as shown in Table 4-57. Note that the combination of the.loop
or.exit whether hint completer with the none importance hint completer is undefined.
The indirect branch predict instructions have a 2-bit branch prediction “whether” opcode hint
extension field in bits 4:3 (wh) as shown in Table 4-58.
Extension
Instruction Operands Opcode
ih wh
See Table 4-56 on See Table 4-57 on
brp.ipwh.ih target25, tag13 7
page 3:335 page 3:335
B7 2 ih t2e x6 b2 timm7a wh
4 1 1 2 6 11 3 7 1 2 3
Extension
Instruction Operands Opcode
x6 ih wh
brp.indwh.ih 10 See Table 4-56 on See Table 4-58 on
b2, tag13 2
brp.ret.indwh.ih 11 page 3:335 page 3:336
B8 0 x6 0
4 4 6 21 6
Extension
Instruction Opcode
x6
cover l 02
clrrrb l 04
clrrrb.pr l 05
rfi e l p 0 08
lp
bsw.0 0C
bsw.1 l p 0D
epc 10
vmsw.0 p 18
p
0
vmsw.1 19
B9 0/2 i x6 imm20a qp
4 1 3 6 1 20 6
Extension
Instruction Operands Opcode
x6
break.b e 0
00
nop.b imm21
2
hint.b 01
The miscellaneous and reciprocal approximation floating-point instructions are encoded within
major opcodes 0 and 1 using a 1-bit opcode extension field (x) in bit 33 and either a second 1-bit
extension field in bit 36 (q) or a 6-bit opcode extension field (x6) in bits 32:27. Table 4-59 shows
the 1-bit x assignments, Table 4-62 shows the additional 1-bit q assignments for the reciprocal
approximation instructions; Table 4-60 and Table 4-61 summarize the 6-bit x6 assignments.
Opcode x x6
Bits Bit Bits Bits 32:31
40:37 33 30:27 0 1 2 3
0 break.f F15 fmerge.s F9
1 1-bit Ext fmerge.ns F9
(Table 4-68)
2 fmerge.se F9
3
4 fsetc F12 fmin F8 fswap F9
5 fclrf F13 fmax F8 fswap.nl F9
6 famin F8 fswap.nr F9
0 0 7 famax F8
8 fchkf F14 fcvt.fx F10 fpack F9
9 fcvt.fxu F10 fmix.lr F9
A fcvt.fx.trunc F10 fmix.r F9
B fcvt.fxu.trunc F10 fmix.l F9
C fcvt.xf F11 fand F9 fsxt.r F9
D fandcm F9 fsxt.l F9
E for F9
F fxor F9
Most floating-point instructions have a 2-bit opcode extension field in bits 35:34 (sf) which
encodes the FPSR status field to be used. Table 4-63 summarizes these assignments.
The fixed-point arithmetic and parallel floating-point select instructions are encoded within major
opcode E using a 1-bit opcode extension field (x) in bit 36. The fixed-point arithmetic instructions
also have a 2-bit opcode extension field (x2) in bits 35:34. These assignments are shown in
Table 4-65.
F1 8-D x sf f4 f3 f2 f1 qp
4 1 2 7 7 7 7 6
Extension
Instruction Operands Opcode
x sf
fma.sf 0
8
fma.s.sf 1
fma.d.sf 0
9
fpma.sf 1
fms.sf 0
A
fms.s.sf 1 See Table 4-63 on
f1 = f3, f4, f2 page 3:339
fms.d.sf 0
B
fpms.sf 1
fnma.sf 0
C
fnma.s.sf 1
fnma.d.sf 0
D
fpnma.sf 1
F2 E x x2 f4 f3 f2 f1 qp
4 1 2 7 7 7 7 6
Extension
Instruction Operands Opcode
x x2
xma.l 0
xma.h f1 = f3, f4, f2 E 1 3
xma.hu 2
F3 E x f4 f3 f2 f1 qp
4 1 2 7 7 7 7 6
Extension
Instruction Operands Opcode
x
fselect f1 = f3, f4, f2 E 0
Opcode ta
ra rb Bit 12
Bits
Bit 33 Bit 36
40:37 0 1
0 fcmp.eq F4 fcmp.eq.unc F4
0
1 fcmp.lt F4 fcmp.lt.unc F4
4
0 fcmp.le F4 fcmp.le.unc F4
1
1 fcmp.unord F4 fcmp.unord.unc F4
The floating-point class instructions are encoded within major opcode 5 using a 1-bit opcode
extension field in bit 12 (ta) as shown in Table 4-67.
F4 4 rb sf ra p2 f3 f2 ta p1 qp
4 1 2 1 6 7 7 1 6 6
Extension
Instruction Operands Opcode
ra rb ta sf
fcmp.eq.sf 0
0
fcmp.lt.sf 1
0
fcmp.le.sf 0
1
fcmp.unord.sf 1 See Table 4-63
p1, p2 = f2, f3 4
fcmp.eq.unc.sf 0 on page 3:339
0
fcmp.lt.unc.sf 1
1
fcmp.le.unc.sf 0
1
fcmp.unord.unc.sf 1
F5 5 fc2 p2 fclass7c f2 ta p1 qp
4 2 2 6 7 7 1 6 6
Extension
Instruction Operands Opcode
ta
fclass.m 0
p1, p2 = f2, fclass9 5
fclass.m.unc 1
4.6.4 Approximation
There are two Reciprocal Approximation instructions. The first, in major op 0, encodes the full
register variant. The second, in major op 1, encodes the parallel variant.
40 37 36 35 34 33 32 27 26 20 19 13 12 6 5 0
F6 0-1 q sf x p2 f3 f2 f1 qp
4 1 2 1 6 7 7 7 6
Extension
Instruction Operands Opcode
x q sf
frcpa.sf 0 See Table 4-63 on
f1, p2 = f2, f3 1 0 page 3:339
fprcpa.sf 1
There are two Reciprocal Square Root Approximation instructions. The first, in major op 0,
encodes the full register variant. The second, in major op 1, encodes the parallel variant.
40 37 36 35 34 33 32 27 26 20 19 13 12 6 5 0
F7 0-1 q sf x p2 f3 f1 qp
4 1 2 1 6 7 7 7 6
Extension
Instruction Operands Opcode
x q sf
frsqrta.sf 0 See Table 4-63 on
f1, p2 = f3 1 1
fprsqrta.sf 1 page 3:339
F8 0-1 sf x x6 f3 f2 f1 qp
4 1 2 1 6 7 7 7 6
Extension
Instruction Operands Opcode
x x6 sf
fmin.sf 14
fmax.sf 15
0
famin.sf 16
famax.sf 17
fpmin.sf 14
fpmax.sf 15
fpamin.sf 16
fpamax.sf 17 See Table 4-63 on
f1 = f2, f3 0
page 3:339
fpcmp.eq.sf 30
fpcmp.lt.sf 31
1
fpcmp.le.sf 32
fpcmp.unord.sf 33
fpcmp.neq.sf 34
fpcmp.nlt.sf 35
fpcmp.nle.sf 36
fpcmp.ord.sf 37
F9 0-1 x x6 f3 f2 f1 qp
4 3 1 6 7 7 7 6
Extension
Instruction Operands Opcode
x x6
fmerge.s 10
fmerge.ns 11
fmerge.se 12
fmix.lr 39
fmix.r 3A
fmix.l 3B
fsxt.r 3C
fsxt.l 3D
0
fpack 28
fswap f1 = f2, f3 0 34
fswap.nl 35
fswap.nr 36
fand 2C
fandcm 2D
for 2E
fxor 2F
fpmerge.s 10
fpmerge.ns 1 11
fpmerge.se 12
4.6.7 Conversion
F10 0-1 sf x x6 f2 f1 qp
4 1 2 1 6 7 7 7 6
Extension
Instruction Operands Opcode
x x6 sf
fcvt.fx.sf 18
fcvt.fxu.sf 19
0
fcvt.fx.trunc.sf 1A
fcvt.fxu.trunc.sf 1B See Table 4-63 on
f1 = f2 0
fpcvt.fx.sf 18 page 3:339
fpcvt.fxu.sf 19
1
fpcvt.fx.trunc.sf 1A
fpcvt.fxu.trunc.sf 1B
F11 0 x x6 f2 f1 qp
4 3 1 6 7 7 7 6
Extension
Instruction Operands Opcode
x x6
fcvt.xf f1 = f2 0 0 1C
Extension
Instruction Operands Opcode
x x6 sf
See Table 4-63 on
fsetc.sf amask7, omask7 0 0 04
page 3:339
F13 0 sf x x6 qp
4 1 2 1 6 21 6
Extension
Instruction Opcode
x x6 sf
fclrf.sf 0 0 05 See Table 4-63 on page 3:339
F14 0 s sf x x6 imm20a qp
4 1 2 1 6 1 20 6
Extension
Instruction Operands Opcode
x x6 sf
See Table 4-63 on
fchkf.sf target25 0 0 08
page 3:339
F15 0 i x x6 imm20a qp
4 1 2 1 6 1 20 6
Extension
Instruction Operands Opcode
x x6
break.f imm21 0 0 00
F-unit nop and hint instructions are encoded within major opcode 0 using a 3-bit opcode extension
field in bits 35:33 (x3), a 6-bit opcode extension field in bits 32:27 (x6), and a 1-bit opcode
extension field in bit 26 (y), as shown in Table 4-46.
F16 0 i x x6 y imm20a qp
4 1 2 1 6 1 20 6
Extension
Instruction Operands Opcode
x x6 y
nop.f 0
imm21 0 0 01
hint.f 1
Opcode x3 x6
Bits Bits Bits Bits 32:31
40:37 35:33 30:27 0 1 2 3
0 break.x X1
1 1-bit Ext
(Table 4-73)
2
3
4
5
6
0 0 7
8
9
A
B
C
D
E
F
X1 0 i x3 x6 imm20a qp imm41
4 1 3 6 1 20 6 41
Extension
Instruction Operands Opcode
x3 x6
break.x imm62 0 0 00
Extension
Instruction Operands Opcode
vc
movl i r1 = imm64 6 0
The long branch instructions encoded within major opcode C use a 3-bit opcode extension field in
bits 8:6 (btype) to distinguish the branch types as shown in Table 4-72.
The long branch instructions have the same opcode hint fields in bit 12 (p), bits 34:33 (wh), and
bit 35 (d) as normal IP-relative branches. These are shown in Table 4-51 on page 3:332, Table 4-52
on page 3:332, and Table 4-54 on page 3:333.
Extension
Instruction Operands Opcode
btype p wh d
See Table 4-51 See Table 4-52 See Table 4-54
brl.cond.bwh.ph.dh e l target64 C 0
on page 3:332 on page 3:332 on page 3:333
X4 D i d wh imm20b p b1 qp imm39
4 1 1 2 20 1 3 3 6 39 2
Extension
Instruction Operands Opcode
p wh d
See Table 4-51 See Table 4-52 See Table 4-54
brl.call.bwh.ph.dh e l b1 = target64 D
on page 3:332 on page 3:332 on page 3:333
X5 0 i x3 x6 y imm20a qp imm41
4 1 3 6 1 20 6 41
Extension
Instruction Operands Opcode
x3 x6 y
nop.x 0
imm62 0 0 01
hint.x 1
a. This encoding causes an Illegal Operation fault if the value of the qualifying predicate is 1.
A WAW (Write-After-Write) dependency is a sequence of two events where both events write the
resource in question. Events may be instructions, interruptions, or other ‘updates’ of the resource.
Table 5-3 covers only dependencies based on instruction writers.
A RAR (Read-After-Read) dependency is a sequence of two instructions where both are readers of
the same resource. Such dependencies are always allowed.
RAW and WAW dependencies are generally not allowed without some type of serialization event
(an implied, data, or instruction serialization after the first writing instruction. (See Section 3.2,
“Serialization” on page 2:15 for details on serialization.) The tables and associated rules in this
appendix provide a comprehensive list of readers and writers of resources and describe the
The serialization of application level (non-privileged) resources is always implied. This means that
if a writer of that resource and a subsequent read of that same resource are in different instruction
groups, then the reader will see the value written. In addition, for dependencies on PRs and BRs,
where the writer is a non-branch instruction and the reader is a branch instruction, the writer and
reader may be in the same instruction group.
System resources generally require explicit serialization, i.e., the use of a srlz.i or srlz.d
instruction, between the writing and the reading of that resource. Note that RAW accesses to CRs
are not exceptional – they require explicit data or instruction serialization. However, in some cases
(other than CRs) where pairs of instructions explicitly encode the same resource, serialization is
implied.
There are cases where it is architecturally allowed to omit a serialization, and that the response
from the CPU must be atomic (act as if either the old or the new state were fully in place). The
tables in this appendix indicate dependency requirements under the assumption that the desired
result is for the dependency to always be observed. In some such cases, the programmer may not
care if the old or new state is used; such situations are allowed, but the value seen is not
deterministic.
On the other hand, if an impliedF dependency is violated, then the program is incorrectly coded and
the processor's behavior is undefined.
Rule 1. These instructions only write a register when that register’s number is explicitly encoded
as a target of the instruction and is only read when it is encoded as a source of the
instruction (or encoded as its PR[qp]).
Rule 2. These instructions only read CFM when they access a rotating GR, FR, or PR.
mov-to-PR and mov-from-PR only access CFM when their qualifying predicate is in the
rotating region.
Rule 4. These instructions only read the given resource when bits {7:0} of the indirect index
register value does not match the register number of the resource.
Rule 6. There is a dependency only when both the index specified by the reader and the index
specified by the writer have the same value in bits {63:61}.
Rule 7. These instructions access the specified resource only when the corresponding mask bit is
set.
Rule 8. PSR.dfh is only read when these instructions reference FR32-127. PSR.dfl is only read
when these instructions reference FR2-31.
Rule 9. PSR.mfl is only written when these instructions write FR2-31. PSR.mfh is only written
when these instructions write FR32-127.
Rule 10. The PSR.bn bit is only accessed when one of GR16-31 is specified in the instruction.
Rule 11. The target predicates are written independently of PR[qp], but source registers are only
read if PR[qp] is true.
Rule 12. This instruction only reads the specified predicate register when that register is the
PR[qp].
Rule 13. This reference to ld-c only applies to the GR whose value is loaded with data returned
from memory, not the post-incremented address register. Thus, a stop is still required
between a post-incrementing ld-c and a consumer that reads the post-incremented GR.
Rule 14. The RSE resource includes implementation-specific internal state. At least one (and
possibly more) of these resources are read by each instruction listed in the rse-readers
class. At least one (and possibly more) of these resources are written by each instruction
listed in the rse-writers class. To determine exactly which instructions read or write each
individual resource, see the corresponding instruction pages.
Rule 15. This class represents all instructions marked as Reserved if PR[qp] is 1 B-type instructions
as described in “Format Summary” on page 3:272.
Rule 16. This class represents all instructions marked as Reserved if PR[qp] is 1 instructions as
described in “Format Summary” on page 3:272.
Rule 17. CR[TPR] has a RAW dependency only between mov-to-CR-TPR and mov-to-PSR-l or
ssm instructions that set PSR.i, PSR,pp or PSR.up.
This section lists all IA-32 instructions and their behavior in the Itanium System Environment and
IA-32 System Environments on an processor based on the Itanium architecture. Unless noted
otherwise all IA-32 and MMX technology and SSE instructions operate as defined in the IA-32
Intel® Architecture Software Developer’s Manual.
This volume describes the complete IA-32 Architecture instruction set, including the integer,
floating-point, MMX technology and SSE technology, and system instructions. The instruction
descriptions are arranged in alphabetical order. For each instruction, the forms are given for each
operand combination, including the opcode, operands required, and a description. Also given for
each instruction are a description of the instruction and its operands, an operational description, a
description of the effect of the instructions on flags in the EFLAGS register, and a summary of the
exceptions that can be generated.
The “Opcode” column gives the complete object code produced for each form of the instruction.
When possible, the 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:
• /digit – A digit between 0 and 7 indicates that the ModR/M byte of the 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 both a register operand and an
r/m operand.
• cb, cw, cd, cp – A 1-byte (cb), 2-byte (cw), 4-byte (cd), or 6-byte (cp) value following the
opcode that is used to specify a code offset and possibly a new value for the code segment
register.
• ib, iw, id – A 1-byte (ib), 2-byte (iw), or 4-byte (id) immediate operand to the instruction that
follows the opcode, ModR/M bytes or scale-indexing bytes. The opcode determines if the
operand is a signed value. All words and doublewords are given with the low-order byte first.
• +rb, +rw, +rd – 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. The register codes are given in Table 1-1.
• +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 1-1. Register Encodings Associated with the +rb, +rw, and +rd Nomenclature
rb rw rd
AL = 0 AX = 0 EAX = 0
CL = 1 CX = 1 ECX = 1
DL = 2 DX = 2 EDX = 2
BL = 3 BX = 3 EBX = 3
rb rw rd
AH = 4 SP = 4 ESP = 4
CH = 5 BP = 5 EBP = 5
DH = 6 SI = 6 ESI = 6
BH = 7 DI = 7 EDI = 7
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.
The “Description” column following the “Instruction” column briefly explains the various forms of
the instruction. The following “Description” and “Operation” sections contain more details of the
instruction's operation.
1.2.1.4 Description
The “Description” section describes the purpose of the instructions and the required operands. It
also discusses the effect of the instruction on flags.
1.2.2 Operation
The “Operation” section contains an algorithmic description (written in pseudo-code) of the
instruction. The pseudo-code uses a notation similar to the Algol or Pascal language. The
algorithms are composed of the following elements:
• Comments are enclosed within the symbol pairs “(*” and “*)”.
IF instruction = CMPSW
THEN OperandSize ←16;
ELSE
IF instruction = CMPSD
THEN OperandSize ←32;
FI;
FI;
See “Operand-Size and Address-Size Attributes” in Chapter 3 of the IA-32 Intel® Architecture
Software Developer’s Manual, Volume 1, for general guidelines on how these attributes
are determined.
• StackAddrSize – Represents the stack address-size attribute associated with the instruction,
which has a value of 16 or 32 bits (see “Address-Size Attribute for Stack” in Chapter 4 of the
IA-32 Intel® Architecture Software Developer’s Manual, Volume 1).
• SRC – Represents the source operand.
• DEST – Represents the destination operand.
31 21 0
BitOffset = 21
If BitBase is a memory address, BitOffset can range from -2 GBits to 2 GBits. 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. This
operation is illustrated in Figure 1-2.
7 5 0 7 0 7 0
7 0 7 0 7 5 0
Application programmers should consult the documentation provided with their operating systems
to determine the actions taken when exceptions occur.
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 is incremented 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 cleared to 0.
Operation
IF ((AL AND FH) > 9) OR (AF = 1)
THEN
AL ←(AL + 6);
AH ←AH + 1;
AF ←1;
CF ←1;
ELSE
AF ←0;
CF ←0;
FI;
AL ← AL AND FH;
Flags Affected
The AF and CF flags are set to 1 if the adjustment results in a decimal carry; otherwise they are
cleared to 0. The OF, SF, ZF, and PF flags are undefined.
None.
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 AL 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 number in registers AH and AL.
Operation
tempAL ←AL;
tempAH ←AH;
AL ←(tempAL + (tempAH ∗ imm8)) AND FFH;
AH ←0
The immediate value (imm8) is taken from the second byte of the instruction, which under normal
assembly is 0AH (10 decimal). However, this immediate value can be changed to produce a
different result.
Flags Affected
The SF, ZF, and PF flags are set according to the result; the OF, AF, and CF flags are undefined.
None.
Description
Adjusts the result of the multiplication of two unpacked BCD values to create a pair of unpacked
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 BCD
result.
Operation
tempAL ←AL;
AH ←tempAL / imm8;
AL ←tempAL MOD imm8;
The immediate value (imm8) is taken from the second byte of the instruction, which under normal
assembly is 0AH (10 decimal). However, this immediate value can be changed to produce a
different result.
Flags Affected
The SF, ZF, and PF flags are set according to the result. The OF, AF, and CF flags are undefined.
None.
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 is decremented 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.
Operation
IF ((AL AND FH) > 9) OR (AF = 1)
THEN
AL ←AL - 6;
AH ←AH - 1;
AF ←1;
CF ←1;
ELSE
CF ←0;
AF ←0;
FI;
AL ←AL AND FH;
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.
None.
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.
The state of the CF flag represents a carry from a previous addition. When an immediate value is
used as an operand, it is sign-extended to the length of the destination operand format.
The ADC instruction does not distinguish between signed or unsigned operands. 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.
Operation
Flags Affected
The OF, SF, ZF, AF, CF, and PF flags are set according to the result.
Description
Adds the first operand (destination operand) and the second operand (source operand) 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. When an
immediate value is used as an operand, it is sign-extended to the length of the destination operand
format.
The ADD instruction does not distinguish between signed or unsigned operands. 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.
Operation
DEST ←DEST + SRC;
Flags Affected
The OF, SF, ZF, AF, CF, and PF flags are set according to the result.
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.
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.
Description
Compares the RPL fields of two segment selectors. The first operand (the destination operand)
contains one segment selector and the second operand (source operand) contains the other. (The
RPL field is located in bits 0 and 1 of each operand.) If the RPL field of the destination operand is
less than the RPL field of the source operand, the ZF flag is set and the RPL field of the destination
operand is increased to match that of the source operand. Otherwise, the ZF flag is cleared and no
change is made to the destination operand. (The destination operand can be a word register or a
memory location; the source operand must be a word register.)
The ARPL instruction is provided for use by operating-system procedures (however, it can also be
used by applications). It is generally used to adjust the RPL of a segment selector that has been
passed to the operating system by an application program to match the privilege level of the
application program. Here the segment selector passed to the operating system is placed in the
destination operand and segment selector for the application program’s code segment is placed in
the source operand. (The RPL field in the source operand represents the privilege level of the
application program.) Execution of the ARPL instruction then insures that the RPL of the segment
selector received by the operating system is no lower (does not have a higher privilege) than the
privilege level of the application program. (The segment selector for the application program’s
code segment can be read from the procedure stack following a procedure call.)
See the IA-32 Intel® Architecture Software Developer’s Manual, Volume 3 for more information
about the use of this instruction.
Operation
IF DEST(RPL) < SRC(RPL)
THEN
ZF ←1;
DEST(RPL) ←SRC(RPL);
ELSE
ZF ←0;
FI;
Flags Affected
The ZF flag is set to 1 if the RPL field of the destination operand is less than that of the source
operand; otherwise, is cleared to 0.
Description
Determines if the first operand (array index) is within the bounds of an array specified the second
operand (bounds operand). The array index is a signed integer located in a register. The bounds
operand is a memory location that points to a pair of signed doubleword-integers (when the
operand-size attribute is 32) or a pair of signed word-integers (when the operand-size attribute is
16). The first doubleword (or word) is the lower bound of the array and the second doubleword (or
word) is the upper bound of the array. The array index must be greater than or equal to the lower
bound and less than or equal to the upper bound plus the operand size in bytes. If the index is not
within bounds, a BOUND range exceeded exception (#BR) is signaled. (When a this exception is
generated, the saved return instruction pointer points to the BOUND instruction.)
The bounds limit data structure (two words or doublewords containing the lower and upper limits
of the array) is usually placed just before the array itself, making the limits addressable via a
constant offset from the beginning of the array. Because the address of the array already will be
present in a register, this practice avoids extra bus cycles to obtain the effective address of the array
bounds.
Operation
IF (ArrayIndex < LowerBound OR ArrayIndex > (UppderBound + OperandSize/8]))
(* Below lower bound or above upper bound *)
THEN
#BR;
FI;
Flags Affected
None.
Description
Searches the source operand (second operand) for the least significant set bit (1 bit). If a least
significant 1 bit is found, its bit index is stored in the destination operand (first operand). The
source operand can be a register or a memory location; the destination operand is a register. The bit
index is an unsigned offset from bit 0 of the source operand. If the contents source operand are 0,
the contents of the destination operand is undefined.
Operation
IF SRC = 0
THEN
ZF ←1;
DEST is undefined;
ELSE
ZF ←0;
temp ←0;
WHILE Bit(SRC, temp) = 0
DO
temp ←temp + 1;
DEST ←temp;
OD;
FI;
Flags Affected
The ZF flag is set to 1 if all the source operand is 0; otherwise, the ZF flag is cleared. The CF, OF,
SF, AF, and PF, flags are undefined.
Description
Searches the source operand (second operand) for the most significant set bit (1 bit). If a most
significant 1 bit is found, its bit index is stored in the destination operand (first operand). The
source operand can be a register or a memory location; the destination operand is a register. The bit
index is an unsigned offset from bit 0 of the source operand. If the contents source operand are 0,
the contents of the destination operand is undefined.
Operation
IF SRC = 0
THEN
ZF ←1;
DEST is undefined;
ELSE
ZF ←0;
temp ←OperandSize - 1;
WHILE Bit(SRC, temp) = 0
DO
temp ←temp −1;
DEST ←temp;
OD;
FI;
Flags Affected
The ZF flag is set to 1 if all the source operand is 0; otherwise, the ZF flag is cleared. The CF, OF,
SF, AF, and PF, flags are undefined.
Description
Reverses the byte order of a 32-bit (destination) register: bits 0 through 7 are swapped with bits 24
through 31, and bits 8 through 15 are swapped with bits 16 through 23. This instruction is provided
for converting little-endian values to big-endian format and vice versa.
To swap bytes in a word value (16-bit register), use the XCHG instruction. When the BSWAP
instruction references a 16-bit register, the result is undefined.
Operation
TEMP ←DEST
DEST(7..0) ←TEMP(31..24)
DEST(15..8) ←TEMP(23..16)
DEST(23..16) ←TEMP(15..8)
DEST(31..24) ←TEMP(7..0)
Flags Affected
None.
None.
The BSWAP instruction is not supported on Intel architecture processors earlier than the Intel486™
processor family. For compatibility with this instruction, include functionally-equivalent code for
execution on Intel processors earlier than the Intel486 processor family.
Description
Selects the bit in a bit string (specified with the first operand, called the bit base) at the bit-position
designated by the bit offset operand (second operand) and stores the value of the bit in the CF flag.
The bit base operand can be a register or a memory location; the bit offset operand can be a register
or an immediate value. If the bit base operand specifies a register, the instruction takes the modulo
16 or 32 (depending on the register size) of the bit offset operand, allowing any bit position to be
selected in a 16- or 32-bit register, respectively. If the bit base operand specifies a memory location,
it represents the address of the byte in memory that contains the bit base (bit 0 of the specified byte)
of the bit string. The offset operand then selects a bit position within the range −231 to 231 −1 for a
register offset and 0 to 31 for an immediate offset.
Some assemblers support immediate bit offsets larger than 31 by using the immediate bit offset
field in combination with the displacement field of the memory operand. In this case, the low-order
3 or 5 bits (3 for 16-bit operands, 5 for 32-bit operands) of the immediate bit offset are stored in the
immediate bit offset field, and the high-order bits are shifted and combined with the byte
displacement in the addressing mode by the assembler. The processor will ignore the high order bits
if they are not zero.
When accessing a bit in memory, the processor may access 4 bytes starting from the memory
address for a 32-bit operand size, using by the following relationship:
Effective Address + (4 ∗ (BitOffset DIV 32))
Or, it may access 2 bytes starting from the memory address for a 16-bit operand, using this
relationship:
Effective Address + (2 ∗ (BitOffset DIV 16))
It may do so even when only a single byte needs to be accessed to reach the given bit. When using
this bit addressing mechanism, software should avoid referencing areas of memory close to address
space holes. In particular, it should avoid references to memory-mapped I/O registers. Instead,
software should use the MOV instructions to load from or store to these addresses, and use the
register form of these instructions to manipulate the data.
Operation
CF ←Bit(BitBase, BitOffset)
Flags Affected
The CF flag contains the value of the selected bit. The OF, SF, ZF, AF, and PF flags are undefined.
Description
Selects the bit in a bit string (specified with the first operand, called the bit base) at the bit-position
designated by the bit offset operand (second operand), stores the value of the bit in the CF flag, and
complements the selected bit in the bit string. The bit base operand can be a register or a memory
location; the bit offset operand can be a register or an immediate value. If the bit base operand
specifies a register, the instruction takes the modulo 16 or 32 (depending on the register size) of the
bit offset operand, allowing any bit position to be selected in a 16- or 32-bit register, respectively. If
the bit base operand specifies a memory location, it represents the address of the byte in memory
that contains the bit base (bit 0 of the specified byte) of the bit string. The offset operand then
selects a bit position within the range −231 to 231 −1 for a register offset and 0 to 31 for an immediate
offset.
Some assemblers support immediate bit offsets larger than 31 by using the immediate bit offset
field in combination with the displacement field of the memory operand. See “BT—Bit Test” on
page 0:410 for more information on this addressing mechanism.
Operation
CF ←Bit(BitBase, BitOffset)
Bit(BitBase, BitOffset) ←NOT Bit(BitBase, BitOffset);
Flags Affected
The CF flag contains the value of the selected bit before it is complemented. The OF, SF, ZF, AF,
and PF flags are undefined.
Description
Selects the bit in a bit string (specified with the first operand, called the bit base) at the bit-position
designated by the bit offset operand (second operand), stores the value of the bit in the CF flag, and
clears the selected bit in the bit string to 0. The bit base operand can be a register or a memory
location; the bit offset operand can be a register or an immediate value. If the bit base operand
specifies a register, the instruction takes the modulo 16 or 32 (depending on the register size) of the
bit offset operand, allowing any bit position to be selected in a 16- or 32-bit register, respectively. If
the bit base operand specifies a memory location, it represents the address of the byte in memory
that contains the bit base (bit 0 of the specified byte) of the bit string. The offset operand then
selects a bit position within the range −231 to 231 −1 for a register offset and 0 to 31 for an immediate
offset.
Some assemblers support immediate bit offsets larger than 31 by using the immediate bit offset
field in combination with the displacement field of the memory operand. See “BT—Bit Test” on
page 0:410 for more information on this addressing mechanism.
Operation
CF ←Bit(BitBase, BitOffset)
Bit(BitBase, BitOffset) ←0;
Flags Affected
The CF flag contains the value of the selected bit before it is cleared. The OF, SF, ZF, AF, and PF
flags are undefined.
Description
Selects the bit in a bit string (specified with the first operand, called the bit base) at the bit-position
designated by the bit offset operand (second operand), stores the value of the bit in the CF flag, and
sets the selected bit in the bit string to 1. The bit base operand can be a register or a memory
location; the bit offset operand can be a register or an immediate value. If the bit base operand
specifies a register, the instruction takes the modulo 16 or 32 (depending on the register size) of the
bit offset operand, allowing any bit position to be selected in a 16- or 32-bit register, respectively. If
the bit base operand specifies a memory location, it represents the address of the byte in memory
that contains the bit base (bit 0 of the specified byte) of the bit string. The offset operand then
selects a bit position within the range −231 to 231 −1 for a register offset and 0 to 31 for an immediate
offset.
Some assemblers support immediate bit offsets larger than 31 by using the immediate bit offset
field in combination with the displacement field of the memory operand. See “BT—Bit Test” on
page 0:410 for more information on this addressing mechanism.
Operation
CF ←Bit(BitBase, BitOffset)
Bit(BitBase, BitOffset) ←1;
Flags Affected
The CF flag contains the value of the selected bit before it is set. The OF, SF, ZF, AF, and PF flags
are undefined.
Description
Saves procedure linking information on the procedure stack and jumps to the procedure (called
procedure) specified with the destination (target) operand. The target operand specifies the address
of the first instruction in the called procedure. This operand can be an immediate value, a
general-purpose register, or a memory location.
The latter two call types (inter-privilege-level call and task switch) can only be executed in
protected mode. See Chapter 6 in the IA-32 Intel® Architecture Software Developer’s Manual,
Volume 3 for information on task switching with the CALL instruction.
When executing a near call, the processor pushes the value of the EIP register (which contains the
address of the instruction following the CALL instruction) onto the procedure stack (for use later as
a return-instruction pointer. The processor then jumps to the address specified with the target
operand for the called procedure. The target operand specifies either an absolute address in the code
segment (that is an offset from the base of the code segment) or a relative offset (a signed offset
relative to the current value of the instruction pointer in the EIP register, which points to the
instruction following the call). An absolute address is specified directly in a register or indirectly in
a memory location (r/m16 or r/m32 target-operand form). (When accessing an absolute address
indirectly using the stack pointer (ESP) as a base register, the base value used is the value of the
ESP before the instruction executes.) A relative offset (rel16 or rel32) is generally specified as a
label in assembly code, but at the machine code level, it is encoded as a signed, 16- or 32-bit
immediate value, which is added to the instruction pointer.
When executing a far call, the processor pushes the current value of both the CS and EIP registers
onto the procedure stack for use as a return-instruction pointer. The processor then performs a far
jump to the code segment and address specified with the target operand for the called procedure.
Here the target operand specifies an absolute far address either directly with a pointer (ptr16:16 or
ptr16:32) or indirectly with a memory location (m16:16 or m16:32). With the pointer method, the
segment and address of the called procedure is encoded in the instruction using a 4-byte (16-bit
operand size) or 6-byte (32-bit operand size) far address immediate. With the indirect method, the
target operand specifies a memory location that contains a 4-byte (16-bit operand size) or 6-byte
(32-bit operand size) far address. The operand-size attribute determines the size of the offset (16 or
32 bits) in the far address. The far address is loaded directly into the CS and EIP registers. If the
operand-size attribute is 16, the upper two bytes of the EIP register are cleared to 0s.
Any far call from a 32-bit code segment to a 16-bit code segment should be made from the first
64 Kbytes of the 32-bit code segment, because the operand-size attribute of the instruction is set to
16, allowing only a 16-bit return address offset to be saved. Also, the call should be made using a
16-bit call gate so that 16-bit values will be pushed on the stack.
When the processor is operating in protected mode, a far call can also be used to access a code
segment at a different privilege level or to switch tasks. Here, the processor uses the segment
selector part of the far address to access the segment descriptor for the segment being jumped to.
Depending on the value of the type and access rights information in the segment selector, the
CALL instructon can perform:
• A far call to the same privilege level (described in the previous paragraph).
• An far call to a different privilege level. Results in an IA-32_Intercept(Gate) in Itanium
System Environment.
• A task switch. Results in an IA-32_Intercept(Gate) in Itanium System Environment.
When executing an inter-privilege-level far call, the code segment for the procedure being called is
accessed through a call gate. The segment selector specified by the target operand identifies the call
gate. In executing a call through a call gate where a change of privilege level occurs, the processor
switches to the stack for the privilege level of the called procedure, pushes the current values of the
CS and EIP registers and the SS and ESP values for the old stack onto the new stack, then performs
a far jump to the new code segment. The new code segment is specified in the call gate descriptor;
the new stack segment is specified in the TSS for the currently running task. The jump to the new
code segment occurs after the stack switch. On the new stack, the processor pushes the segment
selector and stack pointer for the calling procedure’s stack, a set of parameters from the calling
procedures stack, and the segment selector and instruction pointer for the calling procedure’s code
segment. (A value in the call gate descriptor determines how many parameters to copy to the new
stack.)
Finally, the processor jumps to the address of the procedure being called within the new code
segment. The procedure address is the offset specified by the target operand. Here again, the target
operand can specify the far address of the call gate and procedure either directly with a pointer
(ptr16:16 or ptr16:32) or indirectly with a memory location (m16:16 or m16:32).
Operation
IF near call
THEN IF near relative call
IF the instruction pointer is not within code segment limit THEN #GP(0); FI;
THEN IF OperandSize = 32
THEN
IF stack not large enough for a 4-byte return address THEN #SS(0); FI;
Push(EIP);
EIP ←EIP + DEST; (* DEST is rel32 *)
ELSE (* OperandSize = 16 *)
IF stack not large enough for a 2-byte return address THEN #SS(0); FI;
Push(IP);
EIP ←(EIP + DEST) AND 0000FFFFH; (* DEST is rel16 *)
FI;
FI;
ELSE (* near absolute call *)
IF the instruction pointer is not within code segment limit THEN #GP(0); FI;
IF OperandSize = 32
THEN
IF stack not large enough for a 4-byte return address THEN #SS(0); FI;
Push(EIP);
EIP ←DEST; (* DEST is r/m32 *)
ELSE (* OperandSize = 16 *)
IF stack not large enough for a 2-byte return address THEN #SS(0); FI;
Push(IP);
EIP ←DEST AND 0000FFFFH; (* DEST is r/m16 *)
FI;
FI:
IF Itanium System Environment AND PSR.tb THEN IA_32_Exception(Debug);
FI;
IF far call AND (PE = 0 OR (PE = 1 AND VM = 1)) (* real address or virtual 8086 mode *)
THEN
IF OperandSize = 32
THEN
IF stack not large enough for a 6-byte return address THEN #SS(0); FI;
IF the instruction pointer is not within code segment limit THEN #GP(0); FI;
Push(CS); (* padded with 16 high-order bits *)
Push(EIP);
CS ←DEST[47:32]; (* DEST is ptr16:32 or [m16:32] *)
EIP ←DEST[31:0]; (* DEST is ptr16:32 or [m16:32] *)
ELSE (* OperandSize = 16 *)
IF stack not large enough for a 4-byte return address THEN #SS(0); FI;
IF the instruction pointer is not within code segment limit THEN #GP(0); FI;
Push(CS);
Push(IP);
IF far call AND (PE = 1 AND VM = 0) (* Protected mode, not virtual 8086 mode *)
THEN
IF segment selector in target operand null THEN #GP(0); FI;
IF segment selector index not within descriptor table limits
THEN #GP(new code selector);
FI;
Read type and access rights of selected segment descriptor;
IF segment type is not a conforming or nonconforming code segment, call gate,
task gate, or TSS THEN #GP(segment selector); FI;
Depending on type and access rights
GO TO CONFORMING-CODE-SEGMENT;
GO TO NONCONFORMING-CODE-SEGMENT;
GO TO CALL-GATE;
GO TO TASK-GATE;
GO TO TASK-STATE-SEGMENT;
FI;
CONFORMING-CODE-SEGMENT:
IF DPL > CPL THEN #GP(new code segment selector); FI;
IF not present THEN #NP(selector); FI;
IF OperandSize = 32
THEN
IF stack not large enough for a 6-byte return address THEN #SS(0); FI;
IF the instruction pointer is not within code segment limit THEN #GP(0); FI;
Push(CS); (* padded with 16 high-order bits *)
Push(EIP);
CS ←DEST(NewCodeSegmentSelector);
(* segment descriptor information also loaded *)
CS(RPL) ←CPL
EIP ←DEST(offset);
ELSE (* OperandSize = 16 *)
IF stack not large enough for a 4-byte return address THEN #SS(0); FI;
IF the instruction pointer is not within code segment limit THEN #GP(0); FI;
Push(CS);
Push(IP);
CS ←DEST(NewCodeSegmentSelector);
(* segment descriptor information also loaded *)
CS(RPL) ←CPL
EIP ←DEST(offset) AND 0000FFFFH; (* clear upper 16 bits *)
FI;
IF Itanium System Environment AND PSR.tb THEN IA_32_Exception(Debug);
END;
NONCONFORMING-CODE-SEGMENT:
IF (RPL > CPL) OR (DPL ≠ CPL) THEN #GP(new code segment selector); FI;
IF stack not large enough for return address THEN #SS(0); FI;
tempEIP ←DEST(offset)
IF OperandSize=16
THEN
tempEIP ←tempEIP AND 0000FFFFH; (* clear upper 16 bits *)
FI;
IF tempEIP outside code segment limit THEN #GP(0); FI;
IF OperandSize = 32
THEN
Push(CS); (* padded with 16 high-order bits *)
Push(EIP);
CS ←DEST(NewCodeSegmentSelector);
(* segment descriptor information also loaded *)
CS(RPL) ←CPL;
EIP ←tempEIP;
ELSE (* OperandSize = 16 *)
Push(CS);
Push(IP);
CS ←DEST(NewCodeSegmentSelector);
(* segment descriptor information also loaded *)
CS(RPL) ←CPL;
EIP ←tempEIP;
FI;
IF Itanium System Environment AND PSR.tb THEN IA_32_Exception(Debug);
END;
CALL-GATE:
IF call gate DPL < CPL or RPL THEN #GP(call gate selector); FI;
IF not present THEN #NP(call gate selector); FI;
IF Itanium System Environment THEN IA-32_Intercept(Gate,CALL);
IF call gate code-segment selector is null THEN #GP(0); FI;
IF call gate code-segment selector index is outside descriptor table limits
THEN #GP(code segment selector); FI;
Read code segment descriptor;
IF code-segment segment descriptor does not indicate a code segment
OR code-segment segment descriptor DPL > CPL
THEN #GP(code segment selector); FI;
IF code segment not present THEN #NP(new code segment selector); FI;
IF code segment is non-conforming AND DPL < CPL
THEN go to MORE-PRIVILEGE;
ELSE go to SAME-PRIVILEGE;
FI;
END;
MORE-PRIVILEGE:
IF current TSS is 32-bit TSS
THEN
TSSstackAddress ←new code segment (DPL ∗ 8) + 4
IF (TSSstackAddress + 7) > TSS limit
THEN #TS(current TSS selector); FI;
newSS ←TSSstackAddress + 4;
newESP ←stack address;
ELSE (* TSS is 16-bit *)
TSSstackAddress ←new code segment (DPL ∗ 4) + 2
IF (TSSstackAddress + 4) > TSS limit
THEN #TS(current TSS selector); FI;
newESP ←TSSstackAddress;
newSS ←TSSstackAddress + 2;
FI;
IF stack segment selector is null THEN #TS(stack segment selector); FI;
IF stack segment selector index is not within its descriptor table limits
THEN #TS(SS selector); FI
Read code segment descriptor;
IF stack segment selector's RPL ≠ DPL of code segment
OR stack segment DPL ≠ DPL of code segment
OR stack segment is not a writable data segment
THEN #TS(SS selector); FI
IF stack segment not present THEN #SS(SS selector); FI;
IF CallGateSize = 32
THEN
IF stack does not have room for parameters plus 16 bytes
THEN #SS(SS selector); FI;
IF CallGate(InstructionPointer) not within code segment limit THEN #GP(0); FI;
SS ←newSS;
(* segment descriptor information also loaded *)
ESP ←newESP;
CS:EIP ←CallGate(CS:InstructionPointer);
(* segment descriptor information also loaded *)
Push(oldSS:oldESP); (* from calling procedure *)
temp ←parameter count from call gate, masked to 5 bits;
Push(parameters from calling procedure’s stack, temp)
Push(oldCS:oldEIP); (* return address to calling procedure *)
ELSE (* CallGateSize = 16 *)
IF stack does not have room for parameters plus 8 bytes
THEN #SS(SS selector); FI;
IF (CallGate(InstructionPointer) AND FFFFH) not within code segment limit
THEN #GP(0); FI;
SS ←newSS;
(* segment descriptor information also loaded *)
ESP ←newESP;
CS:IP ←CallGate(CS:InstructionPointer);
(* segment descriptor information also loaded *)
Push(oldSS:oldESP); (* from calling procedure *)
temp ←parameter count from call gate, masked to 5 bits;
Push(parameters from calling procedure’s stack, temp)
Push(oldCS:oldEIP); (* return address to calling procedure *)
FI;
CPL ←CodeSegment(DPL)
CS(RPL) ←CPL
END;
SAME-PRIVILEGE:
IF CallGateSize = 32
THEN
IF stack does not have room for 8 bytes
THEN #SS(0); FI;
IF EIP not within code segment limit then #GP(0); FI;
CS:EIP ←CallGate(CS:EIP) (* segment descriptor information also loaded *)
Push(oldCS:oldEIP); (* return address to calling procedure *)
ELSE (* CallGateSize = 16 *)
TASK-GATE:
IF task gate DPL < CPL or RPL
THEN #GP(task gate selector);
FI;
IF task gate not present
THEN #NP(task gate selector);
FI;
IF Itanium System Environment THEN IA-32_Intercept(Gate,CALL);
Read the TSS segment selector in the task-gate descriptor;
IF TSS segment selector local/global bit is set to local
OR index not within GDT limits
THEN #GP(TSS selector);
FI;
Access TSS descriptor in GDT;
IF TSS descriptor specifies that the TSS is busy (low-order 5 bits set to 00001)
THEN #GP(TSS selector);
FI;
IF TSS not present
THEN #NP(TSS selector);
FI;
SWITCH-TASKS (with nesting) to TSS;
IF EIP not within code segment limit
THEN #GP(0);
FI;
END;
TASK-STATE-SEGMENT:
IF TSS DPL < CPL or RPL
ORTSS segment selector local/global bit is set to local
OR TSS descriptor indicates TSS not available
THEN #GP(TSS selector);
FI;
IF TSS is not present
THEN #NP(TSS selector);
FI;
IF Itanium System Environment THEN IA-32_Intercept(Gate,CALL);
SWITCH-TASKS (with nesting) to TSS
IF EIP not within code segment limit
THEN #GP(0);
FI;
END;
Flags Affected
All flags are affected if a task switch occurs; no flags are affected if a task switch does not occur.
Description
Double the size of the source operand by means of sign extension. The CBW (convert byte to
word) instruction copies the sign (bit 7) in the source operand into every bit in the AH register. The
CWDE (convert word to doubleword) instruction copies the sign (bit 15) of the word in the AX
register into the higher 16 bits of the EAX register.
The CBW and CWDE mnemonics reference the same opcode. The CBW instruction is intended for
use when the operand-size attribute is 16 and the CWDE instruction for when the operand-size
attribute is 32. Some assemblers may force the operand size to 16 when CBW is used and to 32
when CWDE is used. Others may treat these mnemonics as synonyms (CBW/CWDE) and use the
current setting of the operand-size attribute to determine the size of values to be converted,
regardless of the mnemonic used.
The CWDE instruction is different from the CWD (convert word to double) instruction. The CWD
instruction uses the DX:AX register pair as a destination operand; whereas, the CWDE instruction
uses the EAX register as a destination.
Operation
IF OperandSize = 16 (* instruction = CBW *)
THEN AX ←SignExtend(AL);
ELSE (* OperandSize = 32, instruction = CWDE *)
EAX ←SignExtend(AX);
FI;
Flags Affected
None.
None.
Description
Operation
CF ←0;
Flags Affected
The CF flag is cleared to 0. The OF, ZF, SF, AF, and PF flags are unaffected.
None.
Description
Clears the DF flag in the EFLAGS register. When the DF flag is set to 0, string operations
increment the index registers (ESI and/or EDI).
Operation
DF ←0;
Flags Affected
The DF flag is cleared to 0. The CF, OF, ZF, SF, AF, and PF flags are unaffected.
None.
Description
Clears the IF flag in the EFLAGS register. No other flags are affected. Clearing the IF flag causes
the processor to ignore maskable external interrupts. The IF flag and the CLI and STI instruction
have no affect on the generation of exceptions and NMI interrupts. In the Itanium System
Environment, external interrupts are enabled for IA-32 instructions if PSR.i and (~CFLG.if
or EFLAG.if) is 1 and for Itanium instructions if PSR.i is 1.
The following decision table indicates the action of the CLI instruction (bottom of the table)
depending on the processor’s mode of operating and the CPL and IOPL of the currently running
program or procedure (top of the table).
PE = 0 1 1 1 1
VM = X 0 X 0 1
CPL X ≤IOPL X > IOPL X
IOPL X X =3 X <3
IF ←0 Y Y Y N N
#GP(0) N N N Y Y
Notes:
XDon't care.
NAction in column 1 not taken.
YAction in column 1 taken.
Operation
OLD_IF <- IF;
IF PE = 0 (* Executing in real-address mode *)
THEN
IF ←0;
ELSE
IF VM = 0 (* Executing in protected mode *)
THEN
IF CR4.PVI = 1
THEN
IF CPL = 3
THEN
IF IOPL<3
THEN VIF <- 0;
ELSE IF <- 0;
FI;
ELSE (*CPL < 3*)
IF IOPL < CPL
THEN #GP(0);
ELSE IF <- 0;
FI;
FI;
ELSE (*CR4.PVI==0 *)
IF IOPL < CPL
THEN #GP(0);
ELSE IF <- 0;
FI;
FI;
ELSE (* Executing in Virtual-8086 mode *)
IF IOPL = 3
THEN
IF ←0;
ELSE
IF CR4.VME= 0
THEN #GP(0);
ELSE VIF <- 0;
FI;
FI;
FI;
FI;
IF Itanium System Environment AND CFLG.ii AND IF != OLD_IF
THEN IA-32_Intercept(System_Flag,CLI);
Flags Affected
The IF is cleared to 0 if the CPL is equal to or less than the IOPL; otherwise, the it is not affected.
The other flags in the EFLAGS register are unaffected.
None.
Description
Clears the task-switched (TS) flag in the CR0 register. This instruction is intended for use in
operating-system procedures. It is a privileged instruction that can only be executed at a CPL of 0.
It is allowed to be executed in real-address mode to allow initialization for protected mode.
The processor sets the TS flag every time a task switch occurs. The flag is used to synchronize the
saving of FPU context in multitasking applications. See the description of the TS flag in the IA-32
Intel® Architecture Software Developer’s Manual, Volume 3 for more information about this flag.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,CLTS);
CR0(TS) ←0;
Flags Affected
None.
Description
Operation
CF ←NOT CF;
Flags Affected
The CF flag contains the complement of its original value. The OF, ZF, SF, AF, and PF flags are
unaffected.
None.
Description
The CMOVcc instructions check the state of one or more of the status flags in the EFLAGS register
(CF, OF, PF, SF, and ZF) and perform a move operation if the flags are in a specified state (or
condition). A condition code (cc) is associated with each instruction to indicate the condition being
tested for. If the condition is not satisfied, a move is not performed and execution continues with
the instruction following the CMOVcc instruction.
If the condition is false for the memory form, some processor implementations will initiate the load
(and discard the loaded data), possible memory faults can be generated. Other processor models
will not initiate the load and not generate any faults if the condition is false.
These instructions can move a 16- or 32-bit value from memory to a general-purpose register or
from one general-purpose register to another. Conditional moves of 8-bit register operands are not
supported.
The conditions for each CMOVcc mnemonic is given in the description column of the above table.
The terms “less” and “greater” are used for comparisons of signed integers and the terms “above”
and “below” are used for unsigned integers.
Because a particular state of the status flags can sometimes be interpreted in two ways, two
mnemonics are defined for some opcodes. For example, the CMOVA (conditional move if above)
instruction and the CMOVNBE (conditional move if not below or equal) instruction are alternate
mnemonics for the opcode 0F 47H.
Operation
temp ←DEST
IF condition TRUE
THEN
DEST ←SRC
ELSE
DEST ←temp
FI;
Flags Affected
None.
If the condition is false for the memory form, some processor implementations will initiate the load
(and discard the loaded data), possible memory faults can be generated. Other processor models
will not initiate the load and not generate any faults if the condition is false.
Description
Compares the first source operand with the second source operand and sets the status flags in the
EFLAGS register according to the results. The comparison is performed by subtracting the second
operand from the first operand and then setting the status flags in the same manner as the SUB
instruction. When an immediate value is used as an operand, it is sign-extended to the length of the
first operand.
The CMP instruction is typically used in conjunction with a conditional jump (Jcc), condition move
(CMOVcc), or SETcc instruction. The condition codes used by the Jcc, CMOVcc, and SETcc
instructions are based on the results of a CMP instruction.
Operation
temp ←SRC1 −SignExtend(SRC2);
ModifyStatusFlags; (* Modify status flags in the same manner as the SUB instruction*)
Flags Affected
The CF, OF, SF, ZF, AF, and PF flags are set according to the result.
Description
Compares the byte, word, or double word specified with the first source operand with the byte,
word, or double word specified with the second source operand and sets the status flags in the
EFLAGS register according to the results. The first source operand specifies the memory location
at the address DS:ESI and the second source operand specifies the memory location at address
ES:EDI. (When the operand-size attribute is 16, the SI and DI register are used as the source-index
and destination-index registers, respectively.) The DS segment may be overridden with a segment
override prefix, but the ES segment cannot be overridden.
The CMPSB, CMPSW, and CMPSD mnemonics are synonyms of the byte, word, and doubleword
versions of the CMPS instructions. They are simpler to use, but provide no type or segment
checking. (For the CMPS instruction, “DS:ESI” and “ES:EDI” must be explicitly specified in the
instruction.)
After the comparison, the ESI and EDI registers are incremented or decremented automatically
according to the setting of the DF flag in the EFLAGS register. (If the DF flag is 0, the ESI and EDI
register are incremented; if the DF flag is 1, the ESI and EDI registers are decremented.) The
registers are incremented or decremented by 1 for byte operations, by 2 for word operations, or by
4 for doubleword operations.
The CMPS, CMPSB, CMPSW, and CMPSD instructions can be preceded by the REP prefix for
block comparisons of ECX bytes, words, or doublewords. More often, however, these instructions
will be used in a LOOP construct that takes some action based on the setting of the status flags
before the next comparison is made.
Operation
temp ←SRC1 −SRC2;
SetStatusFlags(temp);
IF (byte comparison)
THEN IF DF = 0
THEN (E)DI ←1; (E)SI ←1;
ELSE (E)DI ←-1; (E)SI ←-1;
FI;
ELSE IF (word comparison)
THEN IF DF = 0
THEN DI ←2; (E)SI ←2;
ELSE DI ←-2; (E)SI ←-2;
FI;
ELSE (* doubleword comparison *)
THEN IF DF = 0
THEN EDI ←4; (E)SI ←4;
ELSE EDI ←-4; (E)SI ←-4;
FI;
FI;
FI;
Flags Affected
The CF, OF, SF, ZF, AF, and PF flags are set according to the temporary result of the comparison.
Description
Compares the value in the AL, AX, or EAX register (depending on the size of the operand) with the
first operand (destination operand). If the two values are equal, the second operand (source
operand) is loaded into the destination operand. Otherwise, the destination operand is loaded into
the AL, AX, or EAX register.
This instruction can be used with a LOCK prefix to allow the instruction to be executed atomically.
To simplify the interface to the processor’s bus, the destination operand receives a write cycle
without regard to the result of the comparison. The destination operand is written back if the
comparison fails; otherwise, the source operand is written into the destination. (The processor
never produces a locked read without also producing a locked write.)
Operation
(* accumulator = AL, AX, or EAX, depending on whether *)
(* a byte, word, or doubleword comparison is being performed*)
Flags Affected
The ZF flag is set if the values in the destination operand and register AL, AX, or EAX are;
otherwise it is cleared. The CF, PF, AF, SF, and OF flags are set according to the results of the
comparison operation.
This instruction is not supported on Intel processors earlier than the Intel486 processors.
Description
Compares the 64-bit value in EDX:EAX with the operand (destination operand). If the values are
equal, the 64-bit value in ECX:EBX is stored in the destination operand. Otherwise, the value in the
destination operand is loaded into EDX:EAX. The destination operand is an 8-byte memory
location. For the EDX:EAX and ECX:EBX register pairs, EDX and ECX contain the high-order
32 bits and EAX and EBX contain the low-order 32 bits of a 64-bit value.
This instruction can be used with a LOCK prefix to allow the instruction to be executed atomically.
To simplify the interface to the processor’s bus, the destination operand receives a write cycle
without regard to the result of the comparison. The destination operand is written back if the
comparison fails; otherwise, the source operand is written into the destination. (The processor
never produces a locked read without also producing a locked write.)
Operation
IF Itanium System Environment AND External_Atomic_Lock_Required AND DCR.lc
THEN IA-32_Intercept(LOCK,CMPXCHG);
IF (EDX:EAX = DEST)
ZF ←1
DEST ←ECX:EBX
ELSE
ZF ←0
EDX:EAX ←DEST
Flags Affected
The ZF flag is set if the destination operand and EDX:EAX are equal; otherwise it is cleared. The
CF, PF, AF, SF, and OF flags are unaffected.
This instruction is not supported on Intel processors earlier than the Pentium processors.
Description
Returns processor identification and feature information in the EAX, EBX, ECX, and EDX
registers. The information returned is selected by entering a value in the EAX register before the
instruction is executed. Table 1-4 shows the information returned, depending on the initial value
loaded into the EAX register.
The ID flag (bit 21) in the EFLAGS register indicates support for the CPUID instruction. If a
software procedure can set and clear this flag, the processor executing the procedure supports the
CPUID instruction.
The information returned with the CPUID instruction is divided into two groups: basic information
and extended function information. Basic information is returned by entering an input value
starting at 0 in the EAX register; extended function information is returned by entering an input
value starting at 80000000H. When the input value in the EAX register is 0, the processor returns
the highest value the CPUID instruction recognizes in the EAX register for returning basic
information. Always use an EAX parameter value that is equal to or greater than zero and less than
or equal to this highest EAX return value for basic information. When the input value in the EAX
register is 80000000H, the processor returns the highest value the CPUID instruction recognizes in
the EAX register for returning extended function information. Always use an EAX parameter value
that is equal to or greater than zero and less than or equal to this highest EAX return value for
extended function information.
The CPUID instruction can be executed at any privilege level to serialize instruction execution.
Serializing instruction execution guarantees that any modifications to flags, registers, and memory
for previous instructions are completed before the next instruction is fetched and executed.
When the input value is 1, the processor returns version information in the EAX register (see
Figure 1-3). The version information consists of an Intel architecture family identifier, a model
identifier, a stepping ID, and a processor type.
31 28 27 20 19 16 15 14 13 12 11 8 7 43 0
Processor Type
If the values in the family and/or model fields reach or exceed FH, the CPUID instruction will
generate two additional fields in the EAX register: the extended family field and the extended
model field. Here, a value of FH in either the model field or the family field indicates that the
extended model or family field, respectively, is valid. Family and model numbers beyond FH range
from 0FH to FFH, with the least significant hexadecimal digit always FH.
See AP-485, Intel® Processor Identification and the CPUID Instruction (Order Number 241618)
for more information on identifying Intel architecture processors.
When the EAX register contains a value of 1, the CPUID instruction (in addition to loading the
processor signature in the EAX register) loads the EDX register with the feature flags. The feature
flags (when a Flag = 1) indicate what features the processor supports. Table 1-5 lists the currently
defined feature flag values.
A feature flag set to 1 indicates the corresponding feature is supported. Software should identify
Intel as the vendor to properly interpret the feature flags.
When the input value is 2, the processor returns information about the processor’s internal caches
and TLBs in the EAX, EBX, ECX, and EDX registers. The encoding of these registers is as
follows:
• The least-significant byte in register EAX (register AL) indicates the number of times the
CPUID instruction must be executed with an input value of 2 to get a complete description of
the processor’s caches and TLBs.
• The most significant bit (bit 31) of each register indicates whether the register contains valid
information (set to 0) or is reserved (set to 1).
• If a register contains valid information, the information is contained in 1 byte descriptors.
Please see the processor-specific supplement for further information on how to decode the return
values for the processors internal caches and TLBs.
Operation
CASE (EAX) OF
EAX = 0H:
EAX ←Highest input value understood by CPUID;
EBX ←Vendor identification string;
EDX ←Vendor identification string;
ECX ←Vendor identification string;
BREAK;
EAX = 1H:
EAX[3:0] ←Stepping ID;
EAX[7:4] ←Model;
EAX[11:8] ←Family;
EAX[13:12] ←Processor Type;
EAX[15:14] ←Reserved;
EAX[19:16] ←Extended Model;
EAX[27:20] ←Extended Family;
EAX[31:28] ←Reserved;
EBX[7:0] ←Brand Index; (* Always zero for processors based on Itanium architecture *)
EBX[15:8] ←CLFLUSH Line Size;
EBX[16:23] ←Number of logical processors per physical processor;
EBX[31:24] ←Initial APIC ID; (* Reserved for processors based on Itanium architecture *)
ECX ←Reserved;
EDX ←Feature flags;
BREAK;
EAX = 2H:
EAX ←Cache and TLB information;
EBX ←Cache and TLB information;
ECX ←Cache and TLB information;
EDX ←Cache and TLB information;
BREAK;
EAX = 80000000H:
EAX ←Highest extended function input value understood by CPUID;
EBX ←Reserved;
ECX ←Reserved;
EDX ←Reserved;
BREAK;
EAX = 80000001H:
EAX ←Extended Processor Signature and Feature Bits; (* Currently Reserved *)
EBX ←Reserved;
ECX ←Reserved;
EDX ←Reserved;
BREAK;
EAX = 80000002H:
EAX ←Processor Name;
EBX ←Processor Name;
ECX ←Processor Name;
EDX ←Processor Name;
BREAK;
EAX = 80000003H:
EAX ←Processor Name;
EBX ←Processor Name;
ECX ←Processor Name;
EDX ←Processor Name;
BREAK;
EAX = 80000004H:
EAX ←Processor Name;
EBX ←Processor Name;
ECX ←Processor Name;
memory_fence();
instruction_serialize();
Flags Affected
None.
None.
The CPUID instruction is not supported in early models of the Intel486 processor or in any Intel
architecture processor earlier than the Intel486 processor. The ID flag in the EFLAGS register can
be used to determine if this instruction is supported. If a procedure is able to set or clear this flag,
the CPUID is supported by the processor running the procedure.
Description
Doubles the size of the operand in register AX or EAX (depending on the operand size) by means
of sign extension and stores the result in registers DX:AX or EDX:EAX, respectively. The CWD
instruction copies the sign (bit 15) of the value in the AX register into every bit position in the DX
register. The CDQ instruction copies the sign (bit 31) of the value in the EAX register into every bit
position in the EDX register.
The CWD instruction can be used to produce a doubleword dividend from a word before a word
division, and the CDQ instruction can be used to produce a quadword dividend from a doubleword
before doubleword division.
The CWD and CDQ mnemonics reference the same opcode. The CWD instruction is intended for
use when the operand-size attribute is 16 and the CDQ instruction for when the operand-size
attribute is 32. Some assemblers may force the operand size to 16 when CWD is used and to 32
when CDQ is used. Others may treat these mnemonics as synonyms (CWD/CDQ) and use the
current setting of the operand-size attribute to determine the size of values to be converted,
regardless of the mnemonic used.
Operation
IF OperandSize = 16 (* CWD instruction *)
THEN DX ←SignExtend(AX);
ELSE (* OperandSize = 32, CDQ instruction *)
EDX ←SignExtend(EAX);
FI;
Flags Affected
None.
None.
Description
Adjusts the sum of two packed BCD values to create a packed BCD result. The AL register is the
implied source and destination operand. The DAA instruction is only useful when it follows an
ADD instruction that adds (binary addition) two 2-digit, packed BCD values and stores a byte
result in the AL register. The DAA instruction then adjusts the contents of the AL register to
contain the correct 2-digit, packed BCD result. If a decimal carry is detected, the CF and AF flags
are set accordingly.
Operation
IF (((AL AND 0FH) > 9) or AF = 1)
THEN
AL ←AL + 6;
CF ←CF OR CarryFromLastAddition; (* CF OR carry from AL ←AL + 6 *)
AF ←1;
ELSE
AF ←0;
FI;
IF ((AL AND F0H) > 90H) or CF = 1)
THEN
AL ← AL + 60H;
CF ←1;
ELSE
CF ←0;
FI;
Example
Flags Affected
The CF and AF flags are set if the adjustment of the value results in a decimal carry in either digit
of the result (see “Operation” above). The SF, ZF, and PF flags are set according to the result. The
OF flag is undefined.
None.
Description
Adjusts the result of the subtraction of two packed BCD values to create a packed BCD result. The
AL register is the implied source and destination operand. The DAS instruction is only useful when
it follows a SUB instruction that subtracts (binary subtraction) one 2-digit, packed BCD value from
another and stores a byte result in the AL register. The DAS instruction then adjusts the contents of
the AL register to contain the correct 2-digit, packed BCD result. If a decimal borrow is detected,
the CF and AF flags are set accordingly.
Operation
IF (AL AND 0FH) > 9 OR AF = 1
THEN
AL ←AL −6;
CF ←CF OR BorrowFromLastSubtraction; (* CF OR borrow from AL ←AL −6 *)
AF ←1;
ELSE AF ←0;
FI;
IF ((AL > 9FH) or CF = 1)
THEN
AL ←AL −60H;
CF ←1;
ELSE CF ←0;
FI;
Example
Flags Affected
The CF and AF flags are set if the adjustment of the value results in a decimal borrow in either digit
of the result (see “Operation” above). The SF, ZF, and PF flags are set according to the result. The
OF flag is undefined.
None.
Description
Subtracts 1 from the operand, while preserving the state of the CF flag. The source operand can be
a register or a memory location. This instruction allows a loop counter to be updated without
disturbing the CF flag. (Use a SUB instruction with an immediate operand of 1 to perform a
decrement operation that does updates the CF flag.)
Operation
DEST ←DEST - 1;
Flags Affected
The CF flag is not affected. The OF, SF, ZF, AF, and PF flags are set according to the result.
Description
Divides (unsigned) the value in the AL, AX, or EAX register (dividend) by the source operand
(divisor) and stores the result in the AX, DX:AX, or EDX:EAX registers. The source operand can
be a general-purpose register or a memory location. The action of this instruction depends on the
operand size, as shown in the following table:
Maximum
Operand Size Dividend Divisor Quotient Remainder
Quotient
Word/byte AX r/m8 AL AH 255
Doubleword/word DX:AX r/m16 AX DX 65,535
Quadword/doubleword EDX:EAX r/m32 EAX EDX 232 −1
Non-integral results are truncated (chopped) towards 0. The remainder is always less than the
divisor in magnitude. Overflow is indicated with the #DE (divide error) exception rather than with
the CF flag.
Operation
IF SRC = 0
THEN #DE; (* divide error *)
FI;
IF OpernadSize = 8 (* word/byte operation *)
THEN
temp ←AX / SRC;
IF temp > FFH
THEN #DE; (* divide error *) ;
ELSE
AL ←temp;
AH ←AX MOD SRC;
FI;
ELSE
IF OpernadSize = 16 (* doubleword/word operation *)
THEN
temp ←DX:AX / SRC;
IF temp > FFFFH
THEN #DE; (* divide error *) ;
ELSE
AX ←temp;
DX ←DX:AX MOD SRC;
FI;
Flags Affected
The CF, OF, SF, ZF, AF, and PF flags are undefined.
Description
Creates a stack frame for a procedure. The first operand (size operand) specifies the size of the
stack frame (that is, the number of bytes of dynamic storage allocated on the stack for the
procedure). The second operand (nesting level operand) gives the lexical nesting level (0 to 31) of
the procedure. The nesting level determines the number of stack frame pointers that are copied into
the “display area” of the new stack frame from the preceding frame. Both of these operands are
immediate values.
The stack-size attribute determines whether the BP (16 bits) or EBP (32 bits) register specifies the
current frame pointer and whether SP (16 bits) or ESP (32 bits) specifies the stack pointer.
The ENTER and companion LEAVE instructions are provided to support block structured
languages. They do not provide a jump or call to another procedure; they merely set up a new stack
frame for an already called procedure. An ENTER instruction is commonly followed by a CALL,
JMP, or Jcc instruction to transfer program control to the procedure being called.
If the nesting level is 0, the processor pushes the frame pointer from the EBP register onto the
stack, copies the current stack pointer from the ESP register into the EBP register, and loads the
ESP register with the current stack-pointer value minus the value in the size operand. For nesting
levels of 1 or greater, the processor pushes additional frame pointers on the stack before adjusting
the stack pointer. These additional frame pointers provide the called procedure with access points to
other nested frames on the stack.
Operation
NestingLevel ←NestingLevel MOD 32
IF StackSize = 32
THEN
Push(EBP) ;
FrameTemp ←ESP;
ELSE (* StackSize = 16*)
Push(BP);
FrameTemp ←SP;
FI;
IF NestingLevel = 0
THEN GOTO CONTINUE;
FI;
IF (NestingLevel > 0)
FOR i ←1 TO (NestingLevel −1)
DO
IF OperandSize = 32
THEN
IF StackSize = 32
EBP ←EBP −4;
Flags Affected
None.
Itanium Mem FaultsVHPT Data Fault, Nested TLB Fault, Data TLB Fault, Alternate Data TLB
Fault, Data Page Not Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault, Data Dirty Bit Fault
None.
None.
Description
Calculates the exponential value of 2 to the power of the source operand minus 1. The source
operand is located in register ST(0) and the result is also stored in ST(0). The value of the source
operand must lie in the range -1.0 to +1.0. If the source value is outside this range, the result is
undefined.
The following table shows the results obtained when computing the exponential value of various
classes of numbers, assuming that neither overflow nor underflow occurs:
Operation
ST(0) ←(2ST(0) −1);
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Source operand is an SNaN value or unsupported format.
#D Result is a denormal value.
#U Result is too small for destination format.
#P Value cannot be represented exactly in destination format.
Description
Clears the sign bit of ST(0) to create the absolute value of the operand. The following table shows
the results obtained when creating the absolute value of various classes of numbers.
Note:
Fmeans finite-real number.
Operation
ST(0) ←|ST(0)|
Floating-point Exceptions
#IS Stack underflow occurred.
Description
Adds the destination and source operands and stores the sum in the destination location. The
destination operand is always an FPU register; the source operand can be a register or a memory
location. Source operands in memory can be in single-real, double-real, word-integer, or
short-integer formats.
The no-operand version of the instruction adds the contents of the ST(0) register to the ST(1)
register. The one-operand version adds the contents of a memory location (either a real or an integer
value) to the contents of the ST(0) register. The two-operand version, adds the contents of the ST(0)
register to the ST(i) register or vice versa. The value in ST(0) can be doubled by coding:
The FADDP instructions perform the additional operation of popping the FPU register stack after
storing the result. To pop the register stack, the processor marks the ST(0) register as empty and
increments the stack pointer (TOP) by 1. (The no-operand version of the floating-point add
instructions always results in the register stack being popped. In some assemblers, the mnemonic
for this instruction is FADD rather than FADDP.)
The FIADD instructions convert an integer source operand to extended-real format before
performing the addition.
The table on the following page shows the results obtained when adding various classes of
numbers, assuming that neither overflow nor underflow occurs.
When the sum of two operands with opposite signs is 0, the result is +0, except for the round
toward −∞mode, in which case the result is −0. When the source operand is an integer 0, it is treated
as a +0.
When both operand are infinities of the same sign, the result is ∞ of the expected sign. If both
operands are infinities of opposite signs, an invalid-operation exception is generated.
Notes:
Fmeans finite-real number.
Lmeans integer.
*indicates floating-point invalid-arithmetic-operand (#IA) exception.
Operation
IF instruction is FIADD
THEN
DEST ←DEST + ConvertExtendedReal(SRC);
ELSE (* source operand is real number *)
DEST ←DEST + SRC;
FI;
IF instruction = FADDP
THEN
PopRegisterStack;
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Operand is an SNaN value or unsupported format.
Operands are infinities of unlike sign.
#D Result is a denormal value.
#U Result is too small for destination format.
#O Result is too large for destination format.
#P Value cannot be represented exactly in destination format.
Description
Converts the BCD source operand into extended-real format and pushes the value onto the FPU
stack. The source operand is loaded without rounding errors. The sign of the source operand is
preserved, including that of −0.
The packed BCD digits are assumed to be in the range 0 through 9; the instruction does not check
for invalid digits (AH through FH). Attempting to load an invalid encoding produces an undefined
result.
Operation
TOP ←TOP −1;
ST(0) ←ExtendedReal(SRC);
Floating-point Exceptions
#IS Stack overflow occurred.
Description
Converts the value in the ST(0) register to an 18-digit packed BCD integer, stores the result in the
destination operand, and pops the register stack. If the source value is a non-integral value, it is
rounded to an integer value, according to rounding mode specified by the RC field of the FPU
control word. To pop the register stack, the processor marks the ST(0) register as empty and
increments the stack pointer (TOP) by 1.
The destination operand specifies the address where the first byte destination value is to be stored.
The BCD value (including its sign bit) requires 10 bytes of space in memory.
The following table shows the results obtained when storing various classes of numbers in packed
BCD format.
ST(0) DEST
−• *
−F < −1 −D
−1 < −F < −0 **
−0 −0
+0 +0
+0 < +F < +1 **
+F > +1 +D
+∞ *
NaN *
Notes:
Fmeans finite-real number.
Dmeans packed-BCD number.
*indicates floating-point invalid-operation (#IA) exception.
**±0 or ±1, depending on the rounding mode.
If the source value is too large for the destination format and the invalid-operation exception is not
masked, an invalid-operation exception is generated and no value is stored in the destination
operand. If the invalid-operation exception is masked, the packed BCD indefinite value is stored in
memory.
If the source value is a quiet NaN, an invalid-operation exception is generated. Quiet NaNs do not
normally cause this exception to be generated.
Operation
DEST ←BCD(ST(0));
PopRegisterStack;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Source operand is empty; contains a NaN, ±∞, or unsupported format; or
contains value that exceeds 18 BCD digits in length.
#P Value cannot be represented exactly in destination format.
Description
Complements the sign bit of ST(0). This operation changes a positive value into a negative value of
equal magnitude or vice-versa. The following table shows the results obtained when creating the
absolute value of various classes of numbers.
Note:
Fmeans finite-real number.
Operation
SignBit(ST(0)) ←NOT (SignBit(ST(0)))
Floating-point Exceptions
#IS Stack underflow occurred.
Description
Clears the floating-point exception flags (PE, UE, OE, ZE, DE, and IE), the exception summary
status flag (ES), the stack fault flag (SF), and the busy flag (B) in the FPU status word. The FCLEX
instruction checks for and handles any pending unmasked floating-point exceptions before clearing
the exception flags; the FNCLEX instruction does not.
Operation
FPUStatusWord[0..7] ←0;
FPUStatusWord[15] ←0;
The PE, UE, OE, ZE, DE, IE, ES, SF, and B flags in the FPU status word are cleared. The C0, C1,
C2, and C3 flags are undefined.
Floating-point Exceptions
None.
Description
Tests the status flags in the EFLAGS register and moves the source operand (second operand) to
the destination operand (first operand) if the given test condition is true. The source operand is
always in the ST(i) register and the destination operand is always ST(0).
The FCMOVcc instructions are useful for optimizing small IF constructions. They also help
eliminate branching overhead for IF operations and the possibility of branch mispredictions by the
processor.
A processor in the Pentium Pro processor family may not support the FCMOVcc instructions.
Software can check if the FCMOVcc instructions are supported by checking the processor’s feature
information with the CPUID instruction (see “CPUID—CPU Identification” on page 0:448). If
both the CMOV and FPU feature bits are set, the FCMOVcc instructions are supported.
Operation
IF condition TRUE
ST(0) ←ST(i)
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
None.
Description
Compares the contents of register ST(0) and source value and sets condition code flags C0, C2, and
C3 in the FPU status word according to the results (see the table below). The source operand can be
a data register or a memory location. If no source operand is given, the value in ST(0) is compared
with the value in ST(1). The sign of zero is ignored, so that -0.0 = +0.0.
Condition C3 C2 C0
ST(0) > SRC 0 0 0
ST(0) < SRC 0 0 1
ST(0) = SRC 1 0 0
a
Unordered 1 1 1
This instruction checks the class of the numbers being compared. If either operand is a NaN or is in
an unsupported format, an invalid-arithmetic-operand exception (#IA) is raised and, if the
exception is masked, the condition flags are set to “unordered.” If the invalid-arithmetic-operand
exception is unmasked, the condition code flags are not set.
The FCOMP instruction pops the register stack following the comparison operation and the
FCOMPP instruction pops the register stack twice following the comparison operation. To pop the
register stack, the processor marks the ST(0) register as empty and increments the stack pointer
(TOP) by 1.
The FCOM instructions perform the same operation as the FUCOM instructions. The only
difference is how they handle QNaN operands. The FCOM instructions raise an
invalid-arithmetic-operand exception (#IA) when either or both of the operands is a NaN value or is
in an unsupported format. The FUCOM instructions perform the same operation as the FCOM
instructions, except that they do not generate an invalid-arithmetic-operand exception for QNaNs.
Operation
CASE (relation of operands) OF
ST > SRC: C3, C2, C0 ←000;
ST < SRC: C3, C2, C0 ←001;
ST = SRC: C3, C2, C0 ←100;
ESAC;
IF ST(0) or SRC = NaN or unsupported format
THEN
#IA
IF FPUControlWord.IM = 1
THEN
C3, C2, C0 ←111;
FI;
FI;
IF instruction = FCOMP
THEN
PopRegisterStack;
FI;
IF instruction = FCOMPP
THEN
PopRegisterStack;
PopRegisterStack;
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA One or both operands are NaN values or have unsupported formats.
Register is marked empty.
#D One or both operands are denormal values.
Description
Compares the contents of register ST(0) and ST(i) and sets the status flags ZF, PF, and CF in the
EFLAGS register according to the results (see the table below). The sign of zero is ignored for
comparisons, so that -0.0 = +0.0.
Comparison Results ZF PF CF
ST0 > ST(i) 0 0 0
ST0 < ST(i) 0 0 1
ST0 = ST(i) 1 0 0
Unordereda 1 1 1
If invalid-operation exception is unmasked, the status flags are not set if the
invalid-arithmetic-operand exception is generated.
The FCOMIP and FUCOMIP instructions also pop the register stack following the comparison
operation. To pop the register stack, the processor marks the ST(0) register as empty and
increments the stack pointer (TOP) by 1.
Operation
CASE (relation of operands) OF
ST(0) > ST(i): ZF, PF, CF ←000;
ST(0) < ST(i): ZF, PF, CF ←001;
ST(0) = ST(i): ZF, PF, CF ←100;
ESAC;
IF instruction is FCOMI or FCOMIP
THEN
IF ST(0) or ST(i) = NaN or unsupported format
THEN
#IA
IF FPUControlWord.IM = 1
THEN
ZF, PF, CF ←111;
FI;
FI;
FI;
IF instruction is FUCOMI or FUCOMIP
THEN
IF ST(0) or ST(i) = QNaN, but not SNaN or unsupported format
THEN
ZF, PF, CF ←111;
ELSE (* ST(0) or ST(i) is SNaN or unsupported format *)
#IA;
IF FPUControlWord.IM = 1
THEN
ZF, PF, CF ←111;
FI;
FI;
FI;
IF instruction is FCOMIP or FUCOMIP
THEN
PopRegisterStack;
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA (FCOMI or FCOMIP instruction) One or both operands are NaN values or
have unsupported formats.
(FUCOMI or FUCOMIP instruction) One or both operands are SNaN values
(but not QNaNs) or have undefined formats. Detection of a QNaN value does
not raise an invalid-operand exception.
Description
Calculates the cosine of the source operand in register ST(0) and stores the result in ST(0). The
source operand must be given in radians and must be within the range −263 to +263. The following
table shows the results obtained when taking the cosine of various classes of numbers, assuming
that neither overflow nor underflow occurs.
Notes:
Fmeans finite-real number.
* indicates floating-point invalid-arithmetic-operand (#IA) exception.
If the source operand is outside the acceptable range, the C2 flag in the FPU status word is set, and
the value in register ST(0) remains unchanged. The instruction does not raise an exception when
the source operand is out of range. It is up to the program to check the C2 flag for out-of-range
conditions. Source values outside the range −263 to +263 can be reduced to the range of the
instruction by subtracting an appropriate integer multiple of 2π or by using the FPREM instruction
with a divisor of 2π.
Operation
IF |ST(0)| < 263
THEN
C2 ←0;
ST(0) ←cosine(ST(0));
ELSE (*source operand is out-of-range *)
C2 ←1;
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Source operand is an SNaN value, ∞, or unsupported format.
#D Result is a denormal value.
#U Result is too small for destination format.
#P Value cannot be represented exactly in destination format.
Description
Subtracts one from the TOP field of the FPU status word (decrements the top-of-stack pointer). The
contents of the FPU data registers and tag register are not affected.
Operation
IF TOP = 0
THEN TOP ←7;
ELSE TOP ←TOP - 1;
FI;
The C1 flag is set to 0; otherwise, cleared to 0. The C0, C2, and C3 flags are undefined.
Floating-point Exceptions
None.
Description
Divides the destination operand by the source operand and stores the result in the destination
location. The destination operand (dividend) is always in an FPU register; the source operand
(divisor) can be a register or a memory location. Source operands in memory can be in single-real,
double-real, word-integer, or short-integer formats.
The no-operand version of the instruction divides the contents of the ST(1) register by the contents
of the ST(0) register. The one-operand version divides the contents of the ST(0) register by the
contents of a memory location (either a real or an integer value). The two-operand version, divides
the contents of the ST(0) register by the contents of the ST(i) register or vice versa.
The FDIVP instructions perform the additional operation of popping the FPU register stack after
storing the result. To pop the register stack, the processor marks the ST(0) register as empty and
increments the stack pointer (TOP) by 1. The no-operand version of the floating-point divide
instructions always results in the register stack being popped. In some assemblers, the mnemonic
for this instruction is FDIV rather than FDIVP.
The FIDIV instructions convert an integer source operand to extended-real format before
performing the division. When the source operand is an integer 0, it is treated as a +0.
If an unmasked divide by zero exception (#Z) is generated, no result is stored; if the exception is
masked, an ∞ of the appropriate sign is stored in the destination operand.
The following table shows the results obtained when dividing various classes of numbers, assuming
that neither overflow nor underflow occurs.
Notes:
Fmeans finite-real number.
Imeans integer.
*indicates floating-point invalid-arithmetic-operand (#IA) exception.
**indicates floating-point zero-divide (#Z) exception.
Operation
IF SRC = 0
THEN
#Z
ELSE
IF instruction is FIDIV
THEN
DEST ←DEST / ConvertExtendedReal(SRC);
ELSE (* source operand is real number *)
DEST ←DEST / SRC;
FI;
FI;
IF instruction = FDIVP
THEN
PopRegisterStack
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Operand is an SNaN value or unsupported format.
±∞ / ±∞; ±0 / ±0
#D Result is a denormal value.
#Z DEST / ±0, where DEST is not equal to ±0.
#U Result is too small for destination format.
#O Result is too large for destination format.
#P Value cannot be represented exactly in destination format.
Description
Divides the source operand by the destination operand and stores the result in the destination
location. The destination operand (divisor) is always in an FPU register; the source operand
(dividend) can be a register or a memory location. Source operands in memory can be in
single-real, double-real, word-integer, or short-integer formats.
These instructions perform the reverse operations of the FDIV, FDIVP, and FIDIV instructions.
They are provided to support more efficient coding.
The no-operand version of the instruction divides the contents of the ST(0) register by the contents
of the ST(1) register. The one-operand version divides the contents of a memory location (either a
real or an integer value) by the contents of the ST(0) register. The two-operand version, divides the
contents of the ST(i) register by the contents of the ST(0) register or vice versa.
The FDIVRP instructions perform the additional operation of popping the FPU register stack after
storing the result. To pop the register stack, the processor marks the ST(0) register as empty and
increments the stack pointer (TOP) by 1. The no-operand version of the floating-point divide
instructions always results in the register stack being popped. In some assemblers, the mnemonic
for this instruction is FDIVR rather than FDIVRP.
The FIDIVR instructions convert an integer source operand to extended-real format before
performing the division.
If an unmasked divide by zero exception (#Z) is generated, no result is stored; if the exception is
masked, an ∞ of the appropriate sign is stored in the destination operand.
The following table shows the results obtained when dividing various classes of numbers, assuming
that neither overflow nor underflow occurs.
Notes:
Fmeans finite-real number.
Imeans integer.
*indicates floating-point invalid-arithmetic-operand (#IA) exception.
**indicates floating-point zero-divide (#Z) exception.
Operation
IF DEST = 0
THEN
#Z
ELSE
IF instruction is FIDIVR
THEN
DEST ←ConvertExtendedReal(SRC) / DEST;
ELSE (* source operand is real number *)
DEST ←SRC / DEST;
FI;
FI;
IF instruction = FDIVRP
THEN
PopRegisterStack
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Operand is an SNaN value or unsupported format.
±∞ / ±∞; ±0 / ±0
#D Result is a denormal value.
#Z SRC / ±0, where SRC is not equal to ±0.
#U Result is too small for destination format.
#O Result is too large for destination format.
#P Value cannot be represented exactly in destination format.
Description
Sets the tag in the FPU tag register associated with register ST(i) to empty (11B). The contents of
ST(i) and the FPU stack-top pointer (TOP) are not affected.
Operation
TAG(i) ←11B;
Floating-point Exceptions
None.
Description
Compares the value in ST(0) with an integer source operand and sets the condition code flags C0,
C2, and C3 in the FPU status word according to the results (see table below). The integer value is
converted to extended-real format before the comparison is made.
Condition C3 C2 C0
ST(0) > SRC 0 0 0
ST(0) < SRC 0 0 1
ST(0) = SRC 1 0 0
Unordered 1 1 1
These instructions perform an “unordered comparison.” An unordered comparison also checks the
class of the numbers being compared. If either operand is a NaN or is in an undefined format, the
condition flags are set to “unordered.”
The FICOMP instructions pop the register stack following the comparison. To pop the register
stack, the processor marks the ST(0) register empty and increments the stack pointer (TOP) by 1.
Operation
CASE (relation of operands) OF
ST(0) > SRC: C3, C2, C0 ←000;
ST(0) < SRC: C3, C2, C0 ←001;
ST(0) = SRC: C3, C2, C0 ←100;
Unordered: C3, C2, C0 ←111;
ESAC;
IF instruction = FICOMP
THEN
PopRegisterStack;
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA One or both operands are NaN values or have unsupported formats.
#D One or both operands are denormal values.
Description
Converts the signed-integer source operand into extended-real format and pushes the value onto the
FPU register stack. The source operand can be a word, short, or long integer value. It is loaded
without rounding errors. The sign of the source operand is preserved.
Operation
TOP ←TOP −1;
ST(0) ←ExtendedReal(SRC);
Floating-point Exceptions
#IS Stack overflow occurred.
Description
Adds one to the TOP field of the FPU status word (increments the top-of-stack pointer). The
contents of the FPU data registers and tag register are not affected. This operation is not equivalent
to popping the stack, because the tag for the previous top-of-stack register is not marked empty.
Operation
IF TOP = 7
THEN TOP ←0;
ELSE TOP ←TOP + 1;
FI;
The C1 flag is set to 0; otherwise, generates an #IS fault. The C0, C2, and C3 flags are undefined.
Floating-point Exceptions
#IS
Description
Sets the FPU control, status, tag, instruction pointer, and data pointer registers to their default
states. The FPU control word is set to 037FH (round to nearest, all exceptions masked, 64-bit
precision). The status word is cleared (no exception flags set, TOP is set to 0). The data registers in
the register stack are left unchanged, but they are all tagged as empty (11B). Both the instruction
and data pointers are cleared.
The FINIT instruction checks for and handles any pending unmasked floating-point exceptions
before performing the initialization; the FNINIT instruction does not.
Operation
FPUControlWord ←037FH;
FPUStatusWord ←0;
FPUTagWord ←FFFFH;
FPUDataPointer ←0;
FPUInstructionPointer ←0;
FPULastInstructionOpcode ←0;
Floating-point Exceptions
None.
Description
The FIST instruction converts the value in the ST(0) register to a signed integer and stores the
result in the destination operand. Values can be stored in word- or short-integer format. The
destination operand specifies the address where the first byte of the destination value is to be stored.
The FISTP instruction performs the same operation as the FIST instruction and then pops the
register stack. To pop the register stack, the processor marks the ST(0) register as empty and
increments the stack pointer (TOP) by 1. The FISTP instruction can also stores values in
long-integer format.
The following table shows the results obtained when storing various classes of numbers in integer
format.
ST(0) DEST
−∞ *
−F < −1 −I
−1 < −F < −0 **
−0 0
+0 0
+0 < +F < +1 **
+F > +1 +I
+∞ *
NaN *
Notes:
Fmeans finite-real number.
Imeans integer.
*indicates floating-point invalid-operation (#IA) exception.
**±0 or ±1, depending on the rounding mode.
If the source value is a non-integral value, it is rounded to an integer value, according to the
rounding mode specified by the RC field of the FPU control word.
If the value being stored is too large for the destination format, is an ∞, is a NaN, or is in an
unsupported format and if the invalid-arithmetic-operand exception (#IA) is unmasked, an
invalid-operation exception is generated and no value is stored in the destination operand. If the
invalid-operation exception is masked, the integer indefinite value is stored in the destination
operand.
Operation
DEST ←Integer(ST(0));
IF instruction = FISTP
THEN
PopRegisterStack;
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Source operand is too large for the destination format
Source operand is a NaN value or unsupported format.
#P Value cannot be represented exactly in destination format.
Description
Pushes the source operand onto the FPU register stack. If the source operand is in single- or
double-real format, it is automatically converted to the extended-real format before being pushed
on the stack.
The FLD instruction can also push the value in a selected FPU register [ST(i)] onto the stack. Here,
pushing register ST(0) duplicates the stack top.
Operation
IF SRC is ST(i)
THEN
temp ←ST(i)
TOP ←TOP −1;
IF SRC is memory-operand
THEN
ST(0) ←ExtendedReal(SRC);
ELSE (* SRC is ST(i) *)
ST(0) ←temp;
Floating-point Exceptions
#IS Stack overflow occurred.
#IA Source operand is an SNaN value or unsupported format.
#D Source operand is a denormal value. Does not occur if the source operand is
in extended-real format.
FLD—Load Real (Continued)
Description
Push one of seven commonly-used constants (in extended-real format) onto the FPU register stack.
The constants that can be loaded with these instructions include +1.0, +0.0, log210, log2e, π, log102,
and loge2. For each constant, an internal 66-bit constant is rounded (as specified by the RC field in
the FPU control word) to external-real format. The inexact-result exception (#P) is not generated as
a result of the rounding.
Operation
TOP ←TOP −1;
ST(0) ←CONSTANT;
Floating-point Exceptions
#IS Stack overflow occurred.
When the RC field is set to round-to-nearest, the FPU produces the same constants that is produced
by the Intel 8087 and Intel287 math coprocessors.
Description
Loads the 16-bit source operand into the FPU control word. The source operand is a memory
location. This instruction is typically used to establish or change the FPU’s mode of operation.
If one or more exception flags are set in the FPU status word prior to loading a new FPU control
word and the new control word unmasks one or more of those exceptions, a floating-point
exception will be generated upon execution of the next floating-point instruction (except for the
no-wait floating-point instructions. To avoid raising exceptions when changing FPU operating
modes, clear any pending exceptions (using the FCLEX or FNCLEX instruction) before loading
the new control word.
Operation
FPUControlWord ←SRC;
Floating-point Exceptions
None; however, this operation might unmask a pending exception in the FPU status word. That
exception is then generated upon execution of the next waiting floating-point instruction.
Description
Loads the complete FPU operating environment from memory into the FPU registers. The source
operand specifies the first byte of the operating-environment data in memory.This data is typically
written to the specified memory location by a FSTENV or FNSTENV instruction.
The FPU operating environment consists of the FPU control word, status word, tag word,
instruction pointer, data pointer, and last opcode. See the IA-32 Intel® Architecture Software
Developer’s Manual for the layout in memory of the loaded environment, depending on the
operating mode of the processor (protected or real) and the size of the current address attribute
(16-bit or 32-bit). In virtual-8086 mode, the real mode layouts are used.
The FLDENV instruction should be executed in the same operating mode as the corresponding
FSTENV/FNSTENV instruction.
If one or more unmasked exception flags are set in the new FPU status word, a floating-point
exception will be generated upon execution of the next floating-point instruction (except for the
no-wait floating-point instructions. To avoid generating exceptions when loading a new
environment, clear all the exception flags in the FPU status word that is being loaded.
Operation
FPUControlWord ←SRC(FPUControlWord);
FPUStatusWord ←SRC(FPUStatusWord);
FPUTagWord ←SRC(FPUTagWord);
FPUDataPointer ←SRC(FPUDataPointer);
FPUInstructionPointer ←SRC(FPUInstructionPointer);
FPULastInstructionOpcode ←SRC(FPULastInstructionOpcode);
Floating-point Exceptions
None; however, if an unmasked exception is loaded in the status word, it is generated upon
execution of the next waiting floating-point instruction.
Description
Multiplies the destination and source operands and stores the product in the destination location.
The destination operand is always an FPU data register; the source operand can be a register or a
memory location. Source operands in memory can be in single-real, double-real, word-integer, or
short-integer formats.
The no-operand version of the instruction multiplies the contents of the ST(0) register by the
contents of the ST(1) register. The one-operand version multiplies the contents of a memory
location (either a real or an integer value) by the contents of the ST(0) register. The two-operand
version, multiplies the contents of the ST(0) register by the contents of the ST(i) register or vice
versa.
The FMULP instructions perform the additional operation of popping the FPU register stack after
storing the product. To pop the register stack, the processor marks the ST(0) register as empty and
increments the stack pointer (TOP) by 1. The no-operand version of the floating-point multiply
instructions always results in the register stack being popped. In some assemblers, the mnemonic
for this instruction is FMUL rather than FMULP.
The FIMUL instructions convert an integer source operand to extended-real format before
performing the multiplication.
The sign of the result is always the exclusive-OR of the source signs, even if one or more of the
values being multiplied is 0 or ∞. When the source operand is an integer 0, it is treated as a +0.
The following table shows the results obtained when multiplying various classes of numbers,
assuming that neither overflow nor underflow occurs.
Notes:
Fmeans finite-real number.
Imeans Integer.
*indicates invalid-arithmetic-operand (#IA) exception.
Operation
IF instruction is FIMUL
THEN
DEST ←DEST ∗ ConvertExtendedReal(SRC);
ELSE (* source operand is real number *)
DEST ←DEST ∗ SRC;
FI;
IF instruction = FMULP
THEN
PopRegisterStack
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Operand is an SNaN value or unsupported format.
One operand is ±0 and the other is ±∞.
#D Source operand is a denormal value.
#U Result is too small for destination format.
#O Result is too large for destination format.
#P Value cannot be represented exactly in destination format.
Description
Performs no FPU operation. This instruction takes up space in the instruction stream but does not
affect the FPU or machine context, except the EIP register.
Floating-point Exceptions
None.
Description
Computes the arctangent of the source operand in register ST(1) divided by the source operand in
register ST(0), stores the result in ST(1), and pops the FPU register stack. The result in register
ST(0) has the same sign as the source operand ST(1) and a magnitude less than +π.
The following table shows the results obtained when computing the arctangent of various classes of
numbers, assuming that underflow does not occur.
Note:
Fmeans finite-real number.
There is no restriction on the range of source operands that FPATAN can accept.
Operation
ST(1) ←arctan(ST(1) / ST(0));
PopRegisterStack;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Source operand is an SNaN value or unsupported format.
#D Source operand is a denormal value.
#U Result is too small for destination format.
#P Value cannot be represented exactly in destination format.
The source operands for this instruction are restricted for the 80287 math coprocessor to the
following range:
Description
Computes the remainder obtained on dividing the value in the ST(0) register (the dividend) by the
value in the ST(1) register (the divisor or modulus), and stores the result in ST(0). The remainder
represents the following value:
This instruction produces an exact result; the precision (inexact) exception does not occur and the
rounding control has no effect. The following table shows the results obtained when computing the
remainder of various classes of numbers, assuming that underflow does not occur.
Notes:
Fmeans finite-real number.
*indicates floating-point invalid-arithmetic-operand (#IA) exception.
**indicates floating-point zero-divide (#Z) exception.
When the result is 0, its sign is the same as that of the dividend. When the modulus is ∞, the result is
equal to the value in ST(0).
The FPREM instruction does not compute the remainder specified in IEEE Std. 754. The IEEE
specified remainder can be computed with the FPREM1 instruction. The FPREM instruction is
provided for compatibility with the Intel 8087 and Intel287 math coprocessors.
An important use of the FPREM instruction is to reduce the arguments of periodic functions. When
reduction is complete, the instruction stores the three least-significant bits of the quotient in the C3,
C1, and C0 flags of the FPU status word. This information is important in argument reduction for
the tangent function (using a modulus of π/4), because it locates the original angle in the correct
one of eight sectors of the unit circle.
Operation
D ←exponent(ST(0)) - exponent(ST(1));
IF D < 64
THEN
Q ←Integer(TruncateTowardZero(ST(0) / ST(1)));
ST(0) ←ST(0) - (ST(1) ∗ Q);
C2 ←0;
C0, C3, C1 ←LeastSignificantBits(Q); (* Q2, Q1, Q0 *)
ELSE
C2 ←1;
N ←an implementation-dependent number between 32 and 63;
QQ ←Integer(TruncateTowardZero((ST(0) / ST(1)) / 2(D −N)));
ST(0) ←ST(0) - (ST(1) ∗ QQ ∗ 2(D −N));
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Source operand is an SNaN value, modulus is 0, dividend is ∞, or unsupported
format.
#D Source operand is a denormal value.
#U Result is too small for destination format.
Description
Computes the IEEE remainder obtained on dividing the value in the ST(0) register (the dividend)
by the value in the ST(1) register (the divisor or modulus), and stores the result in ST(0). The
remainder represents the following value:
Here, N is an integer value that is obtained by rounding the real-number quotient of [ST(0) / ST(1)]
toward the nearest integer value. The sign of the remainder is the same as the sign of the dividend.
The magnitude of the remainder is less than half the magnitude of the modulus, unless a partial
remainder was computed (as described below).
This instruction produces an exact result; the precision (inexact) exception does not occur and the
rounding control has no effect. The following table shows the results obtained when computing the
remainder of various classes of numbers, assuming that underflow does not occur.
Notes:
Fmeans finite-real number.
*indicates floating-point invalid-arithmetic-operand (#IA) exception.
**indicates floating-point zero-divide (#Z) exception.
When the result is 0, its sign is the same as that of the dividend. When the modulus is ∞, the result is
equal to the value in ST(0).
The FPREM1 instruction computes the remainder specified in IEEE Std 754. This instruction
operates differently from the FPREM instruction in the way that it rounds the quotient of ST(0)
divided by ST(1) to an integer (see the “Operation” below).
An important use of the FPREM1 instruction is to reduce the arguments of periodic functions.
When reduction is complete, the instruction stores the three least-significant bits of the quotient in
the C3, C1, and C0 flags of the FPU status word. This information is important in argument
reduction for the tangent function (using a modulus of π/4), because it locates the original angle in
the correct one of eight sectors of the unit circle.
Operation
D ←exponent(ST(0)) - exponent(ST(1));
IF D < 64
THEN
Q ←Integer(RoundTowardNearestInteger(ST(0) / ST(1)));
ST(0) ←ST(0) - (ST(1) ∗ Q);
C2 ←0;
C0, C3, C1 ←LeastSignificantBits(Q); (* Q2, Q1, Q0 *)
ELSE
C2 ←1;
N ←an implementation-dependent number between 32 and 63;
QQ ←Integer(TruncateTowardZero((ST(0) / ST(1)) / 2(D −N)));
ST(0) ←ST(0) - (ST(1) ∗ QQ ∗ 2(D −N));
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Source operand is an SNaN value, modulus (divisor) is 0, dividend is ∞, or
unsupported format.
#D Source operand is a denormal value.
#U Result is too small for destination format.
Description
Computes the tangent of the source operand in register ST(0), stores the result in ST(0), and pushes
a 1.0 onto the FPU register stack. The source operand must be given in radians and must be less
than ±263. The following table shows the unmasked results obtained when computing the partial
tangent of various classes of numbers, assuming that underflow does not occur.
Notes:
Fmeans finite-real number.
*indicates floating-point invalid-arithmetic-operand (#IA) exception.
If the source operand is outside the acceptable range, the C2 flag in the FPU status word is set, and
the value in register ST(0) remains unchanged. The instruction does not raise an exception when
the source operand is out of range. It is up to the program to check the C2 flag for out-of-range
conditions. Source values outside the range −263 to +263 can be reduced to the range of the
instruction by subtracting an appropriate integer multiple of 2π or by using the FPREM instruction
with a divisor of 2π.
The value 1.0 is pushed onto the register stack after the tangent has been computed to maintain
compatibility with the Intel 8087 and Intel287 math coprocessors. This operation also simplifies the
calculation of other trigonometric functions. For instance, the cotangent (which is the reciprocal of
the tangent) can be computed by executing a FDIVR instruction after the FPTAN instruction.
Operation
IF
IF ST(0) < 263
THEN
C2 ←0;
ST(0) ←tan(ST(0));
TOP ←TOP −1;
ST(0) ←1.0;
ELSE (*source operand is out-of-range *)
C2 ←1;
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Source operand is an SNaN value, ∞, or unsupported format.
#D Source operand is a denormal value.
#U Result is too small for destination format.
#P Value cannot be represented exactly in destination format.
Description
Rounds the source value in the ST(0) register to the nearest integral value, depending on the current
rounding mode (setting of the RC field of the FPU control word), and stores the result in ST(0).
If the source value is ∞, the value is not changed. If the source value is not an integral value, the
floating-point inexact-result exception (#P) is generated.
Operation
ST(0) ←RoundToIntegralValue(ST(0));
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Source operand is an SNaN value or unsupported format.
#D Source operand is a denormal value.
#P Source operand is not an integral value.
Description
Loads the FPU state (operating environment and register stack) from the memory area specified
with the source operand. This state data is typically written to the specified memory location by a
previous FSAVE/FNSAVE instruction.
The FPU operating environment consists of the FPU control word, status word, tag word,
instruction pointer, data pointer, and last opcode. See the IA-32 Intel® Architecture Software
Developer’s Manual for the layout in memory of the stored environment, depending on the
operating mode of the processor (protected or real) and the size of the current address attribute
(16-bit or 32-bit). In virtual-8086 mode, the real mode layouts are used. The contents of the FPU
register stack are stored in the 80 bytes immediately follow the operating environment image.
The FRSTOR instruction should be executed in the same operating mode as the corresponding
FSAVE/FNSAVE instruction.
If one or more unmasked exception bits are set in the new FPU status word, a floating-point
exception will be generated. To avoid raising exceptions when loading a new operating
environment, clear all the exception flags in the FPU status word that is being loaded.
Operation
FPUControlWord ←SRC(FPUControlWord);
FPUStatusWord ←SRC(FPUStatusWord);
FPUTagWord ←SRC(FPUTagWord);
FPUDataPointer ←SRC(FPUDataPointer);
FPUInstructionPointer ←SRC(FPUInstructionPointer);
FPULastInstructionOpcode ←SRC(FPULastInstructionOpcode);
ST(0) ←SRC(ST(0));
ST(1) ←SRC(ST(1));
ST(2) ←SRC(ST(2));
ST(3) ←SRC(ST(3));
ST(4) ←SRC(ST(4));
ST(5) ←SRC(ST(5));
ST(6) ←SRC(ST(6));
ST(7) ←SRC(ST(7));
Floating-point Exceptions
None; however, this operation might unmask an existing exception that has been detected but not
generated, because it was masked. Here, the exception is generated at the completion of the
instruction.
Description
Stores the current FPU state (operating environment and register stack) at the specified destination
in memory, and then re-initializes the FPU. The FSAVE instruction checks for and handles pending
unmasked floating-point exceptions before storing the FPU state; the FNSAVE instruction does
not.
The FPU operating environment consists of the FPU control word, status word, tag word,
instruction pointer, data pointer, and last opcode. See the IA-32 Intel® Architecture Software
Developer’s Manual for the layout in memory of the stored environment, depending on the
operating mode of the processor (protected or real) and the size of the current address attribute
(16-bit or 32-bit). In virtual-8086 mode, the real mode layouts are used. The contents of the FPU
register stack are stored in the 80 bytes immediately follow the operating environment image.
The saved image reflects the state of the FPU after all floating-point instructions preceding the
FSAVE/FNSAVE instruction in the instruction stream have been executed.
After the FPU state has been saved, the FPU is reset to the same default values it is set to with the
FINIT/FNINIT instructions (see “FINIT/FNINIT—Initialize Floating-point Unit” on page 0:503).
The FSAVE/FNSAVE instructions are typically used when the operating system needs to perform a
context switch, an exception handler needs to use the FPU, or an application program needs to pass
a “clean” FPU to a procedure.
Operation
(* Save FPU State and Registers *)
DEST(FPUControlWord) ←FPUControlWord;
DEST(FPUStatusWord) ←FPUStatusWord;
DEST(FPUTagWord) ←FPUTagWord;
DEST(FPUDataPointer) ←FPUDataPointer;
DEST(FPUInstructionPointer) ←FPUInstructionPointer;
DEST(FPULastInstructionOpcode) ←FPULastInstructionOpcode;
DEST(ST(0)) ←ST(0);
DEST(ST(1)) ←ST(1);
DEST(ST(2)) ←ST(2);
DEST(ST(3)) ←ST(3);
DEST(ST(4)) ←ST(4);
DEST(ST(5)) ←ST(5);
DEST(ST(6)) ←ST(6);
DEST(ST(7)) ←ST(7);
(* Initialize FPU *)
FPUControlWord ←037FH;
FPUStatusWord ←0;
FPUTagWord ←FFFFH;
FPUDataPointer ←0;
FPUInstructionPointer ←0;
FPULastInstructionOpcode ←0;
The C0, C1, C2, and C3 flags are saved and then cleared.
Floating-point Exceptions
None.
For Intel math coprocessors and FPUs prior to the Pentium processor, an FWAIT instruction should
be executed before attempting to read from the memory image stored with a prior FSAVE/FNSAVE
instruction. This FWAIT instruction helps insure that the storage operation has been completed.
Description
Multiplies the destination operand by 2 to the power of the source operand and stores the result in
the destination operand. This instruction provides rapid multiplication or division by integral
powers of 2. The destination operand is a real value that is located in register ST(0). The source
operand is the nearest integer value that is smaller than the value in the ST(1) register (that is, the
value in register ST(1) is truncate toward 0 to its nearest integer value to form the source operand).
The actual scaling operation is performed by adding the source operand (integer value) to the
exponent of the value in register ST(0). The following table shows the results obtained when
scaling various classes of numbers, assuming that neither overflow nor underflow occurs.
ST(1)
−N 0 +N
−∞ −∞ −∞ −∞
ST(0) −F −F −F −F
−0 −0 −0 −0
+0 +0 +0 +0
+F +F +F +F
+∞ +∞ +∞ +∞
NaN NaN NaN NaN
Notes:
Fmeans finite-real number.
Nmeans integer.
In most cases, only the exponent is changed and the mantissa (significand) remains unchanged.
However, when the value being scaled in ST(0) is a denormal value, the mantissa is also changed
and the result may turn out to be a normalized number. Similarly, if overflow or underflow results
from a scale operation, the resulting mantissa will differ from the source’s mantissa.
The FSCALE instruction can also be used to reverse the action of the FXTRACT instruction, as
shown in the following example:
FXTRACT;
FSCALE;
FSTP ST(1);
In this example, the FXTRACT instruction extracts the significand and exponent from the value in
ST(0) and stores them in ST(0) and ST(1) respectively. The FSCALE then scales the significand in
ST(0) by the exponent in ST(1), recreating the original value before the FXTRACT operation was
performed. The FSTP ST(1) instruction returns the recreated value to the FPU register where it
originally resided.
Operation
ST(0) ←ST(0) ∗ 2ST(1);
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Source operand is an SNaN value or unsupported format.
#D Source operand is a denormal value.
#U Result is too small for destination format.
#O Result is too large for destination format.
#P Value cannot be represented exactly in destination format.
Description
Calculates the sine of the source operand in register ST(0) and stores the result in ST(0). The source
operand must be given in radians and must be within the range −263 to +263. The following table
shows the results obtained when taking the sine of various classes of numbers, assuming that
underflow does not occur.
Notes:
Fmeans finite-real number.
*indicates floating-point invalid-arithmetic-operand (#IA) exception.
If the source operand is outside the acceptable range, the C2 flag in the FPU status word is set, and
the value in register ST(0) remains unchanged. The instruction does not raise an exception when
the source operand is out of range. It is up to the program to check the C2 flag for out-of-range
conditions. Source values outside the range −263 to +263 can be reduced to the range of the
instruction by subtracting an appropriate integer multiple of 2π or by using the FPREM instruction
with a divisor of 2π.
Operation
IF I
IF ST(0) < 263
THEN
C2 ←0;
ST(0) ←sin(ST(0));
ELSE (* source operand out of range *)
C2 ←1;
FI:
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Source operand is an SNaN value, ∞, or unsupported format.
#D Source operand is a denormal value.
#P Value cannot be represented exactly in destination format.
Description
Computes both the sine and the cosine of the source operand in register ST(0), stores the sine in
ST(0), and pushes the cosine onto the top of the FPU register stack. (This instruction is faster than
executing the FSIN and FCOS instructions in succession.)
The source operand must be given in radians and must be within the range −263 to +263. The
following table shows the results obtained when taking the sine and cosine of various classes of
numbers, assuming that underflow does not occur.
SRC DEST
ST(0)) ST(0) Cosine ST(1) Sine
−∞ * *
−F −1 to +1 −1 to +1
−0 +1 −0
+0 +1 +0
+F −1 to +1 −1 to +1
+∞ * *
NaN NaN NaN
Notes:
Fmeans finite-real number.
*indicates floating-point invalid-arithmetic-operand (#IA) exception.
If the source operand is outside the acceptable range, the C2 flag in the FPU status word is set, and
the value in register ST(0) remains unchanged. The instruction does not raise an exception when
the source operand is out of range. It is up to the program to check the C2 flag for out-of-range
conditions. Source values outside the range −263 to +263 can be reduced to the range of the
instruction by subtracting an appropriate integer multiple of 2π or by using the FPREM instruction
with a divisor of 2π.
Operation
IF ST(0) < 263
THEN
C2 ←0;
TEMP ←cosine(ST(0));
ST(0) ←sine(ST(0));
TOP ←TOP −1;
ST(0) ←TEMP;
ELSE (* source operand out of range *)
C2 ←1;
FI:
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Source operand is an SNaN value, ∞, or unsupported format.
#D Source operand is a denormal value.
#U Result is too small for destination format.
#P Value cannot be represented exactly in destination format.
Description
Calculates the square root of the source value in the ST(0) register and stores the result in ST(0).
The following table shows the results obtained when taking the square root of various classes of
numbers, assuming that neither overflow nor underflow occurs.
Notes:
Fmeans finite-real number.
*indicates floating-point invalid-arithmetic-operand (#IA) exception.
Operation
ST(0) ←SquareRoot(ST(0));
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Source operand is an SNaN value or unsupported format.
Source operand is a negative value (except for −0).
#D Source operand is a denormal value.
#P Value cannot be represented exactly in destination format.
Description
The FST instruction copies the value in the ST(0) register to the destination operand, which can be
a memory location or another register in the FPU registers stack. When storing the value in
memory, the value is converted to single- or double-real format.
The FSTP instruction performs the same operation as the FST instruction and then pops the register
stack. To pop the register stack, the processor marks the ST(0) register as empty and increments the
stack pointer (TOP) by 1. The FSTP instruction can also stores values in memory in extended-real
format.
If the destination operand is a memory location, the operand specifies the address where the first
byte of the destination value is to be stored. If the destination operand is a register, the operand
specifies a register in the register stack relative to the top of the stack.
If the destination size is single- or double-real, the significand of the value being stored is rounded
to the width of the destination (according to rounding mode specified by the RC field of the FPU
control word), and the exponent is converted to the width and bias of the destination format. If the
value being stored is too large for the destination format, a numeric overflow exception (#O) is
generated and, if the exception is unmasked, no value is stored in the destination operand. If the
value being stored is a denormal value, the denormal exception (#D) is not generated. This
condition is simply signaled as a numeric underflow exception (#U) condition.
If the value being stored is ±0, ±∞, or a NaN, the least-significant bits of the significand and the
exponent are truncated to fit the destination format. This operation preserves the value’s identity as
a 0, ∞, or NaN.
If the destination operand is a non-empty register, the invalid-operation exception is not generated.
Operation
DEST ←ST(0);
IF instruction = FSTP
THEN
PopRegisterStack;
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Source operand is an SNaN value or unsupported format.
#U Result is too small for the destination format.
#O Result is too large for the destination format.
#P Value cannot be represented exactly in destination format.
Description
Stores the current value of the FPU control word at the specified destination in memory. The
FSTCW instruction checks for and handles pending unmasked floating-point exceptions before
storing the control word; the FNSTCW instruction does not.
Operation
DEST ←FPUControlWord;
Floating-point Exceptions
None.
Description
Saves the current FPU operating environment at the memory location specified with the destination
operand, and then masks all floating-point exceptions. The FPU operating environment consists of
the FPU control word, status word, tag word, instruction pointer, data pointer, and last opcode. See
the IA-32 Intel® Architecture Software Developer’s Manual for the layout in memory of the stored
environment, depending on the operating mode of the processor (protected or real) and the size of
the current address attribute (16-bit or 32-bit). (In virtual-8086 mode, the real mode layouts are
used.)
The FSTENV instruction checks for and handles any pending unmasked floating-point exceptions
before storing the FPU environment; the FNSTENV instruction does not.The saved image reflects
the state of the FPU after all floating-point instructions preceding the FSTENV/FNSTENV
instruction in the instruction stream have been executed.
These instructions are often used by exception handlers because they provide access to the FPU
instruction and data pointers. The environment is typically saved in the procedure stack. Masking
all exceptions after saving the environment prevents floating-point exceptions from interrupting the
exception handler.
Operation
DEST(FPUControlWord) ←FPUControlWord;
DEST(FPUStatusWord) ←FPUStatusWord;
DEST(FPUTagWord) ←FPUTagWord;
DEST(FPUDataPointer) ←FPUDataPointer;
DEST(FPUInstructionPointer) ←FPUInstructionPointer;
DEST(FPULastInstructionOpcode) ←FPULastInstructionOpcode;
Floating-point Exceptions
None.
Description
Stores the current value of the FPU status word in the destination location. The destination operand
can be either a two-byte memory location or the AX register. The FSTSW instruction checks for
and handles pending unmasked floating-point exceptions before storing the status word; the
FNSTSW instruction does not.
The FNSTSW AX form of the instruction is used primarily in conditional branching (for instance,
after an FPU comparison instruction or an FPREM, FPREM1, or FXAM instruction), where the
direction of the branch depends on the state of the FPU condition code flags. This instruction can
also be used to invoke exception handlers (by examining the exception flags) in environments that
do not use interrupts. When the FNSTSW AX instruction is executed, the AX register is updated
before the processor executes any further instructions. The status stored in the AX register is thus
guaranteed to be from the completion of the prior FPU instruction.
Operation
DEST ←FPUStatusWord;
Floating-point Exceptions
None.
Description
Subtracts the source operand from the destination operand and stores the difference in the
destination location. The destination operand is always an FPU data register; the source operand
can be a register or a memory location. Source operands in memory can be in single-real,
double-real, word-integer, or short-integer formats.
The no-operand version of the instruction subtracts the contents of the ST(0) register from the
ST(1) register and stores the result in ST(1). The one-operand version subtracts the contents of a
memory location (either a real or an integer value) from the contents of the ST(0) register and
stores the result in ST(0). The two-operand version, subtracts the contents of the ST(0) register
from the ST(i) register or vice versa.
The FSUBP instructions perform the additional operation of popping the FPU register stack
following the subtraction. To pop the register stack, the processor marks the ST(0) register as
empty and increments the stack pointer (TOP) by 1. The no-operand version of the floating-point
subtract instructions always results in the register stack being popped. In some assemblers, the
mnemonic for this instruction is FSUB rather than FSUBP.
The FISUB instructions convert an integer source operand to extended-real format before
performing the subtraction.
The following table shows the results obtained when subtracting various classes of numbers from
one another, assuming that neither overflow nor underflow occurs. Here, the SRC value is
subtracted from the DEST value (DEST −SRC = result).
When the difference between two operands of like sign is 0, the result is +0, except for the round
toward −∞ mode, in which case the result is −0. This instruction also guarantees that +0 −(−0) = +0,
and that −0 −(+0) = −0. When the source operand is an integer 0, it is treated as a +0.
When one operand is ∞, the result is ∞of the expected sign. If both operands are ∞of the same sign,
an invalid-operation exception is generated.
Notes:
Fmeans finite-real number.
Imeans integer.
*indicates floating-point invalid-arithmetic-operand (#IA) exception.
Operation
IF instruction is FISUB
THEN
DEST ←DEST −ConvertExtendedReal(SRC);
ELSE (* source operand is real number *)
DEST ←DEST −SRC;
FI;
IF instruction = FSUBP
THEN
PopRegisterStack
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Operand is an SNaN value or unsupported format.
Operands are infinities of like sign.
#D Source operand is a denormal value.
#U Result is too small for destination format.
#O Result is too large for destination format.
#P Value cannot be represented exactly in destination format.
Description
Subtracts the destination operand from the source operand and stores the difference in the
destination location. The destination operand is always an FPU register; the source operand can be
a register or a memory location. Source operands in memory can be in single-real, double-real,
word-integer, or short-integer formats.
These instructions perform the reverse operations of the FSUB, FSUBP, and FISUB instructions.
They are provided to support more efficient coding.
The no-operand version of the instruction subtracts the contents of the ST(1) register from the
ST(0) register and stores the result in ST(1). The one-operand version subtracts the contents of the
ST(0) register from the contents of a memory location (either a real or an integer value) and stores
the result in ST(0). The two-operand version, subtracts the contents of the ST(i) register from the
ST(0) register or vice versa.
The FSUBRP instructions perform the additional operation of popping the FPU register stack
following the subtraction. To pop the register stack, the processor marks the ST(0) register as
empty and increments the stack pointer (TOP) by 1. The no-operand version of the floating-point
reverse subtract instructions always results in the register stack being popped. In some assemblers,
the mnemonic for this instruction is FSUBR rather than FSUBRP.
The FISUBR instructions convert an integer source operand to extended-real format before
performing the subtraction.
The following table shows the results obtained when subtracting various classes of numbers from
one another, assuming that neither overflow nor underflow occurs. Here, the DEST value is
subtracted from the SRC value (SRC −DEST = result).
When one operand is ∞, the result is ∞of the expected sign. If both operands are ∞of the same sign,
an invalid-operation exception is generated.
Notes:
Fmeans finite-real number.
Imeans integer.
*indicates floating-point invalid-arithmetic-operand (#IA) exception.
Operation
IF instruction is FISUBR
THEN
DEST ←ConvertExtendedReal(SRC) −DEST;
ELSE (* source operand is real number *)
DEST ←SRC −DEST;
FI;
IF instruction = FSUBRP
THEN
PopRegisterStack
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Operand is an SNaN value or unsupported format.
Operands are infinities of like sign.
#D Source operand is a denormal value.
#U Result is too small for destination format.
#O Result is too large for destination format.
#P Value cannot be represented exactly in destination format.
Description
Compares the value in the ST(0) register with 0.0 and sets the condition code flags C0, C2, and C3
in the FPU status word according to the results (see table below).
Condition C3 C2 C0
ST(0) > 0.0 0 0 0
ST(0) < 0.0) 0 0 1
ST(0) = 0.0 1 0 0
Unordered 1 1 1
This instruction performs an “unordered comparison.” An unordered comparison also checks the
class of the numbers being compared (see “FXAM—Examine” on page 0:563). If the value in
register ST(0) is a NaN or is in an undefined format, the condition flags are set to “unordered.”)
Operation
CASE (relation of operands) OF
Not comparable: C3, C2, C0 ←111;
ST(0) > 0.0: C3, C2, C0 ←000;
ST(0) < 0.0: C3, C2, C0 ←001;
ST(0) = 0.0: C3, C2, C0 ←100;
ESAC;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA One or both operands are NaN values or have unsupported formats.
#D One or both operands are denormal values.
Description
Performs an unordered comparison of the contents of register ST(0) and ST(i) and sets condition
code flags C0, C2, and C3 in the FPU status word according to the results (see the table below). If
no operand is specified, the contents of registers ST(0) and ST(1) are compared. The sign of zero is
ignored, so that -0.0 = +0.0.
Comparison Results C3 C2 C0
ST0 > ST(i) 0 0 0
ST0 < ST(i) 0 0 1
ST0 = ST(i) 1 0 0
a
Unordered 1 1 1
a. Flags not set if unmasked invalid-arithmetic- operand
(#IA) exception is generated.
An unordered comparison checks the class of the numbers being compared (see “FXAM—
Examine” on page 0:563). The FUCOM instructions perform the same operation as the FCOM
instructions. The only difference is that the FUCOM instruction raises the
invalid-arithmetic-operand exception (#IA) only when either or both operands is an SNaN or is in
an unsupported format; QNaNs cause the condition code flags to be set to unordered, but do not
cause an exception to be generated. The FCOM instruction raises an invalid-operation exception
when either or both of the operands is a NaN value of any kind or is in an unsupported format.
The FUCOMP instructions pop the register stack following the comparison operation and the
FUCOMPP instructions pops the register stack twice following the comparison operation. To pop
the register stack, the processor marks the ST(0) register as empty and increments the stack pointer
(TOP) by 1.
Operation
CASE (relation of operands) OF
ST > SRC: C3, C2, C0 ←000;
ST < SRC: C3, C2, C0 ←001;
ST = SRC: C3, C2, C0 ←100;
ESAC;
IF ST(0) or SRC = QNaN, but not SNaN or unsupported format
THEN
C3, C2, C0 ←111;
ELSE (* ST(0) or SRC is SNaN or unsupported format *)
#IA;
IF FPUControlWord.IM = 1
THEN
C3, C2, C0 ←111;
FI;
FI;
IF instruction = FUCOMP
THEN
PopRegisterStack;
FI;
IF instruction = FUCOMPP
THEN
PopRegisterStack;
PopRegisterStack;
FI;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA One or both operands are SNaN values or have unsupported formats.
Detection of a QNaN value in and of itself does not raise an invalid-operand
exception.
#D One or both operands are denormal values.
Description
Examines the contents of the ST(0) register and sets the condition code flags C0, C2, and C3 in the
FPU status word to indicate the class of value or number in the register (see the table below).
. Class C3 C2 C0
Unsupported 0 0 0
NaN 0 0 1
Normal finite number 0 1 0
Infinity 0 1 1
Zero 1 0 0
Empty 1 0 1
Denormal number 1 1 0
The C1 flag is set to the sign of the value in ST(0), regardless of whether the register is empty or
full.
Operation
C1 ←sign bit of ST; (* 0 for positive, 1 for negative *)
CASE (class of value or number in ST(0)) OF
Unsupported:C3, C2, C0 ←000;
NaN: C3, C2, C0 ←001;
Normal: C3, C2, C0 ←010;
Infinity: C3, C2, C0 ←011;
Zero: C3, C2, C0 ←100;
Empty: C3, C2, C0 ←101;
Denormal: C3, C2, C0 ←110;
ESAC;
Floating-point Exceptions
None.
Description
Exchanges the contents of registers ST(0) and ST(i). If no source operand is specified, the contents
of ST(0) and ST(1) are exchanged.
This instruction provides a simple means of moving values in the FPU register stack to the top of
the stack [ST(0)], so that they can be operated on by those floating-point instructions that can only
operate on values in ST(0). For example, the following instruction sequence takes the square root
of the third register from the top of the register stack:
FXCH ST(3);
FSQRT;
FXCH ST(3);
Operation
IF number-of-operands is 1
THEN
temp ←ST(0);
ST(0) ←SRC;
SRC ←temp;
ELSE
temp ←ST(0);
ST(0) ←ST(1);
ST(1) ←temp;
Floating-point Exceptions
#IS Stack underflow occurred.
Description
Separates the source value in the ST(0) register into its exponent and significand, stores the
exponent in ST(0), and pushes the significand onto the register stack. Following this operation, the
new top-of-stack register ST(0) contains the value of the original significand expressed as a real
number. The sign and significand of this value are the same as those found in the source operand,
and the exponent is 3FFFH (biased value for a true exponent of zero). The ST(1) register contains
the value of the original operand’s true (unbiased) exponent expressed as a real number. (The
operation performed by this instruction is a superset of the IEEE-recommended logb(x) function.)
This instruction and the F2XM1 instruction are useful for performing power and range scaling
operations. The FXTRACT instruction is also useful for converting numbers in extended-real
format to decimal representations (e.g. for printing or displaying).
If the floating-point zero-divide exception (#Z) is masked and the source operand is zero, an
exponent value of -∞is stored in register ST(1) and 0 with the sign of the source operand is stored in
register ST(0).
Operation
TEMP ←Significand(ST(0));
ST(0) ←Exponent(ST(0));
TOP←TOP −1;
ST(0) ←TEMP;
Floating-point Exceptions
#IS Stack underflow occurred.
Stack overflow occurred.
#IA Source operand is an SNaN value or unsupported format.
#Z ST(0) operand is ±0.
#D Source operand is a denormal value.
Description
Calculates (ST(1) ∗ log2 (ST(0))), stores the result in resister ST(1), and pops the FPU register
stack. The source operand in ST(0) must be a non-zero positive number.
The following table shows the results obtained when taking the log of various classes of numbers,
assuming that neither overflow nor underflow occurs.
Notes:
Fmeans finite-real number.
*indicates floating-point invalid-operation (#IA) exception.
**indicates floating-point zero-divide (#Z) exception.
If the divide-by-zero exception is masked and register ST(0) contains ±0, the instruction returns ∞
with a sign that is the opposite of the sign of the source operand in register ST(1).
The FYL2X instruction is designed with a built-in multiplication to optimize the calculation of
logarithms with an arbitrary positive base (b):
logbx = (log2b)-1 ∗ log2x
Operation
IF
ST(1) ←ST(1) ∗ log2ST(0);
PopRegisterStack;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Either operand is an SNaN or unsupported format.
Source operand in register ST(0) is a negative finite value (not −0).
#Z Source operand in register ST(0) is ±0.
#D Source operand is a denormal value.
#U Result is too small for destination format.
#O Result is too large for destination format.
#P Value cannot be represented exactly in destination format.
Description
Calculates the log epsilon (ST(1) ∗ log2(ST(0) + 1.0)), stores the result in register ST(1), and pops
the FPU register stack. The source operand in ST(0) must be in the range:
– ( 1 – 2 ⁄ 2 ) )to ( 1 – 2 ⁄ 2 )
The source operand in ST(1) can range from −∞ to +∞. If either of the source operands is outside its
acceptable range, the result is undefined and no exception is generated.
The following table shows the results obtained when taking the log epsilon of various classes of
numbers, assuming that underflow does not occur:
Notes:
Fmeans finite-real number.
*indicates floating-point invalid-operation (#IA) exception.
This instruction provides optimal accuracy for values of epsilon [the value in register ST(0)] that
are close to 0. When the epsilon value (ε) is small, more significant digits can be retained by using
the FYL2XP1 instruction than by using (ε+1) as an argument to the FYL2X instruction. The (ε+1)
expression is commonly found in compound interest and annuity calculations. The result can be
simply converted into a value in another logarithm base by including a scale factor in the ST(1)
source operand. The following equation is used to calculate the scale factor for a particular
logarithm base, where n is the logarithm base desired for the result of the FYL2XP1 instruction:
Operation
I
ST(1) ←ST(1) ∗ log2(ST(0) + 1.0);
PopRegisterStack;
Floating-point Exceptions
#IS Stack underflow occurred.
#IA Either operand is an SNaN value or unsupported format.
#D Source operand is a denormal value.
#U Result is too small for destination format.
#O Result is too large for destination format.
#P Value cannot be represented exactly in destination format.
Description
Stops instruction execution and places the processor in a HALT state. An enabled interrupt, NMI,
or a reset will resume execution. If an interrupt (including NMI) is used to resume execution after a
HLT instruction, the saved instruction pointer (CS:EIP) points to the instruction following the HLT
instruction.
The HLT instruction is a privileged instruction. When the processor is running in protected or
virtual 8086 mode, the privilege level of a program or procedure must to 0 to execute the HLT
instruction.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,HALT);
Enter Halt state;
Flags Affected
None.
None.
Description
Divides (signed) the value in the AL, AX, or EAX register by the source operand and stores the
result in the AX, DX:AX, or EDX:EAX registers. The source operand can be a general-purpose
register or a memory location. The action of this instruction depends on the operand size, as shown
in the following table:
Non-integral results are truncated (chopped) towards 0. The sign of the remainder is always the
same as the sign of the dividend. The absolute value of the remainder is always less than the
absolute value of the divisor. Overflow is indicated with the #DE (divide error) exception rather
than with the OF flag.
Operation
IF SRC = 0
THEN #DE; (* divide error *)
FI;
IF OpernadSize = 8 (* word/byte operation *)
THEN
temp ←AX / SRC; (* signed division *)
IF (temp > 7FH) OR (temp < 80H)
(* if a positive result is greater than 7FH or a negative result is less than 80H *)
THEN #DE; (* divide error *) ;
ELSE
AL ←temp;
AH ←AX SignedModulus SRC;
FI;
ELSE
IF OpernadSize = 16 (* doubleword/word operation *)
THEN
Flags Affected
The CF, OF, SF, ZF, AF, and PF flags are undefined.
Description
Performs a signed multiplication of two operands. This instruction has three forms, depending on
the number of operands.
• One-operand form. This form is identical to that used by the MUL instruction. Here, the
source operand (in a general-purpose register or memory location) is multiplied by the value in
the AL, AX, or EAX register (depending on the operand size) and the product is stored in the
AX, DX:AX, or EDX:EAX registers, respectively.
• Two-operand form. With this form the destination operand (the first operand) is multiplied by
the source operand (second operand). The destination operand is a general-purpose register
and the source operand is an immediate value, a general-purpose register, or a memory
location. The product is then stored in the destination operand location.
• Three-operand form. This form requires a destination operand (the first operand) and two
source operands (the second and the third operands). Here, the first source operand (which can
be a general-purpose register or a memory location) is multiplied by the second source operand
(an immediate value). The product is then stored in the destination operand (a general-purpose
register).
When an immediate value is used as an operand, it is sign-extended to the length of the destination
operand format.
The CF and OF flags are set when significant bits are carried into the upper half of the result. The
CF and OF flags are cleared when the result fits exactly in the lower half of the result.
The two- and three-operand forms may also be used with unsigned operands because the lower half
of the product is the same regardless if the operands are signed or unsigned. The CF and OF flags,
however, cannot be used to determine if the upper half of the result is non-zero.
Operation
IF (NumberOfOperands = 1)
THEN IF (OperandSize = 8)
THEN
AX ←AL ∗ SRC (* signed multiplication *)
IF ((AH = 00H) OR (AH = FFH))
THEN CF = 0; OF = 0;
ELSE CF = 1; OF = 1;
FI;
ELSE IF OperandSize = 16
THEN
DX:AX ←AX ∗ SRC (* signed multiplication *)
IF ((DX = 0000H) OR (DX = FFFFH))
THEN CF = 0; OF = 0;
ELSE CF = 1; OF = 1;
FI;
ELSE (* OperandSize = 32 *)
EDX:EAX ←EAX ∗ SRC (* signed multiplication *)
IF ((EDX = 00000000H) OR (EDX = FFFFFFFFH))
THEN CF = 0; OF = 0;
ELSE CF = 1; OF = 1;
FI;
FI;
ELSE IF (NumberOfOperands = 2)
THEN
temp ←DEST ∗ SRC (* signed multiplication; temp is double DEST size*)
DEST ←DEST ∗ SRC (* signed multiplication *)
IF temp ≠ DEST
THEN CF = 1; OF = 1;
ELSE CF = 0; OF = 0;
FI;
ELSE (* NumberOfOperands = 3 *)
DEST ←SRC1 ∗ SRC2 (* signed multiplication *)
temp ←SRC1 ∗ SRC2 (* signed multiplication; temp is double SRC1 size *)
IF temp ≠ DEST
THEN CF = 1; OF = 1;
ELSE CF = 0; OF = 0;
FI;
FI;
FI;
Flags Affected
For the one operand form of the instruction, the CF and OF flags are set when significant bits are
carried into the upper half of the result and cleared when the result fits exactly in the lower half of
the result. For the two- and three-operand forms of the instruction, the CF and OF flags are set
when the result must be truncated to fit in the destination operand size and cleared when the result
fits exactly in the destination operand size. The SF, ZF, AF, and PF flags are undefined.
Description
Copies the value from the I/O port specified with the second operand (source operand) to the
destination operand (first operand). The source operand can be a byte-immediate or the DX
register; the destination operand can be register AL, AX, or EAX, depending on the size of the port
being accessed (8, 16, or 32 bits, respectively). Using the DX register as a source operand allows
I/O port addresses from 0 to 65,535 to be accessed; using a byte immediate allows I/O port
addresses 0 to 255 to be accessed.
When accessing an 8-bit I/O port, the opcode determines the port size; when accessing a 16- and
32-bit I/O port, the operand-size attribute determines the port size.
At the machine code level, I/O instructions are shorter when accessing 8-bit I/O ports. Here, the
upper eight bits of the port address will be 0.
This instruction is only useful for accessing I/O ports located in the processor’s I/O address space.
I/O transactions are performed after all prior data memory operations. No subsequent data
memory operations can pass an I/O transaction.
In the Itanium System Environment, I/O port references are mapped into the 64-bit virtual
address pointed to by the IOBase register, with four ports per 4K-byte virtual page.
Operating systems can utilize the TLB in the Itanium architecture to grant or deny
permission to any four I/O ports. The I/O port space can be mapped into any arbitrary 64-bit
physical memory location by operating system code. If CFLG.io is 1 and CPL>IOPL, the TSS
is consulted for I/O permission. If CFLG.io is 0 or CPL<=IOPL, permission is granted
regardless of the state of the TSS I/O permission bitmap (the bitmap is not referenced).
If the referenced I/O port is mapped to an unimplemented virtual address (via the I/O Base
register) or if data translations are disabled (PSR.dt is 0) a GPFault is generated on the
referencing IN instruction.
Operation
IF ((PE = 1) AND ((VM = 1) OR (CPL > IOPL)))
THEN (* Protected mode or virtual-8086 mode with CPL > IOPL *)
IF (CFLG.io AND Any I/O Permission Bit for I/O port being accessed = 1)
THEN #GP(0);
FI;
ELSE ( * Real-address mode or protected mode with CPL ≤IOPL *)
(* or virtual-8086 mode with all I/O permission bits for I/O port cleared *)
FI;
IF (Itanium_System_Environment THEN
SRC_VA = IOBase | (Port{15:2}<<12) | Port{11:0};
SRC_PA = translate(SRC_VA);
DEST ←[SRC_PA]; (* Reads from I/O port *)
FI;
memory_fence();
DEST <-SRC;
memory-fence();
Flags Affected
None.
None.
Description
Adds 1 to the operand, while preserving the state of the CF flag. The source operand can be a
register or a memory location. This instruction allows a loop counter to be updated without
disturbing the CF flag. (Use a ADD instruction with an immediate operand of 1 to perform a
increment operation that does updates the CF flag.)
Operation
DEST ←DEST - 1;
Flags Affected
The CF flag is not affected. The OF, SF, ZF, AF, and PF flags are set according to the result.
Description
Copies the data from the I/O port specified with the second operand (source operand) to the
destination operand (first operand). The source operand must be the DX register, allowing I/O port
addresses from 0 to 65,535 to be accessed. When accessing an 8-bit I/O port, the opcode determines
the port size; when accessing a 16- and 32-bit I/O port, the operand-size attribute determines the
port size.
The destination operand is a memory location at the address ES:EDI. (When the operand-size
attribute is 16, the DI register is used as the destination-index register.) The ES segment cannot be
overridden with a segment override prefix.
The INSB, INSW, and INSD mnemonics are synonyms of the byte, word, and doubleword versions
of the INS instructions. (For the INS instruction, “ES:EDI” must be explicitly specified in the
instruction.)
After the byte, word, or doubleword is transfer from the I/O port to the memory location, the EDI
register is incremented or decremented automatically according to the setting of the DF flag in the
EFLAGS register. (If the DF flag is 0, the EDI register is incremented; if the DF flag is 1, the EDI
register is decremented.) The EDI register is incremented or decremented by 1 for byte operations,
by 2 for word operations, or by 4 for doubleword operations.
The INS, INSB, INSW, and INSD instructions can be preceded by the REP prefix for block input of
ECX bytes, words, or doublewords.
This instruction is only useful for accessing I/O ports located in the processor’s I/O address space.
I/O transactions are performed after all prior data memory operations. No subsequent data
memory operations can pass an I/O transaction.
In the Itanium System Environment, I/O port references are mapped into the 64-bit virtual
address pointed to by the IOBase register, with four ports per 4K-byte virtual page.
Operating systems can utilize the TLBs in the Itanium architecture to grant or deny
permission to any four I/O ports. The I/O port space can be mapped into any arbitrary 64-bit
physical memory location by operating system code. If CFLG.io is 1 and CPL>IOPL, the TSS
is consulted for I/O permission. If CFLG.io is 0 or CPL<=IOPL, permission is granted
regardless of the state of the TSS I/O permission bitmap (the bitmap is not referenced).
If the referenced I/O port is mapped to an unimplemented virtual address (via the IOBase
register) or if data translations are disabled (PSR.dt is 0) a GPFault is generated on the
referencing INS instruction.
Operation
IF ((PE = 1) AND ((VM = 1) OR (CPL > IOPL)))
THEN (* Protected mode or virtual-8086 mode with CPL > IOPL *)
IF (CFLG.io AND Any I/O Permission Bit for I/O port being accessed = 1)
THEN #GP(0);
FI;
ELSE ( * I/O operation is allowed *)
FI;
IF (Itanium_System_Environment) THEN
SRC_VA = IOBase | (Port{15:2}<<12) | Port{11:0};
SRC_PA = translate(SRC_VA);
DEST ←[SRC_PA]; (* Reads from I/O port *)
FI;
memory_fence();
DEST <- SRC;
memory_fence();
IF (byte transfer)
THEN IF DF = 0
THEN (E)DI ←1;
ELSE (E)DI ←-1;
FI;
ELSE IF (word transfer)
THEN IF DF = 0
THEN DI ←2;
ELSE DI ←-2;
FI;
ELSE (* doubleword transfer *)
THEN IF DF = 0
THEN EDI ←4;
ELSE EDI ←-4;
FI;
FI;
FI;
FI;
Flags Affected
None.
Description
The INTn instruction generates a call to the interrupt or exception handler specified with the
destination operand. The destination operand specifies an interrupt vector from 0 to 255, encoded
as an 8-bit unsigned intermediate value. The first 32 interrupt vectors are reserved by Intel for
system use. Some of these interrupts are used for internally generated exceptions.
The INTn instruction is the general mnemonic for executing a software-generated call to an
interrupt handler. The INTO instruction is a special mnemonic for calling overflow exception
(#OF), interrupt vector 4. The overflow interrupt checks the OF flag in the EFLAGS register and
calls the overflow interrupt handler if the OF flag is set to 1.
The INT3 instruction is a special mnemonic for calling the debug exception handler. The action of
the INT3 instruction (opcode CC) is slightly different from the operation of the INT 3 instruction
(opcode CC03), as follows:
• Interrupt redirection does not happen when in VME mode; the interrupt is handled by a
protected-mode handler.
• The virtual-8086 mode IOPL checks do not occur. The interrupt is taken without faulting at
any IOPL level.
The action of the INTn instruction (including the INTO and INT3 instructions) is similar to that of
a far call made with the CALL instruction. The primary difference is that with the INTn instruction,
the EFLAGS register is pushed onto the stack before the return address. (The return address is a far
address consisting of the current values of the CS and EIP registers.) Returns from interrupt
procedures are handled with the IRET instruction, which pops the EFLAGS information and return
address from the stack.
The interrupt vector specifies an interrupt descriptor in the interrupt descriptor table (IDT); that is,
it provides index into the IDT. The selected interrupt descriptor in turn contains a pointer to an
interrupt or exception handler procedure. In protected mode, the IDT contains an array of 8-byte
descriptors, each of which points to an interrupt gate, trap gate, or task gate. In real-address mode,
the IDT is an array of 4-byte far pointers (2-byte code segment selector and a 2-byte instruction
pointer), each of which point directly to procedure in the selected segment.
The following decision table indicates which action in the lower portion of the table is taken given
the conditions in the upper portion of the table. Each Y in the lower section of the decision table
represents a procedure defined in the “Operation” section for this instruction (except #GP).
Notes:
− Don't Care
Y Yes, Action Taken
BlankAction Not Taken
When the processor is executing in virtual-8086 mode, the IOPL determines the action of the INTn
instruction. If the IOPL is less than 3, the processor generates a general protection exception (#GP);
if the IOPL is 3, the processor executes a protected mode interrupt to privilege level 0. The
interrupt gate's DPL must be set to three and the target CPL of the interrupt handler procedure must
be 0 to execute the protected mode interrupt to privilege level 0.
The interrupt descriptor table register (IDTR) specifies the base linear address and limit of the IDT.
The initial base address value of the IDTR after the processor is powered up or reset is 0.
Operation
The following operational description applies not only to the INTn and INTO instructions, but also
to external interrupts and exceptions.
IF Itanium System EnvironmentTHEN
IF INT3 Form THEN IA_32_Exception(3);
IF INTO Form THEN IA_32_Exception(4);
IF INT Form THEN IA-32_Interrupt(N);
FI;
/*IN the Itanium System Environment all of the following operations are intercepted*/
IF PE=0
THEN
GOTO REAL-ADDRESS-MODE;
ELSE (* PE=1 *)
GOTO PROTECTED-MODE;
FI;
REAL-ADDRESS-MODE:
IF ((DEST ∗ 4) + 3) is not within IDT limit THEN #GP; FI;
IF stack not large enough for a 6-byte return information THEN #SS; FI;
Push (EFLAGS[15:0]);
IF ←0; (* Clear interrupt flag *)
TF ←0; (* Clear trap flag *)
AC ←0; (*Clear AC flag*)
Push(CS);
Push(IP);
(* No error codes are pushed *)
CS ←IDT(Descriptor (vector ∗ 4), selector));
EIP ←IDT(Descriptor (vector ∗ 4), offset)); (* 16 bit offset AND 0000FFFFH *)
END;
PROTECTED-MODE:
IF ((DEST ∗ 8) + 7) is not within IDT limits
OR selected IDT descriptor is not an interrupt-, trap-, or task-gate type
THEN #GP((DEST ∗ 8) + 2 + EXT);
(* EXT is bit 0 in error code *)
FI;
IF software interrupt (* generated by INTn, INT3, or INTO *)
THEN
IF gate descriptor DPL < CPL
THEN #GP((vector number ∗ 8) + 2 );
(* PE=1, DPL<CPL, software interrupt *)
FI;
FI;
IF gate not present THEN #NP((vector number ∗ 8) + 2 + EXT); FI;
IF task gate (* specified in the selected interrupt table descriptor *)
THEN GOTO TASK-GATE;
ELSE GOTO TRAP-OR-INTERRUPT-GATE; (* PE=1, trap/interrupt gate *)
FI;
END;
IF CR4.VME = 0
THEN
IF IOPL=3
THEN
IF Gate DPL = 3
THEN (*CPL=3, VM=1, IOPL=3, VME=0, gate DPL=3)
IF Target CPL != 0
THEN #GP(0);
ELSE Goto VM86_INTERURPT_TO_PRIV0;
FI;
ELSE (*Gate DPL < 3*)
#GP(0);
FI;
ELSE (*IOPL < 3*)
#GP(0);
FI;
ELSE (*VME = 1*)
(*Check whether interrupt is directed for INT n instruction only,
(*executes virtual 8086 interupt, protected mode interrupt or faults*)
Ptr <- [TSS + 66]; (*Fetch IO permission bitmpa pointer*)
IF BIT[Ptr-32,N] = 0 (*software redirection bitmap is 32 bytes below IO
Permission*)
THEN (*Interrupt redirected*)
Goto VM86_INTERRUPT_TO_VM86;
ELSE
IF IOPL = 3
THEN
IF Gate DPL = 3
THEN
IF Target CPL != 0
THEN #GP(0);
ELSE Goto VM86_INTERRUPT_TO_PRIV0;
FI;
ELSE #GP(0);
FI;
ELSE (*IOPL < 3*)
#GP(0);
FI;
FI;
FI;
END;
VM86_INTERRUPT_TO_PRIV0:
tempEFLAGS ←EFLAGS;
VM ←0;
TF ←0;
RF ←0;
IF service through interrupt gate THEN IF ←0; FI;
TempSS ←SS;
TempESP ←ESP;
VM86_INTERRUPT_TO_VM86:
IF IOPL = 3
THEN
push(FLAGS OR 3000H); (*Push FLAGS w/ IOPL bits as 11B or IOPL 3*)
push(CS);
push(IP);
CS <- [N*4 + 2]; (*N is vector num, read from interrupt table*)
IP <- [N*4];
FLAGS <- FLAGS AND 7CD5H; (*Clear TF and IF in EFLAGS like 8086*)
ELSE
TempFlags <- FLAGS OR 3000H; (*Set IOPL to 11B or IOPL 3*)
TempFlags.IF <- EFLAGS.VIF;
push(TempFlags);
push(CS);
push(IP);
CS <- [N*4 + 2]; (*N is vector num, read from interrupt table*)
IP <- [N*4];
FLAGS <- FLAGS AND 77ED5H; (*Clear VIF and TF and IF in EFLAGS like 8086*)
FI;
END;
INTRA-PRIVILEGE-LEVEL-INTERRUPT:
(* PE=1, DPL = CPL or conforming segment *)
IF 32-bit gate
THEN
IF current stack does not have room for 16 bytes (error code pushed)
OR 12 bytes (no error code pushed); THEN #SS(0);
FI;
Flags Affected
The EFLAGS register is pushed onto stack. The IF, TF, NT, AC, RF, and VM flags may be cleared,
depending on the mode of operation of the processor when the INT instruction is executed (see
“Operation” section.)
Description
Invalidates (flushes) the processor’s internal caches and issues a special-function bus cycle that
directs external caches to also flush themselves. Data held in internal caches is not written back to
main memory.
After executing this instruction, the processor does not wait for the external caches to complete
their flushing operation before proceeding with instruction execution. It is the responsibility of
hardware to respond to the cache flush signal.
The INVD instruction is a privileged instruction. When the processor is running in protected mode,
the CPL of a program or procedure must be 0 to execute this instruction. This instruction is also
implementation-dependent; its function may be implemented differently on future Intel architecture
processors.
Use this instruction with care. Data cached internally and not written back to main memory will be
lost. Unless there is a specific requirement or benefit to flushing caches without writing back
modified cache lines (for example, testing or fault recovery where cache coherency with main
memory is not a concern), software should use the WBINVD instruction.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,INVD);
Flush(InternalCaches);
SignalFlush(ExternalCaches);
Continue (* Continue execution);
Flags Affected
None.
None.
This instruction is not supported on Intel architecture processors earlier than the Intel486 processor.
Description
Invalidates (flushes) the translation lookaside buffer (TLB) entry specified with the source operand.
The source operand is a memory address. The processor determines the page that contains that
address and flushes the TLB entry for that page.
The INVLPG instruction is a privileged instruction. When the processor is running in protected
mode, the CPL of a program or procedure must be 0 to execute this instruction. This instruction is
also implementation-dependent; its function may be implemented differently on future Intel
architecture processors.
The INVLPG instruction normally flushes the TLB entry only for the specified page; however, in
some cases, it flushes the entire TLB.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,INVLPG);
Flush(RelevantTLBEntries);
Continue (* Continue execution);
Flags Affected
None.
None.
This instruction is not supported on Intel architecture processors earlier than the Intel486 processor.
Description
Returns program control from an exception or interrupt handler to a program or procedure that was
interrupted by an exception, an external interrupt or, a software-generated interrupt, or returns from
a nested task. IRET and IRETD are mnemonics for the same opcode. The IRETD mnemonic
(interrupt return double) is intended for use when returning from an interrupt when using the 32-bit
operand size; however, most assemblers use the IRET mnemonic interchangeably for both operand
sizes.
In Real Address Mode, the IRET instruction preforms a far return to the interrupted program or
procedure. During this operation, the processor pops the return instruction pointer, return code
segment selector, and EFLAGS image from the stack to the EIP, CS, and EFLAGS registers,
respectively, and then resumes execution of the interrupted program or procedure.
In Protected Mode, the action of the IRET instruction depends on the settings of the NT (nested
task) and VM flags in the EFLAGS register and the VM flag in the EFLAGS image stored on the
current stack. Depending on the setting of these flags, the processor performs the following types of
interrupt returns:
• Real Mode.
• Return from virtual-8086 mode.
• Return to virtual-8086 mode.
• Intra-privilege level return.
• Inter-privilege level return.
If the NT flag (EFLAGS register) is cleared, the IRET instruction performs a far return from the
interrupt procedure, without a task switch. The code segment being returned to must be equally or
less privileged than the interrupt handler routine (as indicated by the RPL field of the code segment
selector popped from the stack). As with a real-address mode interrupt return, the IRET instruction
pops the return instruction pointer, return code segment selector, and EFLAGS image from the
stack to the EIP, CS, and EFLAGS registers, respectively, and then resumes execution of the
interrupted program or procedure. If the return is to another privilege level, the IRET instruction
also pops the stack pointer and SS from the stack, before resuming program execution. If the return
is to virtual-8086 mode, the processor also pops the data segment registers from the stack.
If the NT flag is set, the IRET instruction performs a return from a nested task (switches from the
called task back to the calling task) or reverses the operation of an interrupt or exception that
caused a task switch. The updated state of the task executing the IRET instruction is saved in its
TSS. If the task is reentered later, the code that follows the IRET instruction is executed.
Operation
REAL-ADDRESS-MODE;
IF OperandSize = 32
THEN
IF top 12 bytes of stack not within stack limits THEN #SS; FI;
IF instruction pointer not within code segment limits THEN #GP(0); FI;
EIP ←Pop();
CS ←Pop(); (* 32-bit pop, high-order 16-bits discarded *)
tempEFLAGS ←Pop();
EFLAGS ←(tempEFLAGS AND 257FD5H) OR (EFLAGS AND 1A0000H);
ELSE (* OperandSize = 16 *)
IF top 6 bytes of stack are not within stack limits THEN #SS; FI;
IF instruction pointer not within code segment limits THEN #GP(0); FI;
EIP ←Pop();
EIP ←EIP AND 0000FFFFH;
CS ←Pop(); (* 16-bit pop *)
EFLAGS[15:0] ←Pop();
FI;
END;
PROTECTED-MODE:
IF VM = 1 (* Virtual-8086 mode: PE=1, VM=1 *)
THEN
GOTO RETURN-FROM-VIRTUAL-8086-MODE; (* PE=1, VM=1 *)
FI;
IF NT = 1
THEN
GOTO TASK-RETURN;( *PE=1, VM=0, NT=1 *)
FI;
IF OperandSize=32
THEN
IF top 12 bytes of stack not within stack limits
THEN #SS(0)
FI;
tempEIP ←Pop();
tempCS ←Pop();
tempEFLAGS ←Pop();
ELSE (* OperandSize = 16 *)
IF top 6 bytes of stack are not within stack limits
THEN #SS(0);
RETURN-FROM-VIRTUAL-8086-MODE:
(* Processor is in virtual-8086 mode when IRET is executed and stays in virtual-8086 mode *)
IF CR4.VME = 0
THEN
IF IOPL=3 (* Virtual mode: PE=1, VM=1, IOPL=3 *)
THEN
IF OperandSize = 32
THEN
IF top 12 bytes of stack not within stack limits THEN #SS(0); FI;
IF instruction pointer not within code segment limits THEN #GP(0); FI;
EIP ←Pop();
CS ←Pop(); (* 32-bit pop, high-order 16-bits discarded *)
EFLAGS ←Pop();
(*VM,IOPL,VIP,and VIF EFLAGS bits are not modified by pop *)
ELSE (* OperandSize = 16 *)
IF top 6 bytes of stack are not within stack limits THEN #SS(0); FI;
IF instruction pointer not within code segment limits THEN #GP(0); FI;
EIP ←Pop();
EIP ←EIP AND 0000FFFFH;
CS ←Pop(); (* 16-bit pop *)
EFLAGS[15:0] ←Pop(); (* IOPL in EFLAGS is not modified by pop *)
FI;
ELSE #GP(0); (* trap to virtual-8086 monitor: PE=1, VM=1, IOPL<3 *)
FI;
ELSE (*VME is 1*)
IF IOPL = 3
THEN
IF OperandSize = 32
THEN
EIP ←Pop();
CS ←Pop(); (* 32-bit pop, high-order 16-bits discarded *)
TempEFlags ←Pop();
FLAGS = (EFLAGS AND 1B3000H) OR (TempEFlags AND 244FD7H)
(*VM,IOPL,RF,VIP,and VIF EFLAGS bits are not modified by pop *)
ELSE (* OperandSize = 16 *)
EIP ←Pop();
EIP ←EIP AND 0000FFFFH;
END;
RETURN-TO-VIRTUAL-8086-MODE:
END;
RETURN-TO-OUTER-PRIVILGE-LEVEL:
IF OperandSize=32
THEN
IF top 8 bytes on stack are not within limits THEN #SS(0); FI;
ELSE (* OperandSize=16 *)
IF top 4 bytes on stack are not within limits THEN #SS(0); FI;
FI;
Read return segment selector;
IF stack segment selector is null THEN #GP(0); FI;
IF return stack segment selector index is not within its descriptor table limits
THEN #GP(SSselector); FI;
Read segment descriptor pointed to by return segment selector;
IF stack segment selector RPL ≠ RPL of the return code segment selector
IF stack segment selector RPL ≠ RPL of the return code segment selector
OR the stack segment descriptor does not indicate a a writable data segment;
OR stack segment DPL ≠ RPL of the return code segment selector
THEN #GP(SS selector);
FI;
IF stack segment is not present THEN #NP(SS selector); FI;
IF tempEIP is not within code segment limit THEN #GP(0); FI;
EIP ←tempEIP;
CS ←tempCS;
EFLAGS (CF, PF, AF, ZF, SF, TF, DF, OF, NT) ←tempEFLAGS;
IF OperandSize=32
THEN
EFLAGS(RF, AC, ID) ←tempEFLAGS;
FI;
IF CPO ≤IOPL
THEN
EFLAGS(IF) ←tempEFLAGS;
FI;
IF CPL = 0
THEN
EFLAGS(IOPL) ←tempEFLAGS;
IF OperandSize=32
THEN EFLAGS(VM, VIF, VIP) ←tempEFLAGS;
FI;
FI;
CPL ←RPL of the return code segment selector;
FOR each of segment register (ES, FS, GS, and DS)
DO;
IF segment register points to data or non-conforming code segment
AND CPL > segment descriptor DPL (* stored in hidden part of segment register *)
THEN (* segment register invalid *)
SegmentSelector ←0; (* null segment selector *)
FI;
OD;
END:
Flags Affected
All the flags and fields in the EFLAGS register are potentially modified, depending on the mode of
operation of the processor.
Description
Checks the state of one or more of the status flags in the EFLAGS register (CF, OF, PF, SF, and ZF)
and, if the flags are in the specified state (condition), performs a jump to the target instruction
specified by the destination operand. A condition code (cc) is associated with each instruction to
indicate the condition being tested for. If the condition is not satisfied, the jump is not performed
and execution continues with the instruction following the Jcc instruction.
The target instruction is specified with a relative offset (a signed offset relative to the current value
of the instruction pointer in the EIP register). A relative offset (rel8, rel16, or rel32) is generally
specified as a label in assembly code, but at the machine code level, it is encoded as a signed, 8-bit
or 32-bit immediate value, which is added to the instruction pointer. Instruction coding is most
efficient for offsets of -128 to +127. If the operand-size attribute is 16, the upper two bytes of the
EIP register are cleared to 0s, resulting in a maximum instruction pointer size of 16 bits.
The conditions for each Jcc mnemonic are given in the “Description” column of the above table.
The terms “less” and “greater” are used for comparisons of signed integers and the terms “above”
and “below” are used for unsigned integers.
The Jcc instruction does not support far jumps (jumps to other code segments). When the target for
the conditional jump is in a different segment, use the opposite condition from the condition being
tested for the Jcc instruction, and then access the target with an unconditional far jump (JMP
instruction) to the other segment. For example, the following conditional far jump is illegal:
JZ FARLABEL;
JNZ BEYOND;
JMP FARLABEL;
BEYOND:
The JECXZ and JCXZ instructions differs from the other Jcc instructions because they do not
check the status flags. Instead they check the contents of the ECX and CX registers, respectively,
for 0. These instructions are useful at the beginning of a conditional loop that terminates with a
conditional loop instruction (such as LOOPNE). They prevent entering the loop when the ECX or
CX register is equal to 0, which would cause the loop to execute 232 or 64K times, respectively,
instead of zero times.
All conditional jumps are converted to code fetches of one or two cache lines, regardless of
jump address or cacheability.
Operation
IF condition
THEN
EIP ←EIP + SignExtend(DEST);
IF OperandSize = 16
THEN
EIP ←EIP AND 0000FFFFH;
FI;
IF Itanium System Environment AND PSR.tb THEN IA_32_Exception(Debug);
FI;
Flags Affected
None.
Description
Transfers program control to a different point in the instruction stream without recording return
information. The destination (target) operand specifies the address of the instruction being jumped
to. This operand can be an immediate value, a general-purpose register, or a memory location.
• Near jump – A jump to an instruction within the current code segment (the segment currently
pointed to by the CS register), sometimes referred to as an intrasegment call.
• Far jump – A jump to an instruction located in a different segment than the current code
segment, sometimes referred to as an intersegment call.
• Task switch – A jump to an instruction located in a different task. (This is a form of a far
jump.) Results in an IA-32_Intercept(Gate) in Itanium System Environment.
A task switch can only be executed in protected mode (see Chapter 6 in the IA-32 Intel®
Architecture Software Developer’s Manual, Volume 3 for information on task switching with the
JMP instruction).
When executing a near jump, the processor jumps to the address (within the current code segment)
that is specified with the target operand. The target operand specifies either an absolute address
(that is an offset from the base of the code segment) or a relative offset (a signed offset relative to
the current value of the instruction pointer in the EIP register). An absolute address is specified
directly in a register or indirectly in a memory location (r/m16 or r/m32 operand form). A relative
offset (rel8, rel16, or rel32) is generally specified as a label in assembly code, but at the machine
code level, it is encoded as a signed, 8-bit or 32-bit immediate value, which is added to the value in
the EIP register (that is, to the instruction following the JMP instruction). The operand-size
attribute determines the size of the target operand (16 or 32 bits) for absolute addresses. Absolute
addresses are loaded directly into the EIP register. When a relative offset is specified, it is added to
the value of the EIP register. If the operand-size attribute is 16, the upper two bytes of the EIP
register are cleared to 0s, resulting in a maximum instruction pointer size of 16 bits. The CS register
is not changed on near jumps.
When the processor is operating in protected mode, a far jump can also be used to access a code
segment through a call gate or to switch tasks. Here, the processor uses the segment selector part of
the far address to access the segment descriptor for the segment being jumped to. Depending on the
value of the type and access rights information in the segment selector, the JMP instruction can
perform:
• A far jump to a conforming or non-conforming code segment (same mechanism as the far
jump described in the previous paragraph, except that the processor checks the access rights of
the code segment being jumped to).
• An far jump through a call gate.
• A task switch. Results in an IA-32_Intercept(Gate) in Itanium System Environment.
When executing an far jump through a call gate, the segment selector specified by the target
operand identifies the call gate. (The offset part of the target operand is ignored.) The processor
then jumps to the code segment specified in the call gate descriptor and begins executing the
instruction at the offset specified in the gate. No stack switch occurs. Here again, the target operand
can specify the far address of the call gate and instruction either directly with a pointer (ptr16:16 or
ptr16:32) or indirectly with a memory location (m16:16 or m16:32).
Executing a task switch with the JMP instruction, is similar to executing a jump through a call gate.
Here the target operand specifies the segment selector of the task gate for the task being switched
to. (The offset part of the target operand is ignored). The task gate in turn points to the TSS for the
task, which contains the segment selectors for the task’s code, data, and stack segments and the
instruction pointer to the target instruction. One form of the JMP instruction allows the jump to be
made directly to a TSS, without going through a task gate. See Chapter 13 in IA-32 Intel®
Architecture Software Developer’s Manual, Volume 3 the for detailed information on the mechanics
of a task switch.
All branches are converted to code fetches of one or two cache lines, regardless of jump address or
cacheability.
Operation
IF near jump
THEN IF near relative jump
THEN
tempEIP ←EIP + DEST; (* EIP is instruction following JMP instruction*)
ELSE (* near absolute jump *)
tempEIP ←DEST;
FI;
IF tempEIP is beyond code segment limit THEN #GP(0); FI;
IF OperandSize = 32
THEN
EIP ←tempEIP;
ELSE (* OperandSize=16 *)
EIP ←tempEIP AND 0000FFFFH;
FI;
IF Itanium System Environment AND PSR.tb THEN IA_32_Exception(Debug);
FI:
IF far jump AND (PE = 0 OR (PE = 1 AND VM = 1)) (* real address or virtual 8086 mode *)
THEN
tempEIP ←DEST(offset); (* DEST is ptr16:32 or [m16:32] *)
IF tempEIP is beyond code segment limit THEN #GP(0); FI;
CS ←DEST(segment selector); (* DEST is ptr16:32 or [m16:32] *)
IF OperandSize = 32
THEN
EIP ←tempEIP; (* DEST is ptr16:32 or [m16:32] *)
ELSE (* OperandSize = 16 *)
EIP ←tempEIP AND 0000FFFFH; (* clear upper 16 bits *)
FI;
IF Itanium System Environment AND PSR.tb THEN IA_32_Exception(Debug);
FI;
IF far call AND (PE = 1 AND VM = 0) (* Protected mode, not virtual 8086 mode *)
THEN
IF effective address in the CS, DS, ES, FS, GS, or SS segment is illegal
OR segment selector in target operand null
THEN #GP(0);
FI;
IF segment selector index not within descriptor table limits
THEN #GP(new selector);
FI;
Read type and access rights of segment descriptor;
IF segment type is not a conforming or nonconforming code segment, call gate,
task gate, or TSS THEN #GP(segment selector); FI;
Depending on type and access rights
GO TO CONFORMING-CODE-SEGMENT;
GO TO NONCONFORMING-CODE-SEGMENT;
GO TO CALL-GATE;
GO TO TASK-GATE;
GO TO TASK-STATE-SEGMENT;
ELSE
#GP(segment selector);
FI;
NONCONFORMING-CODE-SEGMENT:
IF (RPL > CPL) OR (DPL ≠ CPL) THEN #GP(code segment selector); FI;
IF segment not present THEN #NP(segment selector); FI;
IF instruction pointer outside code segment limit THEN #GP(0); FI;
tempEIP ←DEST(offset);
IF OperandSize=16
THEN tempEIP ←tempEIP AND 0000FFFFH;
FI;
IF tempEIP not in code segment limit THEN #GP(0); FI;
CS ←DEST(SegmentSelector); (* segment descriptor information also loaded *)
CS(RPL) ←CPL
EIP ←tempEIP;
IF Itanium System Environment AND PSR.tb THEN IA_32_Exception(Debug);
END;
CALL-GATE:
END;
TASK-GATE:
IF task gate DPL < CPL
OR task gate DPL < task gate segment-selector RPL
THEN #GP(task gate selector); FI;
IF task gate not present THEN #NP(gate selector); FI;
IF Itanium System Environment THEN IA-32_Intercept(Gate,JMP);
Read the TSS segment selector in the task-gate descriptor;
IF TSS segment selector local/global bit is set to local
OR index not within GDT limits
OR TSS descriptor specifies that the TSS is busy
THEN #GP(TSS selector); FI;
IF TSS not present THEN #NP(TSS selector); FI;
SWITCH-TASKS to TSS;
IF EIP not within code segment limit THEN #GP(0); FI;
END;
TASK-STATE-SEGMENT:
IF TSS DPL < CPL
OR TSS DPL < TSS segment-selector RPL
OR TSS descriptor indicates TSS not available
THEN #GP(TSS selector); FI;
IF TSS is not present THEN #NP(TSS selector); FI;
IF Itanium System Environment THENIA-32_Intercept(Gate,JMP);
SWITCH-TASKS to TSS
IF EIP not within code segment limit THEN #GP(0); FI;
END;
Flags Affected
All flags are affected if a task switch occurs; no flags are affected if a task switch does not occur.
Description
This instruction is available only on processors based on the Itanium architecture in the Itanium
System Environment. Otherwise, execution of this instruction at privilege levels 1, 2, and 3 results
in an Illegal Opcode fault, and at privilege level 0, termination of the IA-32 System Environment
on a processor based on the Itanium architecture.
JMPE switches the processor to the Itanium instruction set and starts execution at the specified
target address There are two forms; an indirect form, r/mr16/32, and an unsigned absolute
form, disp16/32. Both 16 and 32-bit formats are supported.
The absolute form computes the 16-byte aligned 64-bit virtual target address in the Itanium
instruction set by adding the unsigned 16 or 32-bit displacement to the current CS base (IP{31:0} =
disp16/32 + CSD.base). The indirect form specifies the virtual target address by the contents of a
register or memory location (IP{31:0} = [r/m16/32] + CSD.base). Target addresses are constrained
to the lower 4G-bytes of the 64-bit virtual address space within virtual region 0.
GR[1] is loaded with the next sequential instruction address following JMPE.
If PSR.di is 1, the instruction is nullified and a Disabled Instruction Set Transition fault is
generated. If Itanium branch debugging is enabled, an IA_32_Exception(Debug) trap is taken
after JMPE completes execution.
JMPE can be performed at any privilege level and does not change the privilege level of the
processor.
JMPE performs a FWAIT operation, any pending IA-32 unmasked floating-point exceptions are
reported as faults on the JMPE instruction.
If the register stack engine is enabled for eager execution, the register stack engine may
immediately start loading registers when the processor enters the Itanium instruction set.
Operation
if (NOT Itanium System Environment) {
if (PSR.cpl==0) Terminate_IA-32_System_Env();
else IA_32_Exception(IllegalOpcode);
} else if (PSR.di==1) {
Disabled_Instruction_Set_Transition_Fault();
} else if (pending_numeric_exceptions()) {
IA_32_exception(FPError);
} else {
if (absolute_form) { //compute virtual target
IP{31:0} = disp16/32 + AR[CSD].base;//disp is 16/32-bit unsigned value
} else if (indirect_form) {
IP{31:0} = [r/m16/32] + AR[CSD].base;
}
PSR.is = 0; //set Itanium Instruction Set bit
IP{3:0}= 0; //Force 16-byte alignment
IP{63:32} = 0; //zero extend from 32-bits to 64-bits
GR[1]{31:0} = EIP + AR[CSD].base; //next sequential instruction address
GR[1]{63:32} = 0;
PSR.id = EFLAG.rf = 0;
Flags Affected
Description
Moves the low byte of the EFLAGS register (which includes status flags SF, ZF, AF, PF, and CF) to
the AH register. Reserved bits 1, 3, and 5 of the EFLAGS register are set in the AH register as
shown in the “Operation” below.
Operation
AH ←EFLAGS(SF:ZF:0:AF:0:PF:1:CF);
Flags Affected
None (that is, the state of the flags in the EFLAGS register are not affected).
None.
Description
Loads the access rights from the segment descriptor specified by the second operand (source
operand) into the first operand (destination operand) and sets the ZF flag in the EFLAGS register.
The source operand (which can be a register or a memory location) contains the segment selector
for the segment descriptor being accessed. The destination operand is a general-purpose register.
The processor performs access checks as part of the loading process. Once loaded in the destination
register, software can preform additional checks on the access rights information.
When the operand size is 32 bits, the access rights for a segment descriptor comprise the type and
DPL fields and the S, P, AVL, D/B, and G flags, all of which are located in the second doubleword
(bytes 4 through 7) of the segment descriptor. The doubleword is masked by 00FXFF00H before it
is loaded into the destination operand. When the operand size is 16 bits, the access rights comprise
the type and DPL fields. Here, the two lower-order bytes of the doubleword are masked by FF00H
before being loaded into the destination operand.
This instruction performs the following checks before it loads the access rights in the destination
register:
• Checks that the segment selector is not null.
• Checks that the segment selector points to a descriptor that is within the limits of the GDT or
LDT being accessed.
• Checks that the descriptor type is valid for this instruction. All code and data segment
descriptors are valid for (can be accessed with) the LAR instruction. The valid system segment
and gate descriptor types are given in the following table.
• If the segment is not a conforming code segment, it checks that the specified segment
descriptor is visible at the CPL (that is, if the CPL and the RPL of the segment selector are less
than or equal to the DPL of the segment selector).
If the segment descriptor cannot be accessed or is an invalid type for the instruction, the ZF flag is
cleared and no access rights are loaded in the destination operand.
Operation
IF SRC(Offset) > descriptor table limit THEN ZF ←0; FI;
Read segment descriptor;
IF SegmentDescriptor(Type) ≠ conforming code segment
AND (CPL > DPL) OR (RPL > DPL)
OR Segment type is not valid for instruction
THEN
ZF ←0
ELSE
IF OperandSize = 32
THEN
DEST ←[SRC] AND 00FxFF00H;
ELSE (*OperandSize = 16*)
DEST ←[SRC] AND FF00H;
FI;
FI;
Flags Affected
The ZF flag is set to 1 if the access rights are loaded successfully; otherwise, it is cleared to 0.
Description
Load a far pointer (segment selector and offset) from the second operand (source operand) into a
segment register and the first operand (destination operand). The source operand specifies a 48-bit
or a 32-bit pointer in memory depending on the current setting of the operand-size attribute (32 bits
or 16 bits, respectively). The instruction opcode and the destination operand specify a segment
register/general-purpose register pair. The 16-bit segment selector from the source operand is
loaded into the segment register implied with the opcode (DS, SS, ES, FS, or GS). The 32-bit or
16-bit offset is loaded into the register specified with the destination operand.
If one of these instructions is executed in protected mode, additional information from the segment
descriptor pointed to by the segment selector in the source operand is loaded in the hidden part of
the selected segment register.
Also in protected mode, a null selector (values 0000 through 0003) can be loaded into DS, ES, FS,
or GS registers without causing a protection exception. (Any subsequent reference to a segment
whose corresponding segment register is loaded with a null selector, causes a general-protection
exception (#GP) and no memory reference to the segment occurs.)
Operation
IF ProtectedMode
THEN IF SS is loaded
THEN IF SegementSelector = null
THEN #GP(0);
FI;
ELSE IF Segment selector index is not within descriptor table limits
OR Segment selector RPL ≠ CPL
OR Access rights indicate nonwritable data segment
OR DPL ≠ CPL
THEN #GP(selector);
FI;
ELSE IF Segment marked not present
THEN #SS(selector);
FI;
SS ←SegmentSelector(SRC);
SS ←SegmentDescriptor([SRC]);
Flags Affected
None.
Description
Computes the effective address of the second operand (the source operand) and stores it in the first
operand (destination operand). The source operand is a memory address (offset part) specified with
one of the processors addressing modes; the destination operand is a general-purpose register. The
address-size and operand-size attributes affect the action performed by this instruction, as shown in
the following table. The operand-size attribute of the instruction is determined by the chosen
register; the address-size attribute is determined by the attribute of the code segment.
Different assemblers may use different algorithms based on the size attribute and symbolic
reference of the source operand.
Operation
IF OperandSize = 16 AND AddressSize = 16
THEN
DEST ←EffectiveAddress(SRC); (* 16-bit address *)
ELSE IF OperandSize = 16 AND AddressSize = 32
THEN
temp ←EffectiveAddress(SRC); (* 32-bit address *)
DEST ←temp[0..15]; (* 16-bit address *)
ELSE IF OperandSize = 32 AND AddressSize = 16
THEN
temp ←EffectiveAddress(SRC); (* 16-bit address *)
DEST ←ZeroExtend(temp); (* 32-bit address *)
ELSE IF OperandSize = 32 AND AddressSize = 32
THEN
DEST ←EffectiveAddress(SRC); (* 32-bit address *)
FI;
FI;
Flags Affected
None.
Description
Executes a return from a procedure or group of nested procedures established by an earlier ENTER
instruction. The instruction copies the frame pointer (in the EBP register) into the stack pointer
register (ESP), releasing the stack space used by a procedure for its local variables. The old frame
pointer (the frame pointer for the calling procedure that issued the ENTER instruction) is then
popped from the stack into the EBP register, restoring the calling procedure’s frame.
A RET instruction is commonly executed following a LEAVE instruction to return program control
to the calling procedure and remove any arguments pushed onto the stack by the procedure being
returned from.
Operation
IF StackAddressSize = 32
THEN
ESP ←EBP;
ELSE (* StackAddressSize = 16*)
SP ←BP;
FI;
IF OperandSize = 32
THEN
EBP ←Pop();
ELSE (* OperandSize = 16*)
BP ←Pop();
FI;
Flags Affected
None.
Description
Loads the values in the source operand into the global descriptor table register (GDTR) or the
interrupt descriptor table register (IDTR). The source operand is a pointer to 6 bytes of data in
memory that contains the base address (a linear address) and the limit (size of table in bytes) of the
global descriptor table (GDT) or the interrupt descriptor table (IDT). If operand-size attribute is
32 bits, a 16-bit limit (lower 2 bytes of the 6-byte data operand) and a 32-bit base address (upper
4 bytes of the data operand) are loaded into the register. If the operand-size attribute is 16 bits, a
16-bit limit (lower 2 bytes) and a 24-bit base address (third, fourth, and fifth byte) are loaded. Here,
the high-order byte of the operand is not used and the high-order byte of the base address in the
GDTR or IDTR is filled with zeros.
The LGDT and LIDT instructions are used only in operating-system software; they are not used in
application programs. They are the only instructions that directly load a linear address (that is, not a
segment-relative address) and a limit in protected mode. They are commonly executed in
real-address mode to allow processor initialization prior to switching to protected mode.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,LGDT/LIDT);
IF instruction is LIDT
THEN
IF OperandSize = 16
THEN
IDTR(Limit) ←SRC[0:15];
IDTR(Base) ←SRC[16:47] AND 00FFFFFFH;
ELSE (* 32-bit Operand Size *)
IDTR(Limit) ←SRC[0:15];
IDTR(Base) ←SRC[16:47];
FI;
ELSE (* instruction is LGDT *)
IF OperandSize = 16
THEN
GDTR(Limit) ←SRC[0:15];
GDTR(Base) ←SRC[16:47] AND 00FFFFFFH;
ELSE (* 32-bit Operand Size *)
GDTR(Limit) ←SRC[0:15];
GDTR(Base) ←SRC[16:47];
FI;
FI;
Flags Affected
None.
Description
Loads the source operand into the segment selector field of the local descriptor table register
(LDTR). The source operand (a general-purpose register or a memory location) contains a segment
selector that points to a local descriptor table (LDT). After the segment selector is loaded in the
LDTR, the processor uses to segment selector to locate the segment descriptor for the LDT in the
global descriptor table (GDT). It then loads the segment limit and base address for the LDT from
the segment descriptor into the LDTR. The segment registers DS, ES, SS, FS, GS, and CS are not
affected by this instruction, nor is the LDTR field in the task state segment (TSS) for the current
task.
If the source operand is 0, the LDTR is marked invalid and all references to descriptors in the LDT
(except by the LAR, VERR, VERW or LSL instructions) cause a general protection exception
(#GP).
The LLDT instruction is provided for use in operating-system software; it should not be used in
application programs. Also, this instruction can only be executed in protected mode.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,LLDT);
Flags Affected
None.
Description
Loads the source operand into the machine status word, bits 0 through 15 of register CR0. The
source operand can be a 16-bit general-purpose register or a memory location. Only the low-order
4 bits of the source operand (which contains the PE, MP, EM, and TS flags) are loaded into CR0.
The PG, CD, NW, AM, WP, NE, and ET flags of CR0 are not affected. The operand-size attribute
has no effect on this instruction.
If the PE flag of the source operand (bit 0) is set to 1, the instruction causes the processor to switch
to protected mode. The PE flag in the CR0 register is a sticky bit. Once set to 1, the LMSW
instruction cannot be used clear this flag and force a switch back to real address mode.
The LMSW instruction is provided for use in operating-system software; it should not be used in
application programs. In protected or virtual 8086 mode, it can only be executed at CPL 0.
This instruction is provided for compatibility with the Intel 286 processor; programs and
procedures intended to run on processors more recent than the Intel 286 should use the MOV
(control registers) instruction to load the machine status word.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,LMSW);
CR0[0:3] ←SRC[0:3];
Flags Affected
None.
Description
Causes the processor’s LOCK# signal to be asserted during execution of the accompanying
instruction (turns the instruction into an atomic instruction). In a multiprocessor environment, the
LOCK# signal insures that the processor has exclusive use of any shared memory while the signal
is asserted.
The LOCK prefix can be prepended only to the following instructions and to those forms of the
instructions that use a memory operand: ADD, ADC, AND, BTC, BTR, BTS, CMPXCHG, DEC,
INC, NEG, NOT, OR, SBB, SUB, XOR, XADD, and XCHG. An undefined opcode exception will
be generated if the LOCK prefix is used with any other instruction. The XCHG instruction always
asserts the LOCK# signal regardless of the presence or absence of the LOCK prefix.
The LOCK prefix is typically used with the BTS instruction to perform a read-modify-write
operation on a memory location in shared memory environment.
The integrity of the LOCK prefix is not affected by the alignment of the memory field. Memory
locking is observed for arbitrarily misaligned fields.
Operation
IF Itanium System Environment AND External_Bus_Lock_Required AND DCR.lc
THEN IA-32_Intercept(LOCK);
AssertLOCK#(DurationOfAccompaningInstruction)
Flags Affected
None.
Description
Load a byte, word, or doubleword from the source operand into the AL, AX, or EAX register,
respectively. The source operand is a memory location at the address DS:ESI. (When the
operand-size attribute is 16, the SI register is used as the source-index register.) The DS segment
may be overridden with a segment override prefix.
The LODSB, LODSW, and LODSD mnemonics are synonyms of the byte, word, and doubleword
versions of the LODS instructions. (For the LODS instruction, “DS:ESI” must be explicitly
specified in the instruction.)
After the byte, word, or doubleword is transfer from the memory location into the AL, AX, or EAX
register, the ESI register is incremented or decremented automatically according to the setting of
the DF flag in the EFLAGS register. (If the DF flag is 0, the ESI register is incremented; if the DF
flag is 1, the ESI register is decremented.) The ESI register is incremented or decremented by 1 for
byte operations, by 2 for word operations, or by 4 for doubleword operations.
The LODS, LODSB, LODSW, and LODSD instructions can be preceded by the REP prefix for
block loads of ECX bytes, words, or doublewords. More often, however, these instructions are used
within a LOOP construct, because further processing of the data moved into the register is usually
necessary before the next transfer can be made. See “REP/REPE/REPZ/REPNE /REPNZ—Repeat
String Operation Prefix” on page 0:707 for a description of the REP prefix.
Operation
IF (byte load)
THEN
AL ←SRC; (* byte load *)
THEN IF DF = 0
THEN (E)SI ←1;
ELSE (E)SI ←-1;
FI;
ELSE IF (word load)
THEN
AX ←SRC; (* word load *)
THEN IF DF = 0
THEN SI ←2;
ELSE SI ←-2;
FI;
ELSE (* doubleword transfer *)
EAX ←SRC; (* doubleword load *)
THEN IF DF = 0
FI;
FI;
FI;
Flags Affected
None.
Description
Performs a loop operation using the ECX or CX register as a counter. Each time the LOOP
instruction is executed, the count register is decremented, then checked for 0. If the count is 0, the
loop is terminated and program execution continues with the instruction following the LOOP
instruction. If the count is not zero, a near jump is performed to the destination (target) operand,
which is presumably the instruction at the beginning of the loop. If the address-size attribute is
32 bits, the ECX register is used as the count register; otherwise the CX register is used.
The target instruction is specified with a relative offset (a signed offset relative to the current value
of the instruction pointer in the EIP register). This offset is generally specified as a label in
assembly code, but at the machine code level, it is encoded as a signed, 8-bit immediate value,
which is added to the instruction pointer. Offsets of -128 to +127 are allowed with this instruction.
Some forms of the loop instruction (LOOPcc) also accept the ZF flag as a condition for terminating
the loop before the count reaches zero. With these forms of the instruction, a condition code (cc) is
associated with each instruction to indicate the condition being tested for. Here, the LOOPcc
instruction itself does not affect the state of the ZF flag; the ZF flag is changed by other instructions
in the loop.
All branches are converted to code fetches of one or two cache lines, regardless of jump address or
cacheability.
Operation
IF AddressSize = 32
THEN
Count is ECX;
ELSE (* AddressSize = 16 *)
Count is CX;
FI;
Count ←Count - 1;
THEN
IF (ZF =0 ) AND (Count ≠ 0)
Flags Affected
None.
None.
None.
Description
Loads the unscrambled segment limit from the segment descriptor specified with the second
operand (source operand) into the first operand (destination operand) and sets the ZF flag in the
EFLAGS register. The source operand (which can be a register or a memory location) contains the
segment selector for the segment descriptor being accessed. The destination operand is a
general-purpose register.
The processor performs access checks as part of the loading process. Once loaded in the destination
register, software can compare the segment limit with the offset of a pointer.
The segment limit is a 20-bit value contained in bytes 0 and 1 and in the first 4 bits of byte 6 of the
segment descriptor. If the descriptor has a byte granular segment limit (the granularity flag is set to
0), the destination operand is loaded with a byte granular value (byte limit). If the descriptor has a
page granular segment limit (the granularity flag is set to 1), the LSL instruction will translate the
page granular limit (page limit) into a byte limit before loading it into the destination operand. The
translation is performed by shifting the 20-bit “raw” limit left 12 bits and filling the low-order
12 bits with 1s.
When the operand size is 32 bits, the 32-bit byte limit is stored in the destination operand. When the
operand size is 16 bits, a valid 32-bit limit is computed; however, the upper 16 bits are truncated
and only the low-order 16 bits are loaded into the destination operand.
This instruction performs the following checks before it loads the segment limit into the destination
register:
• Checks that the segment selector is not null.
• Checks that the segment selector points to a descriptor that is within the limits of the GDT or
LDT being accessed.
• Checks that the descriptor type is valid for this instruction. All code and data segment
descriptors are valid for (can be accessed with) the LSL instruction. The valid special segment
and gate descriptor types are given in the following table.
• If the segment is not a conforming code segment, the instruction checks that the specified
segment descriptor is visible at the CPL (that is, if the CPL and the RPL of the segment
selector are less than or equal to the DPL of the segment selector).
If the segment descriptor cannot be accessed or is an invalid type for the instruction, the ZF flag is
cleared and no value is loaded in the destination operand.
Operation
IF SRC(Offset) > descriptor table limit
THEN ZF ←0; FI;
Read segment descriptor;
IF SegmentDescriptor(Type) ≠ conforming code segment
AND (CPL > DPL) OR (RPL > DPL)
OR Segment type is not valid for instruction
THEN
ZF ←0
ELSE
temp ←SegmentLimit([SRC]);
IF (G = 1)
THEN
temp ←ShiftLeft(12, temp) OR 00000FFFH;
FI;
IF OperandSize = 32
THEN
DEST ←temp;
ELSE (*OperandSize = 16*)
DEST ←temp AND FFFFH;
FI;
FI;
Flags Affected
The ZF flag is set to 1 if the segment limit is loaded successfully; otherwise, it is cleared to 0.
Description
Loads the source operand into the segment selector field of the task register. The source operand (a
general-purpose register or a memory location) contains a segment selector that points to a task
state segment (TSS). After the segment selector is loaded in the task register, the processor uses to
segment selector to locate the segment descriptor for the TSS in the global descriptor table (GDT).
It then loads the segment limit and base address for the TSS from the segment descriptor into the
task register. The task pointed to by the task register is marked busy, but a switch to the task does
not occur.
The LTR instruction is provided for use in operating-system software; it should not be used in
application programs. It can only be executed in protected mode when the CPL is 0. It is commonly
used in initialization code to establish the first task to be executed.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,LTR);
IF SRC(Offset) > descriptor table limit OR IF SRC(type) ≠ global
THEN #GP(segment selector);
FI;
Reat segment descriptor;
IF segment descriptor is not for an available TSS THEN #GP(segment selector); FI;
IF segment descriptor is not present THEN #NP(segment selector);
TSSsegmentDescriptor(busy) ←1;
(* Locked read-modify-write operation on the entire descriptor when setting busy flag *)
TaskRegister(SegmentSelector) ←SRC;
TaskRegister(SegmentDescriptor) ←TSSSegmentDescriptor;
Flags Affected
None.
Notes:
*The moffs8, moffs16, and moffs32 operands specify a simple offset relative to the segment base, where 8, 16,
and 32 refer to the size of the data. The address-size attribute of the instruction determines the size of the
offset, either 16 or 32 bits.
**In 32-bit mode, the assembler may require the use of the 16-bit operand size prefix (a byte with the value 66H
preceding the instruction).
Description
Copies the second operand (source operand) to the first operand (destination operand). The source
operand can be an immediate value, general-purpose register, segment register, or memory
location; the destination register can be a general-purpose register, segment register, or memory
location. Both operands must be the same size, which can be a byte, a word, or a doubleword.
The MOV instruction cannot be used to load the CS register. Attempting to do so results in an
invalid opcode exception (#UD). To load the CS register, use the RET instruction.
A null segment selector (values 0000-0003) can be loaded into the DS, ES, FS, and GS registers
without causing a protection exception. However, any subsequent attempt to reference a segment
whose corresponding segment register is loaded with a null value causes a general protection
exception (#GP) and no memory reference occurs.
Loading the SS register with a MOV instruction inhibits all external interrupts and traps
until after the execution of the next instruction in the IA-32 System Environment. For the
Itanium System Environment, MOV to SS results in a IA-32_Intercept(SystemFlag) trap
after the instruction completes. This operation allows a stack pointer to be loaded into the ESP
register with the next instruction (MOV ESP, stack-pointer value) before an interrupt occurs. The
LSS instruction offers a more efficient method of loading the SS and ESP registers.
When moving data in 32-bit mode between a segment register and a 32-bit general-purpose
register, the Pentium Pro processor does not require the use of a 16-bit operand size prefix;
however, some assemblers do require this prefix. The processor assumes that the sixteen
least-significant bits of the general-purpose register are the destination or source operand. When
moving a value from a segment selector to a 32-bit register, the processor fills the two high-order
bytes of the register with zeros.
Operation
DEST ←SRC;
Loading a segment register while in protected mode results in special checks and actions, as
described in the following listing. These checks are performed on the segment selector and the
segment descriptor it points to.
IF SS is loaded;
THEN
IF segment selector is null
THEN #GP(0);
FI;
IF segment selector index is outside descriptor table limits
OR segment selector's RPL ≠ CPL
OR segment is not a writable data segment
OR DPL ≠ CPL
THEN #GP(selector);
FI;
IF segment not marked present
THEN #SS(selector);
ELSE
SS ←segment selector;
SS ←segment descriptor;
FI;
FI;
IF DS, ES, FS or GS is loaded with non-null selector;
THEN
IF segment selector index is outside descriptor table limits
OR segment is not a data or readable code segment
OR ((segment is a data or nonconforming code segment)
AND (both RPL and CPL > DPL))
THEN #GP(selector);
IF segment not marked present
THEN #NP(selector);
ELSE
SegmentRegister ←segment selector;
SegmentRegister ←segment descriptor;
FI;
FI;
IF DS, ES, FS or GS is loaded with a null selector;
THEN
SegmentRegister ←null segment selector;
SegmentRegister ←null segment descriptor;
FI;
Flags Affected
None.
Description
Moves the contents of a control register (CR0, CR2, CR3, or CR4) to a general-purpose register or
vice versa. The operand size for these instructions is always 32 bits, regardless of the operand-size
attribute. (See the IA-32 Intel® Architecture Software Developer’s Manual, Volume 3 for a detailed
description of the flags and fields in the control registers.)
When loading a control register, a program should not attempt to change any of the reserved bits;
that is, always set reserved bits to the value previously read.
At the opcode level, the reg field within the ModR/M byte specifies which of the control registers is
loaded or read. The 2 bits in the mod field are always 11B. The r/m field specifies the
general-purpose register loaded or read.
Operation
IF Itanium System Environment AND Move To CR Form THEN IA-32_Intercept(INST,MOVCR);
DEST ←SRC;
Flags Affected
The OF, SF, ZF, AF, PF, and CF flags are undefined.
Description
Moves the contents of two or more debug registers (DR0 through DR3, DR4 and DR5, or DR6 and
DR7) to a general-purpose register or vice versa. The operand size for these instructions is always
32 bits, regardless of the operand-size attribute. (See the IA-32 Intel® Architecture Software
Developer’s Manual, Volume 3 for a detailed description of the flags and fields in the debug
registers.)
When the debug extension (DE) flag in register CR4 is clear, these instructions operate on debug
registers in a manner that is compatible with Intel386™ and Intel486 processors. In this mode,
references to DR4 and DR5 refer to DR6 and DR7, respectively. When the DE set in CR4 is set,
attempts to reference DR4 and DR5 result in an undefined opcode (#UD) exception.
At the opcode level, the reg field within the ModR/M byte specifies which of the debug registers is
loaded or read. The two bits in the mod field are always 11. The r/m field specifies the
general-purpose register loaded or read.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,MOVDR);
IF ((DE = 1) and (SRC or DEST = DR4 or DR5))
THEN
#UD;
ELSE
DEST ←SRC;
Flags Affected
The OF, SF, ZF, AF, PF, and CF flags are undefined.
Description
Moves the byte, word, or doubleword specified with the second operand (source operand) to the
location specified with the first operand (destination operand). The source operand specifies the
memory location at the address DS:ESI and the destination operand specifies the memory location
at address ES:EDI. (When the operand-size attribute is 16, the SI and DI register are used as the
source-index and destination-index registers, respectively.) The DS segment may be overridden
with a segment override prefix, but the ES segment cannot be overridden.
The MOVSB, MOVSW, and MOVSD mnemonics are synonyms of the byte, word, and
doubleword versions of the MOVS instructions. They are simpler to use, but provide no type or
segment checking. (For the MOVS instruction, “DS:ESI” and “ES:EDI” must be explicitly
specified in the instruction.)
After the transfer, the ESI and EDI registers are incremented or decremented automatically
according to the setting of the DF flag in the EFLAGS register. (If the DF flag is 0, the ESI and EDI
register are incremented; if the DF flag is 1, the ESI and EDI registers are decremented.) The
registers are incremented or decremented by 1 for byte operations, by 2 for word operations, or by
4 for doubleword operations.
The MOVS, MOVSB, MOVSW, and MOVSD instructions can be preceded by the REP prefix (see
“REP/REPE/REPZ/REPNE/REPNZ—Repeat Following String Operation” on
“REP/REPE/REPZ/REPNE /REPNZ—Repeat String Operation Prefix” on page 0:707) for block
moves of ECX bytes, words, or doublewords.
Operation
DEST ←SRC;
IF (byte move)
THEN IF DF = 0
THEN (E)DI ←1;
ELSE (E)DI ←-1;
FI;
ELSE IF (word move)
THEN IF DF = 0
THEN DI ←2;
ELSE DI ←-2;
FI;
ELSE (* doubleword move*)
THEN IF DF = 0
Flags Affected
None.
Description
Copies the contents of the source operand (register or memory location) to the destination operand
(register) and sign extends the value to 16 or 32 bits. The size of the converted value depends on the
operand-size attribute.
Operation
DEST ←SignExtend(SRC);
Flags Affected
None.
Description
Copies the contents of the source operand (register or memory location) to the destination operand
(register) and sign extends the value to 16 or 32 bits. The size of the converted value depends on the
operand-size attribute.
Copies the contents of the source operand (register or memory location) to the destination operand
(register) and zero extends the value to 16 or 32 bits. The size of the converted value depends on
the operand-size attribute.
Operation
DEST ←ZeroExtend(SRC);
Flags Affected
None.
Description
Performs an unsigned multiplication of the first operand (destination operand) and the second
operand (source operand) and stores the result in the destination operand. The destination operand
is an implied operand located in register AL, AX or EAX (depending on the size of the operand);
the source operand is located in a general-purpose register or a memory location. The action of this
instruction and the location of the result depends on the opcode and the operand size as shown in
the following table.
The AH, DX, or EDX registers (depending on the operand size) contain the high-order bits of the
product. If the contents of one of these registers are 0, the CF and OF flags are cleared; otherwise,
the flags are set.
Operation
IF byte operation
THEN
AX ←AL ∗ SRC
ELSE (* word or doubleword operation *)
IF OperandSize = 16
THEN
DX:AX ←AX ∗ SRC
ELSE (* OperandSize = 32 *)
EDX:EAX ←EAX ∗ SRC
FI;
FI;
Flags Affected
The OF and CF flags are cleared to 0 if the upper half of the result is 0; otherwise, they are set to 1.
The SF, ZF, AF, and PF flags are undefined.
Description
Replaces the value of operand (the destination operand) with its two's complement. The destination
operand is located in a general-purpose register or a memory location.
Operation
IF DEST = 0
THEN CF ←0
ELSE CF ←1;
FI;
DEST ← - (DEST)
Flags Affected
The CF flag cleared to 0 if the source operand is 0; otherwise it is set to 1. The OF, SF, ZF, AF, and
PF flags are set according to the result.
Description
Performs no operation. This instruction is a one-byte instruction that takes up space in the
instruction stream but does not affect the machine context, except the EIP register.
The NOP instruction performs no operation, no registers are accessed and no faults are
generated.
Flags Affected
None.
None.
Description
Performs a bitwise NOT operation (1’s complement) on the destination operand and stores the
result in the destination operand location. The destination operand can be a register or a memory
location.
Operation
DEST ←NOT DEST;
Flags Affected
None.
Description
Performs a bitwise OR 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.
Operation
DEST ←DEST OR 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.
Description
Copies the value from the second operand (source operand) to the I/O port specified with the
destination operand (first operand). The source operand can be register AL, AX, or EAX,
depending on the size of the port being accessed (8, 16, or 32 bits, respectively); the destination
operand can be a byte-immediate or the DX register. Using a byte immediate allows I/O port
addresses 0 to 255 to be accessed; using the DX register as a source operand allows I/O ports from
0 to 65,535 to be accessed.
When accessing an 8-bit I/O port, the opcode determines the port size; when accessing a 16- and
32-bit I/O port, the operand-size attribute determines the port size.
At the machine code level, I/O instructions are shorter when accessing 8-bit I/O ports. Here, the
upper eight bits of the port address will be 0.
This instruction is only useful for accessing I/O ports located in the processor’s I/O address space.
I/O transactions are performed after all prior data memory operations. No subsequent data
memory operations can pass an I/O transaction.
In the Itanium System Environment, I/O port references are mapped into the 64-bit virtual
address pointed to by the IOBase register, with four ports per 4K-byte virtual page.
Operating systems can utilize TLBs in the Itanium architecture to grant or deny permission
to any four I/O ports. The I/O port space can be mapped into any arbitrary 64-bit physical
memory location by operating system code. If CFLG.io is 1 and CPL>IOPL, the TSS is
consulted for I/O permission. If CFLG.io is 0 or CPL<=IOPL, permission is granted
regardless of the state of the TSS I/O permission bitmap (the bitmap is not referenced).
If the referenced I/O port is mapped to an unimplemented virtual address (via the I/O Base
register) or if data translations are disabled (PSR.dt is 0) a GPFault is generated on the
referencing OUT instruction.
Operation
IF ((PE = 1) AND ((VM = 1) OR (CPL > IOPL)))
THEN (* Protected mode or virtual-8086 mode with CPL > IOPL *)
IF (CFLG.io AND Any I/O Permission Bit for I/O port being accessed = 1)
THEN #GP(0);
FI;
ELSE ( * Real-address mode or protected mode with CPL ≤IOPL *)
(* or virtual-8086 mode with all I/O permission bits for I/O port cleared *)
FI;
IF (Itanium_System_Environment) THEN
DEST_VA = IOBase | (Port{15:2}<<12) | Port{11:0};
DEST_PA = translate(DEST_VA);
memory_fence();
[DEST_PA] ←SRC; (* Writes to selected I/O port *)
memory_fence();
Flags Affected
None.
None.
Description
Copies data from the second operand (source operand) to the I/O port specified with the first
operand (destination operand). The source operand is a memory location at the address DS:ESI.
(When the operand-size attribute is 16, the SI register is used as the source-index register.) The
DS register may be overridden with a segment override prefix.
The destination operand must be the DX register, allowing I/O port addresses from 0 to 65,535 to
be accessed. When accessing an 8-bit I/O port, the opcode determines the port size; when accessing
a 16- and 32-bit I/O port, the operand-size attribute determines the port size.
The OUTSB, OUTSW and OUTSD mnemonics are synonyms of the byte, word, and doubleword
versions of the OUTS instructions. (For the OUTS instruction, “DS:ESI” must be explicitly
specified in the instruction.)
After the byte, word, or doubleword is transfer from the memory location to the I/O port, the
ESI register is incremented or decremented automatically according to the setting of the DF flag in
the EFLAGS register. (If the DF flag is 0, the ESI register is incremented; if the DF flag is 1, the
EDI register is decremented.) The ESI register is incremented or decremented by 1 for byte
operations, by 2 for word operations, or by 4 for doubleword operations.
The OUTS, OUTSB, OUTSW, and OUTSD instructions can be preceded by the REP prefix for
block input of ECX bytes, words, or doublewords. See “REP/REPE/REPZ/REPNE /REPNZ—
Repeat String Operation Prefix” on page 0:707 for a description of the REP prefix.
After an OUTS, OUTSB, OUTSW, or OUTSD instruction is executed, the processor waits for the
acknowledgment of the OUT transaction before beginning to execute the next instruction. Note that
the next instruction may be prefetched, even if the OUT transaction has not completed.
This instruction is only useful for accessing I/O ports located in the processor’s I/O address space.
I/O transactions are performed after all prior data memory operations. No subsequent data
memory operations can pass an I/O transaction.
If the referenced I/O port is mapped to an unimplemented virtual address (via the I/O Base
register) or if data translations are disabled (PSR.dt is 0) a GPFault is generated on the
referencing OUTS instruction.
Operation
IF ((PE = 1) AND ((VM = 1) OR (CPL > IOPL)))
THEN (* Protected mode or virtual-8086 mode with CPL > IOPL *)
IF (CFLG.io AND Any I/O Permission Bit for I/O port being accessed = 1)
THEN #GP(0);
FI;
ELSE ( * I/O operation is allowed *)
FI;
IF (Itanium_System_Environment) THEN
DEST_VA = IOBase | (Port{15:2}<<12) | Port{11:0};
DEST_PA = translate(DEST_VA);
[DEST_PA] ←SRC; (* Writes to selected I/O port *)
FI;
memory_fence();
[DEST_PA] ←SRC; (* Writes to selected I/O port *)
memory_fence();
IF (byte operation)
THEN IF DF = 0
THEN (E)DI ←1;
ELSE (E)DI ←-1;
FI;
ELSE IF (word operation)
THEN IF DF = 0
THEN DI ←2;
ELSE DI ←-2;
FI;
ELSE (* doubleword operation *)
THEN IF DF = 0
THEN EDI ←4;
ELSE EDI ←-4;
FI;
FI;
FI;
FI;
Flags Affected
None.
Description
Loads the value from the top of the procedure stack to the location specified with the destination
operand and then increments the stack pointer. The destination operand can be a general-purpose
register, memory location, or segment register.
The current address-size attribute for the stack segment and the operand-size attribute determine
the amount the stack pointer is incremented (see the “Operation” below). For example, if 32-bit
addressing and operands are being used, the ESP register (stack pointer) is incremented by 4 and, if
16-bit addressing and operands are being used, the SP register (stack pointer for 16-bit addressing)
is incremented by 2. The B flag in the stack segment’s segment descriptor determines the stack’s
address-size attribute.
If the destination operand is one of the segment registers DS, ES, FS, GS, or SS, the value loaded
into the register must be a valid segment selector. In protected mode, popping a segment selector
into a segment register automatically causes the descriptor information associated with that
segment selector to be loaded into the hidden (shadow) part of the segment register and causes the
selector and the descriptor information to be validated (see the “Operation” below).
A null value (0000-0003) may be popped into the DS, ES, FS, or GS register without causing a
general protection fault. However, any subsequent attempt to reference a segment whose
corresponding segment register is loaded with a null value causes a general protection exception
(#GP). In this situation, no memory reference occurs and the saved value of the segment register is
null.
The POP instruction cannot pop a value into the CS register. To load the CS register, use the RET
instruction.
A POP SS instruction inhibits all external interrupts, including the NMI interrupt, and traps until
after execution of the next instruction. in the IA-32 System Environment. For the Itanium
System Environment, POP SS results in an IA-32_Intercept(SystemFlag) trap after the
instruction completes.This operation allows a stack pointer to be loaded into the ESP register with
the next instruction (MOV ESP, stack-pointer value) before an interrupt occurs. The LSS
instruction offers a more efficient method of loading the SS and ESP registers.
If the ESP register is used as a base register for addressing a destination operand in memory, the
POP instructions computes the effective address of the operand after it increments the ESP register.
The POP ESP instruction increments the stack pointer (ESP) before data at the old top of stack is
written into the destination.
Operation
IF StackAddrSize = 32
THEN
IF OperandSize = 32
THEN
DEST ←SS:ESP; (* copy a doubleword *)
ESP ←ESP + 4;
ELSE (* OperandSize = 16*)
DEST ←SS:ESP; (* copy a word *)
ESP ←ESP + 2;
FI;
ELSE (* StackAddrSize = 16* )
IF OperandSize = 16
THEN
DEST ←SS:SP; (* copy a word *)
SP ←SP + 2;
ELSE (* OperandSize = 32 *)
DEST ←SS:SP; (* copy a doubleword *)
SP ←SP + 4;
FI;
FI;
Loading a segment register while in protected mode results in special checks and actions, as
described in the following listing. These checks are performed on the segment selector and the
segment descriptor it points to.
IF SS is loaded;
THEN
IF segment selector is null
THEN #GP(0);
FI;
IF segment selector index is outside descriptor table limits
OR segment selector's RPL ≠ CPL
OR segment is not a writable data segment
OR DPL ≠ CPL
THEN #GP(selector);
FI;
IF segment not marked present
THEN #SS(selector);
ELSE
SS ←segment selector;
SS ←segment descriptor;
FI;
FI;
IF DS, ES, FS or GS is loaded with non-null selector;
THEN
IF segment selector index is outside descriptor table limits
OR segment is not a data or readable code segment
Flags Affected
None.
Description
Pops doublewords (POPAD) or words (POPA) from the procedure stack into the general-purpose
registers. The registers are loaded in the following order: EDI, ESI, EBP, EBX, EDX, ECX, and
EAX (if the current operand-size attribute is 32) and DI, SI, BP, BX, DX, CX, and AX (if the
operand-size attribute is 16). (These instructions reverse the operation of the PUSHA/PUSHAD
instructions.) The value on the stack for the ESP or SP register is ignored. Instead, the ESP or SP
register is incremented after each register is loaded (see the “Operation” below).
The POPA (pop all) and POPAD (pop all double) mnemonics reference the same opcode. The
POPA instruction is intended for use when the operand-size attribute is 16 and the POPAD
instruction for when the operand-size attribute is 32. Some assemblers may force the operand size
to 16 when POPA is used and to 32 when POPAD is used. Others may treat these mnemonics as
synonyms (POPA/POPAD) and use the current setting of the operand-size attribute to determine the
size of values to be popped from the stack, regardless of the mnemonic used.
Operation
IF OperandSize = 32 (* instruction = POPAD *)
THEN
EDI ←Pop();
ESI ←Pop();
EBP ←Pop();
increment ESP by 4 (* skip next 4 bytes of stack *)
EBX ←Pop();
EDX ←Pop();
ECX ←Pop();
EAX ←Pop();
ELSE (* OperandSize = 16, instruction = POPA *)
DI ←Pop();
SI ←Pop();
BP ←Pop();
increment ESP by 2 (* skip next 2 bytes of stack *)
BX ←Pop();
DX ←Pop();
CX ←Pop();
AX ←Pop();
FI;
Flags Affected
None.
Description
Pops a doubleword (POPFD) from the top of the stack (if the current operand-size attribute is 32)
and stores the value in the EFLAGS register or pops a word from the top of the stack (if the
operand-size attribute is 16) and stores it in the lower 16 bits of the EFLAGS register. (These
instructions reverse the operation of the PUSHF/PUSHFD instructions.)
The POPF (pop flags) and POPFD (pop flags double) mnemonics reference the same opcode. The
POPF instruction is intended for use when the operand-size attribute is 16 and the POPFD
instruction for when the operand-size attribute is 32. Some assemblers may force the operand size
to 16 when POPF is used and to 32 when POPFD is used. Others may treat these mnemonics as
synonyms (POPF/POPFD) and use the current setting of the operand-size attribute to determine the
size of values to be popped from the stack, regardless of the mnemonic used.
The effect of the POPF/POPFD instructions on the EFLAGS register changes slightly, depending
on the mode of operation of the processor. When the processor is operating in protected mode at
privilege level 0 (or in real-address mode, which is equivalent to privilege level 0), all the
non-reserved flags in the EFLAGS register except the VIP and VIF flags can be modified. The VIP
and VIF flags are cleared.
When operating in protected mode, but with a privilege level greater an 0, all the flags can be
modified except the IOPL field and the VIP and VIF flags. Here, the IOPL flags are masked and the
VIP and VIF flags are cleared.
When operating in virtual-8086 mode, the I/O privilege level (IOPL) must be equal to 3 to use
POPF/POPFD instructions and the VM, RF, IOPL, VIP, and VIF flags are masked. If the IOPL is
less than 3, the POPF/POPFD instructions cause a general protection exception (#GP).
The IOPL is altered only when executing at privilege level 0. The interrupt flag is altered only
when executing at a level at least as privileged as the IOPL. (Real-address mode is equivalent to
privilege level 0.) If a POPF/POPFD instruction is executed with insufficient privilege, an
exception does not occur, but the privileged bits do not change.
Operation
OLD_IF <- IF; OLD_AC <- AC; OLD_TF <- TF;
IF CR0.PE = 0 (*Real Mode *)
THEN
IF OperandSize = 32;
THEN
EFLAGS ←Pop();
(* All non-reserved flags except VM, RF, VIP and VIF can be modified; *)
ELSE (* OperandSize = 16 *)
EFLAGS[15:0] ←Pop(); (* All non-reserved flags can be modified; *)
FI;
ELSE (*In Protected Mode *)
IF VM=0 (* Not in Virtual-8086 Mode *)
THEN
IF CPL=0
THEN
IF OperandSize = 32;
THEN
EFLAGS ←Pop();
(* All non-reserved flags except VM, RF, VIP and VIF can be *)
(* modified; *)
ELSE (* OperandSize = 16 *)
EFLAGS[15:0] ←Pop(); (* All non-reserved flags can be modified; *)
FI;
ELSE (* CPL > 0 *)
IF OperandSize = 32;
THEN
EFLAGS ←Pop()
(* All non-reserved bits except IOPL, RF, VM, VIP, and VIF can *)
(* be modified; *)
(* IOPL is masked *)
ELSE (* OperandSize = 16 *)
EFLAGS[15:0] ←Pop();
(* All non-reserved bits except IOPL can be modified; IOPL is
masked *)
FI;
FI;
ELSE (* In Virtual-8086 Mode *)
IF IOPL=3
THEN
IF OperandSize=32
THEN
EFLAGS ←Pop()
(* All non-reserved bits except VM, RF, IOPL, VIP, and VIF *)
(* can be modified; VM, RF, IOPL, VIP, and VIF are masked*)
ELSE
EFLAGS[15:0] ←Pop()
(* All non-reserved bits except IOPL can be modified; IOPL is *)
(* masked *)
FI;
ELSE (* IOPL < 3 *)
IF CR4.VME = 0
THEN #GP(0);
ELSE
IF ((OperandSize = 32) OR (STACK.TF = 1) OR (EFLAGS.VIP = 1
AND STACK.IF = 1)
THEN #GP(0);
ELSE
TempFlags <- pop();
FLAGS <- TempFlags; (*IF and IOPL bits are unchanged*)
EFLAGS.VIF <- TempFlags.IF;
FI;
FI;
FI;
FI;
FI;
Flags Affected
Description
Decrements the stack pointer and then stores the source operand on the top of the procedure stack.
The current address-size attribute for the stack segment and the operand-size attribute determine
the amount the stack pointer is decremented (see the “Operation” below). For example, if 32-bit
addressing and operands are being used, the ESP register (stack pointer) is decremented by 4 and, if
16-bit addressing and operands are being used, the SP register (stack pointer for 16-bit addressing)
is decremented by 2. Pushing 16-bit operands when the stack address-size attribute is 32 can result
in a misaligned the stack pointer (that is, the stack pointer not aligned on a doubleword boundary).
The PUSH ESP instruction pushes the value of the ESP register as it existed before the instruction
was executed. Thus, if a PUSH instruction uses a memory operand in which the ESP register is
used as a base register for computing the operand address, the effective address of the operand is
computed before the ESP register is decremented.
In the real-address mode, if the ESP or SP register is 1 when the PUSH instruction is executed, the
processor shuts down due to a lack of stack space. No exception is generated to indicate this
condition.
Operation
IF StackAddrSize = 32
THEN
IF OperandSize = 32
THEN
ESP ←ESP −4;
SS:ESP ←SRC; (* push doubleword *)
ELSE (* OperandSize = 16*)
ESP ←ESP −2;
SS:ESP ←SRC; (* push word *)
FI;
ELSE (* StackAddrSize = 16*)
IF OperandSize = 16
THEN
SP ←SP −2;
SS:SP ←SRC; (* push word *)
ELSE (* OperandSize = 32*)
SP ←SP −4;
SS:SP ←SRC; (* push doubleword *)
FI;
FI;
Flags Affected
None.
For Intel architecture processors from the Intel 286 on, the PUSH ESP instruction pushes the value
of the ESP register as it existed before the instruction was executed. (This is also true in the
real-address and virtual-8086 modes.) For the Intel 8086 processor, the PUSH SP instruction
pushes the new value of the SP register (that is the value after it has been decremented by 2).
Description
Push the contents of the general-purpose registers onto the procedure stack. The registers are stored
on the stack in the following order: EAX, ECX, EDX, EBX, EBP, ESP (original value), EBP, ESI,
and EDI (if the current operand-size attribute is 32) and AX, CX, DX, BX, SP (original value), BP,
SI, and DI (if the operand-size attribute is 16). (These instructions perform the reverse operation of
the POPA/POPAD instructions.) The value pushed for the ESP or SP register is its value before
prior to pushing the first register (see the “Operation” below).
The PUSHA (push all) and PUSHAD (push all double) mnemonics reference the same opcode. The
PUSHA instruction is intended for use when the operand-size attribute is 16 and the PUSHAD
instruction for when the operand-size attribute is 32. Some assemblers may force the operand size
to 16 when PUSHA is used and to 32 when PUSHAD is used. Others may treat these mnemonics as
synonyms (PUSHA/PUSHAD) and use the current setting of the operand-size attribute to
determine the size of values to be pushed from the stack, regardless of the mnemonic used.
Operation
IF OperandSize = 32 (* PUSHAD instruction *)
THEN
Temp ←(ESP);
Push(EAX);
Push(ECX);
Push(EDX);
Push(EBX);
Push(Temp);
Push(EBP);
Push(ESI);
Push(EDI);
ELSE (* OperandSize = 16, PUSHA instruction *)
Temp ←(SP);
Push(AX);
Push(CX);
Push(DX);
Push(BX);
Push(Temp);
Push(BP);
Push(SI);
Push(DI);
FI;
Flags Affected
None.
Description
Decrement the stack pointer by 4 (if the current operand-size attribute is 32) and push the entire
contents of the EFLAGS register onto the procedure stack or decrement the stack pointer by 2 (if
the operand-size attribute is 16) push the lower 16 bits of the EFLAGS register onto the stack.
(These instructions reverse the operation of the POPF/POPFD instructions.)
When copying the entire EFLAGS register to the stack, bits 16 and 17, called the VM and RF flags,
are not copied. Instead, the values for these flags are cleared in the EFLAGS image stored on the
stack.
The PUSHF (push flags) and PUSHFD (push flags double) mnemonics reference the same opcode.
The PUSHF instruction is intended for use when the operand-size attribute is 16 and the PUSHFD
instruction for when the operand-size attribute is 32. Some assemblers may force the operand size
to 16 when PUSHF is used and to 32 when PUSHFD is used. Others may treat these mnemonics as
synonyms (PUSHF/PUSHFD) and use the current setting of the operand-size attribute to determine
the size of values to be pushed from the stack, regardless of the mnemonic used.
When the I/O privilege level (IOPL) is less than 3 in virtual-8086 mode, the PUSHF/PUSHFD
instructions causes a general protection exception (#GP). The IOPL is altered only when executing
at privilege level 0. The interrupt flag is altered only when executing at a level at least as privileged
as the IOPL. (Real-address mode is equivalent to privilege level 0.) If a PUSHF/PUSHFD
instruction is executed with insufficient privilege, an exception does not occur, but the privileged
bits do not change.
Operation
IF VM=0 (* Not in Virtual-8086 Mode *)
THEN
IF OperandSize = 32
THEN
push(EFLAGS AND 00FCFFFFH);
(* VM and RF EFLAG bits are cleared in image stored on the stack*)
ELSE
push(EFLAGS); (* Lower 16 bits only *)
FI;
ELSE (* In Virtual-8086 Mode *)
IF IOPL=3
THEN
IF OperandSize = 32
THEN push(EFLAGS AND 0FCFFFFH);
(* VM and RF EFLAGS bits are cleared in image stored on the stack*)
ELSE push(EFLAGS); (* Lower 16 bits only *)
FI;
ELSE (*IOPL < 3*)
Flags Affected
None.
None.
Description
Shifts (rotates) the bits of the first operand (destination operand) the number of bit positions
specified in the second operand (count operand) and stores the result in the destination operand.
The destination operand can be a register or a memory location; the count operand is an unsigned
integer that can be an immediate or a value in the CL register. The processor restricts the count to a
number between 0 and 31 by masking all the bits in the count operand except the 5 least-significant
bits.
The rotate left (ROL) and rotate through carry left (RCL) instructions shift all the bits toward
more-significant bit positions, except for the most-significant bit, which is rotated to the
least-significant bit location. The rotate right (ROR) and rotate through carry right (RCR)
instructions shift all the bits toward less significant bit positions, except for the least-significant bit,
which is rotated to the most-significant bit location.
The RCL and RCR instructions include the CF flag in the rotation. The RCL instruction shifts the
CF flag into the least-significant bit and shifts the most-significant bit into the CF flag. The RCR
instruction shifts the CF flag into the most-significant bit and shifts the least-significant bit into the
CF flag. For the ROL and ROR instructions, the original value of the CF flag is not a part of the
result, but the CF flag receives a copy of the bit that was shifted from one end to the other.
The OF flag is defined only for the 1-bit rotates; it is undefined in all other cases. For left rotates,
the OF flag is set to the exclusive OR of the CF bit (after the rotate) and the most-significant bit of
the result. For right rotates, the OF flag is set to the exclusive OR of the two most-significant bits of
the result.
Operation
SIZE ←OperandSize
CASE (determine count) OF
SIZE = 8: tempCOUNT ←(COUNT AND 1FH) MOD 9;
SIZE = 16: tempCOUNT ←(COUNT AND 1FH) MOD 17;
SIZE = 32: tempCOUNT ←COUNT AND 1FH;
ESAC;
(* ROL instruction operation *)
WHILE (tempCOUNT ≠ 0)
DO
tempCF ←MSB(DEST);
DEST ←(DEST ∗ 2) +tempCF;
tempCOUNT ←tempCOUNT - 1;
OD;
ELIHW;
CF ←tempCF;
IF COUNT = 1
THEN OF ←MSB(DEST) XOR CF;
ELSE OF is undefined;
FI;
(* ROR instruction operation *)
WHILE (tempCOUNT ≠ 0)
DO
tempCF ←LSB(SRC);
DEST ←(DEST / 2) + (tempCF ∗ 2SIZE);
tempCOUNT ←tempCOUNT - 1;
OD;
IF COUNT = 1
THEN OF ←MSB(DEST) XOR MSB −1(DEST);
ELSE OF is undefined;
FI;
(* RCL instruction operation *)
WHILE (tempCOUNT ≠ 0)
DO
tempCF ←MSB(DEST);
DEST ←(DEST ∗ 2) +tempCF;
tempCOUNT ←tempCOUNT - 1;
OD;
ELIHW;
CF ←tempCF;
IF COUNT = 1
THEN OF ←MSB(DEST) XOR CF;
ELSE OF is undefined;
FI;
(* RCR instruction operation *)
WHILE (tempCOUNT ≠ 0)
DO
tempCF ←LSB(SRC);
DEST ←(DEST / 2) + (tempCF * 2SIZE);
tempCOUNT ←tempCOUNT - 1;
OD;
IF COUNT = 1
IF COUNT = 1
THEN OF ←MSB(DEST) XOR MSB −1(DEST);
ELSE OF is undefined;
FI;
Flags Affected
The CF flag contains the value of the bit shifted into it. The OF flag is affected only for single-bit
rotates (see “Description” above); it is undefined for multi-bit rotates. The SF, ZF, AF, and PF flags
are not affected.
The 8086 does not mask the rotation count. All Intel architecture processors from the Intel386™
processor on do mask the rotation count in all operating modes.
Description
Loads the contents of a 64-bit model specific register (MSR) specified in the ECX register into
registers EDX:EAX. The EDX register is loaded with the high-order 32 bits of the MSR and the
EAX register is loaded with the low-order 32 bits. If less than 64 bits are implemented in the MSR
being read, the values returned to EDX:EAX in unimplemented bit locations are undefined.
This instruction must be executed at privilege level 0 or in real-address mode; otherwise, a general
protection exception #GP(0) will be generated. Specifying a reserved or unimplemented MSR
address in ECX will also cause a general protection exception.
The MSRs control functions for testability, execution tracing, performance-monitoring and
machine check errors.
The CPUID instruction should be used to determine whether MSRs are supported (EDX[5]=1)
before using this instruction.
See model-specific instructions for all the MSRs that can be written to with this instruction and
their addresses
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,RDMSR);
EDX:EAX ←MSR[ECX];
Flags Affected
None.
The MSRs and the ability to read them with the RDMSR instruction were introduced into the Intel
architecture with the Pentium processor. Execution of this instruction by an Intel architecture
processor earlier than the Pentium processor results in an invalid opcode exception #UD.
Description
Loads the contents of the N-bit performance-monitoring counter specified in the ECX register into
registers EDX:EAX. The EDX register is loaded with the high-order N-32 bits of the counter and
the EAX register is loaded with the low-order 32 bits.
The RDPMC instruction allows application code running at a privilege level of 1, 2, or 3 to read the
performance-monitoring counters if the PCE flag in the CR4 register is set for IA-32 System
Environment operation or in the Itanium System Environment if the performance counters have
been configured as user level counters. This instruction is provided to allow performance
monitoring by application code without incurring the overhead of a call to an operating-system
procedure.
The performance-monitoring counters are event counters that can be programmed to count events
such as the number of instructions decoded, number of interrupts received, or number of cache
loads.
The RDPMC instruction does not serialize instruction execution. That is, it does not imply that all
the events caused by the preceding instructions have been completed or that events caused by
subsequent instructions have not begun. If an exact event count is desired, software must use a
serializing instruction (such as the CPUID instruction) before and/or after the execution of the
RDPCM instruction.
The RDPMC instruction can execute in 16-bit addressing mode or virtual 8086 mode; however, the
full contents of the ECX register are used to determine the counter to access and a full N-bit result
is returned (the low-order 32 bits in the EAX register and the high-order N-32 bits in the EDX
register).
Operation
IF (ECX != Implemented Counters) THEN #GP(0)
IF (Itanium System Environment)
THEN
SECURED = PSR.sp || CR4.pce==0;
IF ((PSR.cpl ==0) || (PSR.cpl!=0 && ~PMC[ECX].pm && ~SECURED)))
THEN
EDX:EAX ←PMD[ECX+4];
ELSE
#GP(0)
FI;
ELSE
IF ((CR4.PCE = 1 OR ((CR4.PCE = 0 ) AND (CPL=0)))
THEN
EDX:EAX ←PMD[ECX+4];
ELSE (* CR4.PCE is 0 and CPL is 1, 2, or 3 *)
#GP(0)
FI;
FI;
Flags Affected
None.
Description
Loads the current value of the processor’s time-stamp counter into the EDX:EAX registers. The
time-stamp counter is contained in a 64-bit MSR. The high-order 32 bits of the MSR are loaded
into the EDX register, and the low-order 32 bits are loaded into the EAX register. The processor
increments the time-stamp counter MSR every clock cycle and resets it to 0 whenever the processor
is reset.
In the IA-32 System Environment, the time stamp disable (TSD) flag in register CR4 restricts the
use of the RDTSC instruction. When the TSD flag is clear, the RDTSC instruction can be executed
at any privilege level; when the flag is set, the instruction can only be executed at privilege level 0.
The time-stamp counter can also be read with the RDMSR instruction.
In the Itanium System Environment, PSR.si and CR4.TSD restricts the use of the RDTSC
instruction. When PSR.si is clear and CR4.TSD is clear, the RDTSC instruction can be executed at
any privilege level; when PSR.si is set or CR4.TSD is set, the instruction can only be executed at
privilege level 0.
The RDTSC instruction is not serializing instruction. Thus, it does not necessarily wait until all
previous instructions have been executed before reading the counter. Similarly, subsequent
instructions may begin execution before the read operation is performed.
This instruction was introduced into the Intel architecture in the Pentium processor.
Operation
IF (IA-32 System Environement)
IF (CR4.TSD = 0) OR ((CR4.TSD = 1) AND (CPL=0))
THEN
EDX:EAX ←TimeStampCounter;
ELSE (* CR4 is 1 and CPL is 1, 2, or 3 *)
#GP(0)
FI;
ELSE /*Itanium System Environment*/
SECURED = PSR.si || CR4.TSD;
IF (!SECURED) OR (SECURED AND (CPL=0))
THEN
EDX:EAX ←TimeStampCounter;
ELSE (* CR4 is 1 and CPL is 1, 2, or 3 *)
#GP(0)
FI;
FI;
Flags Affected
None.
Description
Repeats a string instruction the number of times specified in the count register (ECX) or until the
indicated condition of the ZF flag is no longer met. The REP (repeat), REPE (repeat while equal),
REPNE (repeat while not equal), REPZ (repeat while zero), and REPNZ (repeat while not zero)
mnemonics are prefixes that can be added to one of the string instructions. The REP prefix can be
added to the INS, OUTS, MOVS, LODS, and STOS instructions, and the REPE, REPNE, REPZ,
and REPNZ prefixes can be added to the CMPS and SCAS instructions. (The REPZ and REPNZ
prefixes are synonymous forms of the REPE and REPNE prefixes, respectively.) The behavior of
the REP prefix is undefined when used with non-string instructions.
The REP prefixes apply only to one string instruction at a time. To repeat a block of instructions,
use the LOOP instruction or another looping construct.
When the REPE/REPZ and REPNE/REPNZ prefixes are used, the ZF flag does not require
initialization because both the CMPS and SCAS instructions affect the ZF flag according to the
results of the comparisons they make.
A repeating string operation can be suspended by an exception or interrupt. When this happens, the
state of the registers is preserved to allow the string operation to be resumed upon a return from the
exception or interrupt handler. The source and destination registers point to the next string elements
to be operated on, the EIP register points to the string instruction, and the ECX register has the
value it held following the last successful iteration of the instruction. This mechanism allows long
string operations to proceed without affecting the interrupt response time of the system.
When a page fault occurs during CMPS or SCAS instructions that are prefixed with REPNE, the
EFLAGS value may NOT be restored to the state prior to the execution of the instruction. Since
SCAS and CMPS do not use EFLAGS as an input, the processor can resume the instruction after
the page fault handler.
Use the REP INS and REP OUTS instructions with caution. Not all I/O ports can handle the rate at
which these instructions execute.
A REP STOS instruction is the fastest way to initialize a large block of memory.
Operation
IF AddressSize = 16
THEN
use CX for CountReg;
ELSE (* AddressSize = 32 *)
use ECX for CountReg;
FI;
WHILE CountReg ≠ 0
DO
service pending interrupts (if any);
execute associated string instruction;
CountReg ←CountReg - 1;
IF CountReg = 0
THEN exit WHILE loop
FI;
Flags Affected
None; however, the CMPS and SCAS instructions do set the status flags in the EFLAGS register.
None; however, exceptions can be generated by the instruction a repeat prefix is associated with.
Description
Transfers program control to a return address located on the top of the stack. The address is usually
placed on the stack by a CALL instruction, and the return is made to the instruction that follows the
CALL instruction.
The optional source operand specifies the number of stack bytes to be released after the return
address is popped; the default is none. This operand can be used to release parameters from the
stack that were passed to the called procedure and are no longer needed.
The RET instruction can be used to execute three different types of returns:
• Near return – A return to a calling procedure within the current code segment (the segment
currently pointed to by the CS register), sometimes referred to as an intrasegment return.
• Far return – A return to a calling procedure located in a different segment than the current code
segment, sometimes referred to as an intersegment return.
• Inter-privilege-level far return – A far return to a different privilege level than that of the
currently executing program or procedure.
When executing a near return, the processor pops the return instruction pointer (offset) from the top
of the procedure stack into the EIP register and begins program execution at the new instruction
pointer. The CS register is unchanged.
When executing a far return, the processor pops the return instruction pointer from the top of the
procedure stack into the EIP register, then pops the segment selector from the top of the stack into
the CS register. The processor then begins program execution in the new code segment at the new
instruction pointer.
The mechanics of an inter-privilege-level far return are similar to an intersegment return, except
that the processor examines the privilege levels and access rights of the code and stack segments
being returned to determine if the control transfer is allowed to be made. The DS, ES, FS, and GS
segment registers are cleared by the RET instruction during an inter-privilege-level return if they
refer to segments that are not allowed to be accessed at the new privilege level. Since a stack switch
also occurs on an inter-privilege level return, the ESP and SS registers are loaded from the stack.
Operation
(* Near return *)
IF instruction = near return
THEN;
IF OperandSize = 32
THEN
IF top 12 bytes of stack not within stack limits THEN #SS(0); FI;
EIP ←Pop();
ELSE (* OperandSize = 16 *)
IF top 6 bytes of stack not within stack limits
THEN #SS(0)
FI;
tempEIP ←Pop();
tempEIP ←tempEIP AND 0000FFFFH;
IF tempEIP not within code segment limits THEN #GP(0); FI;
EIP ←tempEIP;
FI;
IF instruction has immediate operand
THEN IF StackAddressSize=32
THEN
ESP ←ESP + SRC;
ELSE (* StackAddressSize=16 *)
SP ←SP + SRC;
FI;
FI;
IF Itanium System Environment AND PSR.tb THEN IA_32_Exception(Debug);
FI;
RETURN-SAME-PRIVILEGE-LEVEL:
IF the return instruction pointer is not within ther return code segment limit
THEN #GP(0);
FI;
IF OperandSize=32
THEN
EIP ←Pop();
CS ←Pop(); (* 32-bit pop, high-order 16-bits discarded *)
ESP ←ESP + SRC;
ELSE (* OperandSize=16 *)
EIP ←Pop();
EIP ←EIP AND 0000FFFFH;
CS ←Pop(); (* 16-bit pop *)
ESP ←ESP + SRC;
FI;
IF Itanium System Environment AND PSR.tb THEN IA_32_Exception(Debug);
RETURN-OUTER-PRIVILEGE-LEVEL:
IF top (16 + SRC) bytes of stack are not within stack limits (OperandSize=32)
OR top (8 + SRC) bytes of stack are not within stack limits (OperandSize=16)
THEN #SS(0); FI;
FI;
Read return segment selector;
IF stack segment selector is null THEN #GP(0); FI;
IF return stack segment selector index is not within its descriptor table limits
THEN #GP(selector); FI;
Read segment descriptor pointed to by return segment selector;
IF stack segment selector RPL ≠ RPL of the return code segment selector
OR stack segment is not a writable data segment
OR stack segment descriptor DPL ≠ RPL of the return code segment selector
THEN #GP(selector); FI;
IF stack segment not present THEN #SS(StackSegmentSelector); FI;
IF the return instruction pointer is not within the return code segment limit THEN #GP(0); FI:
CPL ←ReturnCodeSegmentSelector(RPL);
IF OperandSize=32
THEN
EIP ←Pop();
CS ←Pop(); (* 32-bit pop, high-order 16-bits discarded *)
(* segment descriptor information also loaded *)
CS(RPL) ←CPL;
ESP ←ESP + SRC;
tempESP ←Pop();
tempSS ←Pop(); (* 32-bit pop, high-order 16-bits discarded *)
(* segment descriptor information also loaded *)
ESP ←tempESP;
SS ←tempSS;
ELSE (* OperandSize=16 *)
EIP ←Pop();
EIP ←EIP AND 0000FFFFH;
CS ←Pop(); (* 16-bit pop; segment descriptor information also loaded *)
CS(RPL) ←CPL;
ESP ←ESP + SRC;
tempESP ←Pop();
tempSS ←Pop(); (* 16-bit pop; segment descriptor information also loaded *)
(* segment descriptor information also loaded *)
ESP ←tempESP;
SS ←tempSS;
FI;
FOR each of segment register (ES, FS, GS, and DS)
DO;
IF segment register points to data or non-conforming code segment
AND CPL > segment descriptor DPL; (* DPL in hidden part of segment register *)
THEN (* segment register invalid *)
SegmentSelector/Descriptor ←0; (* null segment selector *)
FI;
OD;
For each of ES, FS, GS, and DS
DO
IF segment descriptor indicates the segment is not a data or
readable code segment
OR if the segment is a data or non-conforming code segment and the segment
descriptor’s DPL < CPL or RPL of code segment’s segment selector
THEN
segment selector register ←null selector;
OD;
Flags Affected
None.
Description
Returns program control from system management mode (SMM) to the application program or
operating system procedure that was interrupted when the processor received an SSM interrupt.
The processor’s state is restored from the dump created upon entering SMM. If the processor
detects invalid state information during state restoration, it enters the shutdown state. The following
invalid information can cause a shutdown:
• Any reserved bit of CR4 is set to 1.
• Any illegal combination of bits in CR0, such as (PG=1 and PE=0) or (NW=1 and CD=0).
• (Intel Pentium and Intel486 only.) The value stored in the state dump base field is not a
32-KByte aligned address.
The contents of the model-specific registers are not affected by a return from SMM.
See Chapter 9 in the IA-32 Intel® Architecture Software Developer’s Manual, Volume 3 for more
information about SMM and the behavior of the RSM instruction.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,RSM);
ReturnFromSSM;
ProcessorState ←Restore(SSMDump);
Flags Affected
All.
Description
Loads the SF, ZF, AF, PF, and CF flags of the EFLAGS register with values from the corresponding
bits in the AH register (bits 7, 6, 4, 2, and 0, respectively). Bits 1, 3, and 5 of register AH are
ignored; the corresponding reserved bits (1, 3, and 5) in the EFLAGS registers are set as shown in
the “Operation” below
Operation
EFLAGS(SF:ZF:0:AF:0:PF:1:CF) ←AH;
Flags Affected
The SF, ZF, AF, PF, and CF flags are loaded with values from the AH register. Bits 1, 3, and 5 of the
EFLAGS register are set to 1, 0, and 0, respectively.
None.
Note:
*Not the same form of division as IDIV; rounding is toward negative infinity.
Description
Shift the bits in the first operand (destination operand) to the left or right by the number of bits
specified in the second operand (count operand). Bits shifted beyond the destination operand
boundary are first shifted into the CF flag, then discarded. At the end of the shift operation, the CF
flag contains the last bit shifted out of the destination operand.
The destination operand can be a register or a memory location. The count operand can be an
immediate value or register CL. The count is masked to 5 bits, which limits the count range to from
0 to 31. A special opcode encoding is provide for a count of 1.
The shift arithmetic left (SAL) and shift logical left (SHL) instructions perform the same operation;
they shift the bits in the destination operand to the left (toward more significant bit locations). For
each shift count, the most significant bit of the destination operand is shifted into the CF flag, and
the least significant bit is cleared.
The shift arithmetic right (SAR) and shift logical right (SHR) instructions shift the bits of the
destination operand to the right (toward less significant bit locations). For each shift count, the least
significant bit of the destination operand is shifted into the CF flag, and the most significant bit is
either set or cleared depending on the instruction type. The SHR instruction clears the most
significant bit; the SAR instruction sets or clears the most significant bit to correspond to the sign
(most significant bit) of the original value in the destination operand. In effect, the SAR instruction
fills the empty bit position’s shifted value with the sign of the unshifted value.
The SAR and SHR instructions can be used to perform signed or unsigned division, respectively, of
the destination operand by powers of 2. For example, using the SAR instruction shift a signed
integer 1 bit to the right divides the value by 2.
Using the SAR instruction to perform a division operation does not produce the same result as the
IDIV instruction. The quotient from the IDIV instruction is rounded toward zero, whereas the
“quotient” of the SAR instruction is rounded toward negative infinity. This difference is apparent
only for negative numbers. For example, when the IDIV instruction is used to divide -9 by 4, the
result is -2 with a remainder of -1. If the SAR instruction is used to shift -9 right by two bits, the
result is -3 and the “remainder” is +3; however, the SAR instruction stores only the most significant
bit of the remainder (in the CF flag).
The OF flag is affected only on 1-bit shifts. For left shifts, the OF flag is cleared to 0 if the
most-significant bit of the result is the same as the CF flag (that is, the top two bits of the original
operand were the same); otherwise, it is set to 1. For the SAR instruction, the OF flag is cleared for
all 1-bit shifts. For the SHR instruction, the OF flag is set to the most-significant bit of the original
operand.
Operation
tempCOUNT ←COUNT;
tempDEST ←DEST;
WHILE (tempCOUNT ≠ 0)
DO
IF instruction is SAL or SHL
THEN
CF ←MSB(DEST);
FI;
IF instruction is SAL or SHL
THEN
DEST ←DEST ∗ 2;
ELSE
IF instruction is SAR
THEN
DEST ←DEST / 2 (*Signed divide, rounding toward negative infinity*);
ELSE (* instruction is SHR *)
DEST ←DEST / 2 ; (* Unsigned divide *);
FI;
FI;
temp ←temp - 1;
OD;
(* Determine overflow for the various instructions *)
IF COUNT = 1
THEN
IF instruction is SAL or SHL
THEN
OF ←MSB(DEST) XOR CF;
ELSE
IF instruction is SAR
THEN
OF ←0;
ELSE (* instruction is SHR *)
OF ←MSB(tempDEST);
FI;
FI;
ELSE
OF ←undefined;
FI;
Flags Affected
The CF flag contains the value of the last bit shifted out of the destination operand; it is undefined
for SHL and SHR instructions count is greater than or equal to the size of the destination operand.
The OF flag is affected only for 1-bit shifts (see “Description” above); otherwise, it is undefined.
The SF, ZF, and PF flags are set according to the result. If the count is 0, the flags are not affected.
The 8086 does not mask the shift count. All Intel architecture processors from the Intel386
processor on do mask the rotation count in all operating modes.
Description
Adds the source operand (second operand) and the carry (CF) flag, and subtracts the result from the
destination operand (first operand). The result of the subtraction is stored 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. The state of the CF flag represents a borrow from a
previous subtraction.
When an immediate value is used as an operand, it is sign-extended to the length of the destination
operand format.
The SBB instruction does not distinguish between signed or unsigned operands. Instead, the
processor evaluates the result for both data types and sets the OF and CF flags to indicate a borrow
in the signed or unsigned result, respectively. The SF flag indicates the sign of the signed result.
The SBB instruction is usually executed as part of a multibyte or multiword subtraction in which a
SUB instruction is followed by a SBB instruction.
Operation
DEST ←DEST - (SRC + CF);
Flags Affected
The OF, SF, ZF, AF, PF, and CF flags are set according to the result.
Description
Compares the byte, word, or double word specified with the source operand with the value in the
AL, AX, or EAX register, respectively, and sets the status flags in the EFLAGS register according
to the results. The source operand specifies the memory location at the address ES:EDI. (When the
operand-size attribute is 16, the DI register is used as the source-index register.) The ES segment
cannot be overridden with a segment override prefix.
The SCASB, SCASW, and SCASD mnemonics are synonyms of the byte, word, and doubleword
versions of the SCAS instructions. They are simpler to use, but provide no type or segment
checking. (For the SCAS instruction, “ES:EDI” must be explicitly specified in the instruction.)
After the comparison, the EDI register is incremented or decremented automatically according to
the setting of the DF flag in the EFLAGS register. (If the DF flag is 0, the EDI register is
incremented; if the DF flag is 1, the EDI register is decremented.) The EDI register is incremented
or decremented by 1 for byte operations, by 2 for word operations, or by 4 for doubleword
operations.
The SCAS, SCASB, SCASW, and SCASD instructions can be preceded by the REP prefix for
block comparisons of ECX bytes, words, or doublewords. More often, however, these instructions
will be used in a LOOP construct that takes some action based on the setting of the status flags
before the next comparison is made. See “REP/REPE/REPZ/REPNE /REPNZ—Repeat String
Operation Prefix” on page 0:707 for a description of the REP prefix.
Operation
IF (byte cmparison)
THEN
temp ←AL −SRC;
SetStatusFlags(temp);
THEN IF DF = 0
THEN (E)DI ←1;
ELSE (E)DI ←-1;
FI;
ELSE IF (word comparison)
THEN
temp ←AX −SRC;
SetStatusFlags(temp)
THEN IF DF = 0
THEN DI ←2;
ELSE DI ←-2;
FI;
ELSE (* doubleword comparison *)
temp ←EAX −SRC;
SetStatusFlags(temp)
THEN IF DF = 0
THEN EDI ←4;
ELSE EDI ←-4;
FI;
FI;
FI;
Flags Affected
The OF, SF, ZF, AF, PF, and CF flags are set according to the temporary result of the comparison.
Description
Set the destination operand to the value 0 or 1, depending on the settings of the status flags (CF, SF,
OF, ZF, and PF) in the EFLAGS register. The destination operand points to a byte register or a byte
in memory. The condition code suffix (cc) indicates the condition being tested for.
The terms “above” and “below” are associated with the CF flag and refer to the relationship
between two unsigned integer values. The terms “greater” and “less” are associated with the SF and
OF flags and refer to the relationship between two signed integer values.
Some languages represent a logical one as an integer with all bits set. This representation can be
arrived at by choosing the mutually exclusive condition for the SETcc instruction, then
decrementing the result. For example, to test for overflow, use the SETNO instruction, then
decrement the result.
Operation
IF condition
THEN DEST ←1
ELSE DEST ←0;
FI;
Flags Affected
None.
Description
Stores the contents of the global descriptor table register (GDTR) or the interrupt descriptor table
register (IDTR) in the destination operand. The destination operand is a pointer to 6-byte memory
location. If the operand-size attribute is 32 bits, the 16-bit limit field of the register is stored in the
lower 2 bytes of the memory location and the 32-bit base address is stored in the upper 4 bytes. If
the operand-size attribute is 16 bits, the limit is stored in the lower 2 bytes and the 24-bit base
address is stored in the third, fourth, and fifth byte, with the sixth byte is filled with 0s.
The SGDT and SIDT instructions are useful only in operating-system software; however, they can
be used in application programs.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,SGDT/SIDT);
IF instruction is IDTR
THEN
IF OperandSize = 16
THEN
DEST[0:15] ←IDTR(Limit);
DEST[16:39] ←IDTR(Base); (* 24 bits of base address loaded; *)
DEST[40:47] ←0;
ELSE (* 32-bit Operand Size *)
DEST[0:15] ←IDTR(Limit);
DEST[16:47] ←IDTR(Base); (* full 32-bit base address loaded *)
FI;
ELSE (* instruction is SGDT *)
IF OperandSize = 16
THEN
DEST[0:15] ←GDTR(Limit);
DEST[16:39] ←GDTR(Base); (* 24 bits of base address loaded; *)
DEST[40:47] ←0;
ELSE (* 32-bit Operand Size *)
DEST[0:15] ←GDTR(Limit);
DEST[16:47] ←GDTR(Base); (* full 32-bit base address loaded *)
FI;
FI;
Flags Affected
None.
The 16-bit forms of the SGDT and SIDT instructions are compatible with the Intel 286 processor, if
the upper 8 bits are not referenced. The Intel 286 processor fills these bits with 1s; the Pentium Pro
processor fills these bits with 0s.
Description
Shifts the first operand (destination operand) to the left the number of bits specified by the third
operand (count operand). The second operand (source operand) provides bits to shift in from the
right (starting with bit 0 of the destination operand). The destination operand can be a register or a
memory location; the source operand is a register. The count operand is an unsigned integer that
can be an immediate byte or the contents of the CL register. Only bits 0 through 4 of the count are
used, which masks the count to a value between 0 and 31. If the count is greater than the operand
size, the result in the destination operand is undefined.
If the count is 1 or greater, the CF flag is filled with the last bit shifted out of the destination
operand. For a 1-bit shift, the OF flag is set if a sign change occurred; otherwise, it is cleared. If the
count operand is 0, the flags are not affected.
Operation
COUNT ←COUNT MOD 32;
SIZE ←OperandSize
IF COUNT = 0
THEN
no operation
ELSE
IF COUNT ≥ SIZE
THEN (* Bad parameters *)
DEST is undefined;
CF, OF, SF, ZF, AF, PF are undefined;
ELSE (* Perform the shift *)
CF ←BIT[DEST, SIZE - COUNT];
(* Last bit shifted out on exit *)
FOR i ←SIZE - 1 DOWNTO COUNT
DO
Bit(DEST, i) ←Bit(DEST, i - COUNT);
OD;
FOR i ←COUNT - 1 DOWNTO 0
DO
BIT[DEST, i] ←BIT[SRC, i - COUNT + SIZE];
OD;
FI;
FI;
Flags Affected
If the count is 1 or greater, the CF flag is filled with the last bit shifted out of the destination
operand and the SF, ZF, and PF flags are set according to the value of the result. For a 1-bit shift,
the OF flag is set if a sign change occurred; otherwise, it is cleared. For shifts greater than 1 bit, the
OF flag is undefined. If a shift occurs, the AF flag is undefined. If the count operand is 0, the flags
are not affected. If the count is greater than the operand size, the flags are undefined.
Description
Shifts the first operand (destination operand) to the right the number of bits specified by the third
operand (count operand). The second operand (source operand) provides bits to shift in from the
left (starting with the most significant bit of the destination operand). The destination operand can
be a register or a memory location; the source operand is a register. The count operand is an
unsigned integer that can be an immediate byte or the contents of the CL register. Only bits 0
through 4 of the count are used, which masks the count to a value between 0 and 31. If the count is
greater than the operand size, the result in the destination operand is undefined.
If the count is 1 or greater, the CF flag is filled with the last bit shifted out of the destination
operand. For a 1-bit shift, the OF flag is set if a sign change occurred; otherwise, it is cleared. If the
count operand is 0, the flags are not affected.
Operation
COUNT ←COUNT MOD 32;
SIZE ←OperandSize
IF COUNT = 0
THEN
no operation
ELSE
IF COUNT ≥ SIZE
THEN (* Bad parameters *)
DEST is undefined;
CF, OF, SF, ZF, AF, PF are undefined;
ELSE (* Perform the shift *)
CF ←BIT[DEST, COUNT - 1]; (* last bit shifted out on exit *)
FOR i ←0 TO SIZE - 1 - COUNT
DO
BIT[DEST, i] ←BIT[DEST, i - COUNT];
OD;
FOR i ←SIZE - COUNT TO SIZE - 1
DO
BIT[DEST,i] ←BIT[inBits,i+COUNT - SIZE];
OD;
FI;
FI;
Flags Affected
If the count is 1 or greater, the CF flag is filled with the last bit shifted out of the destination
operand and the SF, ZF, and PF flags are set according to the value of the result. For a 1-bit shift,
the OF flag is set if a sign change occurred; otherwise, it is cleared. For shifts greater than 1 bit, the
OF flag is undefined. If a shift occurs, the AF flag is undefined. If the count operand is 0, the flags
are not affected. If the count is greater than the operand size, the flags are undefined.
Description
Stores the segment selector from the local descriptor table register (LDTR) in the destination
operand. The destination operand can be a general-purpose register or a memory location. The
segment selector stored with this instruction points to the LDT.
When the destination operand is a 32-bit register, the 16-bit segment selector is copied into the
lower 16 bits of the register and the upper 16 bits of the register are cleared to 0s. With the
destination operand is a memory location, the segment selector is written to memory as a 16-bit
quantity, regardless of the operand size.
The SLDT instruction is only useful in operating-system software; however, it can be used in
application programs. Also, this instruction can only be executed in protected mode.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,SLDT);
DEST ←LDTR(SegmentSelector);
Flags Affected
None.
Description
Stores the machine status word (bits 0 through 15 of control register CR0) into the destination
operand. The destination operand can be a 16-bit general-purpose register or a memory location.
When the destination operand is a 32-bit register, the low-order 16 bits of register CR0 are copied
into the low-order 16 bits of the register and the upper 16 bits of the register are undefined. With the
destination operand is a memory location, the low-order 16 bits of register CR0 are written to
memory as a 16-bit quantity, regardless of the operand size.
The SMSW instruction is only useful in operating-system software; however, it is not a privileged
instruction and can be used in application programs.
This instruction is provided for compatibility with the Intel 286 processor; programs and
procedures intended to run on processors more recent than the Intel 286 should use the MOV
(control registers) instruction to load the machine status word.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,SMSW);
DEST ←CR0[15:0]; (* MachineStatusWord *);
Flags Affected
None.
Description
Operation
CF ←1;
Flags Affected
The CF flag is set. The OF, ZF, SF, AF, and PF flags are unaffected.
None.
Description
Sets the DF flag in the EFLAGS register. When the DF flag is set to 1, string operations decrement
the index registers (ESI and/or EDI).
Operation
DF ←1;
Flags Affected
The DF flag is set. The CF, OF, ZF, SF, AF, and PF flags are unaffected.
Operation
DF ←1;
None.
Description
Sets the interrupt flag (IF) in the EFLAGS register. In the IA-32 System Environment, after the
IF flag is set, the processor begins responding to external maskable interrupts after the next
instruction is executed. If the STI instruction is followed by a CLI instruction (which clears the IF
flag) the effect of the STI instruction is negated. In the Itanium System Environment, the
processor will immediately respond do interrupts after STI, unless execution of STI results in
a trap or intercept. External interrupts are enabled for IA-32 instructions if PSR.i and
(~CFLG.if or EFLAG.if).
The IF flag and the STI and CLI instruction have no affect on the generation of exceptions and
NMI interrupts.
The following decision table indicates the action of the STI instruction (bottom of the table)
depending on the processor’s mode of operating and the CPL and IOPL of the currently running
program or procedure (top of the table).
PE = 0 1 1 1
VM = X 0 0 1
CPL X ≤IOPL > IOPL =3
IOPL X X X =3
IF ←1 Y Y N Y
#GP(0) N N Y N
Notes:
XDon't care.
NAction in Column 1 not taken.
YAction in Column 1 taken.
Operation
OLD_IF <- IF;
IF PE=0 (* Executing in real-address mode *)
THEN
IF ←1; (* Set Interrupt Flag *)
ELSE (* Executing in protected mode or virtual-8086 mode *)
IF VM=0 (* Executing in protected mode*)
THEN
IF CR4.PVI = 0
THEN
IF CPL <= IOPL
THEN IF <- 1
ELSE #GP(0);
FI;
ELSE (*PVI is 1 *)
IF CPL = 3
THENSTI—Set Interrupt Flag (Continued)
IF IOPL < 3
THEN
IF VIP = 0
THEN VIF <- 1;
ELSE #GP(0);
FI;
ELSE (*IOPL = 3 *)
IF <- 1;
FI;
ELSE (*CPL < 3*)
IF IOPL < CPL THEN #GP(0); FI;
IF IOPL>=CPL OR IOPL=3 THEN IF <-1; FI;
FI;
FI;
ELSE (*Executing in Virtual-8086 Mode*)
IF IOPL = 3
THEN IF <- 1;
ELSE
IF CR4.VME = 0
THEN #GP(0);
ELSE
IF VIP = 1 (*virtual interrupt is pending*)
THEN #GP(0);
ELSE VIF <- 1;
FI;
FI;
FI;
FI;
FI;
FI;
Flags Affected
None.
Description
Stores a byte, word, or doubleword from the AL, AX, or EAX register, respectively, into the
destination operand. The destination operand is a memory location at the address ES:EDI. (When
the operand-size attribute is 16, the DI register is used as the source-index register.) The ES
segment cannot be overridden with a segment override prefix.
The STOSB, STOSW, and STOSD mnemonics are synonyms of the byte, word, and doubleword
versions of the STOS instructions. They are simpler to use, but provide no type or segment
checking. (For the STOS instruction, “ES:EDI” must be explicitly specified in the instruction.)
After the byte, word, or doubleword is transfer from the AL, AX, or EAX register to the memory
location, the EDI register is incremented or decremented automatically according to the setting of
the DF flag in the EFLAGS register. (If the DF flag is 0, the EDI register is incremented; if the DF
flag is 1, the EDI register is decremented.) The EDI register is incremented or decremented by 1 for
byte operations, by 2 for word operations, or by 4 for doubleword operations.
The STOS, STOSB, STOSW, and STOSD instructions can be preceded by the REP prefix for block
loads of ECX bytes, words, or doublewords. More often, however, these instructions are used
within a LOOP construct, because data needs to be moved into the AL, AX, or EAX register before
it can be stored. See “REP/REPE/REPZ/REPNE /REPNZ—Repeat String Operation Prefix” on
page 0:707 for a description of the REP prefix.
Operation
IF (byte store)
THEN
DEST ←AL;
THEN IF DF = 0
THEN (E)DI ←1;
ELSE (E)DI ←-1;
FI;
ELSE IF (word store)
THEN
DEST ←AX;
THEN IF DF = 0
THEN DI ←2;
ELSE DI ←-2;
FI;
ELSE (* doubleword store *)
DEST ←EAX;
THEN IF DF = 0
FI;
FI;
FI;
Flags Affected
None.
Description
Stores the segment selector from the task register (TR) in the destination operand. The destination
operand can be a general-purpose register or a memory location. The segment selector stored with
this instruction points to the task state segment (TSS) for the currently running task.
When the destination operand is a 32-bit register, the 16-bit segment selector is copied into the
lower 16 bits of the register and the upper 16 bits of the register are cleared to 0s. With the
destination operand is a memory location, the segment selector is written to memory as a 16-bit
quantity, regardless of operand size.
The STR instruction is useful only in operating-system software. It can only be executed in
protected mode.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,STR);
DEST ←TR(SegmentSelector);
Flags Affected
None.
Description
Subtracts the second operand (source operand) from the first operand (destination operand) 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, register, or memory location. When an
immediate value is used as an operand, it is sign-extended to the length of the destination operand
format.
The SUB instruction does not distinguish between signed or unsigned operands. Instead, the
processor evaluates the result for both data types and sets the OF and CF flags to indicate a borrow
in the signed or unsigned result, respectively. The SF flag indicates the sign of the signed result.
Operation
DEST ←DEST - SRC;
Flags Affected
The OF, SF, ZF, AF, PF, and CF flags are set according to the result.
Description
Computes the bit-wise logical AND of first operand (source 1 operand) and the second operand
(source 2 operand) and sets the SF, ZF, and PF status flags according to the result. The result is then
discarded.
Operation
TEMP ←SRC1 AND SRC2;
SF ←MSB(TEMP);
IF TEMP = 0
THEN ZF ←0;
ELSE ZF ←1;
FI:
PF ←BitwiseXNOR(TEMP[0:7]);
CF ←0;
OF ←0;
(*AF is Undefined*)
Flags Affected
The OF and CF flags are cleared to 0. The SF, ZF, and PF flags are set according to the result (see
“Operation” above). The state of the AF flag is undefined.
Description
Generates an invalid opcode. This instruction is provided for software testing to explicitly generate
an invalid opcode. The opcode for this instruction is reserved for this purpose.
Other than raising the invalid opcode exception, this instruction is the same as the NOP instruction.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,0F0B);
#UD (* Generates invalid opcode exception *);
Flags Affected
None.
Description
Verifies whether the code or data segment specified with the source operand is readable (VERR) or
writable (VERW) from the current privilege level (CPL). The source operand is a 16-bit register or
a memory location that contains the segment selector for the segment to be verified. If the segment
is accessible and readable (VERR) or writable (VERW), the ZF flag is set; otherwise, the ZF flag is
cleared. Code segments are never verified as writable. This check cannot be performed on system
segments.
The validation performed is the same as if the segment were loaded into the DS, ES, FS, or GS
register, and the indicated access (read or write) were performed. The selector's value cannot result
in a protection exception, enabling the software to anticipate possible segment access problems.
Operation
IF SRC(Offset) > (GDTR(Limit) OR (LDTR(Limit))
THEN
ZF ←0
Read segment descriptor;
IF SegmentDescriptor(DescriptorType) = 0 (* system segment *)
OR (SegmentDescriptor(Type) ≠ conforming code segment)
AND (CPL > DPL) OR (RPL > DPL)
THEN
ZF ←0
ELSE
IF ((Instruction = VERR) AND (segment = readable))
OR ((Instruction = VERW) AND (segment = writable))
THEN
ZF ←1;
FI;
FI;
Flags Affected
The ZF flag is set to 1 if the segment is accessible and readable (VERR) or writable (VERW);
otherwise, it is cleared to 0.
The only exceptions generated for these instructions are those related to illegal addressing of the
source operand.
#GP(0) 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.
Description
Causes the processor to check for and handle pending unmasked floating-point exceptions before
proceeding. (FWAIT is an alternate mnemonic for the WAIT).
This instruction is useful for synchronizing exceptions in critical sections of code. Coding a WAIT
instruction after a floating-point instruction insures that any unmasked floating-point exceptions
the instruction may raise are handled before the processor can modify the instruction’s results.
Operation
CheckPendingUnmaskedFloatingPointExceptions;
Floating-point Exceptions
None.
Description
Writes back all modified cache lines in the processor’s internal cache to main memory, invalidates
(flushes) the internal caches, and issues a special-function bus cycle that directs external caches to
also write back modified data.
After executing this instruction, the processor does not wait for the external caches to complete
their write-back and flushing operations before proceeding with instruction execution. It is the
responsibility of hardware to respond to the cache write-back and flush signals.
The WBINVD instruction is a privileged instruction. When the processor is running in protected
mode, the CPL of a program or procedure must be 0 to execute this instruction. This instruction is
also a serializing instruction.
In situations where cache coherency with main memory is not a concern, software can use the
INVD instruction.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,WBINVD);
WriteBack(InternalCaches);
Flush(InternalCaches);
SignalWriteBack(ExternalCaches);
SignalFlush(ExternalCaches);
Continue (* Continue execution);
Flags Affected
None.
None.
Description
Writes the contents of registers EDX:EAX into the 64-bit model specific register (MSR) specified
in the ECX register. The high-order 32 bits are copied from EDX and the low-order 32 bits are
copied from EAX. Always set undefined or reserved bits in an MSR to the values previously read.
This instruction must be executed at privilege level 0 or in real-address mode; otherwise, a general
protection exception #GP(0) will be generated. Specifying a reserved or unimplemented MSR
address in ECX will also cause a general protection exception.
When the WRMSR instruction is used to write to an MTRR, the TLBs are invalidated, including
the global entries see the IA-32 Intel® Architecture Software Developer’s Manual, Volume 3).
The MSRs control functions for testability, execution tracing, performance-monitoring and
machine check errors. See model-specific instructions for all the MSRs that can be written to with
this instruction and their addresses.
The CPUID instruction should be used to determine whether MSRs are supported (EDX[5]=1)
before using this instruction.
Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,WRMSR);
MSR[ECX] ←EDX:EAX;
Flags Affected
None.
The MSRs and the ability to read them with the WRMSR instruction were introduced into the Intel
architecture with the Pentium processor. Execution of this instruction by an Intel architecture
processor earlier than the Pentium processor results in an invalid opcode exception #UD.
Description
Exchanges the first operand (destination operand) with the second operand (source operand), then
loads the sum of the two values into the destination operand. The destination operand can be a
register or a memory location; the source operand is a register.
Operation
IF Itanium System Environment AND External_Bus_Lock_Required AND DCR.lc
THEN IA-32_Intercept(LOCK,XADD);
TEMP ←SRC + DEST
SRC ←DEST
DEST ←TEMP
Flags Affected
The CF, PF, AF, SF, ZF, and OF flags are set according to the result stored in the destination
operand.
Intel architecture processors earlier than the Intel486 processor do not recognize this instruction. If
this instruction is used, you should provide an equivalent code sequence that runs on earlier
processors.
Description
Exchanges the contents of the destination (first) and source (second) operands. The operands can be
two general-purpose registers or a register and a memory location. When the operands are two
registers, one of the registers must be the EAX or AX register. If a memory operand is referenced,
the LOCK# signal is automatically asserted for the duration of the exchange operation, regardless
of the presence or absence of the LOCK prefix or of the value of the IOPL.
This instruction is useful for implementing semaphores or similar data structures for process
synchronization. (See Chapter 5, Processor Management and Initialization, in the IA-32 Intel®
Architecture Software Developer’s Manual, Volume 3 for more information on bus locking.)
The XCHG instruction can also be used instead of the BSWAP instruction for 16-bit operands.
Operation
IF Itanium System Environment AND External_Atomic_Lock_Required AND DCR.lc
THEN IA-32_Intercept(LOCK,XCHG);
TEMP ←DEST
DEST ←SRC
SRC ←TEMP
Flags Affected
None.
Description
Locates a byte entry in a table in memory, using the contents of the AL register as a table index,
then copies the contents of the table entry back into the AL register. The index in the AL register is
treated as unsigned integer. The XLAT and XLATB instructions get the base address of the table in
memory from the DS:EBX registers (or the DS:BX registers when the address-size attribute of
16 bits.) The XLAT instruction allows a different segment register to be specified with a segment
override. When assembled, the XLAT and XLATB instructions produce the same machine code.
Operation
IF AddressSize = 16
THEN
AL ←(DS:BX + ZeroExtend(AL))
ELSE (* AddressSize = 32 *)
AL ←(DS:EBX + ZeroExtend(AL));
FI;
Flags Affected
None.
Description
Performs a bitwise exclusive-OR (XOR) 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.
Operation
DEST ←DEST XOR 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.
Instruction Reference 2
This section lists the IA-32 MMX technology instructions designed to increase performance of
multimedia intensive applications.
Description
Sets the values of all the tags in the FPU tag word to empty (all ones). This operation marks the
MMX technology registers as available, so they can subsequently be used by floating-point
instructions. (See Figure 7-11 in the Intel Architecture Software Developer’s Manual, Volume 1, for
the format of the FPU tag word.) All other MMX technology instructions (other than the EMMS
instruction) set all the tags in FPU tag word to valid (all zeros).
The EMMS instruction must be used to clear the MMX technology state at the end of all MMX
technology routines and before calling other procedures or subroutines that may execute
floating-point instructions. If a floating-point instruction loads one of the registers in the FPU
register stack before the FPU tag word has been reset by the EMMS instruction, a floating-point
stack overflow can occur that will result in a floating-point exception or incorrect result.
Operation
FPUTagWord ←FFFFH;
Flags Affected
None.
Description
Copies doubleword from the source operand (second operand) to the destination operand (first
operand). Source and destination operands can be MMX technology registers, memory locations,
or 32-bit general-purpose registers; however, data cannot be transferred from an MMX technology
register to an MMX technology register, from one memory location to another memory location, or
from one general-purpose register to another general-purpose register.
When the destination operand is an MMX technology register, the 32-bit source value is written to
the low-order 32 bits of the 64-bit MMX technology register and zero-extended to 64 bits (see
Figure 2-1). When the source operand is an MMX technology register, the low-order 32 bits of the
MMX technology register are written to the 32-bit general-purpose register or 32-bit memory
location selected with the destination operand.
MOVD m32, mm
63 32 31 0
xxxxxxxx b 3 b2 b1 b0
mm 15 0
b3 b2 W N+1
b1 b0 WN+1 m32
MOVD mm, r32
63 32 31 0
00000000 b 3 b2 b 1 b0
31 0 mm
b 3 b2 b 1 b0 r32
3006010
Operation
IF DEST is MMX register
THEN
DEST ←ZeroExtend(SRC);
ELSE (* SRC is MMX register *)
DEST ←LowOrderDoubleword(SRC);
Flags Affected
None.
Description
Copies quadword from the source operand (second operand) to the destination operand (first
operand). (See Figure 2-2.) A source or destination operand can be either an MMX technology
register or a memory location; however, data cannot be transferred from one memory location to
another memory location. Data can be transferred from one MMX technology register to another
MMX technology register.
Operation
DEST ←SRC;
Flags Affected
None.
Description
Packs and saturates signed words into bytes (PACKSSWB) or signed doublewords into words
(PACKSSDW). The PACKSSWB instruction packs 4 signed words from the destination operand
(first operand) and 4 signed words from the source operand (second operand) into 8 signed bytes in
the destination operand. If the signed value of a word is beyond the range of a signed byte (that is,
greater than 7FH or less than 80H), the saturated byte value of 7FH or 80H, respectively, is stored
into the destination.
The PACKSSDW instruction packs 2 signed doublewords from the destination operand (first
operand) and 2 signed doublewords from the source operand (second operand) into 4 signed words
in the destination operand (see Figure 2-3). If the signed value of a doubleword is beyond the range
of a signed word (that is, greater than 7FFFH or less than 8000H), the saturated word value of
7FFFH or 8000H, respectively, is stored into the destination.
The destination operand for either the PACKSSWB or PACKSSDW instruction must be an MMX
technology register; the source operand may be either an MMX technology register or a quadword
memory location.
D’ C’ B’ A’
mm
Operation
IF instruction is PACKSSWB
THEN
DEST(7..0) ←SaturateSignedWordToSignedByte DEST(15..0);
DEST(15..8) ←SaturateSignedWordToSignedByte DEST(31..16);
DEST(23..16) ←SaturateSignedWordToSignedByte DEST(47..32);
DEST(31..24) ←SaturateSignedWordToSignedByte DEST(63..48);
DEST(39..32) ←SaturateSignedWordToSignedByte SRC(15..0);
DEST(47..40) ←SaturateSignedWordToSignedByte SRC(31..16);
DEST(55..48) ←SaturateSignedWordToSignedByte SRC(47..32);
DEST(63..56) ←SaturateSignedWordToSignedByte SRC(63..48);
Flags Affected
None.
Description
Packs and saturates 4 signed words from the destination operand (first operand) and 4 signed words
from the source operand (second operand) into 8 unsigned bytes in the destination operand (see
Figure 2-4). If the signed value of a word is beyond the range of an unsigned byte (that is, greater
than FFH or less than 00H), the saturated byte value of FFH or 00H, respectively, is stored into the
destination.
The destination operand must be an MMX technology register; the source operand may be either an
MMX technology register or a quadword memory location.
Operation
DEST(7..0) ←SaturateSignedWordToUnsignedByte DEST(15..0);
DEST(15..8) ←SaturateSignedWordToUnsignedByte DEST(31..16);
DEST(23..16) ←SaturateSignedWordToUnsignedByte DEST(47..32);
DEST(31..24) ←SaturateSignedWordToUnsignedByte DEST(63..48);
DEST(39..32) ←SaturateSignedWordToUnsignedByte SRC(15..0);
DEST(47..40) ←SaturateSignedWordToUnsignedByte SRC(31..16);
DEST(55..48) ←SaturateSignedWordToUnsignedByte SRC(47..32);
DEST(63..56) ←SaturateSignedWordToUnsignedByte SRC(63..48);
Flags Affected
None.
Description
Adds the individual data elements (bytes, words, or doublewords) of the source operand (second
operand) to the individual data elements of the destination operand (first operand). (See
Figure 2-5.) If the result of an individual addition exceeds the range for the specified data type
(overflows), the result is wrapped around, meaning that the result is truncated so that only the lower
(least significant) bits of the result are returned (that is, the carry is ignored).
The destination operand must be an MMX technology register; the source operand can be either an
MMX technology register or a quadword memory location.
+ + + +
mm/m64 1111111111111111 0001011100000111
mm 0111111111111111 1001011000111111
3006015
The PADDB instruction adds the bytes of the source operand to the bytes of the destination operand
and stores the results to the destination operand. When an individual result is too large to be
represented in 8 bits, the lower 8 bits of the result are written to the destination operand and
therefore the result wraps around.
The PADDW instruction adds the words of the source operand to the words of the destination
operand and stores the results to the destination operand. When an individual result is too large to
be represented in 16 bits, the lower 16 bits of the result are written to the destination operand and
therefore the result wraps around.
The PADDD instruction adds the doublewords of the source operand to the doublewords of the
destination operand and stores the results to the destination operand. When an individual result is
too large to be represented in 32 bits, the lower 32 bits of the result are written to the destination
operand and therefore the result wraps around.
Operation
IF instruction is PADDB
THEN
DEST(7..0) ←DEST(7..0) + SRC(7..0);
DEST(15..8) ←DEST(15..8) + SRC(15..8);
DEST(23..16) ←DEST(23..16)+ SRC(23..16);
DEST(31..24) ←DEST(31..24) + SRC(31..24);
DEST(39..32) ←DEST(39..32) + SRC(39..32);
DEST(47..40) ←DEST(47..40)+ SRC(47..40);
DEST(55..48) ←DEST(55..48) + SRC(55..48);
DEST(63..56) ←DEST(63..56) + SRC(63..56);
ELSEIF instruction is PADDW
THEN
DEST(15..0) ←DEST(15..0) + SRC(15..0);
DEST(31..16) ←DEST(31..16) + SRC(31..16);
DEST(47..32) ←DEST(47..32) + SRC(47..32);
DEST(63..48) ←DEST(63..48) + SRC(63..48);
ELSE (* instruction is PADDD *)
DEST(31..0) ←DEST(31..0) + SRC(31..0);
DEST(63..32) ←DEST(63..32) + SRC(63..32);
FI;
Flags Affected
None.
Description
Adds the individual signed data elements (bytes or words) of the source operand (second operand)
to the individual signed data elements of the destination operand (first operand). (See Figure 2-6.)
If the result of an individual addition exceeds the range for the specified data type, the result is
saturated. The destination operand must be an MMX technology register; the source operand can be
either an MMX technology register or a quadword memory location.
+ + + +
mm/m64 1111111111111111 0001011100000111
mm 1000000000000000 0111111111111111
3006016
The PADDSB instruction adds the signed bytes of the source operand to the signed bytes of the
destination operand and stores the results to the destination operand. When an individual result is
beyond the range of a signed byte (that is, greater than 7FH or less than 80H), the saturated byte
value of 7FH or 80H, respectively, is written to the destination operand.
The PADDSW instruction adds the signed words of the source operand to the signed words of the
destination operand and stores the results to the destination operand. When an individual result is
beyond the range of a signed word (that is, greater than 7FFFH or less than 8000H), the saturated
word value of 7FFFH or 8000H, respectively, is written to the destination operand.
Operation
IF instruction is PADDSB
THEN
DEST(7..0) ←SaturateToSignedByte(DEST(7..0) + SRC (7..0)) ;
DEST(15..8) ←SaturateToSignedByte(DEST(15..8) + SRC(15..8) );
DEST(23..16) ←SaturateToSignedByte(DEST(23..16)+ SRC(23..16) );
DEST(31..24) ←SaturateToSignedByte(DEST(31..24) + SRC(31..24) );
DEST(39..32) ←SaturateToSignedByte(DEST(39..32) + SRC(39..32) );
DEST(47..40) ←SaturateToSignedByte(DEST(47..40)+ SRC(47..40) );
DEST(55..48) ←SaturateToSignedByte(DEST(55..48) + SRC(55..48) );
DEST(63..56) ←SaturateToSignedByte(DEST(63..56) + SRC(63..56) );
ELSE { (* instruction is PADDSW *)
Flags Affected
None.
Description
Adds the individual unsigned data elements (bytes or words) of the packed source operand (second
operand) to the individual unsigned data elements of the packed destination operand (first operand).
(See Figure 2-7.) If the result of an individual addition exceeds the range for the specified unsigned
data type, the result is saturated. The destination operand must be an MMX technology register; the
source operand can be either an MMX technology register or a quadword memory location.
+ + + + + + + +
mm/m64 11111111 00010111 00000111
The PADDUSB instruction adds the unsigned bytes of the source operand to the unsigned bytes of
the destination operand and stores the results to the destination operand. When an individual result
is beyond the range of an unsigned byte (that is, greater than FFH), the saturated unsigned byte
value of FFH is written to the destination operand.
The PADDUSW instruction adds the unsigned words of the source operand to the unsigned words
of the destination operand and stores the results to the destination operand. When an individual
result is beyond the range of an unsigned word (that is, greater than FFFFH), the saturated unsigned
word value of FFFFH is written to the destination operand.
Operation
IF instruction is PADDUSB
THEN
DEST(7..0) ←SaturateToUnsignedByte(DEST(7..0) + SRC (7..0) );
DEST(15..8) ←SaturateToUnsignedByte(DEST(15..8) + SRC(15..8) );
DEST(23..16) ←SaturateToUnsignedByte(DEST(23..16)+ SRC(23..16) );
DEST(31..24) ←SaturateToUnsignedByte(DEST(31..24) + SRC(31..24) );
DEST(39..32) ←SaturateToUnsignedByte(DEST(39..32) + SRC(39..32) );
DEST(47..40) ←SaturateToUnsignedByte(DEST(47..40)+ SRC(47..40) );
DEST(55..48) ←SaturateToUnsignedByte(DEST(55..48) + SRC(55..48) );
DEST(63..56) ←SaturateToUnsignedByte(DEST(63..56) + SRC(63..56) );
ELSE { (* instruction is PADDUSW *)
DEST(15..0) ←SaturateToUnsignedWord(DEST(15..0) + SRC(15..0) );
DEST(31..16) ←SaturateToUnsignedWord(DEST(31..16) + SRC(31..16) );
DEST(47..32) ←SaturateToUnsignedWord(DEST(47..32) + SRC(47..32) );
DEST(63..48) ←SaturateToUnsignedWord(DEST(63..48) + SRC(63..48) );
FI;
Flags Affected
None.
Description
Performs a bitwise logical AND operation on the quadword source (second) and destination (first)
operands and stores the result in the destination operand location (see Figure 2-8). The source
operand can be an MMX technology register or a quadword memory location; the destination
operand must be an MMX technology register. Each bit of the result of the PAND instruction is set
to 1 if the corresponding bits of the operands are both 1; otherwise it is made zero
&
mm/m64 0001000011011001010100000011000100011110111011110001010110010101
mm 0001000011011000000000000000000100010100100010000001010100010101
3006019
Operation
DEST ←DEST AND SRC;
Flags Affected
None.
Description
Performs a bitwise logical NOT on the quadword destination operand (first operand). Then, the
instruction performs a bitwise logical AND operation on the inverted destination operand and the
quadword source operand (second operand). (See Figure 2-9.) Each bit of the result of the AND
operation is set to one if the corresponding bits of the source and inverted destination bits are one;
otherwise it is set to zero. The result is stored in the destination operand location.
The source operand can be an MMX technology register or a quadword memory location; the
destination operand must be an MMX technology register.
&
m/m64 11111111111110000000000000000101101101010011101111000100010001000
mm 11111111111110000000000000000101101101010011101111000100010001000
Operation
DEST ←(NOT DEST) AND SRC;
Flags Affected
None.
Description
Compares the individual data elements (bytes, words, or doublewords) in the destination operand
(first operand) to the corresponding data elements in the source operand (second operand). (See
Figure 2-10.) If a pair of data elements are equal, the corresponding data element in the destination
operand is set to all ones; otherwise, it is set to all zeros. The destination operand must be an MMX
technology register; the source operand may be either an MMX technology register or a 64-bit
memory location.
== == == ==
mm/m64 0000000000000000 0000000000000000 0111000111000111 0111000111000111
True False False True
The PCMPEQB instruction compares the bytes in the destination operand to the corresponding
bytes in the source operand, with the bytes in the destination operand being set according to the
results.
The PCMPEQW instruction compares the words in the destination operand to the corresponding
words in the source operand, with the words in the destination operand being set according to the
results.
The PCMPEQD instruction compares the doublewords in the destination operand to the
corresponding doublewords in the source operand, with the doublewords in the destination operand
being set according to the results.
Operation
IF instruction is PCMPEQB
THEN
IF DEST(7..0) = SRC(7..0)
THEN DEST(7 0) ←FFH;
ELSE DEST(7..0) ←0;
* Continue comparison of second through seventh bytes in DEST and SRC *
IF DEST(63..56) = SRC(63..56)
THEN DEST(63..56) ←FFH;
ELSE DEST(63..56) ←0;
ELSE IF instruction is PCMPEQW
THEN
IF DEST(15..0) = SRC(15..0)
THEN DEST(15..0) ←FFFFH;
ELSE DEST(15..0) ←0;
* Continue comparison of second and third words in DEST and SRC *
IF DEST(63..48) = SRC(63..48)
THEN DEST(63..48) ←FFFFH;
ELSE DEST(63..48) ←0;
ELSE (* instruction is PCMPEQD *)
IF DEST(31..0) = SRC(31..0)
THEN DEST(31..0) ←FFFFFFFFH;
ELSE DEST(31..0) ←0;
IF DEST(63..32) = SRC(63..32)
THEN DEST(63..32) ←FFFFFFFFH;
ELSE DEST(63..32) ←0;
FI;
Flags Affected
None:
Description
Compare the individual signed data elements (bytes, words, or doublewords) in the destination
operand (first operand) to the corresponding signed data elements in the source operand (second
operand). (See Figure 2-11.) If a data element in the destination operand is greater than its
corresponding data element in the source operand, the data element in the destination operand is set
to all ones; otherwise, it is set to all zeros. The destination operand must be an MMX technology
register; the source operand may be either an MMX technology register or a 64-bit memory
location.
The PCMPGTB instruction compares the signed bytes in the destination operand to the
corresponding signed bytes in the source operand, with the bytes in the destination operand being
set according to the results.
The PCMPGTW instruction compares the signed words in the destination operand to the
corresponding signed words in the source operand, with the words in the destination operand being
set according to the results.
The PCMPGTD instruction compares the signed doublewords in the destination operand to the
corresponding signed doublewords in the source operand, with the doublewords in the destination
operand being set according to the results.
Operation
IF instruction is PCMPGTB
THEN
IF DEST(7..0) > SRC(7..0)
THEN DEST(7 0) ←FFH;
ELSE DEST(7..0) ←0;
* Continue comparison of second through seventh bytes in DEST and SRC *
IF DEST(63..56) > SRC(63..56)
THEN DEST(63..56) ←FFH;
ELSE DEST(63..56) ←0;
ELSE IF instruction is PCMPGTW
THEN
IF DEST(15..0) > SRC(15..0)
THEN DEST(15..0) ←FFFFH;
ELSE DEST(15..0) ←0;
* Continue comparison of second and third bytes in DEST and SRC *
IF DEST(63..48) > SRC(63..48)
THEN DEST(63..48) ←FFFFH;
ELSE DEST(63..48) ←0;
ELSE { (* instruction is PCMPGTD *)
IF DEST(31..0) > SRC(31..0)
THEN DEST(31..0) ←FFFFFFFFH;
ELSE DEST(31..0) ←0;
IF DEST(63..32) > SRC(63..32)
THEN DEST(63..32) ←FFFFFFFFH;
ELSE DEST(63..32) ←0;
FI;
Flags Affected
None.
Description
Multiplies the individual signed words of the destination operand by the corresponding signed
words of the source operand, producing four signed, doubleword results (see Figure 2-12). The two
doubleword results from the multiplication of the high-order words are added together and stored in
the upper doubleword of the destination operand; the two doubleword results from the
multiplication of the low-order words are added together and stored in the lower doubleword of the
destination operand. The destination operand must be an MMX technology register; the source
operand may be either an MMX technology register or a 64-bit memory location.
The PMADDWD instruction wraps around to 80000000H only when all four words of both the
source and destination operands are 8000H.
mm 0111000111000111 0111000111000111
* * * *
mm/m64 1000000000000000 0000010000000000
+ +
mm 1100100011100011 1001110000000000
Operation
DEST(31..0) ←(DEST(15..0) ∗ SRC(15..0)) + (DEST(31..16) ∗ SRC(31..16));
DEST(63..32) ←(DEST(47..32) ∗ SRC(47..32)) + (DEST(63..48) ∗ SRC(63..48));
Flags Affected
None.
Description
Multiplies the four signed words of the source operand (second operand) by the four signed words
of the destination operand (first operand), producing four signed, doubleword, intermediate results
(see Figure 2-13). The high-order word of each intermediate result is then written to its
corresponding word location in the destination operand. The destination operand must be an MMX
technology register; the source operand may be either an MMX technology register or a 64-bit
memory location.
* * * *
mm/m64 1000000000000000 0000010000000000
High Order High Order High Order High Order
mm 1100011100011100 0000000111000111
3006022
Operation
DEST(15..0) ←HighOrderWord(DEST(15..0) ∗ SRC(15..0));
DEST(31..16) ←HighOrderWord(DEST(31..16) ∗ SRC(31..16));
DEST(47..32) ←HighOrderWord(DEST(47..32) ∗ SRC(47..32));
DEST(63..48) ←HighOrderWord(DEST(63..48) ∗ SRC(63..48));
Flags Affected
None.
Description
Multiplies the four signed or unsigned words of the source operand (second operand) with the four
signed or unsigned words of the destination operand (first operand), producing four doubleword,
intermediate results (see Figure 2-14). The low-order word of each intermediate result is then
written to its corresponding word location in the destination operand. The destination operand must
be an MMX technology register; the source operand may be either an MMX technology register or
a 64-bit memory location.
* * * *
mm/m64 1000000000000000 0000010000000000
Low Order Low Order Low Order Low Order
mm 1000000000000000 0001110000000000
3006025
Operation
DEST(15..0) ←LowOrderWord(DEST(15..0) ∗ SRC(15..0));
DEST(31..16) ←LowOrderWord(DEST(31..16) ∗ SRC(31..16));
DEST(47..32) ←LowOrderWord(DEST(47..32) ∗ SRC(47..32));
DEST(63..48) ←LowOrderWord(DEST(63..48) ∗ SRC(63..48));
Flags Affected
None.
Description
Performs a bitwise logical OR operation on the quadword source (second) and destination (first)
operands and stores the result in the destination operand location (see Figure 2-15). The source
operand can be an MMX technology register or a quadword memory location; the destination
operand must be an MMX technology register. Each bit of the result is made 0 if the corresponding
bits of both operands are 0; otherwise the bit is set to 1.
mm/m64 0001000011011001010100000011000100011110111011110001010110010101
mm 1111111111111001010100000011010110111111111011110111011111110111
3006024
Operation
DEST ←DEST OR SRC;
Flags Affected
None.
Description
Shifts the bits in the data elements (words, doublewords, or quadword) in the destination operand
(first operand) to the left by the number of bits specified in the unsigned count operand (second
operand). (See Figure 2-16.) The result of the shift operation is written to the destination operand.
As the bits in the data elements are shifted left, the empty low-order bits are cleared (set to zero). If
the value specified by the count operand is greater than 15 (for words), 31 (for doublewords), or
63 (for a quadword), then the destination operand is set to all zeros.
The destination operand must be an MMX technology register; the count operand can be either an
MMX technology register, a 64-bit memory location, or an 8-bit immediate.
The PSLLW instruction shifts each of the four words of the destination operand to the left by the
number of bits specified in the count operand; the PSLLD instruction shifts each of the two
doublewords of the destination operand; and the PSLLQ instruction shifts the 64-bit quadword in
the destination operand. As the individual data elements are shifted left, the empty low-order bit
positions are filled with zeros.
PSLLW mm, 2
mm 1111111111111100 0001000111000111
mm 1111111111110000 0100011100011100
3006026
Operation
IF instruction is PSLLW
THEN
DEST(15..0) ←DEST(15..0) << COUNT;
DEST(31..16) ←DEST(31..16) << COUNT;
DEST(47..32) ←DEST(47..32) << COUNT;
DEST(63..48) ←DEST(63..48) << COUNT;
ELSE IF instruction is PSLLD
THEN {
DEST(31..0) ←DEST(31..0) << COUNT;
DEST(63..32) ←DEST(63..32) << COUNT;
ELSE (* instruction is PSLLQ *)
DEST ←DEST << COUNT;
FI;
Flags Affected
None.
Description
Shifts the bits in the data elements (words or doublewords) in the destination operand (first
operand) to the right by the amount of bits specified in the unsigned count operand (second
operand). (See Figure 2-17.) The result of the shift operation is written to the destination operand.
The empty high-order bits of each element are filled with the initial value of the sign bit of the data
element. If the value specified by the count operand is greater than 15 (for words) or 31 (for
doublewords), each destination data element is filled with the initial value of the sign bit of the
element.
The destination operand must be an MMX technology register; the count operand (source operand)
can be either an MMX technology register, a 64-bit memory location, or an 8-bit immediate.
The PSRAW instruction shifts each of the four words in the destination operand to the right by the
number of bits specified in the count operand; the PSRAD instruction shifts each of the two
doublewords in the destination operand. As the individual data elements are shifted right, the empty
high-order bit positions are filled with the sign value.
PSRAW mm, 2
mm 1111111111111100 1101000111000111
mm 1111111111111111 1111010001110001
3006048
Operation
IF instruction is PSRAW
THEN
DEST(15..0) ←SignExtend (DEST(15..0) >> COUNT);
DEST(31..16) ←SignExtend (DEST(31..16) >> COUNT);
DEST(47..32) ←SignExtend (DEST(47..32) >> COUNT);
DEST(63..48) ←SignExtend (DEST(63..48) >> COUNT);
ELSE { (*instruction is PSRAD *)
DEST(31..0) ←SignExtend (DEST(31..0) >> COUNT);
DEST(63..32) ←SignExtend (DEST(63..32) >> COUNT);
FI;
Flags Affected
None.
Description
Shifts the bits in the data elements (words, doublewords, or quadword) in the destination operand
(first operand) to the right by the number of bits specified in the unsigned count operand (second
operand). (See Figure 2-18.) The result of the shift operation is written to the destination operand.
As the bits in the data elements are shifted right, the empty high-order bits are cleared (set to zero).
If the value specified by the count operand is greater than 15 (for words), 31 (for doublewords), or
63 (for a quadword), then the destination operand is set to all zeros.
The destination operand must be an MMX technology register; the count operand can be either an
MMX technology register, a 64-bit memory location, or an 8-bit immediate.
The PSRLW instruction shifts each of the four words of the destination operand to the right by the
number of bits specified in the count operand; the PSRLD instruction shifts each of the two
doublewords of the destination operand; and the PSRLQ instruction shifts the 64-bit quadword in
the destination operand. As the individual data elements are shifted right, the empty high-order bit
positions are filled with zeros.
PSRLW mm, 2
mm 1111111111111100 0001000111000111
mm 0011111111111111 0000010001110001
3006027
Operation
IF instruction is PSRLW
THEN {
DEST(15..0) ←DEST(15..0) >> COUNT;
DEST(31..16) ←DEST(31..16) >> COUNT;
DEST(47..32) ←DEST(47..32) >> COUNT;
DEST(63..48) ←DEST(63..48) >> COUNT;
ELSE IF instruction is PSRLD
THEN {
DEST(31..0) ←DEST(31..0) >> COUNT;
DEST(63..32) ←DEST(63..32) >> COUNT;
ELSE (* instruction is PSRLQ *)
DEST ←DEST >> COUNT;
FI;
Flags Affected
None.
Description
Subtracts the individual data elements (bytes, words, or doublewords) of the source operand
(second operand) from the individual data elements of the destination operand (first operand). (See
Figure 2-19.) If the result of a subtraction exceeds the range for the specified data type (overflows),
the result is wrapped around, meaning that the result is truncated so that only the lower (least
significant) bits of the result are returned (that is, the carry is ignored).
The destination operand must be an MMX technology register; the source operand can be either an
MMX technology register or a quadword memory location.
– – – –
mm/m64 0000000000000001 1110100011111001
mm 0111111111111111 1001011000111111
3006028
The PSUBB instruction subtracts the bytes of the source operand from the bytes of the destination
operand and stores the results to the destination operand. When an individual result is too large to
be represented in 8 bits, the lower 8 bits of the result are written to the destination operand and
therefore the result wraps around.
The PSUBW instruction subtracts the words of the source operand from the words of the
destination operand and stores the results to the destination operand. When an individual result is
too large to be represented in 16 bits, the lower 16 bits of the result are written to the destination
operand and therefore the result wraps around.
The PSUBD instruction subtracts the doublewords of the source operand from the doublewords of
the destination operand and stores the results to the destination operand. When an individual result
is too large to be represented in 32 bits, the lower 32 bits of the result are written to the destination
operand and therefore the result wraps around.
Operation
IF instruction is PSUBB
THEN
DEST(7..0) ←DEST(7..0) - SRC(7..0);
DEST(15..8) ←DEST(15..8) - SRC(15..8);
DEST(23..16) ←DEST(23..16) - SRC(23..16);
DEST(31..24) ←DEST(31..24) - SRC(31..24);
DEST(39..32) ←DEST(39..32) - SRC(39..32);
DEST(47..40) ←DEST(47..40) - SRC(47..40);
DEST(55..48) ←DEST(55..48) - SRC(55..48);
DEST(63..56) ←DEST(63..56) - SRC(63..56);
ELSEIF instruction is PSUBW
THEN
DEST(15..0) ←DEST(15..0) - SRC(15..0);
DEST(31..16) ←DEST(31..16) - SRC(31..16);
DEST(47..32) ←DEST(47..32) - SRC(47..32);
DEST(63..48) ←DEST(63..48) - SRC(63..48);
ELSE { (* instruction is PSUBD *)
DEST(31..0) ←DEST(31..0) - SRC(31..0);
DEST(63..32) ←DEST(63..32) - SRC(63..32);
FI;
Flags Affected
None.
Description
Subtracts the individual signed data elements (bytes or words) of the source operand (second
operand) from the individual signed data elements of the destination operand (first operand). (See
Figure 2-20.) If the result of a subtraction exceeds the range for the specified data type, the result is
saturated. The destination operand must be an MMX technology register; the source operand can be
either an MMX technology register or a quadword memory location.
– – – –
mm/m64 0000000000000001 1110100011111001
mm 1000000000000000 0111111111111111
3006029
The PSUBSB instruction subtracts the signed bytes of the source operand from the signed bytes of
the destination operand and stores the results to the destination operand. When an individual result
is beyond the range of a signed byte (that is, greater than 7FH or less than 80H), the saturated byte
value of 7FH or 80H, respectively, is written to the destination operand.
The PSUBSW instruction subtracts the signed words of the source operand from the signed words
of the destination operand and stores the results to the destination operand. When an individual
result is beyond the range of a signed word (that is, greater than 7FFFH or less than 8000H), the
saturated word value of 7FFFH or 8000H, respectively, is written to the destination operand.
Operation
IF instruction is PSUBSB
THEN
DEST(7..0) ←SaturateToSignedByte(DEST(7..0) - SRC (7..0));
DEST(15..8) ←SaturateToSignedByte(DEST(15..8) - SRC(15..8));
DEST(23..16) ←SaturateToSignedByte(DEST(23..16) - SRC(23..16));
DEST(31..24) ←SaturateToSignedByte(DEST(31..24) - SRC(31..24));
DEST(39..32) ←SaturateToSignedByte(DEST(39..32) - SRC(39..32));
DEST(47..40) ←SaturateToSignedByte(DEST(47..40) - SRC(47..40));
DEST(55..48) ←SaturateToSignedByte(DEST(55..48) - SRC(55..48));
DEST(63..56) ←SaturateToSignedByte(DEST(63..56) - SRC(63..56))
ELSE (* instruction is PSUBSW *)
DEST(15..0) ←SaturateToSignedWord(DEST(15..0) - SRC(15..0));
DEST(31..16) ←SaturateToSignedWord(DEST(31..16) - SRC(31..16));
DEST(47..32) ←SaturateToSignedWord(DEST(47..32) - SRC(47..32));
DEST(63..48) ←SaturateToSignedWord(DEST(63..48) - SRC(63..48));
FI;
Flags Affected
None.
Description
Subtracts the individual unsigned data elements (bytes or words) of the source operand (second
operand) from the individual unsigned data elements of the destination operand (first operand).
(See Figure 2-21.) If the result of an individual subtraction exceeds the range for the specified
unsigned data type, the result is saturated. The destination operand musts be an MMX technology
register; the source operand can be either an MMX technology register or a quadword memory
location.
– – – – – – – –
mm/m64 11111111 00010111 00000111
The PSUBUSB instruction subtracts the unsigned bytes of the source operand from the unsigned
bytes of the destination operand and stores the results to the destination operand. When an
individual result is less than zero (a negative value), the saturated unsigned byte value of 00H is
written to the destination operand.
The PSUBUSW instruction subtracts the unsigned words of the source operand from the unsigned
words of the destination operand and stores the results to the destination operand. When an
individual result is less than zero (a negative value), the saturated unsigned word value of 0000H is
written to the destination operand.
Operation
IF instruction is PSUBUSB
THEN
DEST(7..0) ←SaturateToUnsignedByte (DEST(7..0 - SRC (7..0) );
DEST(15..8) ←SaturateToUnsignedByte ( DEST(15..8) - SRC(15..8) );
DEST(23..16) ←SaturateToUnsignedByte (DEST(23..16) - SRC(23..16) );
DEST(31..24) ←SaturateToUnsignedByte (DEST(31..24) - SRC(31..24) );
DEST(39..32) ←SaturateToUnsignedByte (DEST(39..32) - SRC(39..32) );
DEST(47..40) ←SaturateToUnsignedByte (DEST(47..40) - SRC(47..40) );
DEST(55..48) ←SaturateToUnsignedByte (DEST(55..48) - SRC(55..48) );
DEST(63..56) ←SaturateToUnsignedByte (DEST(63..56) - SRC(63..56) );
ELSE { (* instruction is PSUBUSW *)
DEST(15..0) ←SaturateToUnsignedWord (DEST(15..0) - SRC(15..0) );
DEST(31..16) ←SaturateToUnsignedWord (DEST(31..16) - SRC(31..16) );
DEST(47..32) ←SaturateToUnsignedWord (DEST(47..32) - SRC(47..32) );
DEST(63..48) ←SaturateToUnsignedWord (DEST(63..48) - SRC(63..48) );
FI;
Flags Affected
None.
Description
Unpacks and interleaves the high-order data elements (bytes, words, or doublewords) of the
destination operand (first operand) and source operand (second operand) into the destination
operand (see Figure 2-22). The low-order data elements are ignored. The destination operand must
be an MMX technology register; the source operand may be either an MMX technology register or
a 64-bit memory location. When the source data comes from a memory operand, the full 64-bit
operand is accessed from memory, but the instruction uses only the high-order 32 bits.
Figure 2-22. High-order Unpacking and Interleaving of Bytes with the PUNPCKHBW
Instruction
27 17 26 16 25 15 24 14
mm
3006031
The PUNPCKHBW instruction interleaves the four high-order bytes of the source operand and the
four high-order bytes of the destination operand and writes them to the destination operand.
The PUNPCKHWD instruction interleaves the two high-order words of the source operand and the
two high-order words of the destination operand and writes them to the destination operand.
The PUNPCKHDQ instruction interleaves the high-order doubleword of the source operand and
the high-order doubleword of the destination operand and writes them to the destination operand.
If the source operand is all zeros, the result (stored in the destination operand) contains zero
extensions of the high-order data elements from the original value in the destination operand. With
the PUNPCKHBW instruction the high-order bytes are zero extended (that is, unpacked into
unsigned words), and with the PUNPCKHWD instruction, the high-order words are zero extended
(unpacked into unsigned doublewords).
Operation
IF instruction is PUNPCKHBW
THEN
DEST(7..0) ←DEST(39..32);
DEST(15..8) ←SRC(39..32);
DEST(23..16) ←DEST(47..40);
DEST(31..24) ←SRC(47..40);
DEST(39..32) ←DEST(55..48);
DEST(47..40) ←SRC(55..48);
DEST(55..48) ←DEST(63..56);
DEST(63..56) ←SRC(63..56);
ELSE IF instruction is PUNPCKHW
THEN
DEST(15..0) ←DEST(47..32);
DEST(31..16) ←SRC(47..32);
DEST(47..32) ←DEST(63..48);
DEST(63..48) ←SRC(63..48);
ELSE (* instruction is PUNPCKHDQ *)
DEST(31..0) ←DEST(63..32)
DEST(63..32) ←SRC(63..32);
FI;
Flags Affected
None.
Description
Unpacks and interleaves the low-order data elements (bytes, words, or doublewords) of the
destination and source operands into the destination operand (see Figure 2-23). The destination
operand must be an MMX technology register; the source operand may be either an MMX
technology register or a memory location. When source data comes from an MMX technology
register, the upper 32 bits of the register are ignored. When the source data comes from a memory,
only 32-bits are accessed from memory.
Figure 2-23. Low-order Unpacking and Interleaving of Bytes with the PUNPCKLBW
Instruction
2 3 1 3 22 12 21 11 20 10
mm
3006032
The PUNPCKLBW instruction interleaves the four low-order bytes of the source operand and the
four low-order bytes of the destination operand and writes them to the destination operand.
The PUNPCKLWD instruction interleaves the two low-order words of the source operand and the
two low-order words of the destination operand and writes them to the destination operand.
The PUNPCKLDQ instruction interleaves the low-order doubleword of the source operand and the
low-order doubleword of the destination operand and writes them to the destination operand.
If the source operand is all zeros, the result (stored in the destination operand) contains zero
extensions of the high-order data elements from the original value in the destination operand. With
the PUNPCKLBW instruction the low-order bytes are zero extended (that is, unpacked into
unsigned words), and with the PUNPCKLWD instruction, the low-order words are zero extended
(unpacked into unsigned doublewords).
Operation
IF instruction is PUNPCKLBW
THEN
DEST(63..56) ←SRC(31..24);
DEST(55..48) ←DEST(31..24);
DEST(47..40) ←SRC(23..16);
DEST(39..32) ←DEST(23..16);
DEST(31..24) ←SRC(15..8);
DEST(23..16) ←DEST(15..8);
DEST(15..8) ←SRC(7..0);
DEST(7..0) ←DEST(7..0);
ELSE IF instruction is PUNPCKLWD
THEN
DEST(63..48) ←SRC(31..16);
DEST(47..32) ←DEST(31..16);
DEST(31..16) ←SRC(15..0);
DEST(15..0) ←DEST(15..0);
ELSE (* instruction is PUNPCKLDQ *)
DEST(63..32) ←SRC(31..0);
DEST(31..0) ←DEST(31..0);
FI;
Flags Affected
None.
Description
Performs a bitwise logical exclusive-OR (XOR) operation on the quadword source (second) and
destination (first) operands and stores the result in the destination operand location (see
Figure 2-24). The source operand can be an MMX technology register or a quadword memory
location; the destination operand must be an MMX technology register. Each bit of the result is 1 if
the corresponding bits of the two operands are different; each bit is 0 if the corresponding bits of
the operands are the same.
^
mm/m64 0001000011011001010100000011000100011110111011110001010110010101
mm 1110111100100001010100000011010010101011011001110110001011100010
3006033
Operation
DEST ←DEST XOR SRC;
Flags Affected
None.
The Intel SSE architecture introduces new general purpose floating-point instructions, which
operate on a new set of eight 128-bit SSE registers. This gives the programmer the ability to
develop algorithms that can finely mix packed single-precision floating-point and integer using
both SSE and MMX technology instructions respectively. In addition to these instructions, the Intel
SSE architecture also provides new instructions to control cacheability of all MMX technology
data types. These include ability to stream data into and from the processor while minimizing
pollution of the caches and the ability to prefetch data before it is actually used. The main focus of
packed floating-point instructions is the acceleration of 3D geometry. The new definition also
contains additional SIMD Integer instructions to accelerate 3D rendering and video encoding and
decoding. Together with the cacheability control instruction, this combination enables the
development of new algorithms that can significantly accelerate 3D graphics.
The new SSE state requires OS support for saving and restoring the new state during a context
switch. A new set of extended FSAVE/FRSTOR instructions will permit saving/restoring new and
existing state for applications and OS. To make use of these new instructions, an application must
verify that the processor supports the Intel SSE architecture and the operating system supports this
new extension. If both the extension and support is enabled, then the software application can use
the new features.
The SSE instruction set is fully compatible with all software written for Intel architecture
microprocessors. All existing software continues to run correctly, without modification, on
microprocessors that incorporate the Intel SSE architecture, as well as in the presence of existing
and new applications that incorporate this technology.
The Intel SSE architecture is 100% compatible with the IEEE Standard 754 for Binary
Floating-point Arithmetic. The SSE instructions are accessible from all IA execution modes:
Protected mode, Real address mode, and Virtual 8086 mode.New Features
The Intel SSE architecture provides the following new features, while maintaining backward
compatibility with all existing Intel architecture microprocessors, IA applications and operating
systems.
• New data type
• Eight SSE registers
• Enhanced instruction set
The Intel SSE architecture can enhance the performance of applications that use these features.
The SIMD Integer instructions will operate on the packed byte, word or doubleword data types.
The prefetch instruction works on typeless data of size 32 bytes or greater.
127 96 95 65 63 32 31 0
Packed Single-FP
The SSE registers can hold packed 128-bit data. The SSE instructions access the SSE registers
directly using the registers names XMM0 to XMM7 (Figure 3-2).
SSE registers can be used to perform calculation on data. They cannot be used to address memory;
addressing is accomplished by using the integer registers and existing IA addressing modes.
There is a new control/status register MXCSR which is used to mask/unmask numerical exception
handling, to set rounding modes, to set flush-to-zero mode, and to view status flags.
XMM7
XMM6
XMM5
XMM4
XMM3
XMM2
XMM1
XMM0
OP OP OP OP
OP
The ADDSS (Add scalar single-precision floating-point) and SUBSS (Subtract scalar
single-precision floating-point) instructions add or subtract the least significant pair of packed
single-precision floating-point operands; the upper three fields are passed through from the source
operand.
The DIVPS (Divide packed single-precision floating-point) instruction divides four pairs of packed
single-precision floating-point operands.
The DIVSS (Divide scalar single-precision floating-point) instruction divides the least significant
pair of packed single-precision floating-point operands; the upper three fields are passed through
from the source operand.
The SQRTSS (Square root scalar single-precision floating-point) instruction returns the square root
of the least significant component of the packed single-precision floating-point numbers from
source to a destination register; the upper three fields are passed through from the source operand.
Packed Maximum/Minimum
The MAXPS (Maximum packed single-precision floating-point) instruction returns the maximum
of each pair of packed single-precision floating-point numbers into the destination register.
The MAXSS (Maximum scalar single-precision floating-point) instructions returns the maximum
of the least significant pair of packed single-precision floating-point numbers into the destination
register; the upper three fields are passed through from the source operand, to the destination
register.
The MINPS (Minimum packed single-precision floating-point) instruction returns the minimum of
each pair of packed single-precision floating-point numbers into the destination register.
The MINSS (Minimum scalar single-precision floating-point) instruction returns the minimum of
the least significant pair of packed single-precision floating-point numbers into the destination
register; the upper three fields are passed through from the source operand, to the destination
register
The ANDPS (Bit-wise packed logical AND for single-precision floating-point) instruction returns
a bitwise AND between the two operands.
The ANDNPS (Bit-wise packed logical AND NOT for single-precision floating-point) instruction
returns a bitwise AND NOT between the two operands.
The ORPS (Bit-wise packed logical OR for single-precision floating-point) instruction returns a
bitwise OR between the two operands.
The XORPS (Bit-wise packed logical XOR for single-precision floating-point) instruction returns a
bitwise XOR between the two operands.
The CMPPS (Compare packed single-precision floating-point) instruction compares four pairs of
packed single-precision floating-point numbers using the immediate operand as a predicate,
returning per SP field an all “1” 32-bit mask or an all “0” 32-bit mask as a result. The instruction
supports a full set of 12 conditions: equal, less than, less than equal, greater than, greater than or
equal, unordered, not equal, not less than, not less than or equal, not greater than, not greater than or
equal, ordered.
The CMPSS (Compare scalar single-precision floating-point) instruction compares the least
significant pairs of packed single-precision floating-point numbers using the immediate operand as
a predicate (same as CMPPS), returning per SP field an all “1” 32-bit mask or an all “0” 32-bit
mask as a result.
The COMISS (Compare scalar single-precision floating-point ordered and set EFLAGS)
instruction compares the least significant pairs of packed single-precision floating-point numbers
and sets the ZF,PF,CF bits in the EFLAGS register (the OF, SF and AF bits are cleared).
The UCOMISS (Unordered compare scalar single-precision floating-point ordered and set
EFLAGS) instruction compares the least significant pairs of packed single-precision floating-point
numbers and sets the ZF,PF,CF bits in the EFLAGS register as described above (the OF, SF and AF
bits are cleared).
The SHUFPS (Shuffle packed single-precision floating-point) instruction is able to shuffle any of
the packed four single-precision floating-point numbers from one source operand to the lower two
destination fields; the upper two destination fields are generated from a shuffle of any of the four
SP FP numbers from the second source operand (Figure 3-5). By using the same register for both
sources, SHUFPS can return any combination of the four SP FP numbers from this register.
X4 X3 X2 X1
Y4 Y3 Y2 Y1
X4 X3 X2 X1
Y4 Y3 Y2 Y1
Y4 X4 Y3 X3
X4 X3 X2 X1
Y4 Y3 Y2 Y1
Y2 X2 Y1 X1
These instructions support packed and scalar conversions between 128-bit SSE registers and either
64-bit integer MMX technology registers or 32-bit integer IA-32 registers. The packed versions
behave identically to original MMX technology instructions, in the presence of x87-FP
instructions, including:
• Transition from x87-FP to MMX technology (TOS=0, FP valid bits set to all valid).
• MMX technology instructions write ones (1’s) to the exponent part of the corresponding
x87-FP register.
• Use of EMMS for transition from MMX technology to x87-FP.
The CVTSI2SS (Convert scalar 32-bit integer to scalar single-precision floating-point) instruction
converts a 32-bit signed integer in a MMX technology register to the least significant
single-precision floating-point number; when the conversion is inexact, the rounded value
according to the rounding mode in MXCSR is returned. The upper three significant numbers in the
destination register are retained.
The MOVAPS (Move aligned packed single-precision floating-point) instruction transfers 128-bits
of packed data from memory to SSE registers and vice versa, or between SSE registers. The
memory address is aligned to 16-byte boundary; if not then a general protection exception will
occur.
The MOVHPS (Move aligned high packed single-precision floating-point) instruction transfers
64-bits of packed data from memory to the upper two fields of a SSE register and vice versa. The
lower field is left unchanged.
The MOVLPS (Move aligned low packed single-precision floating-point) instruction transfers
64-bits of packed data from memory to the lower two fields of a SSE register and vice versa. The
upper field is left unchanged.
The MOVMSKPS (Move mask packed single-precision floating-point) instruction transfers the
most significant bit of each of the four packed single-precision floating-point number to an IA
integer register. This 4-bit value can then be used as a condition to perform branching.
The MOVSS (Move scalar single-precision floating-point) instruction transfers a single 32-bit
floating-point number from memory to a SSE register or vice versa, and between registers.
The LDMXCSR (Load SSE Control and Status Register) instruction loads the SSE control and
status register from memory. STMXCSR (Store SSE Control and Status Register) instruction stores
the SSE control and status word to memory.
The FXSAVE instruction saves FP and MMX technology state and SSE state to memory. Unlike
FSAVE, FXSAVE does not clear the x87-FP state. FXRSTOR loads FP and MMX technology state
and SSE state from memory.
The PEXTRW (Extract 16-bit word from MMX technology register) instruction moves the word in
a MMX technology register selected by the two least significant bits of the immediate operand to
the lower half of a 32-bit integer register; the upper word in the integer register is cleared.
The PINSRW (Insert 16-bit word into MMX technology register) instruction moves the lower word
in a 32-bit integer register or 16-bit word from memory into one of the four word locations in a
MMX technology register, selected by the two least significant bits of the immediate operand.
The PMAXUB/PMAXSW (Maximum of packed unsigned integer bytes or signed integer words)
instruction returns the maximum of each pair of packed elements into the destination register.
The PMINUB/PMINSW (Minimum of packed unsigned integer bytes or signed integer words)
instructions returns the minimum of each pair of packed data elements into the destination register.
The PMOVMSKB (Move Byte Mask from MMX technology register) instruction returns an 8-bit
mask formed of the most significant bits of each byte of its source operand in a MMX technology
register to an IA integer register.
The PMULHUW (Unsigned high packed integer word multiply in MMX technology register)
instruction performs an unsigned multiply on each word field of the two source MMX technology
registers, returning the high word of each result to a MMX technology register.
The PSADBW (Sum of absolute differences) instruction computes the absolute difference for each
pair of sub-operand byte sources and then accumulates the 8 differences into a single 16-bit result.
The PSHUFW (Shuffle packed integer word in MMX technology register) instruction performs a
full shuffle of any source word field to any result word field, using an 8-bit immediate operand.
Data referenced by a programmer can have temporal (data will be used again) or spatial (data will
be in adjacent locations, e.g. same cache line) locality. Some multimedia data types, such as the
display list in a 3D graphics application, are referenced once and not reused in the immediate
future. We will refer to this data type as non-temporal data. Thus the programmer does not want the
application’s cached code and data to be overwritten by this non-temporal data. The cacheability
control instructions enable the programmer to control caching so that non-temporal accesses will
minimize cache pollution.
In addition, the execution engine needs to be fed such that it does not become stalled waiting for
data. SSE instructions allow the programmer to prefetch data long before it’s final use. These
instructions are not architectural since they do not update any architectural state, and are specific to
each implementation. The programmer may have to tune his application for each implementation to
take advantage of these instructions. These instructions merely provide a hint to the hardware, and
they will not generate exceptions or faults. Excessive use of prefetch instructions may be throttled
by the processor.
The following four instructions provide hints to the cache hierarchy which enables the data to be
prefetched to different levels of the cache hierarchy and avoid polluting cache with non-temporal
data.
The MASKMOVQ (Non-temporal byte mask store of packed integer in a MMX technology
register) instruction stores data from a MMX technology register to the location specified by the
EDI register. The most significant bit in each byte of the second MMX technology mask register is
used to selectively write the data of the first register on a per-byte basis. The instruction is
implicitly weakly-ordered, with all of the characteristics of the WC memory type; successive
non-temporal stores may not write memory in program-order, do not write-allocate (i.e. the
processor will not fetch the corresponding cache line into the cache hierarchy, prior to performing
the store), write combine/collapse, and minimize cache pollution.
The MOVNTQ (Non-temporal store of packed integer in a MMX technology register) instruction
stores data from a MMX technology register to memory. The instruction is implicitly
weakly-ordered, does not write-allocate and minimizes cache pollution.
The main difference between a non-temporal store and a regular cacheable store is in the
write-allocation policy. The memory type of the region being written to can override the
non-temporal hint, leading to the following considerations:
• If the programmer specifies a non-temporal store to uncacheable memory, then the store
behaves like an uncacheable store; the non-temporal hint is ignored and the memory type for
the region is retained. Uncacheable as referred to here means that the region being written to
has been mapped with either a UC or WP memory type. If the memory region has been
mapped as WB, WT or WC, the non-temporal store will implement weakly-ordered (WC)
semantic behavior.
The PREFETCH (Load 32 or greater number of bytes) instructions load either non-temporal data or
temporal data in the specified cache level. This access and the cache level are specified as a hint.
The prefetch instructions do not affect functional behavior of the program and will be
implementation specific.
The SFENCE (Store Fence) instruction guarantees that every store instruction that precedes the
store fence instruction in program order is globally visible before any store instruction which
follows the fence. The SFENCE instruction provides an efficient way of ensuring ordering between
routines that produce weakly-ordered results and routines that consume this data.
This section describes how real numbers are represented in floating-point format in the processor. It
also introduces terms such as normalized numbers, denormalized numbers, biased exponents,
signed zeros, and NaNs. Readers who are already familiar with floating-point processing
techniques and the IEEE standards may wish to skip this section.
+10
10.0000000000000000000000
1.11111111111111111111111
Precision 24 Binary Digits
Because the size and number of registers that any computer can have is limited, only a subset of the
real-number continuum can be used in real-number calculations. As shown at the bottom of
Figure 3-1, the subset of real numbers that a particular processor supports represents an
approximation of the real number system. The range and precision of this real-number subset is
determined by the format that the processor uses to represent real numbers.
To increase the speed and efficiency of real-number computations, computers typically represent
real numbers in a binary floating-point format. In this format, a real number has three parts: a sign,
a significand, and an exponent. Figure 3-9 shows the binary floating-point format that SSE data
uses. This format conforms to the IEEE standard.
The sign is a binary value that indicates whether the number is positive (0) or negative (1). The
significand has two parts: a 1-bit binary integer (also referred to as the J-bit) and a binary fraction.
The J-bit is often not represented, but instead is an implied value. The exponent is a binary integer
that represents the base-2 power that the significand is raised to.
Sign
Exponent Significand
Fraction
Integer or J-Bit
Table 3-1 shows how the real number 178.125 (in ordinary decimal format) is stored in
floating-point format. The table lists a progression of real number notations that leads to the format
that the processor uses. In this format, the binary real number is normalized and the exponent is
biased.
In most cases, the processor represents real numbers in normalized form. This means that except
for zero, the significand is always made up of an integer of 1 and the following fraction:
1.fff...ff
For values less than 1, leading zeros are eliminated. (For each leading zero eliminated, the exponent
is decremented by one.)
The processor represents exponents in a biased form. This means that a constant is added to the
actual exponent so that the biased exponent is always a positive number. The value of the biasing
constant depends on the number of bits available for representing exponents in the floating-point
format being used. The biasing constant is chosen so that the smallest normalized number can be
reciprocated without overflow.
A variety of real numbers and special values can be encoded in the processor’s floating-point
format. These numbers and values are generally divided into the following classes:
• Signed zeros
• Denormalized finite numbers
• Normalized finite numbers
• Signed infinities
• NaNs
• Indefinite numbers
Figure 3-10 shows how the encodings for these numbers and non-numbers fit into the real number
continuum. The encodings shown here are for the IEEE single-precision (32-bit) format, where the
term “S” indicates the sign bit, “E” the biased exponent, and “F” the fraction. (The exponent values
are given in decimal.)
The processor can operate on and/or return any of these values, depending on the type of
computation being performed. The following sections describe these number and non-number
classes.
Zero can be represented as a +0 or a −0 depending on the sign bit. Both encodings are equal in
value. The sign of a zero result depends on the operation being performed and the rounding mode
being used. Signed zeros have been provided to aid in implementing interval arithmetic. The sign
of a zero may indicate the direction from which underflow occurred, or it may indicate the sign of
an ∞ that has been reciprocated.
Non-zero, finite numbers are divided into two classes: normalized and denormalized. The
normalized finite numbers comprise all the non-zero finite values that can be encoded in a
normalized real number format between zero and ∞. In the format shown in Figure 3-10, this group
of numbers includes all the numbers with biased exponents ranging from 1 to 25410 (unbiased, the
exponent range is from −12610 to +12710).
NaN NaN
-Denormalized Finite +Denormalized Finite
-∞ -Normalized Finite -0 +0 +Normalized Finite +∞
-Denormalized +Denormalized
1 0 0.XXX2 Finite Finite 0 0 0.XXX2
-Normalized +Normalized
1 1...254 Any Value Finite 0 1...254 Any Value
Finite
1 255 0 -∞ +∞ 0 255 0
Notes
1. Sign bit ignored
2. Fractions must be non-zero
When real numbers become very close to zero, the normalized-number format can no longer be
used to represent the numbers. This is because the range of the exponent is not large enough to
compensate for shifting the binary point to the right to eliminate leading zeros.
When the biased exponent is zero, smaller numbers can only be represented by making the integer
bit (and perhaps other leading bits) of the significand zero. The numbers in this range are called
denormalized (or tiny) numbers. The use of leading zeros with denormalized numbers allows
smaller numbers to be represented. However, this denormalization causes a loss of precision (the
number of significant bits in the fraction is reduced by the leading zeros).
A denormalized number is computed through a technique called gradual underflow. Table 3-2 gives
an example of gradual underflow in the denormalization process. Here the single-real format is
being used, so the minimum exponent (unbiased) is −12610. The true result in this example requires
an exponent of −12910 in order to have a normalized number. Since −12910 is beyond the allowable
exponent range, the result is denormalized by inserting leading zeros until the minimum exponent
of −12610 is reached.
In the extreme case, all the significant bits are shifted out to the right by leading zeros, creating a
zero result.
The two infinities, +∞ and −∞, represent the maximum positive and negative real numbers,
respectively, that can be represented in the floating-point format. Infinity is always represented by a
zero significand (fraction and integer bit) and the maximum biased exponent allowed in the
specified format (for example, 25510 for the single-real format).
The signs of infinities are observed, and comparisons are possible. Infinities are always interpreted
in the affine sense; that is, -∞is less than any finite number and +∞ is greater than any finite number.
Arithmetic on infinities is always exact. Exceptions are generated only when the use of an infinity
as a source operand constitutes an invalid operation.
Whereas denormalized numbers represent an underflow condition, the two infinity numbers
represent the result of an overflow condition. Here, the normalized result of a computation has a
biased exponent greater than the largest allowable exponent for the selected result format.
3.7.1.8 NaNs
Since NaNs are non-numbers, they are not part of the real number line. In Figure 3-10, the
encoding space for NaNs in the processor floating-point formats is shown above the ends of the real
number line. This space includes any value with the maximum allowable biased exponent and a
non-zero fraction. (The sign bit is ignored for NaNs.)
The IEEE standard defines two classes of NaN: quiet NaNs (QNaNs) and signaling NaNs (SNaNs).
A QNaN is a NaN with the most significant fraction bit set; an SNaN is a NaN with the most
significant fraction bit clear. QNaNs are allowed to propagate through most arithmetic operations
without signaling an exception. SNaNs generally signal an invalid-operation exception whenever
they appear as operands in arithmetic operations. Exceptions, as well as detailed information on
how the processor handles NaNs, are discussed in Section 3.7.2, “Operating on NaNs”.
As a general rule, when a QNaN is used in one or more arithmetic floating-point instructions, it is
allowed to propagate through a computation. An SNaN on the other hand causes a floating-point
invalid-operation exception to be signaled. SNaNs are typically used to trap or invoke an exception
handler.
The invalid operation exception has a flag and a mask bit associated with it in MXCSR. The mask
bit determines how the an SNaN value is handled. If the invalid operation mask bit is set, the SNaN
is converted to a QNaN by setting the most-significant fraction bit of the value to 1. The result is
then stored in the destination operand and the invalid operation flag is set. If the invalid operation
mask is clear, an invalid operation fault is signaled and no result is stored in the destination
operand.
When a real operation or exception delivers a QNaN result, the value of the result depends on the
source operands, as shown in Table 3-3. The exceptions to the behavior described in Table 3-3 are
the MINPS and MAXPS instructions. If only one source is a NaN for these instructions, the Src2
operand (either NaN or real value) is written to the result; this differs from the behavior for other
instructions as defined in Table 3-3, which is to always write the NaN to the result, regardless of
which source operand contains the NaN. This approach for MINPS/MAXPS allows NaN data to be
screened out of the bounds-checking portion of an algorithm. If instead of this behavior, it is
required that the NaN source operand be returned, the min/max functionality can be emulated using
a sequence of instructions: comparison followed by AND, ANDN and OR.
Except for the rules given at the beginning of this section for encoding SNaNs and QNaNs,
software is free to use the bits in the significand of a NaN for any purpose. Both SNaNs and QNaNs
can be encoded to carry and store data, such as diagnostic information.
Bytes in the new data type format have consecutive memory addresses. The ordering is always little
endian, that is, the bytes with the lower addresses are less significant than the bytes with the higher
addresses.
Byte 15 Byte 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Table 3-5 shows the encodings for all the classes of real numbers (that is, zero, denormalized-finite,
normalized-finite, and ∞) and NaNs for the single-real data-type. It also gives the format for the real
indefinite value, which is a QNaN encoding that is generated by several SSE instructions in
response to a masked floating-point invalid-operation exception.
When storing real values in memory, single-real values are stored in 4 consecutive bytes in
memory. The 128-bit access mode is used for 128-bit memory accesses, 128-bit transfers between
SSE registers, and all logical, unpack and arithmetic instructions.The 32-bit access mode is used for
32-bit memory access, 32-bit transfers between SSE registers, and all arithmetic instructions.
There are sixty-eight new instructions in SSE instruction set. This chapter describes the packed and
scalar floating-point instructions in alphabetical order, with a full description of each instruction.
The last two sections of this chapter describe the SIMD Integer instructions and the cacheability
control instructions.
Applying a prefix, in a manner not defined in this document, is considered reserved behavior. For
example, Table 3-6 shows general behavior for most SSE instructions; however, the application of
a prefix (Repeat, Repeat NE, Operand Size) is reserved for the following instructions:
3.12 Notations
Besides opcodes, two kinds of notations are found which both describe information found in the
ModR/M byte:
1. /digit: (digit between 0 and 7) indicates that the instruction uses only the r/m (register and
memory) operand. The reg field contains the digit that provides an extension to the
instruction's opcode.
2. /r: indicates that the ModR/M byte of an instruction contains both a register operand and an
r/m operand.
When there is ambiguity, xmm1 indicates the first source operand and xmm2 the second source
operand.
Table 3-9 describes the naming conventions used in the SSE instruction mnemonics.
Description: The ADDPS instruction adds the packed SP FP numbers of both their operands.
Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set. #XM for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception (CR4.OSXMMEXCPT
=0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set. #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0)
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
xmm1[63-32] = xmm1[63-32];
xmm1[95-64] = xmm1[95-64];
xmm1[127-96] = xmm1[127-96];
Description: The ADDSS instruction adds the lower SP FP numbers of both their operands; the upper 3 fields
are passed through from xmm1.
FP Exceptions: None.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #XM for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if
CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Description: The ANDNPS instructions returns a bit-wise logical AND between the complement of XMM1 and
XMM2/Mem.
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set.
Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault; #UD if
CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: The usage of Repeat Prefixes (F2H, F3H) with ANDNPS is reserved. Different processor
implementations may handle this prefix differently. Usage of this prefix with ANDNPS risks
incompatibility with future processors.
Description: The ANDPS instruction returns a bit-wise logical AND between XMM1 and XMM2/Mem.
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0;
#UD if CPUID.XMM(EDX bit 25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: The usage of Repeat Prefixes (F2H, F3H) with ANDPS is reserved. Different processor
implementations may handle this prefix differently. Usage of this prefix with ANDPS risks
incompatibility with future processors.
default: Reserved;
cmp0 = op(xmm1[31-0],xmm2/m128[31-0]);
cmp1 = op(xmm1[63-32],xmm2/m128[63-32]);
cmp2 = op(xmm1[95-64],xmm2/m128[95-64]);
cmp3 = op(xmm1[127-96],xmm2/m128[127-96]);
Description: For each individual pairs of SP FP numbers, the CMPPS instruction returns an all “1” 32-bit mask
or an all “0” 32-bit mask, using the comparison predicate specified by imm8; note that a subsequent
computational instruction which uses this mask as an input operand will not generate a fault, since
a mask of all “0’s” corresponds to a FP value of +0.0 and a mask of all “1’s” corresponds to a FP
value of -qNaN. Some of the comparisons can be achieved only through software emulation. For
these comparisons the programmer must swap the operands, copying registers when necessary to
protect the data that will now be in the destination, and then perform the compare using a different
predicate. The predicate to be used for these emulations is listed in under the heading “Emulation.”
The following table shows the different comparison types:
a. The greater-than, greater-than-or-equal, not-greater-than, and not-greater-than-or-equal relations are not directly implemented
in hardware.
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
Numeric Exceptions: Invalid if sNaN operand, invalid if qNaN and predicate as listed in above table, denormal.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set. #XM for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception (CR4.OSXMMEXCPT
=0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: Compilers and assemblers should implement the following 2-operand pseudo-ops in addition to the
3-operand CMPPS instruction:
The greater-than relations not implemented in hardware require more than one instruction to
emulate in software and therefore should not be implemented as pseudo-ops. (For these, the
programmer should reverse the operands of the corresponding less than relations and use move
instructions to ensure that the mask is moved to the correct destination register and that the source
operand is left intact.)
Bits 7-4 of the immediate field are reserved. Different processors may handle them differently.
Usage of these bits risks incompatibility with future processors.
default: Reserved;
cmp0 = op(xmm1[31-0],xmm2/m32[31-0]);
xmm1[63-32] = xmm1[63-32];
xmm1[95-64] = xmm1[95-64];
xmm1[127-96] = xmm1[127-96];
Description: For the lowest pair of SP FP numbers, the CMPSS instruction returns an all “1” 32-bit mask or an
all “0” 32-bit mask, using the comparison predicate specified by imm8; the values for the upper
three pairs of SP FP numbers are not compared. Note that a subsequent computational instruction
which uses this mask as an input operand will not generate a fault, since a mask of all “0’s”
corresponds to a FP value of +0.0 and a mask of all “1’s” corresponds to a FP value of -qNaN.
Some of the comparisons can be achieved only through software emulation. For these comparisons
the programmer must swap the operands, copying registers when necessary to protect the data that
will now be in the destination, and then perform the compare using a different predicate. The
predicate to be used for these emulations is listed in under the heading “Emulation.” The following
table shows the different comparison types:
a. The greater-than, greater-than-or-equal, not-greater-than, and not-greater-than-or-equal relations are not directly implemented
in hardware.
FP Exceptions: None.
Numeric Exceptions: Invalid if sNaN operand, invalid if qNaN and predicate as listed in above table, denormal.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true (CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #XM for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if
CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Pseudo-Op Implementation
CMPEQSS xmm1, xmm2 CMPSS xmm1,xmm2, 0
CMPLTSS xmm1, xmm2 CMPSS xmm1,xmm2, 1
CMPLESS xmm1, xmm2 CMPSS xmm1,xmm2, 2
CMPUNORDSS xmm1, xmm2 CMPSS xmm1,xmm2, 3
CMPNEQSS xmm1, xmm2 CMPSS xmm1,xmm2, 4
CMPNLTSS xmm1, xmm2 CMPSS xmm1,xmm2, 5
CMPNLESS xmm1, xmm2 CMPSS xmm1,xmm2, 6
CMPORDSS xmm1, xmm2 CMPSS xmm1,xmm2, 7
The greater-than relations not implemented in hardware require more than one instruction to
emulate in software and therefore should not be implemented as pseudo-ops. (For these, the
programmer should reverse the operands of the corresponding less than relations and use move
instructions to ensure that the mask is moved to the correct destination register and that the source
operand is left intact.)
Bits 7-4 of the immediate field are reserved. Different processors may handle them differently.
Usage of these bits risks incompatibility with future processors.
OF,SF,AF = 000;
Description: The COMISS instructions compare two SP FP numbers and sets the ZF,PF,CF bits in the EFLAGS
register as described above. Although the data type is packed single-FP, only the lower SP numbers
are compared. In addition, the OF, SF and AF bits in the EFLAGS register are zeroed out. The
unordered predicate is returned if either source operand is a NaN (qNaN or sNaN).
FP Exceptions: None.
Numeric Exceptions: Invalid (if SNaN or QNaN operands), Denormal. Integer EFLAGS values will not be
updated in the presence of unmasked numeric exceptions.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #XM for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if
CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: COMISS differs from UCOMISS in that it signals an invalid numeric exception when a source
operand is either a qNaN or sNaN; UCOMISS signals invalid only if a source operand is an sNaN.
The usage of Repeat (F2H, F3H) and Operand-Size (66H) prefixes with COMISS is reserved.
Different processor implementations may handle this prefix differently. Usage of this prefix with
COMISS risks incompatibility with future processors.
xmm[95-64] = xmm[95-64];
xmm[127-96] = xmm[127-96];
Description: The CVTPI2PS instruction converts signed 32-bit integers to SP FP numbers; when the conversion
is inexact, rounding is done according to MXCSR.
FP Exceptions: None.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception; #AC for unaligned
memory reference; #AC for unaligned memory reference. To enable #AC exceptions, three
conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #XM for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if
CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU
exception; #AC for unaligned memory reference; #XM for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception (CR4.OSXMMEXCPT
=0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
However, the use of a memory source operand with this instruction will not result in the above
transition from x87-FP to MMX technology.
Memory source
1. Invalid opcode (CR0.EM=1)
2. DNA (CR0.TS=1)
3. #SS or #GP, for limit violation
4. #PF, page fault
5. SSE numeric fault (i.e. precision)
Register source
1. Invalid opcode (CR0.EM=1)
2. DNA (CR0.TS=1)
3. #MF, pending x87-FP fault signalled
4. After returning from #MF, x87-FP->MMX technology transition
5. SSE numeric fault (i.e. precision)
Description: The CVTPS2PI instruction converts the lower 2 SP FP numbers in xmm/m64 to signed 32-bit
integers in mm; when the conversion is inexact, the value rounded according to the MXCSR is
returned. If the converted result(s) is/are larger than the maximum signed 32 bit value, the Integer
Indefinite value (0x80000000) will be returned.
FP Exceptions: None.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception; #AC for unaligned
memory reference. To enable #AC exceptions, three conditions must be true(CR0.AM is set;
EFLAGS.AC is set; current CPL is 3); #XM for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception (CR4.OSXMMEXCPT
=0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU
exception; #XM for an unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) =
0; #UD if CPUID.XMM(EDX bit 25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: This instruction behaves identically to original MMX technology instructions, in the presence of
x87-FP instructions, including:
Memory source
1. Invalid opcode (CR0.EM=1)
2. DNA (CR0.TS=1)
3. #MF, pending x87-FP fault signalled
4. After returning from #MF, x87-FP->MMX technology transition
5. #SS or #GP, for limit violation
6. #PF, page fault
7. SSE numeric fault (i.e. invalid, precision)
Register source
1. Invalid opcode (CR0.EM=1)
2. DNA (CR0.TS=1)
3. #MF, pending x87-FP fault signalled
4. After returning from #MF, x87-FP->MMX technology transition
5. SSE numeric fault (i.e. precision)
xmm[63-32] = xmm[63-32];
xmm[95-64] = xmm[95-64];
xmm[127-96] = xmm[127-96];
Description: The CVTSI2SS instruction converts a signed 32-bit integer from memory or from a 32-bit integer
register to a SP FP number; when the conversion is inexact, rounding is done according to the
MXCSR.
FP Exceptions: None.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #XM for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if
CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Description: The CVTSS2SI instruction converts a SP FP number to a signed 32-bit integer and returns it in the
32-bit integer register; when the conversion is inexact, the rounded value according to the MXCSR
is returned. If the converted result is larger than the maximum signed 32 bit integer, the Integer
Indefinite value (0x80000000) will be returned.
FP Exceptions: None.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #XM for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT = 0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if
CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Description: The CVTTPS2PI instruction converts the lower 2 SP FP numbers in xmm/m64 to 2 32-bit signed
integers in mm; if the conversion is inexact, the truncated result is returned. If the converted
result(s) is/are larger than the maximum signed 32 bit value, the Integer Indefinite value
(0x80000000) will be returned.
FP Exceptions: None.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception; #AC for unaligned
memory reference. To enable #AC exceptions, three conditions must be true(CR0.AM is set;
EFLAGS.AC is set; current CPL is 3); #XM for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception (CR4.OSXMMEXCPT
=0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU
exception; #XM for an unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) =
0; #UD if CPUID.XMM(EDX bit 25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Memory source
1. Invalid opcode (CR0.EM=1)
2. DNA (CR0.TS=1)
3. #MF, pending x87-FP fault signalled
4. After returning from #MF, x87-FP->MMX technology transition
5. #SS or #GP, for limit violation
6. #PF, page fault
7. SSE numeric fault (i.e. invalid, precision)
Register source
1. Invalid opcode (CR0.EM=1)
2. DNA (CR0.TS=1)
3. #MF, pending x87-FP fault signalled
4. After returning from #MF, x87-FP->MMX technology transition
5. SSE numeric fault (i.e. precision)
Description: The CVTTSS2SI instruction converts a SP FP number to a signed 32-bit integer and returns it in
the 32-bit integer register; if the conversion is inexact, the truncated result is returned. If the
converted result is larger than the maximum signed 32 bit value, the Integer Indefinite value
(0x80000000) will be returned.
FP Exceptions: None.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3; #XM for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if
CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Description: The DIVPS instruction divides the packed SP FP numbers of both their operands.
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception (CR4.OSXMMEXCPT
=0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
xmm1[63-32] = xmm1[63-32];
xmm1[95-64] = xmm1[95-64];
xmm1[127-96] = xmm1[127-96];
Description: The DIVSS instructions divide the lowest SP FP numbers of both operands; the upper 3 fields are
passed through from xmm1.
FP Exceptions: None.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #XM for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if
CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Description: The FXRSTOR instruction reloads the FP and MMX technology state and SSE state (environment
and registers) from the memory area defined by m512byte. This data should have been written by a
previous FXSAVE.
The FP and MMX technology and SSE environment and registers consist of the following data
structure (little-endian byte order as arranged in memory, with byte offset into row described by
right column):
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Rsrvd CS IP FOP FTW FSW FCW 0
Reserved MXCSR Rsrvd DS DP 16
Reserved ST0/MM0 32
Reserved ST1/MM1 48
Reserved ST2/MM2 64
Reserved ST3/MM3 80
Reserved ST4/MM4 96
Reserved ST5/MM5 112
Reserved ST6/MM6 128
Reserved ST7/MM7 144
XMM0 160
XMM1 176
XMM2 192
XMM3 208
XMM4 224
XMM5 240
XMM6 256
XMM7 272
Reserved 288
Reserved 304
Reserved 320
Reserved 336
Reserved 352
Reserved 368
Reserved 384
Reserved 400
Reserved 416
Reserved 432
Reserved 448
Reserved 464
Reserved 480
Reserved 496
If the MXCSR state contains an unmasked exception with corresponding status flag also set,
loading it will not result in a floating-point error condition being asserted; only the next occurrence
of this unmasked exception will result in the error condition being asserted.
Some bits of MXCSR (bits 31-16 and bit 6) are defined as reserved and cleared; attempting to write
a non-zero value to these bits will result in a general protection exception.
FXRSTOR does not flush pending x87-FP exceptions, unlike FRSTOR. To check and raise
exceptions when loading a new operating environment, use FWAIT after FXRSTOR.
The SSE fields in the save image (XMM0-XMM7 and MXCSR) may not be loaded into the
processor if the CR4.OSFXSR bit is not set. This CR4 bit must be set in order to enable execution
of SSE instructions.
FP Exceptions: If #AC exception detection is disabled, a general protection exception is signalled if the address is
not aligned on 16-byte boundary. Note that if #AC is enabled (and CPL is 3), signalling of #AC is
not guaranteed and may vary with implementation; in all implementations where #AC is not
signalled, a general protection fault will instead be signalled. In addition, the width of the alignment
check when #AC is enabled may also vary with implementation; for instance, for a given
implementation #AC might be signalled for a 2-byte misalignment, whereas #GP might be
signalled for all other misalignments (4/8/16-byte). Invalid opcode exception if instruction is
preceded by a LOCK override prefix. General protection fault if reserved bits of MXCSR are
loaded with non-zero values
#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; #NM if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #NM if CR0.EM = 1; #NM if TS bit in CR0 is set.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Notes: State saved with FXSAVE and restored with FRSTOR (and vice versa) will result in incorrect
restoration of state in the processor. The address size prefix will have the usual effect on address
calculation but will have no effect on the format of the FXRSTOR image.
The use of Repeat (F2H, F3H) and Operand Size (66H) prefixes with FXRSTOR is reserved.
Different processor implementations may handle this prefix differently. Use of this prefix with
FXRSTOR risks incompatibility with future processors.
Description: The FXSAVE instruction writes the current FP and MMX technology state and SSE state
(environment and registers) to the specified destination defined by m512byte. It does this without
checking for pending unmasked floating-point exceptions, similar to the operation of FNSAVE.
Unlike the FSAVE/FNSAVE instructions, the processor retains the contents of the FP and MMX
technology state and SSE state in the processor after the state has been saved. This instruction has
been optimized to maximize floating-point save performance. The save data structure is as follows
(little-endian byte order as arranged in memory, with byte offset into row described by right
column):
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Rsrvd CS IP FOP FTW FSW FCW 0
Reserved MXCSR Rsrvd DS DP 16
Reserved ST0/MM0 32
Reserved ST1/MM1 48
Reserved ST2/MM2 64
Reserved ST3/MM3 80
Reserved ST4/MM4 96
Reserved ST5/MM5 112
Reserved ST6/MM6 128
Reserved ST7/MM7 144
XMM0 160
XMM1 176
XMM2 192
XMM3 208
XMM4 224
XMM5 240
XMM6 256
XMM7 272
Reserved 288
Reserved 304
Reserved 320
Reserved 336
Reserved 352
Reserved 368
Reserved 384
Reserved 400
Three fields in the floating-point save area contain reserved bits that are not indicated in the table:
• FOP: The lower 11-bits contain the opcode, upper 5-bits are reserved.
• IP & DP: 32-bit mode: 32-bit IP-offset.
• 16-bit mode: lower 16-bits are IP-offset and upper 16-bits are reserved.
The FXSAVE instruction is used when an operating system needs to perform a context switch or
when an exception handler needs to use the FP and MMX technology and SSE units. It cannot be
used by an application program to pass a “clean” FP state to a procedure, since it retains the current
state. An application must explicitly execute an FINIT instruction after FXSAVE to provide for this
functionality.
All of the x87-FP fields retain the same internal format as in FSAVE except for FTW.
Unlike FSAVE, FXSAVE saves only the FTW valid bits rather than the entire x87-FP FTW field.
The FTW bits are saved in a non-TOS relative order, which means that FR0 is always saved first,
followed by FR1, FR2 and so forth. As an example, if TOS=4 and only ST0, ST1 and ST2 are
valid, FSAVE saves the FTW field in the following format:
ST3 ST2 ST1 ST0 ST7 ST6 ST5 ST4 (TOS=4)
FR7 FR6 FR5 FR4 FR3 FR2 FR1 FR0
11 xx xx xx 11 11 11 11
where xx is one of (00, 01, 10). (11) indicates an empty stack elements, and the 00, 01, and 10
indicate Valid, Zero, and Special, respectively. In this example, FXSAVE would save the following
vector:
FR7 FR6 FR5 FR4 FR3 FR2 FR1 FR0
0 1 1 1 0 0 0 0
The FSAVE format for FTW can be recreated from the FTW valid bits and the stored 80-bit FP data
(assuming the stored data was not the contents of MMX technology registers) using the following
table:
The J-bit is defined to be the 1-bit binary integer to the left of the decimal place in the significand.
The M-bit is defined to be the most significant bit of the fractional portion of the significand (i.e.
the bit immediately to the right of the decimal place).
When the M-bit is the most significant bit of the fractional portion of the significand, it must be 0 if
the fraction is all 0’s.
If the FXSAVE instruction is immediately preceded by an FP instruction which does not use a
memory operand, then the FXSAVE instruction does not write/update the DP field, in the FXSAVE
image.
MXCSR holds the contents of the SSE Control/Status Register. See the LDMXCSR instruction for
a full description of this field.
The fields XMM0-XMM7 contain the content of registers XMM0-XMM7 in exactly the same
format as they exist in the registers.
The SSE fields in the save image (XMM0-XMM7 and MXCSR) may not be loaded into the
processor if the CR4.OSFXSR bit is not set. This CR4 bit must be set in order to enable execution
of SSE instructions.
FP Exceptions: If #AC exception detection is disabled, a general protection exception is signalled if the address is
not aligned on 16-byte boundary. Note that if #AC is enabled (and CPL is 3), signalling of #AC is
not guaranteed and may vary with implementation; in all implementations where #AC is not
signalled, a general protection fault will instead be signalled. In addition, the width of the alignment
check when #AC is enabled may also vary with implementation; for instance, for a given
implementation #AC might be signalled for a 2-byte misalignment, whereas #GP might be
signalled for all other misalignments (4/8/16-byte). Invalid opcode exception if instruction is
preceded by a LOCK override prefix.
#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; #NM if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #NM if CR0.EM = 1; #NM if TS bit in CR0 is set.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault, Data
Dirty Bit Fault
Notes: State saved with FXSAVE and restored with FRSTOR (and vice versa) will result in incorrect
restoration of state in the processor. The address size prefix will have the usual effect on address
calculation but will have no effect on the format of the FXSAVE image.
If there is a pending unmasked FP exception at the time FXSAVE is executed, the sequence of
FXSAVE-FWAIT-FXRSTOR will result in incorrect state in the processor. The FWAIT instruction
causes the processor to check and handle pending unmasked FP exceptions. Since the processor
does not clear the FP state with FXSAVE (unlike FSAVE), the exception is handled but that fact is
not reflected in the saved image. When the image is reloaded using FXRSTOR, the exception bits
in FSW will be incorrectly reloaded.
The use of Repeat (F2H, F3H) and Operand Size (66H) prefixes with FXSAVE is reserved.
Different processor implementations may handle this prefix differently. Use of these prefixes with
FXSAVE risks incompatibility with future processors.
Description: The MXCSR control/status register is used to enable masked/unmasked exception handling, to set
rounding modes, to set flush-to-zero mode, and to view exception status flags. The following figure
shows the format and encoding of the fields in MXCSR.
31-16 15 10 5 0
Reserved FZ RC RC PM UM OM ZM DM IM Rsvd PE UE OE ZE DE IE
Bits 5-0 indicate whether an SSE numerical exception has been detected. They are “sticky” flags,
and can be cleared by using the LDMXCSR instruction to write zeroes to these fields. If a
LDMXCSR instruction clears a mask bit and sets the corresponding exception flag bit, an
exception will not be immediately generated. The exception will occur only upon the next SSE
instruction to cause this type of exception. The Intel SSE architecture uses only one exception flag
for each exception. There is no provision for individual exception reporting within a packed data
type. In situations where multiple identical exceptions occur within the same instruction, the
associated exception flag is updated and indicates that at least one of these conditions happened.
These flags are cleared upon reset.
Bits 12-7 configure numerical exception masking; an exception type is masked if the corresponding
bit is set and it is unmasked if the bit is clear. These enables are set upon reset, meaning that all
numerical exceptions are masked.
Bits 14-13 encode the rounding-control, which provides for the common round-to-nearest mode, as
well as directed rounding and true chop. Rounding control affects the arithmetic instructions and
certain conversion instructions. The encoding for RC is as follows:
Bit 15 (FZ) is used to turn on the Flush To Zero mode (bit is set). Turning on the Flush To Zero
mode has the following effects during underflow situations:
• Zero results are returned with the sign of the true result.
• Precision and underflow exception flags are set.
The other bits of MXCSR (bits 31-16 and bit 6) are defined as reserved and cleared; attempting to
write a non-zero value to these bits, using either the FXRSTOR or LDMXCSR instructions, will
result in a general protection exception.
The linear address corresponds to the address of the least-significant byte of the referenced memory
data.
FP Exceptions: General protection fault if reserved bits are loaded with non-zero values.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set. #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #UD if
CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0;
#UD if CPUID.XMM(EDX bit 25) = 0.
Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault. #AC for unaligned
memory reference.
Comments: The usage of Repeat (F2H, F3H) and Operand Size (66H) prefixes with LDMXCSR is reserved.
Different processor implementations may handle this prefix differently. Usage of this prefix with
LDMXCSR risks incompatibility with future processors.
Description: The MAXPS instruction returns the maximum SP FP numbers from XMM1 and XMM2/Mem. If
the values being compared are both zeros, source2 (xmm2/m128) would be returned. If source2
(xmm2/m128) is an sNaN, this sNaN is forwarded unchanged to the destination (i.e. a quieted
version of the sNaN is not returned).
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception (CR4.OSXMMEXCPT
=0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: Note that if only one source is a NaN for these instructions, the Src2 operand (either NaN or real
value) is written to the result; this differs from the behavior for other instructions as defined in
Table 3-3, which is to always write the NaN to the result, regardless of which source operand
contains the NaN. This approach for MAXPS allows compilers to use the MAXPS instruction for
common C conditional constructs. If instead of this behavior, it is required that the NaN source
operand be returned, the min/max functionality can be emulated using a sequence of instructions:
comparison followed by AND, ANDN and OR.
xmm1[63-32] = xmm1[63-32];
xmm1[95-64] = xmm1[95-64];
xmm1[127-96] = xmm1[127-96];
Description: The MAXSS instruction returns the maximum SP FP number from the lower SP FP numbers of
XMM1 and XMM2/Mem; the upper 3 fields are passed through from xmm1. If the values being
compared are both zeros, source2 (xmm2/m128) would be returned. If source2 (xmm2/m128) is an
sNaN, this sNaN is forwarded unchanged to the destination (i.e. a quieted version of the sNaN is
not returned).
FP Exceptions: None
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #XM for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if
CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: Note that if only one source is a NaN for these instructions, the Src2 operand (either NaN or real
value) is written to the result; this differs from the behavior for other instructions as defined in
Table 3-3, which is to always write the NaN to the result, regardless of which source operand
contains the NaN. The upper three operands are still bypassed from the src1 operand, as in all other
scalar operations. This approach for MAXSS allows compilers to use the MAXSS instruction for
common C conditional constructs. If instead of this behavior, it is required that the NaN source
operand be returned, the min/max functionality can be emulated using a sequence of instructions:
comparison followed by AND, ANDN and OR.
Description: The MINPS instruction returns the minimum SP FP numbers from XMM1 and XMM2/Mem. If the
values being compared are both zeros, source2 (xmm2/m128) would be returned. If source2
(xmm2/m128) is an sNaN, this sNaN is forwarded unchanged to the destination (i.e. a quieted
version of the sNaN is not returned).
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set. #XM for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception (CR4.OSXMMEXCPT
=0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: Note that if only one source is a NaN for these instructions, the Src2 operand (either NaN or real
value) is written to the result; this differs from the behavior for other instructions as defined in
Table 3-3, which is to always write the NaN to the result, regardless of which source operand
contains the NaN. This approach for MINPS allows compilers to use the MINPS instruction for
common C conditional constructs. If instead of this behavior, it is required that the NaN source
operand be returned, the min/max functionality can be emulated using a sequence of instructions:
comparison followed by AND, ANDN and OR.
xmm1[63-32] = xmm1[63-32];
xmm1[95-64] = xmm1[95-64];
xmm1[127-96] = xmm1[127-96];
Description: The MINSS instruction returns the minimum SP FP number from the lower SP FP numbers from
XMM1 and XMM2/Mem; the upper 3 fields are passed through from xmm1.If the values being
compared are both zeros, source2 (xmm2/m128) would be returned. If source2 (xmm2/m128) is an
sNaN, this sNaN is forwarded unchanged to the destination (i.e. a quieted version of the sNaN is
not returned).
FP Exceptions: None
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #XM for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if
CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Same exceptions as in Real Address Mode; #PF (fault-code) for a page fault; #AC for unaligned
memory references.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: Note that if only one source is a NaN for these instructions, the Src2 operand (either NaN or real
value) is written to the result; this differs from the behavior for other instructions as defined in
Table 3-3, which is to always write the NaN to the result, regardless of which source operand
contains the NaN. The upper three operands are still bypassed from the src1 operand, as in all other
scalar operations. This approach for MINSS allows compilers to use the MINSS instruction for
common C conditional constructs. If instead of this behavior, it is required that the NaN source
operand be returned, the min/max functionality can be emulated using a sequence of instructions:
comparison followed by AND, ANDN and OR.
if (source == m128) {
// load instruction
xmm1[127-0] = m128;
else {
// move instruction
xmm1[127=0] = xmm2[127-0];
else {
if (destination == m128) {
// store instruction
m128 = xmm1[127-0];
else {
// move instruction
xmm2[127-0] = xmm1[127-0];
Description: The linear address corresponds to the address of the least-significant byte of the referenced memory
data. When a memory address is indicated, the 16 bytes of data at memory location m128 are
loaded or stored. When the register-register form of this operation is used, the content of the 128-bit
source register is copied into 128-bit destination register.
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0;
#UD if CPUID.XMM(EDX bit 25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: MOVAPS should be used when dealing with 16-byte aligned SP FP numbers. If the data is not
known to be aligned, MOVUPS should be used instead of MOVAPS. The usage of this instruction
should be limited to the cases where the aligned restriction is easy to meet. Processors that support
the Intel SSE architecture will provide optimal aligned performance for the MOVAPS instruction.
The usage of Repeat Prefixes (F2H, F3H) with MOVAPS is reserved. Different processor
implementations may handle this prefix differently. Usage of this prefix with MOVAPS risks
incompatibility with future processors.
xmm1[127-64] = xmm1[127-64];
xmm1[63-0] = xmm2[127-64];
Description: The upper 64-bits of the source register xmm2 are loaded into the lower 64-bits of the 128-bit
register xmm1 and the upper 64-bits of xmm1 are left unchanged.
FP Exceptions: None
Comments: The usage of Repeat (F2H, F3H) and Operand Size (66H) prefixes with MOVHLPS is reserved.
Different processor implementations may handle these prefixes differently. Usage of these prefixes
with MOVHLPS risks incompatibility with future processors.
// load instruction
xmm[127-64] = m64;
xmm[31-0] = xmm[31-0];
xmm[63-32] = xmm[63-32];
else {
// store instruction
m64 = xmm[127-64];
Description: The linear address corresponds to the address of the least-significant byte of the referenced memory
data. When the load form of this operation is used, m64 is loaded into the upper 64-bits of the
128-bit register xmm and the lower 64-bits are left unchanged.
FP Exceptions: None
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #UD if
CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0;
#UD if CPUID.XMM(EDX bit 25) = 0.
Same exceptions as in Real Address Mode; #PF (fault-code) for a page fault; #AC for unaligned
memory reference if the current privilege level is 3.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault, Data
Dirty Bit Fault
Comments: The usage of Repeat Prefixes (F2H, F3H) with MOVHPS is reserved. Different processor
implementations may handle this prefix differently. Usage of this prefix with MOVHPS risks
incompatibility with future processors.
xmm1[127-64] = xmm2[63-0];
xmm1[63-0] = xmm1[63-0];
Description: The lower 64-bits of the source register xmm2 are loaded into the upper 64-bits of the 128-bit
register xmm1 and the lower 64-bits of xmm1 are left unchanged.
FP Exceptions: None
Comments:
Example: The usage of Repeat (F2H, F3H) and Operand Size (66H) prefixes with MOVLHPS is reserved.
Different processor implementations may handle these prefixes differently. Usage of these prefixes
with MOVLHPS risks incompatibility with future processors.
// load instruction
xmm[63-0] = m64;
xmm[95-64] = xmm[95-64];
xmm[127-96] = xmm[127-96];
else {
// store instruction
m64 = xmm[63-0];
Description: The linear address corresponds to the address of the least-significant byte of the referenced memory
data. When the load form of this operation is used, m64 is loaded into the lower 64-bits of the
128-bit register xmm and the upper 64-bits are left unchanged.
FP Exceptions: None
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #UD if
CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set.; #UD if CRCR4.OSFXSR(bit 9) = 0;
#UD if CPUID.XMM(EDX bit 25) = 0.
Same exceptions as in Real Address Mode; #PF (fault-code) for a page fault; #AC for unaligned
memory reference if the current privilege level is 3.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault, Data
Dirty Bit Fault
Comments: The usage of Repeat Prefixes (F2H, F3H) with MOVLPS is reserved. Different processor
implementations may handle this prefix differently. Usage of this prefix with MOVLPS risks
incompatibility with future processors.
r32[31-16] = 0x0000;
Description: The MOVMSKPS instruction returns to the integer register r32 a 4-bit mask formed of the most
significant bits of each SP FP number of its operand.
FP Exceptions: None
#UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception.;
#UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Comments: The usage of Repeat Prefixes (F2H, F3H) with MOVMSKPS is reserved. Different processor
implementations may handle this prefix differently. Usage of this prefix with MOVMSKPS risks
incompatibility with future processors.
if (source == m32) {
// load instruction
xmm1[31-0] = m32;
xmm1[63-32] = 0x00000000;
xmm1[95-64] = 0x00000000;
xmm1[127-96] = 0x00000000;
else {
// move instruction
xmm1[31-0] = xmm2[31-0];
xmm1[63-32] = xmm1[63-32];
xmm1[95-64] = xmm1[95-64];
xmm1[127-96] = xmm1[127-96];
else {
if (destination == m32) {
// store instruction
m32 = xmm1[31-0];
else {
// move instruction
xmm2[31-0] = xmm1[31-0]
xmm2[63-32] = xmm2[63-32];
xmm2[95-64] = xmm2[95-64];
Description: The linear address corresponds to the address of the least-significant byte of the referenced memory
data. When a memory address is indicated, the 4 bytes of data at memory location m32 are loaded
or stored. When the load form of this operation is used, the 32-bits from memory are copied into the
lower 32 bits of the 128-bit register xmm, the 96 most significant bits being cleared.
FP Exceptions: None
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #UD if
CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0;
#UD if CPUID.XMM(EDX bit 25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault, Data
Dirty Bit Fault
if (source == m128) {
// load instruction
xmm1[127-0] = m128;
else {
// move instruction
xmm1[127-0] = xmm2[127-0];
else {
if (destination == m128) {
// store instruction
m128 = xmm1[127-0];
else {
// move instruction
xmm2[127-0] = xmm1[127-0];
Description: The linear address corresponds to the address of the least-significant byte of the referenced memory
data. When a memory address is indicated, the 16 bytes of data at memory location m128 are
loaded to the 128-bit multimedia register xmm or stored from the 128-bit multimedia register xmm.
When the register-register form of this operation is used, the content of the 128-bit source register
is copied into 128-bit register xmm. No assumption is made about alignment.
FP Exceptions: None
#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; #UD if CR0.EM
= 1; #AC for unaligned memory reference if the current privilege level is 3; #NM if TS bit in CR0
is set.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault, Data
Dirty Bit Fault
Comments: MOVUPS should be used with SP FP numbers when that data is known to be unaligned.The usage
of this instruction should be limited to the cases where the aligned restriction is hard or impossible
to meet. SSE implementations guarantee optimum unaligned support for MOVUPS. Efficient SSE
applications should mainly rely on MOVAPS, not MOVUPS, when dealing with aligned data.
The usage of Repeat-NE Prefix (F2H) and Operand Size Prefix (66H) with MOVUPS is reserved.
Different processor implementations may handle this prefix differently. Usage of this prefix with
MOVUPS risks incompatibility with future processors.
A linear address of the 128 bit data access, while executing in 16-bit mode, that overlaps the end of
a 16-bit segment is not allowed and is defined as reserved behavior. Different processor
implementations may/may not raise a GP fault in this case if the segment limit has been exceeded;
additionally, the address that spans the end of the segment may/may not wrap around to the
beginning of the segment.
Description: The MULPS instructions multiply the packed SP FP numbers of both their operands.
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception (CR4.OSXMMEXCPT
=0).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0).
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
xmm1[63-32] = xmm1[63-32];
xmm1[95-64] = xmm1[95-64];
xmm1[127-96] = xmm1[127-96];
Description: The MULSS instructions multiply the lowest SP FP numbers of both their operands; the upper
3 fields are passed through from xmm1.
FP Exceptions: None
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #XM for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =0).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0).
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Description: The ORPS instructions return a bit-wise logical OR between xmm1 and xmm2/mem.
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: The usage of Repeat Prefixes (F2H, F3H) with ORPS is reserved. Different processor
implementations may handle this prefix differently. Usage of this prefix with ORPS risks
incompatibility with future processors.
Description: RCPPS returns an approximation of the reciprocal of the SP FP numbers from xmm2/m128. The
relative error for this approximation is Error, which satisfies:
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: RCPPS is not affected by the rounding control in MXCSR. Denormal inputs are treated as zeros (of
the same sign) and tiny results are always flushed to zero, with the sign of the operand.
Results are guaranteed not to be tiny, and therefore not flushed to zero, for input values x which
satisfy
flush-to-zero might or might not occur, depending on the implementation (this interval contains
6144 + 3072 = 9216 single precision floating-point numbers).
Results are guaranteed to be tiny, and therefore flushed to zero, for input values x which satisfy
The decimal approximations of the single precision numbers that delimit the three intervals
specified above, are as follows:
1.11111111110100000000000B×2125 ~= 8.5039437×1037
1.11111111110100000000001B×2125 ~= 8.5039443×1037
1.00000000000110000000000B×2126 ~= 4.2550872×1037
1.00000000000110000000001B×2126 ~= 4.2550877×1037
The hexadecimal representations of the single precision numbers that delimit the three intervals
specified above, are as follows:
1.11111111110100000000000B×2125 = 0x7e7fe800
1.11111111110100000000001B×2125 = 0x7e7fe801
1.00000000000110000000000B×2126 = 0x7e800c00
1.00000000000110000000001B×2126 = 0x7e800c01
xmm1[63-32] = xmm1[63-32];
xmm1[95-64] = xmm1[95-64];
xmm1[127-96] = xmm1[127-96];
Description: RCPSS returns an approximation of the reciprocal of the lower SP FP number from xmm2/m32;
the upper 3 fields are passed through from xmm1. The relative error for this approximation is Error,
which satisfies:
#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; #UD if CR0.EM
= 1; #AC for unaligned memory reference if the current privilege level is 3; #NM if TS bit in CR0
is set.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: RCPSS is not affected by the rounding control in MXCSR. Denormal inputs are treated as zeros (of
the same sign) and tiny results are always flushed to zero, with the sign of the operand.
Results are guaranteed not to be tiny, and therefore not flushed to zero, for input values x which
satisfy
flush-to-zero might or might not occur, depending on the implementation (this interval contains
6144 + 3072 = 9216 single precision floating-point numbers).
Results are guaranteed to be tiny, and therefore flushed to zero, for input values x which satisfy
The decimal approximations of the single precision numbers that delimit the three intervals
specified above, are as follows:
1.11111111110100000000000B×2125 ~= 8.5039437×1037
1.11111111110100000000001B×2125 ~= 8.5039443×1037
1.00000000000110000000000B×2126 ~= 4.2550872×1037
1.00000000000110000000001B×2126 ~= 4.2550877×1037
The hexadecimal representations of the single precision numbers that delimit the three intervals
specified above, are as follows:
1.11111111110100000000000B×2125 = 0x7e7fe800
1.11111111110100000000001B×2125 = 0x7e7fe801
1.00000000000110000000000B×2126 = 0x7e800c00
1.00000000000110000000001B×2126 = 0x7e800c01
Description: RSQRTPS returns an approximation of the reciprocal of the square root of the SP FP numbers from
xmm2/m128. The relative error for this approximation is Error, which satisfies:
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0;
#UD if CPUID.XMM(EDX bit 25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: RSQRTPS is not affected by the rounding control in MXCSR. Denormal inputs are treated as zeros
(of the same sign).
xmm1[63-32] = xmm1[63-32];
xmm1[95-64] = xmm1[95-64];
xmm1[127-96] = xmm1[127-96];
Description: RSQRTSS returns an approximation of the reciprocal of the square root of the lowest SP FP
number from xmm2/m32; the upper 3 fields are passed through from xmm1. The relative error for
this approximation is Error, which satisfies:
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments:
Example: RSQRTSS is not affected by the rounding control in MXCSR. Denormal inputs are treated as zeros
(of the same sign).
(fp_select == 1) ? xmm1[63-32] :
(fp_select == 2) ? xmm1[95-64] :
xmm1[127-96];
(fp_select == 1) ? xmm1[63-32] :
(fp_select == 2) ? xmm1[95-64] :
xmm1[127-96];
(fp_select == 1) ? xmm2/m128[63-32] :
(fp_select == 2) ? xmm2/m128[95-64] :
xmm2/m128[127-96];
(fp_select == 1) ? xmm2/m128[63-32] :
(fp_select == 2) ? xmm2/m128[95-64] :
xmm2/m128[127-96];
Description: The SHUFPS instruction is able to shuffle any of the four SP FP numbers from xmm1 to the lower
2 destination fields; the upper 2 destination fields are generated from a shuffle of any of the four SP
FP numbers from xmm2/m128. By using the same register for both sources, SHUFPS can return
any combination of the four SP FP numbers from this register. Bits 0 and 1 of the immediate field
are used to select which of the four input SP FP numbers will be put in the first SP FP number of
the result; bits 3 and 2 of the immediate field are used to select which of the four input SP FP will
be put in the second SP FP number of the result; etc.
X4 X3 X2 X1
xmm1
Y4 Y3 Y2 Y1
xmm2/m128
xmm1
{Y4... Y1} {Y4... Y1} {X4... X1} {X4... X1}
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0;
#UD if CPUID.XMM(EDX bit 25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: The usage of Repeat Prefixes (F2H, F3H) with SHUFPS is reserved. Different processor
implementations may handle this prefix differently. Usage of this prefix with SHUFPS risks
incompatibility with future processors.
Description: The SQRTPS instruction returns the square root of the packed SP FP numbers from xmm2/m128.
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception (CR4.OSXMMEXCPT
=0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
xmm1[63-32] = xmm1[63-32];
xmm1[95-64] = xmm1[95-64];
xmm1[127-96] = xmm1[127-96];
Description: The SQRTSS instructions return the square root of the lowest SP FP numbers of their operand.
FP Exceptions: None
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #XM for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if
CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Description: The MXCSR control/status register is used to enable masked/unmasked exception handling, to set
rounding modes, to set flush-to-zero mode, and to view exception status flags. Refer to LDMXCSR
for a description of the format of MXCSR. The linear address corresponds to the address of the
least-significant byte of the referenced memory data. The reserved bits in the MXCSR are stored as
zeroes.
FP Exceptions: None.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set. #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #UD if
CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0;
#UD if CPUID.XMM(EDX bit 25) = 0.
Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault. #AC for unaligned
memory reference.
Comments: The usage of Repeat (F2H, F3H) and Operand Size (66H) prefixes with STMXCSR is reserved.
Different processor implementations may handle this prefix differently. Usage of this prefix with
STMXCSR risks incompatibility with future processors.
Description: The SUBPS instruction subtracts the packed SP FP numbers of both their operands.
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception (CR4.OSXMMEXCPT
=0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
xmm1[63-32] = xmm1[63-32];
xmm1[95-64] = xmm1[95-64];
xmm1[127-96] = xmm1[127-96];
Description: The SUBSS instruction subtracts the lower SP FP numbers of both their operands.
FP Exceptions: None.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #XM for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if
CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF(fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
OF,SF,AF = 000;
Description: The UCOMISS instructions compare the two lowest scalar SP FP numbers and sets the ZF,PF,CF
bits in the EFLAGS register as described above. In addition, the OF, SF and AF bits in the
EFLAGS register are zeroed out. The unordered predicate is returned if either source operand is a
NaN (qNaN or sNaN).
FP Exceptions: None.
Numeric Exceptions: Invalid (if SNaN operands), Denormal. Integer EFLAGS values will not be updated in the
presence of unmasked numeric exceptions.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #AC for unaligned memory reference. To enable #AC exceptions,
three conditions must be true(CR0.AM is set; EFLAGS.AC is set; current CPL is 3); #XM for an
unmasked SSE numeric exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if
CPUID.XMM(EDX bit 25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #XM for an unmasked SSE numeric
exception (CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =0); #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: UCOMISS differs from COMISS in that it signals an invalid numeric exception when a source
operand is an sNaN; COMISS signals invalid if a source operand is either a qNaN or an sNaN.
The usage of Repeat (F2H, F3H) and Operand-Size prefixes with UCOMISS is reserved. Different
processor implementations may handle this prefix differently. Usage of this prefix with UCOMISS
risks incompatibility with future processors.
xmm1[63-32] = xmm2/m128[95-64];
xmm1[95-64] = xmm1[127-96];
xmm1[127-96] = xmm2/m128[127-96];
Description: The UNPCKHPS instruction performs an interleaved unpack of the high-order data elements of
XMM1 and XMM2/Mem. It ignores the lower half of the sources.
Example:
X4 X3 X2 X1
xmm1
Y4 Y3 Y2 Y1
xmm2/m128
xmm1
Y4 X4 Y3 X3
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0;
#UD if CPUID.XMM(EDX bit 25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: When unpacking from a memory operand, an implementation may decide to fetch only the
appropriate 64 bits. Alignment to 16-byte boundary and normal segment checking will still be
enforced.
The usage of Repeat Prefixes (F2H, F3H) with UNPCKHPS is reserved. Different processor
implementations may handle this prefix differently. Usage of this prefix with UNPCKHPS risks
incompatibility with future processors.
xmm1[63-32] = xmm2/m128[31-0];
xmm1[95-64] = xmm1[63-32];
xmm1[127-96] = xmm2/m128[63-32];
Description: The UNPCKLPS instruction performs an interleaved unpack of the low-order data elements of
XMM1 and XMM2/Mem. It ignores the upper half part of the sources.
Example:
X4 X3 X2 X1
xmm1
Y4 Y3 Y2 Y1
xmm2/m128
xmm1
Y2 X2 Y1 X1
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0;
#UD if CPUID.XMM(EDX bit 25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments: When unpacking from a memory operand, an implementation may decide to fetch only the
appropriate 64 bits. Alignment to 16-byte boundary and normal segment checking will still be
enforced.
The usage of Repeat Prefixes (F2H, F3H) with UNPCKLPS is reserved. Different processor
implementations may handle this prefix differently. Usage of this prefix with UNPCKLPS risks
incompatibility with future processors.
Description: The XORPS instruction returns a bit-wise logical XOR between XMM1 and XMM2/Mem.
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0;
#UD if CPUID.XMM(EDX bit 25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Comments:
The usage of Repeat Prefixes (F2H, F3H) with XORPS is reserved. Different processor
implementations may handle this prefix differently. Usage of this prefix with XORPS risks
incompatibility with future processors.
mm1[7-0] = res[0];
...
mm1[63-56] = res[7];
mm1[15-0] = res[0];
...
mm1[63-48] = res[3];
Description: The PAVG instructions add the unsigned data elements of the source operand to the unsigned data
elements of the destination register, along with a carry-in. The results of the add are then each
independently right shifted by one bit position. The high order bits of each element are filled with
the carry bits of the corresponding sum.
The destination operand is a MMX technology register. The source operand can either be a MMX
technology register or a 64-bit memory operand.
The PAVGB instruction operates on packed unsigned bytes and the PAVGW instruction operates on
packed unsigned words.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set. #MF if there is a pending FPU exception; #AC for unaligned
memory reference. To enable #AC exceptions, three conditions must be true(CR0.AM is set;
EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU
exception.
Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault; #AC for unaligned
memory references (if the current privilege level is 3).
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
r[15-0] = mm_temp[15-0];
r[31-16] = 0x0000;
Description: The PEXTRW instruction moves the word in MM selected by the two least significant bits of imm8
to the lower half of a 32-bit integer register.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set. #MF if there is a pending FPU exception.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set. #MF if there is a pending FPU
exception.
0xffff000000000000;
Description: The PINSRW instruction loads a word from the lower half of a 32-bit integer register (or from
memory) and inserts it in the MM destination register at a position defined by the two least
significant bits of the imm8 constant. The insertion is done in such a way that the three other words
from the destination register are left untouched.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception; #AC for unaligned
memory reference. To enable #AC exceptions, three conditions must be true(CR0.AM is set;
EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set. #MF if there is a pending FPU
exception.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Description: The PMAXSW instruction returns the maximum between the four signed words in MM1 and
MM2/Mem.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception #AC for unaligned
memory reference. To enable #AC exceptions, three conditions must be true(CR0.AM is set;
EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set. #MF if there is a pending FPU
exception.
Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault; #AC for unaligned
memory reference if the current privilege level is 3.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Description: The PMAXUB instruction returns the maximum between the eight unsigned words in MM1 and
MM2/Mem.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception #AC for unaligned
memory reference. To enable #AC exceptions, three conditions must be true(CR0.AM is set;
EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set. #MF if there is a pending FPU
exception.
Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault; #AC for unaligned
memory reference if the current privilege level is 3.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Description: The PMINSW instruction returns the minimum between the four signed words in MM1 and
MM2/Mem.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception#AC for unaligned
memory reference. To enable #AC exceptions, three conditions must be true (CR0.AM is set;
EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set. #MF if there is a pending FPU
exception.
Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault; #AC for unaligned
memory reference if the current privilege level is 3.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Description: The PMINUB instruction returns the minimum between the eight unsigned words in MM1 and
MM2/Mem.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception; #AC for unaligned
memory reference. To enable #AC exceptions, three conditions must be true(CR0.AM is set;
EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU
exception.
Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault; #AC for unaligned
memory reference if the current privilege level is 3.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
r32[31-8] = 0x000000;
Description: The PMOVMSKB instruction returns a 8-bit mask formed of the most significant bits of each byte
of its source operand.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception; #AC for unaligned
memory reference. To enable #AC exceptions, three conditions must be true(CR0.AM is set;
EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU
exception.
Same exceptions as in Real Address Mode; #PF (fault-code) for a page fault; #AC for unaligned
memory reference if the current privilege level is 3.
Description: The PMULHUW instruction multiplies the four unsigned words in the destination operand with the
four unsigned words in the source operand. The high-order 16 bits of the 32-bit intermediate results
are written to the destination operand.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception; #AC for unaligned
memory reference. To enable #AC exceptions, three conditions must be true(CR0.AM is set;
EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU
exception.
Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault; #AC for unaligned
memory reference if the current privilege level is 3.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
mm1[31:16] = 0x00000000;
mm1[47:32] = 0x00000000;
mm1[63:48] = 0x00000000;
Description: The PSADBW instruction computes the absolute value of the difference of unsigned bytes for mm1
and mm2/m64. These differences are then summed to produce a word result in the lower 16-bit
field; the upper 3 words are cleared.
The destination operand is a MMX technology register. The source operand can either be a MMX
technology register or a 64-bit memory operand.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception; #AC for unaligned
memory reference. To enable #AC exceptions, three conditions must be true(CR0.AM is set;
EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU
exception.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Description: The PSHUF instruction uses the imm8 operand to select which of the four words in MM2/Mem
will be placed in each of the words in MM1. Bits 1 and 0 of imm8 encode the source for destination
word 0 (MM1[15-0]), bits 3 and 2 encode for word 1, bits 5 and 4 encode for word 2, and bits 7 and
6 encode for word 3 (MM1[63-48]). Similarly, the two bit encoding represents which source word
is to be used, e.g. an binary encoding of 10 indicates that source word 2 (MM2/Mem[47-32]) will
be used.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception; #AC for unaligned
memory reference. To enable #AC exceptions, three conditions must be true(CR0.AM is set;
EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU
exception.
Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault; #AC for unaligned
memory reference if the current privilege level is 3.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault
Description: Data is stored from the mm1 register to the location specified by the di/edi register (using DS
segment). The size of the store address depends on the address-size attribute. The most significant
bit in each byte of the mask register mm2 is used to selectively write the data (0 = no write,
1 = write), on a per-byte basis. Behavior with a mask of all zeroes is as follows:
• No data will be written to memory. However, transition from FP to MMX technology state (if
necessary) will occur, irrespective of the value of the mask.
• For memory references, a zero byte mask does not prevent addressing faults (i.e. #GP, #SS)
from being signalled.
• Signalling of page faults (#PF) is implementation specific.
• #UD, #NM, #MF, and #AC faults are signalled irrespective of the value of the mask.
• Signalling of breakpoints (code or data) is not guaranteed; different processor implementations
may signal or not signal these breakpoints.
• If the destination memory region is mapped as UC or WP, enforcement of associated semantics
for these memory types is not guaranteed (i.e. is reserved) and is implementation specific.
Dependency on the behavior of a specific implementation in this case is not recommended, and
may lead to future incompatibility.
The Mod field of the ModR/M byte must be 11, or an Invalid Opcode Exception will result.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception; #AC for unaligned
memory reference. To enable #AC exceptions, three conditions must be true(CR0.AM is set;
EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU
exception.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Comments: MASKMOVQ can be used to improve performance for algorithms which need to merge data on a
byte granularity.MASKMOVQ should not cause a read for ownership; doing so generates
unnecessary bandwidth since data is to be written directly using the byte-mask without allocating
old data prior to the store. Similar to the SSE non-temporal store instructions, MASKMOVQ
minimizes pollution of the cache hierarchy. MASKMOVQ implicitly uses weakly-ordered,
write-combining stores (WC). See Section 3.6.1.9, “Cacheability Control Instructions” for further
information about non-temporal stores.
This instruction behaves identically to MMX technology instructions, in the presence of x87-FP
instructions: transition from x87-FP to MMX technology (TOS=0, FP valid bits set to all valid).
MASMOVQ ignores the value of CR4.OSFXSR. Since it does not affect the new SSE state, they
will not generate an invalid exception if CR4.OSFXSR = 0.
Description: The linear address corresponds to the address of the least-significant byte of the referenced memory
data. This store instruction minimizes cache pollution.
FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.
#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; #UD if CR0.EM =
1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #UD if CRCR4.OSFXSR(bit 9) = 0;
#UD if CPUID.XMM(EDX bit 25) = 0.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault, Data
Dirty Bit Fault
Comments: MOVTNPS should be used when dealing with 16-byte aligned single-precision FP numbers.
MOVNTPS minimizes pollution in the cache hierarchy. As a consequence of the resulting
weakly-ordered memory consistency model, a fencing operation should be used if multiple
processors may use different memory types to read/write the memory location. See Section 3.6.1.9,
“Cacheability Control Instructions” for further information about non-temporal stores.
The usage of Repeat Prefixes(F2H, F3H) with MOVNTPS is reserved. Different processor
implementations may handle this prefix differently. Usage of this prefix with MOVNTPS risks
incompatibility with future processors.
Description: The linear address corresponds to the address of the least-significant byte of the referenced memory
data. This store instruction minimizes cache pollution.
#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; #UD if CR0.EM
= 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU exception; #AC for unaligned
memory reference. To enable #AC exceptions, three conditions must be true(CR0.AM is set;
EFLAGS.AC is set; current CPL is 3).
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to
0FFFFH; #UD if CR0.EM = 1; #NM if TS bit in CR0 is set; #MF if there is a pending FPU
exception.
Same exceptions as in Real Address Mode; #AC for unaligned memory reference if the current
privilege level is 3; #PF (fault-code) for a page fault.
Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Fault
Itanium Mem Faults VHPT Data Fault, Data TLB Fault, Alternate Data TLB Fault, Data Page Not
Present Fault, Data NaT Page Consumption Abort, Data Key Miss Fault, Data
Key Permission Fault, Data Access Rights Fault, Data Access Bit Fault, Data
Dirty Bit Fault
Comments: MOVNTQ minimizes pollution in the cache hierarchy. As a consequence of the resulting
weakly-ordered memory consistency model, a fencing operation should be used if multiple
processors may use different memory types to read/write the memory location. See Section 3.6.1.9,
“Cacheability Control Instructions” for further information about non-temporal stores.
MOVNTQ ignores the value of CR4.OSFXSR. Since it does not affect the new SSE state, they will
not generate an invalid exception if CR4.OSFXSR = 0.
Description: If there are no excepting conditions, the prefetch instruction fetches the line containing the
addresses byte to a location in the cache hierarchy specified by a locality hint. If the line is already
present in the cache hierarchy at a level closer to the processor, no data movement occurs. The bits
5:3 of the ModR/M byte specify locality hints as follows:
• Temporal data(t0) - prefetch data into all cache levels.
• Temporal with respect to first level cache (t1) – prefetch data in all cache levels except 0th
cache level.
• Temporal with respect to second level cache (t2) – prefetch data in all cache levels, except 0th
and 1st cache levels.
• Non-temporal with respect to all cache levels (nta) – prefetch data into non-temporal cache
structure.
Locality hints do not affect the functional behavior of the program. They are implementation
dependent, and can be overloaded or ignored by an implementation. The prefetch instruction does
not cause any exceptions (except for code breakpoints), does not affect program behavior and may
be ignored by the implementation. The amount of data prefetched is implementation dependent. It
will however be a minimum of 32 bytes. Prefetches to uncacheable memory (UC or WC memory
types) will be ignored. Additional ModRM encodings, besides those specified above, are defined to
be reserved and the use of reserved encodings risks future incompatibility.
Comments: This instruction is merely a hint.If executed, this instruction moves data closer to the processor in
anticipation of future use. The performance of these instructions in application code can be
implementation specific. To achieve maximum speedup, code tuning might be necessary for each
implementation. The non temporal hint also minimizes pollution of useful cache data.
PREFETCH instructions ignore the value of CR4.OSFXSR. Since they do not affect the new SSE
state, they will not generate an invalid exception if CR4.OSFXSR = 0.
Description: Weakly ordered memory types can enable higher performance through such techniques as
out-of-order issue, write-combining, and write-collapsing. Memory ordering issues can arise
between a producer and a consumer of data and there are a number of common usage models which
may be affected by weakly ordered stores: (1) library functions, which use weakly ordered memory
to write results (2) compiler-generated code, which also benefit from writing weakly-ordered
results, and (3) hand-written code. The degree to which a consumer of data knows that the data is
weakly ordered can vary for these cases. As a result, the SFENCE instruction provides a
performance-efficient way of ensuring ordering between routines that produce weakly-ordered
results and routines that consume this data.
All other ModRM encodings are defined to be reserved, and use of these encodings risks
incompatibility with future processors.
Comments: SFENCE ignores the value of CR4.OSFXSR. SFENCE will not generate an invalid exception if
CR4.OSFXSR = 0
Symbols 2:595
32-bit virtual addressing 2:67 addressable units 1:33
pointer “swizzling” model 2:67, 2:68 advanced load address table 1:59, 1:64, 2:524
sign-extension model 2:67 ALAT 1:59, 1:60, 1:61, 1:62, 1:63, 1:64, 1:148, 1:190,
zero-extension model 2:67 2:82, 2:83, 2:84, 2:141, 2:142, 2:523, 2:524,
2:528, 2:542, 2:595, 3:323, 3:359, 3:367,
A 3:374
data speculation 1:59, 1:60, 1:64, 1:148, 2:553
AAA instruction 3:391 related instructions 1:60
AAD instruction 3:392 alloc 1:16, 1:39, 1:41, 1:44, 1:45, 1:46, 1:50, 1:71,
AAM instruction 3:393 1:140, 2:65, 2:83, 2:131, 2:133, 2:134, 2:139,
AAS instruction 3:394 2:140, 2:141, 3:18, 3:326, 3:328, 3:359,
abort 2:91, 2:514, 3:399, 3:401, 3:403, 3:405, 3:407, 3:360, 3:366, 3:367, 3:368, 3:373, 3:378,
3:411, 3:412, 3:414, 3:416, 3:425, 3:476, 3:379
3:511, 3:544, 3:549, 3:550, 3:554, 3:557, and 3:20
3:558, 3:561, 3:563, 3:565, 3:567, 3:570, AND instruction 3:399, 3:642
3:572, 3:575, 3:579, 3:581, 3:582, 3:585, andcm 3:21
3:607, 3:617, 3:621, 3:623, 3:626, 3:629, application programming model 1:43
3:630, 3:642, 3:645, 3:647, 3:650, 3:656,
application register
3:663, 3:664, 3:665, 3:667, 3:669, 3:672,
3:674, 3:677, 3:680, 3:683, 3:686, 3:689, Backing Store Pointer (read-only) (BSP – AR 17)
3:691, 3:694, 3:696, 3:699, 3:704, 3:706, 1:26
3:709, 3:714, 3:717, 3:720, 3:722, 3:723, Backing Store Pointer for Memory Stores
3:725, 3:727, 3:733, 3:735, 3:747, 3:749, (BSPSTORE – AR 18) 1:26
3:751, 3:755, 3:761, 3:763, 3:765, 3:767, Compare and Exchange Compare Value Register
3:772, 3:773, 3:776, 3:778, 3:781, 3:784, (CCV – AR 32) 1:26, 1:28
3:787, 3:789, 3:791, 3:794, 3:797, 3:799, Epilog Count Register (EC – AR 66) 1:26, 1:30
3:801, 3:803, 3:805, 3:808, 3:811, 3:814, Floating-point Status Register (FPSR – AR 40) 1:26,
3:817, 3:820, 3:823, 3:826, 3:829, 3:831, 1:29
3:855, 3:856, 3:857, 3:858, 3:860, 3:863, IA-32 Code Segment Descriptor / Compare and Store
3:866, 3:867, 3:869, 3:871, 3:872, 3:873, Data register (CSD – AR 25) 1:26
3:875, 3:876, 3:877, 3:880, 3:884, 3:886, IA-32 Combined CR0 and CR4 register (CFLG – AR
3:888, 3:890, 3:892, 3:894, 3:896, 3:899, 27) 1:26
3:902, 3:905, 3:907, 3:908, 3:909, 3:910, IA-32 Floating-point Control Register (FCR – AR 21)
3:911, 3:913, 3:915, 3:916, 3:918, 3:919, 1:26
3:920, 3:921, 3:922, 3:923, 3:925, 3:927, IA-32 Floating-point Data Register (FDR – AR 30)
3:929, 3:930, 3:932, 3:934, 3:935, 3:936, 1:26
3:937, 3:938, 3:940, 3:942, 3:943, 3:947, IA-32 Floating-point Instruction Register (FIR – AR
3:948 29) 1:26
IA-32 Floating-point Status Register (FSR – AR 28)
interruption priorities 2:104
1:26
machine check abort 2:599, 2:601
IA-32 Stack Segment Descriptor (SSD – AR 26) 1:26
PAL-based interruptions 2:91, 2:92, 2:93, 2:97,
IA-32 time stamp counter (TSC) 1:29, 1:114, 2:32,
2:108, 2:514
2:579
PSR.mc bit is 0 2:94
Interval Time Counter (ITC – AR 44) 1:26, 1:29
reset abort 2:591
Kernel Registers 0-7 (KR 0-7 – AR 0-7) 1:26, 1:27
abort handling 2:601 Loop Count Register (LC – AR 65) 1:26, 1:30
Access rights, segment descriptor 3:622 Previous Function State (PFS – AR 64) 1:26, 1:29
acquire semantics 1:68, 2:79, 2:257, 2:483 Register Stack Configuration Register (RSC – AR 16)
ADC instruction 3:395, 3:642 1:26, 1:27
add 1:47, 1:49, 1:75, 1:149, 1:181, 3:16, 3:281, RSE backing store pointer (BSP – AR 17) 1:27
3:373, 3:378, 3:395, 3:396, 3:397, 3:398, RSE NaT Collection Register (RNAT – AR 19) 1:26,
3:457, 3:470, 3:471, 3:472, 3:582, 3:642, 1:28
3:761, 3:762, 3:780, 3:781, 3:782, 3:783, User NaT Collection Register (UNAT – AR 36) 1:26,
3:784, 3:785, 3:786, 3:787, 3:788, 3:799, 1:28
3:800, 3:855, 3:856, 3:932 application register state 1:21
ADD instruction 3:395, 3:397, 3:457, 3:642 application register model 1:23
addp4 3:17 ignored fields 1:22
address space model 2:533, 2:537 ignored register 1:21, 1:22, 1:31
read-only register 1:22, 1:27, 2:118
reserved fields 1:22, 3:853