0% found this document useful (0 votes)
31 views

Itanium2 Software Developer's Manual - V3

Uploaded by

Sun minggang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Itanium2 Software Developer's Manual - V3

Uploaded by

Sun minggang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 986

Intel® Itanium® Architecture

Software Developer’s Manual


Volume 3: Instruction Set Reference

Revision 2.2

January 2006

Document Number: 245319-005


THIS DOCUMENT IS PROVIDED “AS IS” WITH NO WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY,
FITNESS FOR ANY PARTICULAR PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR
SAMPLE.
INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL® PRODUCTS. NO LICENSE, EXPRESS OR IMPLIED, BY
ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN
INTEL'S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER, AND INTEL DISCLAIMS
ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES
RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER
INTELLECTUAL PROPERTY RIGHT. INTEL PRODUCTS ARE NOT INTENDED FOR USE IN MEDICAL, LIFE SAVING, OR LIFE SUSTAINING
APPLICATIONS.
Intel may make changes to specifications and product descriptions at any time, without notice.
Designers must not rely on the absence or characteristics of any features or instructions marked "reserved" or "undefined." Intel reserves these for
future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising from future changes to them.
Intel processors based on the Itanium architecture may contain design defects or errors known as errata which may cause the product to deviate from
published specifications. Current characterized errata are available on request.
Contact your local Intel sales office or your distributor to obtain the latest specifications and before placing your product order.
Copies of documents which have an order number and are referenced in this document, or other Intel literature, may be obtained by calling
1-800-548-4725, or by visiting Intel's website at http://www.intel.com.
Intel, Intel486, Itanium, Pentium, VTune and MMX are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States
and other countries.
Copyright © 2000-2005, Intel Corporation. All rights reserved.
*Other names and brands may be claimed as the property of others.

ii Volume 3: Intel® Itanium® Architecture Software Developer’s Manual


Contents
Part I: Intel® Itanium® Instruction Set Descriptions

1 About this Manual .................................................................................................................. 3:1


1.1 Overview of Volume 1: Application Architecture.......................................................... 3:1
1.1.1 Part 1: Application Architecture Guide ........................................................... 3:1
1.1.2 Part 2: Optimization Guide for the Intel® Itanium® Architecture ..................... 3:2
1.2 Overview of Volume 2: System Architecture ............................................................... 3:2
1.2.1 Part 1: System Architecture Guide ................................................................. 3:2
1.2.2 Part 2: System Programmer’s Guide.............................................................. 3:3
1.2.3 Appendices..................................................................................................... 3:4
1.3 Overview of Volume 3: Instruction Set Reference ....................................................... 3:4
1.3.1 Part 1: Intel® Itanium® Instruction Set Descriptions ....................................... 3:4
1.3.2 Part 2: IA-32 Instruction Set Descriptions....................................................... 3:4
1.4 Terminology................................................................................................................. 3:5
1.5 Related Documents ..................................................................................................... 3:5
1.6 Revision History .......................................................................................................... 3:6

2 Instruction Reference .......................................................................................................... 3:11


2.1 Instruction Page Conventions ................................................................................... 3:11
2.2 Instruction Descriptions ............................................................................................. 3:13

3 Pseudo-Code Functions .................................................................................................... 3:259

4 Instruction Formats............................................................................................................ 3:271


4.1 Format Summary..................................................................................................... 3:272
4.2 A-Unit Instruction Encodings ................................................................................... 3:278
4.2.1 Integer ALU ................................................................................................ 3:278
4.2.2 Integer Compare ........................................................................................ 3:281
4.2.3 Multimedia .................................................................................................. 3:284
4.3 I-Unit Instruction Encodings .................................................................................... 3:288
4.3.1 Multimedia and Variable Shifts ................................................................... 3:288
4.3.2 Integer Shifts .............................................................................................. 3:293
4.3.3 Test Bit ....................................................................................................... 3:295
4.3.4 Miscellaneous I-Unit Instructions................................................................ 3:296
4.3.5 GR/BR Moves ............................................................................................ 3:299
4.3.6 GR/Predicate/IP Moves .............................................................................. 3:300
4.3.7 GR/AR Moves (I-Unit)................................................................................. 3:300
4.3.8 Sign/Zero Extend/Compute Zero Index ...................................................... 3:301
4.3.9 Test Feature ............................................................................................... 3:302
4.4 M-Unit Instruction Encodings .................................................................................. 3:302
4.4.1 Loads and Stores ....................................................................................... 3:302
4.4.2 Line Prefetch .............................................................................................. 3:316
4.4.3 Semaphores ............................................................................................... 3:318
4.4.4 Set/Get FR ................................................................................................. 3:319

Volume 3: Intel® Itanium® Architecture Software Developer’s Manual iii


4.4.5 Speculation and Advanced Load Checks....................................................3:320
4.4.6 Cache/Synchronization/RSE/ALAT .............................................................3:321
4.4.7 GR/AR Moves (M-Unit) ...............................................................................3:322
4.4.8 GR/CR Moves .............................................................................................3:323
4.4.9 Miscellaneous M-Unit Instructions...............................................................3:324
4.4.10 System/Memory Management ....................................................................3:325
4.4.11 Nop/Hint (M-Unit) ........................................................................................3:330
4.5 B-Unit Instruction Encodings ....................................................................................3:330
4.5.1 Branches .....................................................................................................3:331
4.5.2 Branch Predict/Nop/Hint..............................................................................3:334
4.5.3 Miscellaneous B-Unit Instructions ...............................................................3:336
4.6 F-Unit Instruction Encodings ....................................................................................3:337
4.6.1 Arithmetic ....................................................................................................3:340
4.6.2 Parallel Floating-point Select.......................................................................3:341
4.6.3 Compare and Classify .................................................................................3:341
4.6.4 Approximation .............................................................................................3:342
4.6.5 Minimum/Maximum and Parallel Compare .................................................3:343
4.6.6 Merge and Logical.......................................................................................3:344
4.6.7 Conversion ..................................................................................................3:344
4.6.8 Status Field Manipulation ............................................................................3:345
4.6.9 Miscellaneous F-Unit Instructions ...............................................................3:346
4.7 X-Unit Instruction Encodings ....................................................................................3:346
4.7.1 Miscellaneous X-Unit Instructions ...............................................................3:346
4.7.2 Move Long Immediate64................................................................................................... 3:347
4.7.3 Long Branches ............................................................................................3:348
4.7.4 Nop/Hint (X-Unit) .........................................................................................3:349
4.8 Immediate Formation ...............................................................................................3:349

5 Resource and Dependency Semantics ............................................................................ 3:353


5.1 Reading and Writing Resources...............................................................................3:353
5.2 Dependencies and Serialization...............................................................................3:353
5.3 Resource and Dependency Table Format Notes .....................................................3:354
5.3.1 Special Case Instruction Rules ...................................................................3:356
5.3.2 RAW Dependency Table.............................................................................3:356
5.3.3 WAW Dependency Table ............................................................................3:365
5.3.4 WAR Dependency Table.............................................................................3:369
5.3.5 Listing of Rules Referenced in Dependency Tables ...................................3:369
5.4 Support Tables .........................................................................................................3:371

Part II: IA-32 Instruction Set Descriptions

1 Base IA-32 Instruction Reference ..................................................................................... 3:381


1.1 Additional Intel® Itanium® Faults ..............................................................................3:381
1.2 Interpreting the IA-32 Instruction Reference Pages .................................................3:382
1.2.1 IA-32 Instruction Format..............................................................................3:382
1.2.2 Operation.....................................................................................................3:385
1.2.3 Flags Affected .............................................................................................3:388
1.2.4 FPU Flags Affected .....................................................................................3:388

iv Volume 3: Intel® Itanium® Architecture Software Developer’s Manual


1.2.5 Protected Mode Exceptions ....................................................................... 3:389
1.2.6 Real-address Mode Exceptions ................................................................. 3:389
1.2.7 Virtual-8086 Mode Exceptions ................................................................... 3:390
1.2.8 Floating-point Exceptions ........................................................................... 3:390
1.3 IA-32 Base Instruction Reference ........................................................................... 3:390

2 IA-32 Intel® MMX™ Technology Instruction Reference .................................................. 3:769

3 IA-32 SSE Instruction Reference ...................................................................................... 3:833


3.1 IA-32 SSE Instructions ............................................................................................ 3:833
3.2 About the Intel® SSE Architecture........................................................................... 3:833
3.3 Single Instruction Multiple Data ............................................................................... 3:834
3.4 New Data Types...................................................................................................... 3:834
3.5 SSE Registers ......................................................................................................... 3:835
3.6 Extended Instruction Set ......................................................................................... 3:835
3.6.1 Instruction Group Review ........................................................................... 3:836
3.7 IEEE Compliance .................................................................................................... 3:843
3.7.1 Real Number System ................................................................................. 3:844
3.7.2 Operating on NaNs..................................................................................... 3:849
3.8 Data Formats........................................................................................................... 3:850
3.8.1 Memory Data Formats................................................................................ 3:850
3.8.2 SSE Register Data Formats ....................................................................... 3:850
3.9 Instruction Formats.................................................................................................. 3:852
3.10 Instruction Prefixes.................................................................................................. 3:852
3.11 Reserved Behavior and Software Compatibility ...................................................... 3:853
3.12 Notations ................................................................................................................. 3:853
3.13 SIMD Integer Instruction Set Extensions................................................................. 3:930
3.14 Cacheability Control Instructions ............................................................................. 3:944

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

Volume 3: Intel® Itanium® Architecture Software Developer’s Manual v


2-18 Floating-point Swap ..............................................................................................................3:124
2-19 Floating-point Swap Negate Left ...........................................................................................3:124
2-20 Floating-point Swap Negate Right ........................................................................................3:125
2-21 Floating-point Sign Extend Left .............................................................................................3:126
2-22 Floating-point Sign Extend Right...........................................................................................3:126
2-23 Function of getf.exp...............................................................................................................3:130
2-24 Function of getf.sig ................................................................................................................3:130
2-25 Mix Examples ........................................................................................................................3:156
2-26 Mux1 Operation (8-bit elements)...........................................................................................3:174
2-27 Mux2 Examples (16-bit elements).........................................................................................3:175
2-28 Pack Operation .....................................................................................................................3:179
2-29 Parallel Add Examples ..........................................................................................................3:181
2-30 Parallel Average Example .....................................................................................................3:184
2-31 Parallel Average with Round Away from Zero Example........................................................3:185
2-32 Parallel Average Subtract Example ......................................................................................3:187
2-33 Parallel Compare Examples..................................................................................................3:189
2-34 Parallel Maximum Examples .................................................................................................3:191
2-35 Parallel Minimum Examples ..................................................................................................3:192
2-36 Parallel Multiply Operation ....................................................................................................3:193
2-37 Parallel Multiply and Shift Right Operation............................................................................3:194
2-38 Parallel Sum of Absolute Difference Example.......................................................................3:199
2-39 Parallel Shift Left Examples ..................................................................................................3:200
2-40 Parallel Subtract Examples ...................................................................................................3:205
2-41 Function of setf.exp ...............................................................................................................3:220
2-42 Function of setf.sig ................................................................................................................3:220
2-43 Shift Left and Add Pointer .....................................................................................................3:224
2-44 Shift Right Pair ......................................................................................................................3:226
2-45 Unpack Operation .................................................................................................................3:248
4-1 Bundle Format.......................................................................................................................3:271

Part II: IA-32 Instruction Set Descriptions


1-1 Bit Offset for BIT[EAX,21] .....................................................................................................3:388
1-2 Memory Bit Indexing .............................................................................................................3:388
1-3 Version Information in Registers EAX ...................................................................................3:449
2-1 Operation of the MOVD Instruction .......................................................................................3:771
2-2 Operation of the MOVQ Instruction .......................................................................................3:773
2-3 Operation of the PACKSSDW Instruction .............................................................................3:775
2-4 Operation of the PACKUSWB Instruction .............................................................................3:778
2-5 Operation of the PADDW Instruction ....................................................................................3:780
2-6 Operation of the PADDSW Instruction ..................................................................................3:783
2-7 Operation of the PADDUSB Instruction ................................................................................3:786
2-8 Operation of the PAND Instruction ........................................................................................3:789
2-9 Operation of the PANDN Instruction .....................................................................................3:791
2-10 Operation of the PCMPEQW Instruction ...............................................................................3:793
2-11 Operation of the PCMPGTW Instruction ...............................................................................3:796
2-12 Operation of the PMADDWD Instruction ...............................................................................3:799
2-13 Operation of the PMULHW Instruction ..................................................................................3:801
2-14 Operation of the PMULLW Instruction ..................................................................................3:803
2-15 Operation of the POR Instruction. .........................................................................................3:805
2-16 Operation of the PSLLW Instruction......................................................................................3:807
2-17 Operation of the PSRAW Instruction.....................................................................................3:810

vi Volume 3: Intel® Itanium® Architecture Software Developer’s Manual


2-18 Operation of the PSRLW Instruction .................................................................................... 3:813
2-19 Operation of the PSUBW Instruction.................................................................................... 3:816
2-20 Operation of the PSUBSW Instruction ................................................................................. 3:819
2-21 Operation of the PSUBUSB Instruction................................................................................ 3:822
2-22 High-order Unpacking and Interleaving of Bytes with the PUNPCKHBW Instruction .......... 3:825
2-23 Low-order Unpacking and Interleaving of Bytes with the PUNPCKLBW Instruction ............ 3:828
2-24 Operation of the PXOR Instruction....................................................................................... 3:831
3-1 Packed Single-FP Data Type ............................................................................................... 3:834
3-2 SSE Register Set ................................................................................................................. 3:835
3-3 Packed Operation................................................................................................................. 3:836
3-4 Scalar Operation .................................................................................................................. 3:836
3-5 Packed Shuffle Operation .................................................................................................... 3:838
3-6 Unpack High Operation ........................................................................................................ 3:839
3-7 Unpack Low Operation......................................................................................................... 3:839
3-8 Binary Real Number System ................................................................................................ 3:844
3-9 Binary Floating-point Format ................................................................................................ 3:845
3-10 Real Numbers and NaNs ..................................................................................................... 3:847
3-11 Four Packed FP Data in Memory (at address 1000H) ......................................................... 3:850

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

Volume 3: Intel® Itanium® Architecture Software Developer’s Manual vii


2-30 Floating-point Parallel Comparison Relations ......................................................................3:94
2-31 Hint Immediates .................................................................................................................3:132
2-32 sz Completers ....................................................................................................................3:138
2-33 Load Types.........................................................................................................................3:138
2-34 Load Hints ..........................................................................................................................3:139
2-35 fsz Completers ...................................................................................................................3:143
2-36 FP Load Types ...................................................................................................................3:143
2-37 lftype Mnemonic Values .....................................................................................................3:150
2-38 lfhint Mnemonic Values ......................................................................................................3:151
2-39 Move to BR Whether Hints.................................................................................................3:160
2-40 Indirect Register File Mnemonics .......................................................................................3:166
2-41 Mux Permutations for 8-bit Elements .................................................................................3:174
2-42 Pack Saturation Limits........................................................................................................3:179
2-43 Parallel Add Saturation Completers ...................................................................................3:181
2-44 Parallel Add Saturation Limits ............................................................................................3:181
2-45 Pcmp Relations ..................................................................................................................3:189
2-46 Parallel Multiply and Shift Right Shift Options ....................................................................3:194
2-47 Parallel Subtract Saturation Completers ............................................................................3:205
2-48 Parallel Subtract Saturation Limits .....................................................................................3:205
2-49 Store Types ........................................................................................................................3:229
2-50 Store Hints..........................................................................................................................3:230
2-51 xsz Mnemonic Values ........................................................................................................3:235
2-52 Test Bit Relations for Normal and unc tbits ........................................................................3:238
2-53 Test Bit Relations for Parallel tbits .....................................................................................3:238
2-54 Test Feature Relations for Normal and unc tf ....................................................................3:240
2-55 Test Feature Relations for Parallel tf..................................................................................3:240
2-56 Test Feature Features Assignment ....................................................................................3:240
2-57 Test NaT Relations for Normal and unc tnats ....................................................................3:243
2-58 Test NaT Relations for Parallel tnats..................................................................................3:243
2-59 Memory Exchange Size .....................................................................................................3:251
3-1 Pseudo-code Functions......................................................................................................3:259
4-1 Relationship between Instruction Type and Execution Unit Type ......................................3:271
4-2 Template Field Encoding and Instruction Slot Mapping .....................................................3:272
4-3 Major Opcode Assignments ...............................................................................................3:273
4-4 Instruction Format Summary ..............................................................................................3:274
4-5 Instruction Field Color Key .................................................................................................3:276
4-6 Instruction Field Names......................................................................................................3:276
4-7 Special Instruction Notations..............................................................................................3:277
4-8 Integer ALU 2-bit+1-bit Opcode Extensions .......................................................................3:279
4-9 Integer ALU 4-bit+2-bit Opcode Extensions .......................................................................3:279
4-10 Integer Compare Opcode Extensions ................................................................................3:281
4-11 Integer Compare Immediate Opcode Extensions ..............................................................3:281
4-12 Multimedia ALU 2-bit+1-bit Opcode Extensions.................................................................3:284
4-13 Multimedia ALU Size 1 4-bit+2-bit Opcode Extensions......................................................3:285
4-14 Multimedia ALU Size 2 4-bit+2-bit Opcode Extensions......................................................3:285
4-15 Multimedia ALU Size 4 4-bit+2-bit Opcode Extensions......................................................3:286
4-16 Multimedia and Variable Shift 1-bit Opcode Extensions ....................................................3:288
4-17 Multimedia Opcode 7 Size 1 2-bit Opcode Extensions ......................................................3:288
4-18 Multimedia Opcode 7 Size 2 2-bit Opcode Extensions ......................................................3:289
4-19 Multimedia Opcode 7 Size 4 2-bit Opcode Extensions ......................................................3:289
4-20 Variable Shift Opcode 7 2-bit Opcode Extensions .............................................................3:290
4-21 Integer Shift/Test Bit/Test NaT 2-bit Opcode Extensions...................................................3:293

viii Volume 3: Intel® Itanium® Architecture Software Developer’s Manual


4-22 Deposit Opcode Extensions .............................................................................................. 3:293
4-23 Test Bit Opcode Extensions .............................................................................................. 3:295
4-24 Misc I-Unit 3-bit Opcode Extensions ................................................................................. 3:296
4-25 Misc I-Unit 6-bit Opcode Extensions ................................................................................. 3:297
4-26 Misc I-Unit 1-bit Opcode Extensions ................................................................................. 3:297
4-27 Move to BR Whether Hint Completer ................................................................................ 3:299
4-28 Integer Load/Store/Semaphore/Get FR 1-bit Opcode Extensions .................................... 3:302
4-29 Floating-point Load/Store/Load Pair/Set FR 1-bit Opcode Extensions ............................. 3:302
4-30 Integer Load/Store Opcode Extensions............................................................................. 3:303
4-31 Integer Load +Reg Opcode Extensions ............................................................................ 3:303
4-32 Integer Load/Store +Imm Opcode Extensions .................................................................. 3:304
4-33 Semaphore/Get FR/16-Byte Opcode Extensions.............................................................. 3:304
4-34 Floating-point Load/Store/Lfetch Opcode Extensions ....................................................... 3:305
4-35 Floating-point Load/Lfetch +Reg Opcode Extensions ....................................................... 3:305
4-36 Floating-point Load/Store/Lfetch +Imm Opcode Extensions ............................................. 3:306
4-37 Floating-point Load Pair/Set FR Opcode Extensions ........................................................ 3:306
4-38 Floating-point Load Pair +Imm Opcode Extensions .......................................................... 3:307
4-39 Load Hint Completer.......................................................................................................... 3:307
4-40 Store Hint Completer ......................................................................................................... 3:307
4-41 Line Prefetch Hint Completer ............................................................................................ 3:316
4-42 Opcode 0 System/Memory Management 3-bit Opcode Extensions.................................. 3:325
4-43 Opcode 0 System/Memory Management 4-bit+2-bit Opcode Extensions......................... 3:326
4-44 Opcode 1 System/Memory Management 3-bit Opcode Extensions.................................. 3:326
4-45 Opcode 1 System/Memory Management 6-bit Opcode Extensions.................................. 3:327
4-46 Misc M-Unit 1-bit Opcode Extensions ............................................................................... 3:330
4-47 IP-Relative Branch Types.................................................................................................. 3:331
4-48 Indirect/Miscellaneous Branch Opcode Extensions .......................................................... 3:331
4-49 Indirect Branch Types........................................................................................................ 3:332
4-50 Indirect Return Branch Types............................................................................................ 3:332
4-51 Sequential Prefetch Hint Completer .................................................................................. 3:332
4-52 Branch Whether Hint Completer........................................................................................ 3:332
4-53 Indirect Call Whether Hint Completer ................................................................................ 3:333
4-54 Branch Cache Deallocation Hint Completer ...................................................................... 3:333
4-55 Indirect Predict/Nop/Hint Opcode Extensions ................................................................... 3:335
4-56 Branch Importance Hint Completer ................................................................................... 3:335
4-57 IP-Relative Predict Whether Hint Completer ..................................................................... 3:335
4-58 Indirect Predict Whether Hint Completer ........................................................................... 3:336
4-59 Miscellaneous Floating-point 1-bit Opcode Extensions..................................................... 3:337
4-60 Opcode 0 Miscellaneous Floating-point 6-bit Opcode Extensions .................................... 3:338
4-61 Opcode 1 Miscellaneous Floating-point 6-bit Opcode Extensions .................................... 3:338
4-62 Reciprocal Approximation 1-bit Opcode Extensions ......................................................... 3:339
4-63 Floating-point Status Field Completer ............................................................................... 3:339
4-64 Floating-point Arithmetic 1-bit Opcode Extensions............................................................ 3:340
4-65 Fixed-point Multiply Add and Select Opcode Extensions .................................................. 3:340
4-66 Floating-point Compare Opcode Extensions..................................................................... 3:341
4-67 Floating-point Class 1-bit Opcode Extensions................................................................... 3:341
4-68 Misc F-Unit 1-bit Opcode Extensions ................................................................................ 3:346
4-69 Misc X-Unit 3-bit Opcode Extensions ................................................................................ 3:347
4-70 Misc X-Unit 6-bit Opcode Extensions ................................................................................ 3:347
4-71 Move Long 1-bit Opcode Extensions................................................................................. 3:348
4-72 Long Branch Types ........................................................................................................... 3:348
4-73 Misc X-Unit 1-bit Opcode Extensions ................................................................................ 3:349

Volume 3: Intel® Itanium® Architecture Software Developer’s Manual ix


4-74 Immediate Formation .........................................................................................................3:349
5-1 Semantics of Dependency Codes ......................................................................................3:355
5-2 RAW Dependencies Organized by Resource ....................................................................3:357
5-3 WAW Dependencies Organized by Resource ...................................................................3:365
5-4 WAR Dependencies Organized by Resource ....................................................................3:369
5-5 Instruction Classes .............................................................................................................3:371

Part II: IA-32 Instruction Set Descriptions


1-1 Register Encodings Associated with the +rb, +rw, and +rd Nomenclature ........................3:383
1-2 Exception Mnemonics, Names, and Vector Numbers........................................................3:389
1-3 Floating-point Exception Mnemonics and Names ..............................................................3:390
1-4 Information Returned by CPUID Instruction .......................................................................3:448
1-5 Feature Flags Returned in EDX Register...........................................................................3:450
1-6 FPATAN Zeros and NaNs ..................................................................................................3:519
1-7 FPREM Zeros and NaNs....................................................................................................3:521
1-8 FPREM1 Zeros and NaNs..................................................................................................3:524
1-9 FSUB Zeros and NaNs.......................................................................................................3:553
1-10 FSUBR Zeros and NaNs ....................................................................................................3:556
1-11 FYL2X Zeros and NaNs .....................................................................................................3:569
1-12 FYL2XP1 Zeros and NaNs.................................................................................................3:571
1-13 IDIV Operands....................................................................................................................3:574
1-14 INT Cases ..........................................................................................................................3:588
1-15 LAR Descriptor Validity ......................................................................................................3:623
1-16 LEA Address and Operand Sizes.......................................................................................3:628
1-17 Repeat Conditions..............................................................................................................3:708
3-1 Real Number Notation........................................................................................................3:845
3-2 Denormalization Process ...................................................................................................3:848
3-3 Results of Operations with NAN Operands ........................................................................3:850
3-4 Precision and Range of SSE Datatype ..............................................................................3:851
3-5 Real Number and NaN Encodings ....................................................................................3:851
3-6 SSE Instruction Behavior with Prefixes ..............................................................................3:852
3-7 SIMD Integer Instructions – Behavior with Prefixes ...........................................................3:852
3-8 Cacheability Control Instruction Behavior with Prefixes .....................................................3:852
3-9 Key to SSE Naming Convention ........................................................................................3:854

x Volume 3: Intel® Itanium® Architecture Software Developer’s Manual


Part I: Intel® Itanium® Instruction
Set Descriptions
3

About this Manual 1

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.

The Intel® Itanium® Architecture Software Developer’s Manual provides a comprehensive


description of the programming environment, resources, and instruction set visible to both the
application and system programmer. In addition, it also describes how programmers can take
advantage of the features of the Itanium architecture to help them optimize code.

1.1 Overview of Volume 1: Application Architecture


This volume defines the Itanium application architecture, including application level resources,
programming environment, and the IA-32 application interface. This volume also describes
optimization techniques used to generate high performance software.

1.1.1 Part 1: Application Architecture Guide


Chapter 1, “About this Manual” provides an overview of all volumes in the Intel® Itanium®
Architecture Software Developer’s Manual.

Chapter 2, “Introduction to the Intel® Itanium® Architecture” provides an overview of the


architecture.

Chapter 3, “Execution Environment” describes the Itanium register set used by applications and the
memory organization models.

Chapter 4, “Application Programming Model” gives an overview of the behavior of Itanium


application instructions (grouped into related functions).

Chapter 5, “Floating-point Programming Model” describes the Itanium floating-point architecture


(including integer multiply).

Chapter 6, “IA-32 Application Execution Model in an Intel® Itanium® System Environment”


describes the operation of IA-32 instructions within the Itanium System Environment from the
perspective of an application programmer.

Volume 3: About this Manual 3:1


1.1.2 Part 2: Optimization Guide for the Intel® Itanium®
Architecture
Chapter 1, “About the Optimization Guide” gives an overview of the optimization guide.

Chapter 2, “Introduction to Programming for the Intel® Itanium® Architecture” provides an


overview of the application programming environment for the Itanium architecture.

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 6, “Floating-point Applications” discusses current performance limitations in


floating-point applications and features that address these limitations.

1.2 Overview of Volume 2: System Architecture


This volume defines the Itanium system architecture, including system level resources and
programming state, interrupt model, and processor firmware interface. This volume also provides a
useful system programmer's guide for writing high performance system software.

1.2.1 Part 1: System Architecture Guide


Chapter 1, “About this Manual” provides an overview of all volumes in the Intel® Itanium®
Architecture Software Developer’s Manual.

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 7, “Debugging and Performance Monitoring” is an overview of the performance


monitoring and debugging resources that are available in the Itanium architecture.

3:2 Volume 3: About this Manual


Chapter 8, “Interruption Vector Descriptions” lists all interruption vectors.

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 10, “Itanium®Architecture-based Operating System Interaction Model with IA-32


Applications” defines the operation of IA-32 instructions within the Itanium System Environment
from the perspective of an Itanium architecture-based operating system.

Chapter 11, “Processor Abstraction Layer” describes the firmware layer which abstracts processor
implementation-dependent features.

1.2.2 Part 2: System Programmer’s Guide


Chapter 1, “About the System Programmer’s Guide” gives an introduction to the second section of
the system architecture guide.

Chapter 2, “MP Coherence and Synchronization” describes multiprocessing synchronization


primitives and the Itanium memory ordering model.

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 5, “Memory Management” introduces various memory management strategies.

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 9, “IA-32 Application Support” describes the support an Itanium architecture-based


operating system needs to provide to host IA-32 applications.

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.

Volume 3: About this Manual 3:3


Chapter 13, “Firmware Overview” introduces the firmware model, and how various firmware
layers (PAL, SAL, EFI) work together to enable processor and system initialization, and operating
system boot.

1.2.3 Appendices
Appendix A, “Code Examples” provides OS boot flow sample code.

1.3 Overview of Volume 3: Instruction Set Reference


This volume is a comprehensive reference to the Itanium instruction set, including instruction
format/encoding.

1.3.1 Part 1: Intel® Itanium® Instruction Set Descriptions


Chapter 1, “About this Manual” provides an overview of all volumes in the Intel® Itanium®
Architecture Software Developer’s Manual.

Chapter 2, “Instruction Reference” provides a detailed description of all Itanium instructions,


organized in alphabetical order by assembly language mnemonic.

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.

1.3.2 Part 2: IA-32 Instruction Set Descriptions


Chapter 1, “Base IA-32 Instruction Reference” provides a detailed description of all base IA-32
instructions, organized in alphabetical order by assembly language mnemonic.

Chapter 2, “IA-32 Intel® MMX™ Technology Instruction Reference” provides a detailed


description of all IA-32 Intel® MMX™ technology instructions designed to increase performance
of multimedia intensive applications. Organized in alphabetical order by assembly language
mnemonic.

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.

3:4 Volume 3: About this Manual


1.4 Terminology
The following definitions are for terms related to the Itanium architecture and will be used
throughout this document:

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.

1.5 Related Documents


The following documents can be downloaded at the Intel’s Developer Site at
http://developer.intel.com:
• Intel® Itanium® 2 Processor Reference Manual for Software Development and
Optimization – This document (Document number 251110) describes model-specific
architectural features incorporated into the Intel® Itanium® 2 processor, the second processor
based on the Itanium architecture.
• Intel® Itanium® Processor Reference Manual for Software Development – This document
(Document number 245320) describes model-specific architectural features incorporated into
the Intel® Itanium® processor, the first processor based on the Itanium architecture.
• IA-32 Intel® Architecture Software Developer’s Manual – This set of manuals describes the
Intel 32-bit architecture. They are available from the Intel Literature Department by calling
1-800-548-4725 and requesting Document Numbers 243190, 243191and 243192.
• Intel® Itanium® Software Conventions and Runtime Architecture Guide – This document
(Document number 245358) defines general information necessary to compile, link, and
execute a program on an Itanium architecture-based operating system.

Volume 3: About this Manual 3:5


• Intel® Itanium® Processor Family System Abstraction Layer Specification – This document
(Document number 245359) specifies requirements to develop platform firmware for Itanium
architecture-based systems.
• Extensible Firmware Interface Specification – This document defines a new model for the
interface between operating systems and platform firmware.

1.6 Revision History


Date of Revision
Description
Revision Number
December 2005 2.2 Added TF instruction in Vol 3 Ch 2.
Updated IA-32 CPUID I-page in Vol 4 Ch 2.
Add support for the absence of INIT, PMI, and LINT pins in Vol 2, Part I,
Section 5.8.
Add text to "ev" field of Vol 2, Section 7.2.1 Table 7.4 to define a PMU external
notification mechanism as implementation dependent.
Extensions to PAL procedures to support data poisoning in Vol 2, Part I, Ch
11.
Virtualization Addendum - Requires that processors have a way to
enable/disable vmsw instruction in Vol 2, Part I, Sections 2.2, 3.4 and 11.9.3.
Change the description of CR[IFA] and CR[ITIR] to provide hardware the
option of checking them for reserved values on a write. Also mention this
option in the description of the Translation Insertion Format.
Addition of new return status to PAL_TEST_PROC in Vol 2, Part I, Ch 11.
Fix small holes in INTA/XTP definition in Vol 2, Part I, Sections 5.8.4.3 and
5.8.4.4.
Virtualization Addendum - Unimplemented Virtual Address Checking in Vol 3
Ch 2.
Fix small discrepancies in the cmp8xchg16 definition in Vol 3 Ch 2.
Change rules about overlapping inserts to allow Itanium 2 behavior in Vol 2,
Part I, Section 4.1.8.
Update PAL_BUS_GET/SET_FEATURES bit 52 definition in Vol 2 Ch 11.
Allow register fields in CR.LID register to be read-only and CR.LID checking
on interruption messages by processors optional. See Vol 2, Part I, Ch 5
“Interruptions” and Section 11.2.2 PALE_RESET Exit State for details.
Relaxed reserved and ignored fields checkings in IA-32 application registers
in Vol 1 Ch 6 and Vol 2, Part I, Ch 10.
Introduced visibility constraints between stores and local purges to ensure
TLB consistency for UP VHPT update and local purge scenarios. See Vol 2,
Part I, Ch 4 and description of ptc.l instruction in Vol 3 for details.
Architecture extensions for processor Power/Performance states (P-states).
See Vol 2 PAL Chapter for details.
Introduced Unimplemented Instruction Address fault.
Relaxed ordering constraints for VHPT walks. See Vol 2, Part I, Ch 4 and 5 for
details.
Architecture extensions for processor virtualization.
All instructions which must be last in an instruction group results in undefined
behavior when this rule is violated.
Added architectural sequence that guarantees increasing ITC and PMD
values on successive reads.

3:6 Volume 3: About this Manual


Date of Revision
Description
Revision Number

December 2005 2.2 Addition of PAL_BRAND_INFO, PAL_GET_HW_POLICY,


(Continued) PAL_MC_ERROR_INJECT, PAL_MEMORY_BUFFER,
PAL_SET_HW_POLICY and PAL_SHUTDOWN procedures.
Allows IPI-redirection feature to be optional.
Undefined behavior for 1-byte accesses to the non-architected regions in the
IPI block.
Modified insertion behavior for TR overlaps. See Vol 2, Part I, Ch 4 for details.
“Bus parking” feature is now optional for PAL_BUS_GET_FEATURES.
FR32-127 is now preserved in PAL calling convention.
New return value from PAL_VM_SUMMARY procedure to indicate the
number of multiple concurrent outstanding TLB purges.
Performance Monitor Data (PMD) registers are no longer sign-extended.
New memory attribute transition sequence for memory on-line delete. See Vol
2, Part I, Ch 4 for details.
Added 'shared error' (se) bit to the Processor State Parameter (PSP) in
PAL_MC_ERROR_INFO procedure.
Clarified PMU interrupts as edge-triggered.
Modified ‘proc_number’ parameter in PAL_LOGICAL_TO_PHYSICAL
procedure.
Modified pal_copy_info alignment requirements.
New bit in PAL_PROC_GET_FEATURES for variable P-state performance.
Clarified descriptions for check_target_register and
check_target_register_sof.
Various fixes in dependency tables in Vol 3 Ch 5.
Clarified effect of sending IPIs to non-existent processor in Vol 2, Part I, Ch 5.
Clarified instruction serialization requirements for interruptions in Vol 2, Part II,
Ch 3.
Updated performance monitor context switch routine in Vol 2, Part I, Ch 7.
October 2002 2.1 Added New fc.i Instruction (Sections 4.4.6.1 and 4.4.6.2, Part I, Vol. 1;
Sections 4.3.3, 4.4.1, 4.4.5, 4.4.7, 5.5.2, and 7.1.2, Part I, Vol. 2; Sections 2.5,
2.5.1, 2.5.2, 2.5.3, and 4.5.2.1, Part II, Vol. 2; and Sections 2.2, 3, 4.1, 4.4.6.5,
and 4.4.10.10, Part I, Vol. 3).
Added New Atomic Operations ld16,st16,cmp8xchg16 (Sections 3.1.8,
3.1.8.6, 4.4.1, 4.4.2, and 4.4.3, Part I, Vol. 1; Section 4.5, Part I, Vol. 2; and
Sections 2.2, 3, 5.3.2, and 5.4, Part I, Vol. 3).
Added Spontaneous NaT Generation on Speculative Load (Sections 5.5.5
and 11.9, Part I, Vol. 2 and Sections 2.2 and 3, Part I, Vol. 3).
Added New Hint Instruction (Section 2.2, Part I, Vol. 3).
Added Fault Handling Semantics for lfetch.fault Instruction (Section 2.2,
Part I, Vol. 3).
Added Capability for Allowing Multiple PAL_A_SPEC and PAL_B Entries in
the Firmware Interface Table (Section 11.1.6, Part I, Vol. 2).
Added BR1 to Min-state Save Area and Clarified Alignment (Sections 11.3.2.3
and 11.3.3, Part I, Vol. 2).
Added New PAL Procedures: PAL_LOGICAL_TO_PHYSICAL and
PAL_CACHE_SHARED_INFO (Section 11.9.1, Part I, Vol. 2).
Added Op Fields to PAL_MC_ERROR_INFO (Section 11.9, Part I, Vol. 2).
Added New Error Exit States (Section 11.2.2.2, Part I, Vol. 2).
Added Performance Counter Standardization (Sections 7.2.3 and 11.6, Part I,
Vol. 2).
Modified CPUID[4] for Atomic Operations and Spontaneous Deferral
(Section 3.1.11, Part I, Vol. 1).

Volume 3: About this Manual 3:7


Date of Revision
Description
Revision Number

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).

3:8 Volume 3: About this Manual


Date of Revision
Description
Revision Number

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).

Volume 3: About this Manual 3:9


Date of Revision
Description
Revision Number

July 2000 1.1 Volume 3:


(continued) fmix instruction page figures corrected (Chapter 2).
Clarification of “reserved” fields in ITIR (Chapters 2 and 3).
Modified conditions for alloc/loadrs/flushrs instruction placement in bundle/
instruction group (Chapters 2 and 4).
IA-32 JMPE instruction page typo fix (p. 5-238).
Processor Serial Number feature removed (Chapter 5).
January 2000 1.0 Initial release of document.

3:10 Volume 3: About this Manual


3

Instruction Reference 2

This chapter describes the function of each Itanium instruction. The pages of this chapter are sorted
alphabetically by assembly language mnemonic.

2.1 Instruction Page Conventions


The instruction pages are divided into multiple sections as listed in Table 2-1. The first three
sections are present on all instruction pages. The last three sections are present only when
necessary. Table 2-2 lists the font conventions which are used by the instruction pages.

Table 2-1. Instruction Page Description


Section Name Contents
Format Assembly language syntax, instruction type and encoding format
Description Instruction function in English
Operation Instruction function in C code
FP Exceptions IEEE floating-point traps
Interruptions Prioritized list of interruptions that may be caused by the instruction
Serialization Serializing behavior or serialization requirements

Table 2-2. Instruction Page Font Conventions


Font Interpretation
regular (Format section) Required characters in an assembly language mnemonic
italic (Format section) Assembly language field name that must be filled with one of a range
of legal values listed in the Description section
code (Operation section) C code specifying instruction behavior
code_italic (Operation section) Assembly language field name corresponding to a italic field listed
in the Format section

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.

Volume 3: Instruction Reference 3:11


Table 2-3. Register File Notation
Assembly Indirect
Register File C Notation
Mnemonic Access
Application registers AR ar
Branch registers BR b
Control registers CR cr
CPU identification registers CPUID cpuid Y
Data breakpoint registers DBR dbr Y
Instruction breakpoint registers IBR ibr Y
Data TLB translation cache DTC N/A
Data TLB translation registers DTR dtr Y
Floating-point registers FR f
General registers GR r
Instruction TLB translation cache ITC N/A
Instruction TLB translation registers ITR itr Y
Protection key registers PKR pkr Y
Performance monitor configuration registers PMC pmc Y
Performance monitor data registers PMD pmd Y
Predicate registers PR p
Region registers RR rr Y

Table 2-4. C Syntax Differences


Syntax Function
{msb:lsb}, {bit} Bit field specifier. When appended to a variable, denotes a bit field extending from the
most significant bit specified by “msb” to the least significant bit specified by “lsb”
including bits “msb” and “lsb.” If “msb” and “lsb” are equal then a single bit is
accessed. The second form denotes a single bit.
u>, u>=, u<, u<= Unsigned inequality relations. Variables on either side of the operator are treated as
unsigned.
u>>, u>>= Unsigned right shift. Zeroes are shifted into the most significant bit position.
u+ Unsigned addition. Operands are treated as unsigned, and zero-extended.
u* Unsigned multiplication. Operands are treated as unsigned.

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.

Table 2-5. Pervasive Conditions Not Included in Instruction Description Code


Condition Action
Read of a register outside the current frame. An undefined value is returned (no fault).
Access to a banked general register (GR 16 through GR 31). The GR bank specified by PSR.bn is accessed.
PSR.ss is set. A Single Step trap is raised.

3:12 Volume 3: Instruction Reference


2.2 Instruction Descriptions
The remainder of this chapter provides a description of each of the Itanium instructions.

Volume 3: Instruction Reference 3:13


add

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 (register_form) // register form


tmp_src = GR[r2];
else if (imm14_form) // 14-bit immediate form
tmp_src = sign_ext(imm14, 14);
else // 22-bit immediate form
tmp_src = sign_ext(imm22, 22);

tmp_nat = (register_form? GR[r2].nat: 0);

if (plus1_form)
GR[r1] = tmp_src + GR[r3] + 1;
else
GR[r1] = tmp_src + GR[r3];

GR[r1].nat = tmp_nat || GR[r3].nat;


}

Interruptions: Illegal Operation fault

3:14 Volume 3: Instruction Reference


addp4

addp4 — Add Pointer


Format: (qp) addp4 r1 = r2, r3 register_form A1
(qp) addp4 r1 = imm14, r3 imm14_form A4

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.

Figure 2-1. Add Pointer

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);

tmp_src = (register_form? GR[r2]: sign_ext(imm14, 14));


tmp_nat = (register_form? GR[r2].nat: 0);

tmp_res = tmp_src + GR[r3];


tmp_res = zero_ext(tmp_res{31:0}, 32);
tmp_res{62:61} = GR[r3]{31:30};
GR[r1] = tmp_res;
GR[r1].nat = tmp_nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:15


alloc

alloc — Allocate Stack Frame


Format: (qp) alloc r1 = ar.pfs, i, l, o, r M34

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.

Figure 2-2. 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.

3:16 Volume 3: Instruction Reference


alloc

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();

alat_frame_update(0, tmp_sof - CFM.sof);


rse_new_frame(CFM.sof, tmp_sof);// Make room for new registers; Mandatory
// RSE stores can raise faults listed below.
CFM.sof = tmp_sof;
CFM.sol = tmp_sol;
CFM.sor = tmp_sor;

GR[r1] = AR[PFS];
GR[r1].nat = 0;

Interruptions: Illegal Operation fault Data NaT Page Consumption fault


Reserved Register/Field fault Data Key Miss fault
Unimplemented Data Address fault Data Key Permission fault
VHPT Data fault Data Access Rights fault
Data Nested TLB fault Data Dirty Bit fault
Data TLB fault Data Access Bit fault
Alternate Data TLB fault Data Debug fault
Data Page Not Present fault

Volume 3: Instruction Reference 3:17


and

and — Logical And


Format: (qp) and r1 = r2, r3 register_form A1
(qp) and r1 = imm8, r3 imm8_form A3

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);

tmp_src = (register_form? GR[r2]: sign_ext(imm8, 8));


tmp_nat = (register_form? GR[r2].nat: 0);

GR[r1] = tmp_src & GR[r3];


GR[r1].nat = tmp_nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

3:18 Volume 3: Instruction Reference


andcm

andcm — And Complement


Format: (qp) andcm r1 = r2, r3 register_form A1
(qp) andcm r1 = imm8, r3 imm8_form A3

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);

tmp_src = (register_form? GR[r2]: sign_ext(imm8, 8));


tmp_nat = (register_form? GR[r2].nat: 0);

GR[r1] = tmp_src & ~GR[r3];


GR[r1].nat = tmp_nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:19


br

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 .

Table 2-6. Branch Types


btype Function Branch Condition Target Address
cond or none Conditional branch Qualifying predicate IP-rel or Indirect
call Conditional procedure call Qualifying predicate IP-rel or Indirect
ret Conditional procedure return Qualifying predicate Indirect
ia Invoke IA-32 instruction set Unconditional Indirect
cloop Counted loop branch Loop count IP-rel
ctop, cexit Mod-scheduled counted loop Loop count and epilog IP-rel
count
wtop, wexit Mod-scheduled while loop Qualifying predicate and IP-rel
epilog count

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.

3:20 Volume 3: Instruction Reference


br

• 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.

Volume 3: Instruction Reference 3:21


br

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.

3:22 Volume 3: Instruction Reference


br

Figure 2-3. Operation of br.ctop and br.cexit

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

PR[63] = 1 PR[63] = 0 PR[63] = 0 PR[63] = 0

RRB-- RRB-- RRB-- RRB = RRB

ctop: Branch ctop: Fall-thru


cexit: Fall-thru cexit: Branch

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.

Figure 2-4. Operation of br.wtop and br.wexit

wtop, wexit

==0 (Prolog / Epilog)


(Special
PR[qp]?
Unrolled

>1 == 0 Loops)
(Prolog / == 1
EC?
Kernel) (Prolog /
Epilog) (Epilog) == 1

EC = EC EC-- EC-- EC = EC

PR[63] = 0 PR[63] = 0 PR[63] = 0 PR[63] = 0

RRB-- RRB-- RRB-- RRB = RRB

wtop: Branch wtop: Fall-thru


wexit: Fall-thru wexit: Branch

Volume 3: Instruction Reference 3:23


br

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.

Table 2-7. Branch Whether Hint


bwh Completer Branch Whether Hint
spnt Static Not-Taken
sptk Static Taken
dpnt Dynamic Not-Taken
dptk Dynamic Taken

Table 2-8. Sequential Prefetch Hint


ph Completer Sequential Prefetch Hint
few or none Few lines
many Many lines

Table 2-9. Branch Cache Deallocation Hint


dh Completer Branch Cache Deallocation Hint
none Don’t deallocate
clr Deallocate branch information

Operation: if (ip_relative_form) // determine branch target


tmp_IP = IP + sign_ext((imm21 << 4), 25);
else // indirect_form
tmp_IP = BR[b2];

if (btype!= ‘ia’) // for Itanium branches,


tmp_IP = tmp_IP & ~0xf; // ignore bottom 4 bits of target

lower_priv_transition = 0;

3:24 Volume 3: Instruction Reference


br

switch (btype) {
case ‘cond’: // simple conditional branch
tmp_taken = PR[qp];
break;

case ‘call’: // call saves a return link


tmp_taken = PR[qp];
if (tmp_taken) {
BR[b1] = IP + 16;

AR[PFS].pfm = CFM; //... and saves the stack frame


AR[PFS].pec = AR[EC];
AR[PFS].ppl = PSR.cpl;

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;

case ‘ret’: // return restores stack frame


tmp_taken = PR[qp];
if (tmp_taken) {
// tmp_growth indicates the amount to move logical TOP *up*:
// tmp_growth = sizeof(previous out) - sizeof(current frame)
// a negative amount indicates a shrinking stack
tmp_growth = (AR[PFS].pfm.sof - AR[PFS].pfm.sol) - CFM.sof;
alat_frame_update(-AR[PFS].pfm.sol, 0);
rse_fatal = rse_restore_frame(AR[PFS].pfm.sol,
tmp_growth, CFM.sof);
if (rse_fatal) {
// See Section 6.4, “RSE Operation” on page 2:131
CFM.sof = 0;
CFM.sol = 0;
CFM.sor = 0;
CFM.rrb.gr = 0;
CFM.rrb.fr = 0;
CFM.rrb.pr = 0;
} else // normal branch return
CFM = AR[PFS].pfm;

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;

case ‘ia’: // switch to IA mode


tmp_taken = 1;
if (PSR.ic == 0 || PSR.dt == 0 || PSR.mc == 1 || PSR.it == 0)
undefined_behavior();
if (qp!= 0)
illegal_operation_fault();
if (AR[BSPSTORE]!= AR[BSP])

Volume 3: Instruction Reference 3:25


br

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;

// Note the register stack is disabled during IA-32 instruction


// set execution
break;

case ‘cloop’: // simple counted loop


if (slot!= 2)
illegal_operation_fault();
tmp_taken = (AR[LC]!= 0);
if (AR[LC]!= 0)
AR[LC]--;
break;

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();

3:26 Volume 3: Instruction Reference


br

} 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();
}

Interruptions: Illegal Operation fault Lower-Privilege Transfer trap


Disabled Instruction Set Transition fault Taken Branch trap
Unimplemented Instruction Address trap

Additional Faults on IA-32 target instructions:


IA_32_Exception(GPFault)
Disabled FP Reg Fault if PSR.dfh is 1

Volume 3: Instruction Reference 3:27


break

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);
}

Interruptions: Break Instruction fault

3:28 Volume 3: Instruction Reference


brl

brl — Branch Long


Format: (qp) brl.btype.bwh.ph.dh target64 X3
(qp) brl.btype.bwh.ph.dh b1 = target64 call_form X4
brl.ph.dh target64 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.
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.

Table 2-10. Long Branch Types


btype Function Branch Condition Target Address
cond or none Conditional branch Qualifying predicate IP-relative
call Conditional procedure call Qualifying predicate IP-relative

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.

Volume 3: Instruction Reference 3:29


brl

Operation: tmp_IP = IP + (imm60 << 4); // determine branch target


if (!followed_by_stop())
undefined_behavior();
if (!instruction_implemented(BRL))
illegal_operation_fault();

switch (btype) {
case ‘cond’: // simple conditional branch
tmp_taken = PR[qp];
break;

case ‘call’: // call saves a return link


tmp_taken = PR[qp];
if (tmp_taken) {
BR[b1] = IP + 16;

AR[PFS].pfm = CFM; //... and saves the stack frame


AR[PFS].pec = AR[EC];
AR[PFS].ppl = PSR.cpl;

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();
}

Interruptions: Illegal Operation fault Taken Branch trap


Unimplemented Instruction Address trap

3:30 Volume 3: Instruction Reference


brp

brp — Branch Predict


Format: brp.ipwh.ih target25, tag13 ip_relative_form B6
brp.indwh.ih b2, tag13 indirect_form B7
brp.ret.indwh.ih b2, tag13 return_form, indirect_form B7

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.

Table 2-11. IP-relative Branch Predict Whether Hint


ipwh Completer IP-relative Branch Predict Whether Hint
sptk Presaged branch should be predicted Static Taken
loop Presaged branch will be br.cloop, br.ctop, or br.wtop
exit Presaged branch will be br.cexit or br.wexit
dptk Presaged branch should be predicted Dynamically

Table 2-12. Indirect Branch Predict Whether Hint


indwh Completer Indirect Branch Predict Whether Hint
sptk Presaged branch should be predicted Static Taken
dptk Presaged branch should be predicted Dynamically

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.

Table 2-13. Importance Hint


ih Completer Branch Predict Importance Hint
none Less important
imp More important

Volume 3: Instruction Reference 3:31


brp

Operation: tmp_tag = IP + sign_ext((timm9 << 4), 13);


if (ip_relative_form) {
tmp_target = IP + sign_ext((imm21 << 4), 25);
tmp_wh = ipwh;
} else { // indirect_form
tmp_target = BR[b2];
tmp_wh = indwh;
}
branch_predict(tmp_wh, ih, return_form, tmp_target, tmp_tag);

Interruptions: None

3:32 Volume 3: Instruction Reference


bsw

bsw — Bank Switch


Format: bsw.0 zero_form B8
bsw.1 one_form B8

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;

Interruptions: Privileged Operation fault Virtualization fault

Serialization: This instruction does not require any additional instruction or data serialization operation. The bank
switch occurs synchronously with its execution.

Volume 3: Instruction Reference 3:33


chk

chk — Speculation Check


Format: (qp) chk.s r2, target25 pseudo-op
(qp) chk.s.i r2, target25 control_form, i_unit_form, gr_form I20
(qp) chk.s.m r2, target25 control_form, m_unit_form, gr_form M20
(qp) chk.s f2, target25 control_form, fr_form M21
(qp) chk.a.aclr r1, target25 data_form, gr_form M22
(qp) chk.a.aclr f1, target25 data_form, fr_form M23

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).

Table 2-14. ALAT Clear Completer


aclr Completer Effect on ALAT
clr Invalidate matching ALAT entry
nc Don’t invalidate

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.

3:34 Volume 3: Instruction Reference


chk

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);
}

Interruptions: Disabled Floating-point Register fault Unimplemented Instruction Address trap


Speculative Operation fault Taken Branch trap

Volume 3: Instruction Reference 3:35


clrrrb

clrrrb — Clear RRB


Format: clrrrb all_form B8
clrrrb.pr pred_form B8

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

3:36 Volume 3: Instruction Reference


cmp

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.

Table 2-15. Comparison Types


PR[qp]==1
Pseudo-op PR[qp]==0 Result==0, Result==1, One or More
ctype
of No Source NaTs No Source NaTs Source NaTs
PR[p1] PR[p2] PR[p1] PR[p2] PR[p1] PR[p2] PR[p1] PR[p2]
none 0 1 1 0 0 0
unc 0 0 0 1 1 0 0 0
or 1 1
and 0 0 0 0
or.andcm 1 0
orcm or 1 1
andcm and 0 0 0 0
and.orcm or.andcm 0 1

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).

Volume 3: Instruction Reference 3:37


cmp

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.

Table 2-17. 64-bit Comparison Relations for Parallel Compares


Compare Relation Register Form is a
crel Immediate Range
(a rel b) pseudo-op of
eq a == b -128.. 127
ne a!= b -128.. 127
lt 0<b signed no immediate forms
lt a<0 gt a´b
le 0 <= b
le a <= 0 ge a´b
gt 0>b
gt a>0 lt a´b
ge 0 >= b
ge a >= 0 le a´b

3:38 Volume 3: Instruction Reference


cmp

Operation: if (PR[qp]) {
if (p1 == p2)
illegal_operation_fault();

tmp_nat = (register_form? GR[r2].nat: 0) || GR[r3].nat;


if (register_form)
tmp_src = GR[r2];
else if (imm8_form)
tmp_src = sign_ext(imm8, 8);
else // parallel_inequality_form
tmp_src = 0;

if (crel == ‘eq’) tmp_rel = tmp_src == GR[r3];


else if (crel == ‘ne’) tmp_rel = tmp_src!= GR[r3];
else if (crel == ‘lt’) tmp_rel = lesser_signed(tmp_src, GR[r3]);
else if (crel == ‘le’) tmp_rel = lesser_equal_signed(tmp_src, GR[r3]);
else if (crel == ‘gt’) tmp_rel = greater_signed(tmp_src, GR[r3]);
else if (crel == ‘ge’) tmp_rel = greater_equal_signed(tmp_src, GR[r3]);
else if (crel == ‘ltu’) tmp_rel = lesser(tmp_src, GR[r3]);
else if (crel == ‘leu’) tmp_rel = lesser_equal(tmp_src, GR[r3]);
else if (crel == ‘gtu’) tmp_rel = greater(tmp_src, GR[r3]);
else tmp_rel = greater_equal(tmp_src, GR[r3]);//‘geu’

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;
}
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:39


cmp4

cmp4 — Compare 4 Bytes


Format: (qp) cmp4.crel.ctype p1, p2 = r2, r3 register_form A6
(qp) cmp4.crel.ctype p1, p2 = imm8, r3 imm8_form A8
(qp) cmp4.crel.ctype p1, p2 = r0, r3 parallel_inequality_form A7
(qp) cmp4.crel.ctype p1, p2 = r3, r0 pseudo-op

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.

Table 2-18. Immediate Range for 32-bit Compares


Compare Relation
crel Immediate Range
(a rel b)
eq a == b -128.. 127
ne a!= b -128.. 127
lt a<b signed -128.. 127
le a <= b -127.. 128
gt a>b -127.. 128
ge a >= b -128.. 127
ltu a<b unsigned 0.. 127, 232-128.. 232-1
leu a <= b 1.. 128, 232-127.. 232
gtu a>b 1.. 128, 232-127.. 232
geu a >= b 0.. 127, 232-128.. 232-1

3:40 Volume 3: Instruction Reference


cmp4

Operation: if (PR[qp]) {
if (p1 == p2)
illegal_operation_fault();

tmp_nat = (register_form? GR[r2].nat: 0) || GR[r3].nat;

if (register_form)
tmp_src = GR[r2];
else if (imm8_form)
tmp_src = sign_ext(imm8, 8);
else // parallel_inequality_form
tmp_src = 0;

if (crel == ‘eq’) tmp_rel = tmp_src{31:0} == GR[r3]{31:0};


else if (crel == ‘ne’) tmp_rel = tmp_src{31:0}!= GR[r3]{31:0};
else if (crel == ‘lt’)
tmp_rel = lesser_signed(sign_ext(tmp_src, 32),
sign_ext(GR[r3], 32));
else if (crel == ‘le’)
tmp_rel = lesser_equal_signed(sign_ext(tmp_src, 32),
sign_ext(GR[r3], 32));
else if (crel == ‘gt’)
tmp_rel = greater_signed(sign_ext(tmp_src, 32),
sign_ext(GR[r3], 32));
else if (crel == ‘ge’)
tmp_rel = greater_equal_signed(sign_ext(tmp_src, 32),
sign_ext(GR[r3], 32));
else if (crel == ‘ltu’)
tmp_rel = lesser(zero_ext(tmp_src, 32),
zero_ext(GR[r3], 32));
else if (crel == ‘leu’)
tmp_rel = lesser_equal(zero_ext(tmp_src, 32),
zero_ext(GR[r3], 32));
else if (crel == ‘gtu’)
tmp_rel = greater(zero_ext(tmp_src, 32),
zero_ext(GR[r3], 32));
else // ‘geu’
tmp_rel = greater_equal(zero_ext(tmp_src, 32),
zero_ext(GR[r3], 32));

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) {

Volume 3: Instruction Reference 3:41


cmp4

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;
}
}

Interruptions: Illegal Operation fault

3:42 Volume 3: Instruction Reference


cmpxchg

cmpxchg — Compare and Exchange


Format: (qp) cmpxchgsz.sem.ldhint r1 = [r3], r2, ar.ccv M16
(qp) cmp8xchg16.sem.ldhint r1 = [r3], r2, ar.csd, ar.ccv sixteen_byte_form M16

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.

Table 2-19. Memory Compare and Exchange Size


sz Completer Bytes Accessed
1 1
2 2
4 4
8 8

Table 2-20. Compare and Exchange Semaphore Types


sem Ordering
Semaphore Operation
Completer Semantics
acq Acquire The memory read/write is made visible prior to all subsequent data memory
accesses.
rel Release The memory read/write is made visible after all previous data memory
accesses.

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.

Volume 3: Instruction Reference 3:43


cmpxchg

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);

paddr = tlb_translate(GR[r3], size, SEMAPHORE, PSR.cpl, &mattr,


&tmp_unused);

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;
}

Interruptions: Illegal Operation fault Data Key Miss fault


Register NaT Consumption fault Data Key Permission fault
Unimplemented Data Address fault Data Access Rights fault
Data Nested TLB fault Data Dirty Bit fault
Alternate Data TLB fault Data Access Bit fault
VHPT Data fault Data Debug fault
Data TLB fault Unaligned Data Reference fault
Data Page Not Present fault Unsupported Data Reference fault
Data NaT Page Consumption fault

3:44 Volume 3: Instruction Reference


cover

cover — Cover Stack Frame


Format: cover B8

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();

if (PSR.cpl == 0 && PSR.vm == 1)


virtualization_fault();

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;

Interruptions: Virtualization fault

Volume 3: Instruction Reference 3:45


czx

czx — Compute Zero Index


Format: (qp) czx1.l r1 = r3 one_byte_form, left_form I29
(qp) czx1.r r1 = r3 one_byte_form, right_form I29
(qp) czx2.l r1 = r3 two_byte_form, left_form I29
(qp) czx2.r r1 = r3 two_byte_form, right_form I29

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.

Table 2-21. Result Ranges for czx


Range of Result if Zero Element Default Result if No Zero Element
Size Element Width
Found Found
1 8 bit 0-7 8
2 16 bit 0-3 4

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;

3:46 Volume 3: Instruction Reference


czx

}
}
GR[r1].nat = GR[r3].nat;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:47


dep

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.

Figure 2-5. Deposit Example (merge_form)

52 36 0 16 15 0
GR r3: GR r2:

GR r1:
52 36 0

The operation of dep.z r1 = r2, 36, 16 is illustrated in Figure 2-6.

Figure 2-6. Deposit Example (zero_form)

16 15 0

GR r2:

GR r1: 0 0
52 36 0

3:48 Volume 3: Instruction Reference


dep

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;

GR[r1]{(pos6 + tmp_len - 1):pos6} = tmp_src{(tmp_len - 1):0};


GR[r1].nat = tmp_nat;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:49


epc

epc — Enter Privileged Code


Format: epc B8

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.

Operation: if (AR[PFS].ppl u< PSR.cpl)


illegal_operation_fault();

if (PSR.it)
PSR.cpl = tlb_enter_privileged_code();
else
PSR.cpl = 0;

Interruptions: Illegal Operation fault

3:50 Volume 3: Instruction Reference


extr

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.

Figure 2-7. Extract Example

63 56 7 0

GR r3:

GR r1: Sign
63 49 0

Operation: if (PR[qp]) {
check_target_register(r1);

tmp_len = len6;

if (pos6 + tmp_len u> 64)


tmp_len = 64 - pos6;

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;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:51


fabs

fabs — Floating-point Absolute Value


Format: (qp) fabs f1 = f3 pseudo-op of: (qp) fmerge.s f1 = f0, f3

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.

Operation: See “fmerge — Floating-point Merge” on page 3:75.

3:52 Volume 3: Instruction Reference


fadd

fadd — Floating-point Add


Format: (qp) fadd.pc.sf f1 = f3, f2 pseudo-op of: (qp) fma.pc.sf f1 = f3, f1, f2

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.

Table 2-22. Specified pc Mnemonic Values


pc Mnemonic Precision Specified
.s single
.d double
none dynamic
(i.e. use pc value in status field)

Table 2-23. sf Mnemonic Values


sf Mnemonic Status Field Accessed
.s0 or none sf0
.s1 sf1
.s2 sf2
.s3 sf3

Operation: See “fma — Floating-point Multiply Add” on page 3:73.

Volume 3: Instruction Reference 3:53


famax

famax — Floating-point Absolute Maximum


Format: (qp) famax.sf f1 = f2, f3 F8

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);
}

FP Exceptions: Invalid Operation (V)


Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault

3:54 Volume 3: Instruction Reference


famin

famin — Floating-point Absolute Minimum


Format: (qp) famin.sf f1 = f2, f3 F8

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);
}

FP Exceptions: Invalid Operation (V)


Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:55


fand

fand — Floating-point Logical And


Format: (qp) fand f1 = f2, f3 F9

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

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

3:56 Volume 3: Instruction Reference


fandcm

fandcm — Floating-point And Complement


Format: (qp) fandcm f1 = f2, f3 F9

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

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:57


fc

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);
}

Interruptions: Register NaT Consumption fault Data TLB fault


Unimplemented Data Address fault Data Page Not Present fault
Data Nested TLB fault Data NaT Page Consumption fault
Alternate Data TLB fault Data Access Rights fault
VHPT Data fault

3:58 Volume 3: Instruction Reference


fchkf

fchkf — Floating-point Check Flags


Format: (qp) fchkf.sf target25 F14

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

Interruptions: Speculative Operation fault Taken Branch trap


Unimplemented Instruction Address trap

Volume 3: Instruction Reference 3:59


fclass

fclass — Floating-point Class


Format: (qp) fclass.fcrel.fctype p1, p2 = f2, fclass9 F5

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.

Table 2-24. Floating-point Class Relations


fcrel Test Relation
m FR f2 agrees with the pattern specified by fclass9 (is a member)
nm FR f2 does not agree with the pattern specified by fclass9 (is not a member)

A number agrees with the pattern specified by fclass9 if:


• the number is NaTVal and fclass9 {8} is 1, or
• the number is a quiet NaN and fclass9 {7} is 1, or
• the number is a signaling NaN and fclass9 {6} is 1, or
• the sign of the number agrees with the sign specified by one of the two low-order bits of
fclass9, and the type of the number (disregarding the sign) agrees with the number-type
specified by the next four bits of fclass9, as shown in Table 2-25.
Note: An fclass9 of 0x1FF is equivalent to testing for any supported operand.
The class names used in Table 2-25 are defined in Table 5-2, “Floating-point Register Encodings”
on page 1:83.

Table 2-25. Floating-point Classes


fclass9 Class Mnemonic
Either these cases can be tested for
0x0100 NaTVal @nat
0x080 Quiet NaN @qnan
0x040 Signaling NaN @snan
or the OR of the following two cases
0x001 Positive @pos
0x002 Negative @neg
AND’ed with OR of the following four cases
0x004 Zero @zero
0x008 Unnormalized @unorm
0x010 Normalized @norm
0x020 Infinity @inf

3:60 Volume 3: Instruction Reference


fclass

Operation: if (PR[qp]) {
if (p1 == p2)
illegal_operation_fault();

if (tmp_isrcode = fp_reg_disabled(f2, 0, 0, 0))


disabled_fp_register_fault(tmp_isrcode, 0);

tmp_rel = ((fclass9{0} &&!FR[f2].sign || fclass9{1} && FR[f2].sign)


&& ((fclass9{2} && fp_is_zero(FR[f2]))||
(fclass9{3} && fp_is_unorm(FR[f2])) ||
(fclass9{4} && fp_is_normal(FR[f2])) ||
(fclass9{5} && fp_is_inf(FR[f2]))
)
)
|| (fclass9{6} && fp_is_snan(FR[f2]))
|| (fclass9{7} && fp_is_qnan(FR[f2]))
|| (fclass9{8} && fp_is_natval(FR[f2]));

tmp_nat = fp_is_natval(FR[f2]) && (!fclass9{8});

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

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:61


fclrf

fclrf — Floating-point Clear Flags


Format: (qp) fclrf.sf F13

Description: The status field’s 6-bit flags field is reset to zero.


The mnemonic values for sf are given in Table 2-23 on page 3:53.

Operation: if (PR[qp]) {
fp_set_sf_flags(sf, 0);
}

FP Exceptions: None

Interruptions: None

3:62 Volume 3: Instruction Reference


fcmp

fcmp — Floating-point Compare


Format: (qp) fcmp.frel.fctype.sf p1, p2 = f2, f3 F4

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.

Table 2-26. Floating-point Comparison Types


PR[qp]==1
PR[qp]==0 Result==0, Result==1, One or More
fctype
No Source NaTVals No Source NaTVals Source NaTVals
PR[p1] PR[p2] PR[p1] PR[p2] PR[p1] PR[p2] PR[p1] PR[p2]
none 0 1 1 0 0 0
unc 0 0 0 1 1 0 0 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-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.

Table 2-27. Floating-point Comparison Relations


Quiet NaN
frel Completer
frel Relation Pseudo-op of as Operand
Unabbreviated
Signals Invalid
eq equal f2 == f3 No
lt less than f2 < f3 Yes
le less than or equal f2 <= f3 Yes
gt greater than f2 > f3 lt f 2 ´ f3 Yes
ge greater than or equal f2 >= f3 le f 2 ´ f3 Yes
unord unordered f2? f3 No
neq not equal !(f2 == f3) eq p1 ´ p2 No
nlt not less than !(f2 < f3) lt p1 ´ p2 Yes
nle not less than or equal !(f2 <= f3) le p1 ´ p2 Yes
ngt not greater than !(f2 > f3) lt f 2 ´ f3 p1 ´ p2 Yes
nge not greater than or equal !(f2 >= f3) le f 2 ´ f3 p1 ´ p2 Yes
ord ordered !(f2? f3) unord p1 ´ p2 No

Volume 3: Instruction Reference 3:63


fcmp

Operation: if (PR[qp]) {
if (p1 == p2)
illegal_operation_fault();

if (tmp_isrcode = fp_reg_disabled(f2, f3, 0, 0))


disabled_fp_register_fault(tmp_isrcode, 0);

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]);

if (frel == ‘eq’) tmp_rel = fp_equal(tmp_fr2,


tmp_fr3);
else if (frel == ‘lt’) tmp_rel = fp_less_than(tmp_fr2,
tmp_fr3);
else if (frel == ‘le’) tmp_rel = fp_lesser_or_equal(tmp_fr2,
tmp_fr3);
else if (frel == ‘gt’) tmp_rel = fp_less_than(tmp_fr3,
tmp_fr2);
else if (frel == ‘ge’) tmp_rel = fp_lesser_or_equal(tmp_fr3,
tmp_fr2);
else if (frel == ‘unord’) tmp_rel = fp_unordered(tmp_fr2,
tmp_fr3);
else if (frel == ‘neq’) tmp_rel =!fp_equal(tmp_fr2,
tmp_fr3);
else if (frel == ‘nlt’) tmp_rel =!fp_less_than(tmp_fr2,
tmp_fr3);
else if (frel == ‘nle’) tmp_rel =!fp_lesser_or_equal(tmp_fr2,
tmp_fr3);
else if (frel == ‘ngt’) tmp_rel =!fp_less_than(tmp_fr3,
tmp_fr2);
else if (frel == ‘nge’) tmp_rel =!fp_lesser_or_equal(tmp_fr3,
tmp_fr2);
else tmp_rel =!fp_unordered(tmp_fr2,
tmp_fr3); //‘ord’

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;
}
}

FP Exceptions: Invalid Operation (V)


Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

3:64 Volume 3: Instruction Reference


fcmp

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:65


fcvt.fx

fcvt.fx — Convert Floating-point to Integer


Format: (qp) fcvt.fx.sf f1 = f2 signed_form F10
(qp) fcvt.fx.trunc.sf f1 = f2 signed_form, trunc_form F10
(qp) fcvt.fxu.sf f1 = f2 unsigned_form F10
(qp) fcvt.fxu.trunc.sf f1 = f2 unsigned_form, trunc_form F10

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));
}
}

3:66 Volume 3: Instruction Reference


fcvt.fx

FP Exceptions: Invalid Operation (V) Inexact (I)


Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault Floating-point Exception trap

Volume 3: Instruction Reference 3:67


fcvt.xf

fcvt.xf — Convert Signed Integer to Floating-point


Format: (qp) fcvt.xf f1 = f2 F11

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

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

3:68 Volume 3: Instruction Reference


fcvt.xuf

fcvt.xuf — Convert Unsigned Integer to Floating-point


Format: (qp) fcvt.xuf.pc.sf f1 = f3 pseudo-op of: (qp) fma.pc.sf f1 = f3, f1, f0

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.

Operation: See “fma — Floating-point Multiply Add” on page 3:73.

Volume 3: Instruction Reference 3:69


fetchadd

fetchadd — Fetch and Add Immediate


Format: (qp) fetchadd4.sem.ldhint r1 = [r3], inc3 four_byte_form M17
(qp) fetchadd8.sem.ldhint r1 = [r3], inc3 eight_byte_form M17

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.

Table 2-28. Fetch and Add Semaphore Types


sem Ordering
Semaphore Operation
Completer Semantics
acq Acquire The memory read/write is made visible prior to all subsequent data memory
accesses.
rel Release The memory read/write is made visible after all previous data memory
accesses.

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.

3:70 Volume 3: Instruction Reference


fetchadd

Operation: if (PR[qp]) {
check_target_register(r1);

if (GR[r3].nat)
register_nat_consumption_fault(SEMAPHORE);

size = four_byte_form? 4: 8;

paddr = tlb_translate(GR[r3], size, SEMAPHORE, PSR.cpl, &mattr,


&tmp_unused);
if (!ma_supports_fetchadd(mattr))
unsupported_data_reference_fault(SEMAPHORE, GR[r3]);

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);

GR[r1] = zero_ext(val, size * 8);


GR[r1].nat = 0;
}

Interruptions: Illegal Operation fault Data Key Miss fault


Register NaT Consumption fault Data Key Permission fault
Unimplemented Data Address fault Data Access Rights fault
Data Nested TLB fault Data Dirty Bit fault
Alternate Data TLB fault Data Access Bit fault
VHPT Data fault Data Debug fault
Data TLB fault Unaligned Data Reference fault
Data Page Not Present fault Unsupported Data Reference fault
Data NaT Page Consumption fault

Volume 3: Instruction Reference 3:71


flushrs

flushrs — Flush Register Stack


Format: flushrs M25

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.

Operation: while (AR[BSPSTORE]!= AR[BSP]) {


rse_store(MANDATORY); // increments AR[BSPSTORE]
deliver_unmasked_pending_external_interrupt();
}

Interruptions: Unimplemented Data Address fault Data Key Miss fault


VHPT Data fault Data Key Permission fault
Data Nested TLB fault Data Access Rights fault
Data TLB fault Data Dirty Bit fault
Alternate Data TLB fault Data Access Bit fault
Data Page Not Present fault Data Debug fault
Data NaT Page Consumption fault

3:72 Volume 3: Instruction Reference


fma

fma — Floating-point Multiply Add


Format: (qp) fma.pc.sf f1 = f3, f4, f2 F1

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));
}
}

FP Exceptions: Invalid Operation (V) Underflow (U)


Denormal/Unnormal Operand (D) Overflow (O)
Software Assist (SWA) fault Inexact (I)
Software Assist (SWA) trap

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault Floating-point Exception trap

Volume 3: Instruction Reference 3:73


fmax

fmax — Floating-point Maximum


Format: (qp) fmax.sf f1 = f2, f3 F8

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);
}

FP Exceptions: Invalid Operation (V)


Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault

3:74 Volume 3: Instruction Reference


fmerge

fmerge — Floating-point Merge


Format: (qp) fmerge.ns f1 = f2, f3 neg_sign_form F9
(qp) fmerge.s f1 = f2, f3 sign_form F9
(qp) fmerge.se f1 = f2, f3 sign_exp_form F9

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.

Figure 2-8. Floating-point Merge Negative Sign Operation

81 80 64 63 0 81 80 64 63 0
FR f2 FR f3

Negated 81 80 64 63 0
Sign Bit FR f1

Figure 2-9. Floating-point Merge Sign Operation

81 80 64 63 0 81 80 64 63 0
FR f2 FR f3

81 80 64 63 0
FR f1

Figure 2-10. Floating-point Merge Sign and Exponent Operation

81 80 64 63 0 81 80 64 63 0
FR f2 FR f3

81 80 64 63 0
FR f1

Volume 3: Instruction Reference 3:75


fmerge

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

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

3:76 Volume 3: Instruction Reference


fmin

fmin — Floating-point Minimum


Format: (qp) fmin.sf f1 = f2, f3 F8

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);
}

FP Exceptions: Invalid Operation (V)


Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:77


fmix

fmix — Floating-point Mix


Format: (qp) fmix.l f1 = f2, f3 mix_l_form F9
(qp) fmix.r f1 = f2, f3 mix_r_form F9
(qp) fmix.lr f1 = f2, f3 mix_lr_form F9

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.

Figure 2-11. Floating-point Mix Left

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

Figure 2-12. Floating-point Mix Right

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

Figure 2-13. Floating-point Mix Left-Right

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

3:78 Volume 3: Instruction Reference


fmix

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

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:79


fmpy

fmpy — Floating-point Multiply


Format: (qp) fmpy.pc.sf f1 = f3, f4 pseudo-op of: (qp) fma.pc.sf f1 = f3, f4, f0

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.

Operation: See “fma — Floating-point Multiply Add” on page 3:73.

3:80 Volume 3: Instruction Reference


fms

fms — Floating-point Multiply Subtract


Format: (qp) fms.pc.sf f1 = f3, f4, f2 F1

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));
}
}

FP Exceptions: Invalid Operation (V) Underflow (U)


Denormal/Unnormal Operand (D) Overflow (O)
Software Assist (SWA) fault Inexact (I)
Software Assist (SWA) trap

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault Floating-point Exception trap

Volume 3: Instruction Reference 3:81


fneg

fneg — Floating-point Negate


Format: (qp) fneg f1 = f3 pseudo-op of: (qp) fmerge.ns f1 = f3, f3

Description: The value in FR f3 is negated and placed in FR f1.


If FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result.

Operation: See “fmerge — Floating-point Merge” on page 3:75.

3:82 Volume 3: Instruction Reference


fnegabs

fnegabs — Floating-point Negate Absolute Value


Format: (qp) fnegabs f1 = f3 pseudo-op of: (qp) fmerge.ns f1 = f0, f3

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.

Operation: See “fmerge — Floating-point Merge” on page 3:75.

Volume 3: Instruction Reference 3:83


fnma

fnma — Floating-point Negative Multiply Add


Format: (qp) fnma.pc.sf f1 = f3, f4, f2 F1

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));
}
}

FP Exceptions: Invalid Operation (V) Underflow (U)


Denormal/Unnormal Operand (D) Overflow (O)
Software Assist (SWA) fault Inexact (I)
Software Assist (SWA) trap

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault Floating-point Exception trap

3:84 Volume 3: Instruction Reference


fnmpy

fnmpy — Floating-point Negative Multiply


Format: (qp) fnmpy.pc.sf f1 = f3, f4 pseudo-op of: (qp) fnma.pc.sf f1 = f3, f4,f0

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.

Operation: See “fnma — Floating-point Negative Multiply Add” on page 3:84.

Volume 3: Instruction Reference 3:85


fnorm

fnorm — Floating-point Normalize


Format: (qp) fnorm.pc.sf f1 = f3 pseudo-op of: (qp) fma.pc.sf f1 = f3, f1, f0

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.

Operation: See “fma — Floating-point Multiply Add” on page 3:73.

3:86 Volume 3: Instruction Reference


for

for — Floating-point Logical Or


Format: (qp) for f1 = f2, f3 F9

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

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:87


fpabs

fpabs — Floating-point Parallel Absolute Value


Format: (qp) fpabs f1 = f3 pseudo-op of: (qp) fpmerge.s f1 = f0, f3

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.

Operation: See “fpmerge — Floating-point Parallel Merge” on page 3:101.

3:88 Volume 3: Instruction Reference


fpack

fpack — Floating-point Pack


Format: (qp) fpack f1 = f2, f3 pack_form F9

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.

Figure 2-14. Floating-point Pack

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]);

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

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:89


fpamax

fpamax — Floating-point Parallel Absolute Maximum


Format: (qp) fpamax.sf f1 = f2, f3 F8

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));

tmp_fr2 = tmp_right = fp_reg_read_hi(f2);


tmp_fr3 = tmp_left = fp_reg_read_hi(f3);
tmp_right.sign = FP_SIGN_POSITIVE;
tmp_left.sign = FP_SIGN_POSITIVE;
tmp_bool_res = fp_less_than(tmp_left, tmp_right);
tmp_res_hi = fp_single(tmp_bool_res? tmp_fr2: tmp_fr3);

tmp_fr2 = tmp_right = fp_reg_read_lo(f2);


tmp_fr3 = tmp_left = fp_reg_read_lo(f3);
tmp_right.sign = FP_SIGN_POSITIVE;
tmp_left.sign = FP_SIGN_POSITIVE;
tmp_bool_res = fp_less_than(tmp_left, tmp_right);
tmp_res_lo = fp_single(tmp_bool_res? tmp_fr2: tmp_fr3);

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_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
}

FP Exceptions: Invalid Operation (V)


Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

3:90 Volume 3: Instruction Reference


fpamax

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:91


fpamin

fpamin — Floating-point Parallel Absolute Minimum


Format: (qp) fpamin.sf f1 = f2, f3 F8

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));

tmp_fr2 = tmp_left = fp_reg_read_hi(f2);


tmp_fr3 = tmp_right = fp_reg_read_hi(f3);
tmp_left.sign = FP_SIGN_POSITIVE;
tmp_right.sign = FP_SIGN_POSITIVE;
tmp_bool_res = fp_less_than(tmp_left, tmp_right);
tmp_res_hi = fp_single(tmp_bool_res? tmp_fr2: tmp_fr3);

tmp_fr2 = tmp_left = fp_reg_read_lo(f2);


tmp_fr3 = tmp_right = fp_reg_read_lo(f3);
tmp_left.sign = FP_SIGN_POSITIVE;
tmp_right.sign = FP_SIGN_POSITIVE;
tmp_bool_res = fp_less_than(tmp_left, tmp_right);
tmp_res_lo = fp_single(tmp_bool_res? tmp_fr2: tmp_fr3);

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_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
}

FP Exceptions: Invalid Operation (V)


Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

3:92 Volume 3: Instruction Reference


fpamin

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:93


fpcmp

fpcmp — Floating-point Parallel Compare


Format: (qp) fpcmp.frel.sf f1= f2, f3 F8

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).

Table 2-29. Floating-point Parallel Comparison Results


PR[qp]==1
PR[qp]==0 Result==false, Result==true, One or More
No Source NaTVals No Source NaTVals Source NaTVals
unchanged 0...0 1...1 NaTVal

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.

Table 2-30. Floating-point Parallel Comparison Relations


Quiet NaN
frel Completer
frel Relation Pseudo-op of as Operand
Unabbreviated
Signals Invalid
eq equal f2 == f3 No
lt less than f 2 < f3 Yes
le less than or equal f2 <= f3 Yes
gt greater than f 2 > f3 lt f2 ´ f3 Yes
ge greater than or equal f2 >= f3 le f2 ´ f3 Yes
unord unordered f2? f3 No
neq not equal !(f2 == f3) No
nlt not less than !(f2 < f3) Yes
nle not less than or equal !(f2 <= f3) Yes
ngt not greater than !(f2 > f3) nlt f2 ´ f3 Yes
nge not greater than or equal !(f2 >= f3) nle f2 ´ f 3 Yes
ord ordered !(f2? f3) No

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);

3:94 Volume 3: Instruction Reference


fpcmp

tmp_fr3 = fp_reg_read_hi(f3);

if (frel == ‘eq’) tmp_rel = fp_equal(tmp_fr2, tmp_fr3);


else if (frel == ‘lt’) tmp_rel = fp_less_than(tmp_fr2, tmp_fr3);
else if (frel == ‘le’) tmp_rel = fp_lesser_or_equal(tmp_fr2,
tmp_fr3);
else if (frel == ‘gt’) tmp_rel = fp_less_than(tmp_fr3, tmp_fr2);
else if (frel == ‘ge’) tmp_rel = fp_lesser_or_equal(tmp_fr3,
tmp_fr2);
else if (frel == ‘unord’) tmp_rel = fp_unordered(tmp_fr2, tmp_fr3);
else if (frel == ‘neq’) tmp_rel =!fp_equal(tmp_fr2, tmp_fr3);
else if (frel == ‘nlt’) tmp_rel =!fp_less_than(tmp_fr2, tmp_fr3);
else if (frel == ‘nle’) tmp_rel =!fp_lesser_or_equal(tmp_fr2,
tmp_fr3);
else if (frel == ‘ngt’) tmp_rel =!fp_less_than(tmp_fr3, tmp_fr2);
else if (frel == ‘nge’) tmp_rel =!fp_lesser_or_equal(tmp_fr3,
tmp_fr2);
else tmp_rel =!fp_unordered(tmp_fr2,
tmp_fr3); //‘ord’

tmp_res_hi = (tmp_rel? 0xFFFFFFFF: 0x00000000);

tmp_fr2 = fp_reg_read_lo(f2);
tmp_fr3 = fp_reg_read_lo(f3);

if (frel == ‘eq’) tmp_rel = fp_equal(tmp_fr2, tmp_fr3);


else if (frel == ‘lt’) tmp_rel = fp_less_than(tmp_fr2, tmp_fr3);
else if (frel == ‘le’) tmp_rel = fp_lesser_or_equal(tmp_fr2,
tmp_fr3);
else if (frel == ‘gt’) tmp_rel = fp_less_than(tmp_fr3, tmp_fr2);
else if (frel == ‘ge’) tmp_rel = fp_lesser_or_equal(tmp_fr3,
tmp_fr2);
else if (frel == ‘unord’) tmp_rel = fp_unordered(tmp_fr2, tmp_fr3);
else if (frel == ‘neq’) tmp_rel =!fp_equal(tmp_fr2, tmp_fr3);
else if (frel == ‘nlt’) tmp_rel =!fp_less_than(tmp_fr2, tmp_fr3);
else if (frel == ‘nle’) tmp_rel =!fp_lesser_or_equal(tmp_fr2,
tmp_fr3);
else if (frel == ‘ngt’) tmp_rel =!fp_less_than(tmp_fr3, tmp_fr2);
else if (frel == ‘nge’) tmp_rel =!fp_lesser_or_equal(tmp_fr3,
tmp_fr2);
else tmp_rel =!fp_unordered(tmp_fr2,
tmp_fr3); //‘ord’

tmp_res_lo = (tmp_rel? 0xFFFFFFFF: 0x00000000);

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_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
}

FP Exceptions: Invalid Operation (V)


Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:95


fpcvt.fx

fpcvt.fx — Convert Parallel Floating-point to Integer


Format: (qp) fpcvt.fx.sf f1 = f2 signed_form F10
(qp) fpcvt.fx.trunc.sf f1 = f2 signed_form, trunc_form F10
(qp) fpcvt.fxu.sf f1 = f2 unsigned_form F10
(qp) fpcvt.fxu.trunc.sf f1 = f2 unsigned_form, trunc_form F10

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.

3:96 Volume 3: Instruction Reference


fpcvt.fx

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};
}

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_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));
}
}

FP Exceptions: Invalid Operation (V) Inexact (I)


Denormal/Unnormal Operand (D)
Software Assist (SWA) Fault

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault Floating-point Exception trap

Volume 3: Instruction Reference 3:97


fpma

fpma — Floating-point Parallel Multiply Add


Format: (qp) fpma.sf f1 = f3, f4, f2 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 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.

3:98 Volume 3: Instruction Reference


fpma

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);
}

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_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));
}
}

FP Exceptions: Invalid Operation (V) Underflow (U)


Denormal/Unnormal Operand (D) Overflow (O)
Software Assist (SWA) Fault Inexact (I)
Software Assist (SWA) trap

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault Floating-point Exception trap

Volume 3: Instruction Reference 3:99


fpmax

fpmax — Floating-point Parallel Maximum


Format: (qp) fpmax.sf f1 = f2, f3 F8

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));

tmp_fr2 = tmp_right = fp_reg_read_hi(f2);


tmp_fr3 = tmp_left = fp_reg_read_hi(f3);
tmp_bool_res = fp_less_than(tmp_left, tmp_right);
tmp_res_hi = fp_single(tmp_bool_res? tmp_fr2: tmp_fr3);

tmp_fr2 = tmp_right = fp_reg_read_lo(f2);


tmp_fr3 = tmp_left = fp_reg_read_lo(f3);
tmp_bool_res = fp_less_than(tmp_left, tmp_right);
tmp_res_lo = fp_single(tmp_bool_res? tmp_fr2: tmp_fr3);

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_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
}

FP Exceptions: Invalid Operation (V)


Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault

3:100 Volume 3: Instruction Reference


fpmerge

fpmerge — Floating-point Parallel Merge


Format: (qp) fpmerge.ns f1 = f2, f3 neg_sign_form F9
(qp) fpmerge.s f1 = f2, f3 sign_form F9
(qp) fpmerge.se f1 = f2, f3 sign_exp_form F9

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.

Figure 2-15. Floating-point Parallel Merge Negative Sign Operation

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

Figure 2-16. Floating-point Parallel Merge Sign Operation

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

Volume 3: Instruction Reference 3:101


fpmerge

Figure 2-17. Floating-point Parallel Merge Sign and Exponent Operation

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});
}

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

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

3:102 Volume 3: Instruction Reference


fpmin

fpmin — Floating-point Parallel Minimum


Format: (qp) fpmin.sf f1 = f2, f3 F8

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));

tmp_fr2 = tmp_left = fp_reg_read_hi(f2);


tmp_fr3 = tmp_right = fp_reg_read_hi(f3);
tmp_bool_res = fp_less_than(tmp_left, tmp_right);
tmp_res_hi = fp_single(tmp_bool_res? tmp_fr2: tmp_fr3);

tmp_fr2 = tmp_left = fp_reg_read_lo(f2);


tmp_fr3 = tmp_right = fp_reg_read_lo(f3);
tmp_bool_res = fp_less_than(tmp_left, tmp_right);
tmp_res_lo = fp_single(tmp_bool_res? tmp_fr2: tmp_fr3);

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_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
}

FP Exceptions: Invalid Operation (V)


Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:103


fpmpy

fpmpy — Floating-point Parallel Multiply


Format: (qp) fpmpy.sf f1 = f3, f4 pseudo-op of: (qp) fpma.sf f1 = f3, f4, f0

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.

Operation: See “fpma — Floating-point Parallel Multiply Add” on page 3:98.

3:104 Volume 3: Instruction Reference


fpms

fpms — Floating-point Parallel Multiply Subtract


Format: (qp) fpms.sf f1 = f3, f4, f2 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 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].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);


FR[f1].exponent = FP_INTEGER_EXP;

Volume 3: Instruction Reference 3:105


fpms

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));
}
}

FP Exceptions: Invalid Operation (V) Underflow (U)


Denormal/Unnormal Operand (D) Overflow (O)
Software Assist (SWA) fault Inexact (I)
Software Assist (SWA) trap

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault Floating-point Exception trap

3:106 Volume 3: Instruction Reference


fpneg

fpneg — Floating-point Parallel Negate


Format: (qp) fpneg f1 = f3 pseudo-op of: (qp) fpmerge.ns f1 = f3, f3

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.

Operation: See “fpmerge — Floating-point Parallel Merge” on page 3:101.

Volume 3: Instruction Reference 3:107


fpnegabs

fpnegabs — Floating-point Parallel Negate Absolute Value


Format: (qp) fpnegabs f1 = f3 pseudo-op of: (qp) fpmerge.ns f1 = f0, f3

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.

Operation: See “fpmerge — Floating-point Parallel Merge” on page 3:101.

3:108 Volume 3: Instruction Reference


fpnma

fpnma — Floating-point Parallel Negative Multiply Add


Format: (qp) fpnma.sf f1 = f3, f4, f2 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, 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.

Volume 3: Instruction Reference 3:109


fpnma

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);
}

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_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));
}
}

FP Exceptions: Invalid Operation (V) Underflow (U)


Denormal/Unnormal Operand (D) Overflow (O)
Software Assist (SWA) fault Inexact (I)
Software Assist (SWA) trap

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault Floating-point Exception trap

3:110 Volume 3: Instruction Reference


fpnmpy

fpnmpy — Floating-point Parallel Negative Multiply


Format: (qp) fpnmpy.sf f1 = f3, f4 pseudo-op of: (qp) fpnma.sf f1 = f3, f4,f0

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.

Volume 3: Instruction Reference 3:111


fprcpa

fprcpa — Floating-point Parallel Reciprocal Approximation


Format: (qp) fprcpa.sf f1, p2 = f2, f3 F6

Description: If PR qp is 0, PR p2 is cleared and FR f1 remains unchanged.


If PR qp is 1, the following will occur:
• Each half of the significand of FR f1 is either set to an approximation (with a relative error <
2-8.886) of the reciprocal of the corresponding half of FR f3, or set to the IEEE-754 mandated
response for the quotient FR f2/FR f3 of the corresponding half — if that half of FR f2 or of FR
f3 is in the set {-Infinity, -0, +0, +Infinity, NaN}.
• If either half of FR f1 is set to the IEEE-754 mandated quotient, or is set to an approximation of
the reciprocal which may cause the Newton-Raphson iterations to fail to produce the correct
IEEE-754 divide result, then PR p2 is set to 0, otherwise it is set to 1.
For correct IEEE divide results, when PR p2 is cleared, user software is expected to compute
the quotient (FR f2/FR f3) for each half (using the non-parallel frcpa instruction), and merge the
results into FR f1, keeping PR p2 cleared.
• 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, and
PR p2 is cleared.
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;
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;

3:112 Volume 3: Instruction Reference


fprcpa

} 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);
}

FR[f1].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);


FR[f1].exponent = FP_INTEGER_EXP;
FR[f1].sign = FP_SIGN_POSITIVE;
PR[p2] = tmp_pred_hi && tmp_pred_lo;

fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
} else {
PR[p2] = 0;
}

FP Exceptions: Invalid Operation (V)


Zero Divide (Z)
Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:113


fprsqrta

fprsqrta — Floating-point Parallel Reciprocal Square Root Approximation


Format: (qp) fprsqrta.sf f1, p2 = f3 F7

Description: If PR qp is 0, PR p2 is cleared and FR f1 remains unchanged.


If PR qp is 1, the following will occur:
• Each half of the significand of FR f1 is either set to an approximation (with a relative error <
2-8.831) of the reciprocal square root of the corresponding half of FR f3, or set to the IEEE-754
compliant response for the reciprocal square root of the corresponding half of FR f3 — if that
half of FR f3 is in the set {-Infinity, -Finite, -0, +0, +Infinity, NaN}.
• If either half of FR f1 is set to the IEEE-754 mandated reciprocal square root, or is set to an
approximation of the reciprocal square root which may cause the Newton-Raphson iterations
to fail to produce the correct IEEE-754 square root result, then PR p2 is set to 0, otherwise it is
set to 1.
For correct IEEE square root results, when PR p2 is cleared, user software is expected to
compute the square root for each half (using the non-parallel frsqrta instruction), and merge the
results in FR f1, keeping PR p2 cleared.
• 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, and PR p2 is
cleared.
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, 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;

3:114 Volume 3: Instruction Reference


fprsqrta

}
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);
}

FR[f1].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);


FR[f1].exponent = FP_INTEGER_EXP;
FR[f1].sign = FP_SIGN_POSITIVE;
PR[p2] = tmp_pred_hi && tmp_pred_lo;

fp_update_fpsr(sf, tmp_fp_env);
}
fp_update_psr(f1);
} else {
PR[p2] = 0;
}

FP Exceptions: Invalid Operation (V)


Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:115


frcpa

frcpa — Floating-point Reciprocal Approximation


Format: (qp) frcpa.sf f1, p2 = f2, f3 F6

Description: If PR qp is 0, PR p2 is cleared and FR f1 remains unchanged.


If PR qp is 1, the following will occur:
• FR f1 is either set to an approximation (with a relative error < 2-8.886) of the reciprocal of FR f3,
or to the IEEE-754 mandated quotient of FR f2/FR f3 — if either FR f2 or FR f3 is in the set
{-Infinity, -0, Pseudo-zero, +0, +Infinity, NaN, Unsupported}.
• If FR f1 is set to the approximation of the reciprocal of FR f3, then PR p2 is set to 1; otherwise,
it is set to 0.
• If FR f2 and FR f3 are such that the approximation of FR f3’s reciprocal may cause the
Newton-Raphson iterations to fail to produce the correct IEEE-754 result of FR f2/FR f3, then a
Floating-point Exception fault for Software Assist occurs.
System software is expected to compute the IEEE-754 quotient (FR f2/FR f3), return the result
in FR f1, and set PR p2 to 0.
• If either FR f2 or FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result, and
PR p2 is cleared.
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;
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;

3:116 Volume 3: Instruction Reference


frcpa

}
}
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);
}

FP Exceptions: Invalid Operation (V)


Zero Divide (Z)
Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

Volume 3: Instruction Reference 3:117


frcpa

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault

3:118 Volume 3: Instruction Reference


frsqrta

frsqrta — Floating-point Reciprocal Square Root Approximation


Format: (qp) frsqrta.sf f1, p2 = f3 F7

Description: If PR qp is 0, PR p2 is cleared and FR f1 remains unchanged.


If PR qp is 1, the following will occur:
• FR f1 is either set to an approximation (with a relative error < 2-8.831) of the reciprocal square
root of FR f3, or set to the IEEE-754 mandated square root of FR f3 — if FR f3 is in the set
{-Infinity, -Finite, -0, Pseudo-zero, +0, +Infinity, NaN, Unsupported}.
• If FR f1 is set to an approximation of the reciprocal square root of FR f3, then PR p2 is set to 1;
otherwise, it is set to 0.
• If FR f3 is such the approximation of its reciprocal square root may cause the Newton-Raphson
iterations to fail to produce the correct IEEE-754 square root result, then a Floating-point
Exception fault for Software Assist occurs.
System software is expected to compute the IEEE-754 square root, return the result in FR f1,
and set PR p2 to 0.
• If FR f3 is a NaTVal, FR f1 is set to NaTVal instead of the computed result, and PR p2 is
cleared.
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, 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;

Volume 3: Instruction Reference 3:119


frsqrta

// 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,
};

tmp_index = (root.exponent{0} << 7) | root.significand{62:56};


tmp_res.significand = (1 << 63) | (RECIP_SQRT_TABLE[tmp_index] << 53);
tmp_res.exponent = FP_REG_EXP_HALF -
((root.exponent - FP_REG_BIAS) >> 1);
tmp_res.sign = FP_SIGN_POSITIVE;
return (tmp_res);
}

FP Exceptions: Invalid Operation (V)


Denormal/Unnormal Operand (D)
Software Assist (SWA) fault

Interruptions: Illegal Operation fault Floating-point Exception fault


Disabled Floating-point Register fault

3:120 Volume 3: Instruction Reference


fselect

fselect — Floating-point Select


Format: (qp) fselect f1 = f3, f4, f2 F3

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

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:121


fsetc

fsetc — Floating-point Set Controls


Format: (qp) fsetc.sf amask7, omask7 F12

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

Interruptions: Reserved Register/Field fault

3:122 Volume 3: Instruction Reference


fsub

fsub — Floating-point Subtract


Format: (qp) fsub.pc.sf f1 = f3, f2 pseudo-op of: (qp) fms.pc.sf f1 = f3, f1, f2

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.

Operation: See “fms — Floating-point Multiply Subtract” on page 3:81.

Volume 3: Instruction Reference 3:123


fswap

fswap — Floating-point Swap


Format: (qp) fswap f1 = f2, f3 swap_form F9
(qp) fswap.nl f1 = f2, f3 swap_nl_form F9
(qp) fswap.nr f1 = f2, f3 swap_nr_form F9

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.

Figure 2-18. Floating-point Swap

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

Figure 2-19. Floating-point Swap Negate Left

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

3:124 Volume 3: Instruction Reference


fswap

Figure 2-20. Floating-point Swap Negate Right

81 80 64 63 62 32 31 0 81 80 64 63 32 31 0
FR f2 FR f3

Negated Sign Bit

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});
}

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

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:125


fsxt

fsxt — Floating-point Sign Extend


Format: (qp) fsxt.l f1 = f2, f3 sxt_l_form F9
(qp) fsxt.r f1 = f2, f3 sxt_r_form F9

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.

Figure 2-21. Floating-point Sign Extend Left

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

Figure 2-22. Floating-point Sign Extend Right

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};
}

FR[f1].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);


FR[f1].exponent = FP_INTEGER_EXP;
FR[f1].sign = FP_SIGN_POSITIVE;
}

3:126 Volume 3: Instruction Reference


fsxt

fp_update_psr(f1);
}

FP Exceptions: None

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:127


fwb

fwb — Flush Write Buffers


Format: (qp) fwb M24

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

3:128 Volume 3: Instruction Reference


fxor

fxor — Floating-point Exclusive Or


Format: (qp) fxor f1 = f2, f3 F9

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

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:129


getf

getf — Get Floating-point Value or Exponent or Significand


Format: (qp) getf.s r1 = f2 single_form M19
(qp) getf.d r1 = f2 double_form M19
(qp) getf.exp r1 = f2 exponent_form M19
(qp) getf.sig r1 = f2 significand_form M19

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.

Figure 2-23. Function of getf.exp

FR f2 s exponent significand

63 18 16 0

GR r1 0
46 1 17

In the significand_form, the significand field of the value in FR f2 is copied to GR r1

Figure 2-24. Function of getf.sig

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]))

3:130 Volume 3: Instruction Reference


getf

GR[r1].nat = 1;
else
GR[r1].nat = 0;
}

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:131


hint

hint — Performance Hint


Format: (qp) hint imm21 pseudo-op
(qp) hint.i imm21 i_unit_form I18
(qp) hint.b imm21 b_unit_form B9
(qp) hint.m imm21 m_unit_form M48
(qp) hint.f imm21 f_unit_form F16
(qp) hint.x imm62 x_unit_form X5

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.

Table 2-31. Hint Immediates


imm21 or imm62 Mnemonic Hint
0x0 @pause Indicates to the processor that the currently executing stream is waiting,
spinning, or doing low priority tasks. This hint can be used by the processor
to allocate more resources or time to another executing stream on the
same processor.
0x01-0x3f These values are available for future architected extensions and will
execute as a nop on all current processors. Use of these values may cause
unexpected performance issues on future processors and should not be
used.
other Implementation specific. Performs an implementation-specific hint action.
Consult processor model-specific documentation for details.

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

3:132 Volume 3: Instruction Reference


invala

invala — Invalidate ALAT


Format: (qp) invala complete_form M24
(qp) invala.e r1 gr_form, entry_form M26
(qp) invala.e f1 fr_form, entry_form M27

Description: The selected entry or entries in the ALAT are invalidated.


In the complete_form, all ALAT entries are invalidated. In the entry_form, the ALAT is queried
using the general register specifier r1 (gr_form), or the floating-point register specifier f1 (fr_form),
and if any ALAT entry matches, it is invalidated.

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

Volume 3: Instruction Reference 3:133


itc

itc — Insert Translation Cache


Format: (qp) itc.i r2 instruction_form M41
(qp) itc.d r2 data_form M41

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.

3:134 Volume 3: Instruction Reference


itc

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 (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);
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);
}
}

Interruptions: Machine Check abort Reserved Register/Field fault


Illegal Operation fault Unimplemented Data Address fault
Privileged Operation fault Virtualization fault
Register NaT Consumption fault

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.

Volume 3: Instruction Reference 3:135


itr

itr — Insert Translation Register


Format: (qp) itr.i itr[r3] = r2 instruction_form M42
(qp) itr.d dtr[r3] = r2 data_form M42

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);

tmp_tr_type = instruction_form? ITR_TYPE: DTR_TYPE;

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);
}
}

Interruptions: Machine Check abort Reserved Register/Field fault


Illegal Operation fault Unimplemented Data Address fault

3:136 Volume 3: Instruction Reference


itr

Privileged Operation fault Virtualization fault


Register NaT Consumption fault

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.

Volume 3: Instruction Reference 3:137


ld

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.

Table 2-32. sz Completers


sz Completer Bytes Accessed
1 1 byte
2 2 bytes
4 4 bytes
8 8 bytes

Table 2-33. Load Types


ldtype
Interpretation Special Load Operation
Completer
none Normal load
s Speculative load Certain exceptions may be deferred rather than generating a fault.
Deferral causes the target register’s NaT bit to be set. The NaT bit is
later used to detect deferral.
a Advanced load An entry is added to the ALAT. This allows later instructions to check for
colliding stores. If the referenced data page has a non-speculative
attribute, the target register and NaT bit is cleared, and the processor
ensures that no ALAT entry exists for the target register. The absence of
an ALAT entry is later used to detect deferral or collision.

3:138 Volume 3: Instruction Reference


ld

Table 2-33. Load Types (Continued)


ldtype
Interpretation Special Load Operation
Completer
sa Speculative An entry is added to the ALAT, and certain exceptions may be deferred.
Advanced load Deferral causes the target register’s NaT bit to be set, and the
processor ensures that no ALAT entry exists for the target register. The
absence of an ALAT entry is later used to detect deferral or collision.
c.nc Check load The ALAT is searched for a matching entry. If found, no load is done
– no clear and the target register is unchanged. Regardless of ALAT hit or miss,
base register updates are performed, if specified. An implementation
may optionally cause the ALAT lookup to fail independent of whether an
ALAT entry matches. If not found, a load is performed, and an entry is
added to the ALAT (unless the referenced data page has a
non-speculative attribute, in which case no ALAT entry is allocated).
c.clr Check load The ALAT is searched for a matching entry. If found, the entry is
– clear removed, no load is done and the target register is unchanged.
Regardless of ALAT hit or miss, base register updates are performed, if
specified. An implementation may optionally cause the ALAT lookup to
fail independent of whether an ALAT entry matches. If not found, a clear
check load behaves like a normal load.
c.clr.acq Ordered check load This type behaves the same as the unordered clear form, except that
– clear the ALAT lookup (and resulting load, if no ALAT entry is found) is
performed with acquire semantics.
acq Ordered load An ordered load is performed with acquire semantics.
bias Biased load A hint is provided to the implementation to acquire exclusive ownership
of the accessed cache line.

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.

Table 2-34. Load Hints


ldhint Completer Interpretation
none Temporal locality, level 1
nt1 No temporal locality, level 1
nta No temporal locality, all levels

Volume 3: Instruction Reference 3:139


ld

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);

speculative = (ldtype == ‘s’ || ldtype == ‘sa’);


advanced = (ldtype == ‘a’ || ldtype == ‘sa’);
check_clear = (ldtype == ‘c.clr’ || ldtype == ‘c.clr.acq’);
check_no_clear = (ldtype == ‘c.nc’);
check = check_clear || check_no_clear;
acquire = (acquire_form || ldtype == ‘acq’ || ldtype == ‘c.clr.acq’);
otype = acquire? ACQUIRE: UNORDERED;
bias = (ldtype == ‘bias’)? BIAS: 0;
translate_address = 1;
read_memory = 1;

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;
}

if (!speculative && GR[r3].nat) // fault on NaT address


register_nat_consumption_fault(itype);
defer = speculative && (GR[r3].nat || PSR.ed); // defer exception if spec

if (check && alat_cmp(GENERAL, r1)) {


translate_address = alat_translate_address_on_hit(ldtype, GENERAL, r1);
read_memory = alat_read_memory_on_hit(ldtype, GENERAL, r1);
}
if (!translate_address) {
if (check_clear || advanced) // remove any old alat entry
alat_inval_single_entry(GENERAL, r1);
} else {
if (!defer) {
paddr = tlb_translate(GR[r3], size, itype, PSR.cpl, &mattr,
&defer);

3:140 Volume 3: Instruction Reference


ld

spontaneous_deferral(paddr, size, UM.be, mattr, otype,


bias | ldhint, &defer);
if (!defer && read_memory) {
if (size == 16) {
mem_read_pair(&val, &val_ar, paddr, size, UM.be, mattr,
otype, ldhint);
}
else {
val = mem_read(paddr, size, UM.be, mattr, otype,
bias | ldhint);
}
}
}
if (check_clear || advanced) // remove any old ALAT entry
alat_inval_single_entry(GENERAL, r1);
if (defer) {
if (speculative) {
GR[r1] = natd_gr_read(paddr, size, UM.be, mattr, otype,
bias | ldhint);
GR[r1].nat = 1;
} else {
GR[r1] = 0; // ld.a to sequential memory
GR[r1].nat = 0;
}
} else { // execute load normally
if (fill_form) { // fill NaT on ld8.fill
bit_pos = GR[r3]{8:3};
GR[r1] = val;
GR[r1].nat = AR[UNAT]{bit_pos};
} else { // clear NaT on other types
if (size == 16) {
GR[r1] = val;
AR[CSD] = val_ar;
}
else {
GR[r1] = zero_ext(val, size * 8);
}
GR[r1].nat = 0;
}
if ((check_no_clear || advanced) && ma_is_speculative(mattr))
// add entry to ALAT
alat_write(ldtype, GENERAL, r1, paddr, size);
}
}

if (imm_base_update_form) { // update base register


GR[r3] = GR[r3] + sign_ext(imm9, 9);
GR[r3].nat = GR[r3].nat;
} else if (reg_base_update_form) {
GR[r3] = GR[r3] + tmp_r2;
GR[r3].nat = GR[r3].nat || tmp_r2nat;
}

if ((reg_base_update_form || imm_base_update_form) &&!GR[r3].nat)


mem_implicit_prefetch(GR[r3], ldhint | bias, itype);
}

Interruptions: Illegal Operation fault Data NaT Page Consumption fault


Register NaT Consumption fault Data Key Miss fault
Unimplemented Data Address fault Data Key Permission fault
Data Nested TLB fault Data Access Rights fault

Volume 3: Instruction Reference 3:141


ld

Alternate Data TLB fault Data Access Bit fault


VHPT Data fault Data Debug fault
Data TLB fault Unaligned Data Reference fault
Data Page Not Present fault Unsupported Data Reference fault

3:142 Volume 3: Instruction Reference


ldf

ldf — Floating-point Load


Format: (qp) ldffsz.fldtype.ldhint f1 = [r3] no_base_update_form M6
(qp) ldffsz.fldtype.ldhint f1 = [r3], r2 reg_base_update_form M7
(qp) ldffsz.fldtype.ldhint f1 = [r3], imm9 imm_base_update_form M8
(qp) ldf8.fldtype.ldhint f1 = [r3] integer_form, no_base_update_form M6
(qp) ldf8.fldtype.ldhint f1 = [r3], r2 integer_form, reg_base_update_form M7
(qp) ldf8.fldtype.ldhint f1 = [r3], imm9 integer_form, imm_base_update_form M8
(qp) ldf.fill.ldhint f1 = [r3] fill_form, no_base_update_form M6
(qp) ldf.fill.ldhint f1 = [r3], r2 fill_form, reg_base_update_form M7
(qp) ldf.fill.ldhint f1 = [r3], imm9 fill_form, imm_base_update_form M8

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.

Table 2-35. fsz Completers


fsz Completer Bytes Accessed Memory Format
s 4 bytes Single precision
d 8 bytes Double precision
e 10 bytes Extended precision

Table 2-36. FP Load Types


fldtype
Interpretation Special Load Operation
Completer
none Normal load
s Speculative load Certain exceptions may be deferred rather than generating a fault.
Deferral causes NaTVal to be placed in the target register. The NaTVal
value is later used to detect deferral.
a Advanced load An entry is added to the ALAT. This allows later instructions to check for
colliding stores. If the referenced data page has a non-speculative
attribute, no ALAT entry is added to the ALAT and the target register is
set as follows: for the integer_form, the exponent is set to 0x1003E and
the sign and significand are set to zero; for all other forms, the sign,
exponent and significand are set to zero. The absence of an ALAT entry
is later used to detect deferral or collision.

Volume 3: Instruction Reference 3:143


ldf

Table 2-36. FP Load Types (Continued)


fldtype
Interpretation Special Load Operation
Completer
sa Speculative An entry is added to the ALAT, and certain exceptions may be deferred.
Advanced load Deferral causes NaTVal to be placed in the target register, and the
processor ensures that no ALAT entry exists for the target register. The
absence of an ALAT entry is later used to detect deferral or collision.
c.nc Check load – The ALAT is searched for a matching entry. If found, no load is done
no clear and the target register is unchanged. Regardless of ALAT hit or miss,
base register updates are performed, if specified. An implementation
may optionally cause the ALAT lookup to fail independent of whether an
ALAT entry matches. If not found, a load is performed, and an entry is
added to the ALAT (unless the referenced data page has a
non-speculative attribute, in which case no ALAT entry is allocated).
c.clr Check load – clear The ALAT is searched for a matching entry. If found, the entry is
removed, no load is done and the target register is unchanged.
Regardless of ALAT hit or miss, base register updates are performed, if
specified. An implementation may optionally cause the ALAT lookup to
fail independent of whether an ALAT entry matches. If not found, a clear
check load behaves like a normal load.

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.

3:144 Volume 3: Instruction Reference


ldf

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 (!speculative && GR[r3].nat) // fault on NaT address


register_nat_consumption_fault(itype);

defer = speculative && (GR[r3].nat || PSR.ed); // defer exception if spec

if (check && alat_cmp(FLOAT, f1)) {


translate_address = alat_translate_address_on_hit(fldtype, FLOAT, f1);
read_memory = alat_read_memory_on_hit(fldtype, FLOAT, f1);
}

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);

if ((check_no_clear || advanced) && ma_is_speculative(mattr))


// add entry to ALAT
alat_write(fldtype, FLOAT, f1, paddr, size);
}
}

if (imm_base_update_form) { // update base register


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];

Volume 3: Instruction Reference 3:145


ldf

GR[r3].nat = GR[r3].nat || GR[r2].nat;


}

if ((reg_base_update_form || imm_base_update_form) &&!GR[r3].nat)


mem_implicit_prefetch(GR[r3], ldhint, itype);

fp_update_psr(f1);
}

Interruptions: Illegal Operation fault Data NaT Page Consumption fault


Disabled Floating-point Register fault Data Key Miss fault
Register NaT Consumption fault Data Key Permission fault
Unimplemented Data Address fault Data Access Rights fault
Data Nested TLB fault Data Access Bit fault
Alternate Data TLB fault Data Debug fault
VHPT Data fault Unaligned Data Reference fault
Data TLB fault Unsupported Data Reference fault
Data Page Not Present fault

3:146 Volume 3: Instruction Reference


ldfp

ldfp — Floating-point Load Pair


Format: (qp) ldfps.fldtype.ldhint f1, f2 = [r3] single_form, no_base_update_form M11
(qp) ldfps.fldtype.ldhint f1, f2 = [r3], 8 single_form, base_update_form M12
(qp) ldfpd.fldtype.ldhint f1, f2 = [r3] double_form, no_base_update_form M11
(qp) ldfpd.fldtype.ldhint f1, f2 = [r3], 16 double_form, base_update_form M12
(qp) ldfp8.fldtype.ldhint f1, f2 = [r3] integer_form, no_base_update_form M11
(qp) ldfp8.fldtype.ldhint f1, f2 = [r3], 16 integer_form, base_update_form M12

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).

Volume 3: Instruction Reference 3:147


ldfp

Operation: if (PR[qp]) {
size = single_form? 8: 16;

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 (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 (!speculative && GR[r3].nat) // fault on NaT address


register_nat_consumption_fault(itype);

defer = speculative && (GR[r3].nat || PSR.ed); // defer exception if spec

if (check && alat_cmp(FLOAT, f1)) {


translate_address = alat_translate_address_on_hit(fldtype, FLOAT, f1);
read_memory = alat_read_memory_on_hit(fldtype, FLOAT, f1);
}

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);

if ((check_no_clear || advanced) && ma_is_speculative(mattr))

3:148 Volume 3: Instruction Reference


ldfp

// add entry to ALAT


alat_write(fldtype, FLOAT, f1, paddr, size);
}
}

if (base_update_form) { // update base register


GR[r3] = GR[r3] + size;
GR[r3].nat = GR[r3].nat;
if (!GR[r3].nat)
mem_implicit_prefetch(GR[r3], ldhint, itype);
}

fp_update_psr(f1);
fp_update_psr(f2);
}

Interruptions: Illegal Operation fault Data Page Not Present fault


Disabled Floating-point Register fault Data NaT Page Consumption fault
Register NaT Consumption fault Data Key Miss fault
Unimplemented Data Address fault Data Key Permission fault
Data Nested TLB fault Data Access Rights fault
Alternate Data TLB fault Data Access Bit fault
VHPT Data fault Data Debug fault
Data TLB fault Unaligned Data Reference fault

Volume 3: Instruction Reference 3:149


lfetch

lfetch — Line Prefetch


Format: (qp) lfetch.lftype.lfhint [r3] no_base_update_form M13
(qp) lfetch.lftype.lfhint [r3], r2 reg_base_update_form M14
(qp) lfetch.lftype.lfhint [r3], imm9 imm_base_update_form M15
(qp) lfetch.lftype.excl.lfhint [r3] no_base_update_form, exclusive_form M13
(qp) lfetch.lftype.excl.lfhint [r3], r2 reg_base_update_form, exclusive_form M14
(qp) lfetch.lftype.excl.lfhint [r3], imm9 imm_base_update_form, exclusive_form M15

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.

Table 2-37. lftype Mnemonic Values


lftype Mnemonic Interpretation
none Ignore faults
fault Raise faults

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.

3:150 Volume 3: Instruction Reference


lfetch

Table 2-38. lfhint Mnemonic Values


lfhint Mnemonic Interpretation
none Temporal locality, level 1
nt1 No temporal locality, level 1
nt2 No temporal locality, level 2
nta No temporal locality, all levels

A faulting lfetch to an unimplemented address results in an Unimplemented Data Address fault. A


non-faulting lfetch to an unimplemented address does not take the fault and will not issue a prefetch
request, but, if specified, will perform a register post-increment.
Both the non-faulting and the faulting forms of lfetch can be used speculatively. The purpose of
raising faults on the faulting form is to allow the operating system to resolve problems with the
address to the extent that it can do so relatively quickly. If problems with the address cannot be
resolved quickly, the OS simply returns to the program, and forces the data prefetch to be skipped
over.
Specifically, if a faulting lfetch takes any of the listed faults (other than Illegal Operation fault), the
operating system must handle this fault to the extent that it can do so relatively quickly and
invisibly to the interrupted program. If the fault cannot be handled quickly or cannot be handled
invisibly (e.g., if handling the fault would involve terminating the program), the OS must return to
the interrupted program, skipping over the data prefetch. This can easily be done by setting the
IPSR.ed bit to 1 before executing an rfi to go back to the process, which will allow the lfetch.fault to
perform its base register post-increment (if specified), but will suppress any prefetch request and
hence any prefetch-related fault. Note that the OS can easily identify that a faulting lfetch was the
cause of the fault by observing that ISR.na is 1, and ISR.code{3:0} is 4. The one exception to this is
the Illegal Operation fault, which can be caused by an lfetch.fault if base register post-increment is
specified, and the base register is outside of the current stack frame, or is GR0. Since this one fault
is not related to the prefetch aspect of lfetch.fault, but rather to the base update portion, Illegal
Operation faults on lfetch.fault should be handled the same as for any other instruction.

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 (lftype == ‘fault’) { // faulting form


if (GR[r3].nat &&!PSR.ed) // fault on NaT address
register_nat_consumption_fault(itype);
}

excl_hint = (exclusive_form)? EXCLUSIVE: 0;

if (!GR[r3].nat &&!PSR.ed) {// faulting form already faulted if r3 is nat


paddr = tlb_translate(GR[r3], 1, itype, PSR.cpl, &mattr, &defer);
if (!defer)
mem_promote(paddr, mattr, lfhint | excl_hint);
}

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];

Volume 3: Instruction Reference 3:151


lfetch

GR[r3].nat = GR[r2].nat || GR[r3].nat;


}

if ((reg_base_update_form || imm_base_update_form) &&!GR[r3].nat)


mem_implicit_prefetch(GR[r3], lfhint | excl_hint, itype);
}

Interruptions: Illegal Operation fault Data Page Not Present fault


Register NaT Consumption fault Data NaT Page Consumption fault
Unimplemented Data Address fault Data Key Miss fault
Data Nested TLB fault Data Key Permission fault
Alternate Data TLB fault Data Access Rights fault
VHPT Data fault Data Access Bit fault
Data TLB fault Data Debug fault

3:152 Volume 3: Instruction Reference


loadrs

loadrs — Load Register Stack


Format: loadrs M25

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();

if ((CFM.sof!= 0) && (AR[RSC].loadrs!= 0))


illegal_operation_fault();

rse_ensure_regs_loaded(AR[RSC].loadrs); // can raise faults listed below


AR[RNAT] = undefined();

Interruptions: Illegal Operation fault Data NaT Page Consumption fault


Unimplemented Data Address fault Data Key Miss fault
Data Nested TLB fault Data Key Permission fault
Alternate Data TLB fault Data Access Rights fault
VHPT Data fault Data Access Bit fault
Data TLB fault Data Debug fault
Data Page Not Present fault

Volume 3: Instruction Reference 3:153


mf

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

3:154 Volume 3: Instruction Reference


mix

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.

Volume 3: Instruction Reference 3:155


mix

Figure 2-25. Mix Examples

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:

3:156 Volume 3: Instruction Reference


mix

Operation: if (PR[qp]) {
check_target_register(r1);

if (one_byte_form) { // one-byte elements


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 (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]);

} 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 (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]);

} 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 (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;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:157


mov ar

mov — Move Application Register


Format: (qp) mov r1 = ar3 pseudo-op
(qp) mov ar3 = r2 pseudo-op
(qp) mov ar3 = imm8 pseudo-op
(qp) mov.i r1 = ar3 i_form, from_form I28
(qp) mov.i ar3 = r2 i_form, register_form, to_form I26
(qp) mov.i ar3 = imm8 i_form, immediate_form, to_form I27
(qp) mov.m r1 = ar3 m_form, from_form M31
(qp) mov.m ar3 = r2 m_form, register_form, to_form M29
(qp) mov.m ar3 = imm8 m_form, immediate_form, to_form M30

Description: The source operand is copied to the destination register.


In the from_form, the application register specified by ar3 is copied into GR r1 and the
corresponding NaT bit is cleared.
In the to_form, the value in GR r2 (in the register_form), or the sign-extended value in imm8 (in the
immediate_form), is placed in AR ar3. In the register_form if the NaT bit corresponding to GR r2 is
set, then a Register NaT Consumption fault is raised.
Only a subset of the application registers can be accessed by each execution unit (M or I). Table 3-3
on page 1:26 indicates which application registers may be accessed from which execution unit
type. An access to an application register from the wrong unit type causes an Illegal Operation
fault.
This instruction has multiple forms with the pseudo operation eliminating the need for specifying
the execution unit. Accesses of the ARs are always implicitly serialized. While implicitly
serialized, read-after-write and write-after-write dependency violations must be avoided (e.g.,
setting CCV, followed by cmpxchg in the same instruction group, or simultaneous writes to the
UNAT register by ld.fill and mov to UNAT).

3:158 Volume 3: Instruction Reference


mov ar

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 (ar3 == ITC && PSR.si && PSR.cpl!= 0)


privileged_register_fault();

if (ar3 == ITC && PSR.si && PSR.vm == 1)


virtualization_fault();

GR[r1] = (is_ignored_reg(ar3))? 0: AR[ar3];


GR[r1].nat = 0;
} else { // to_form
tmp_val = (register_form)? GR[r2]: sign_ext(imm8, 8);

if (is_read_only_register(AR_TYPE, ar3) ||
(((ar3 == BSPSTORE) || (ar3 == RNAT)) && (AR[RSC].mode!= 0)))
illegal_operation_fault();

if (register_form && GR[r2].nat)


register_nat_consumption_fault(0);

if (is_reserved_field(AR_TYPE, ar3, tmp_val))


reserved_register_field_fault();

if ((is_kernel_reg(ar3) || ar3 == ITC) && (PSR.cpl!= 0))


privileged_register_fault();

if (ar3 == ITC && PSR.vm == 1)


virtualization_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();
}
}
}
}

Interruptions: Illegal Operation fault Privileged Register fault


Register NaT Consumption fault Virtualization fault
Reserved Register/Field fault

Volume 3: Instruction Reference 3:159


mov br

mov — Move Branch Register


Format: (qp) mov r1 = b2 from_form I22
(qp) mov b1 = r2 pseudo-op
(qp) mov.mwh.ih b1 = r2, tag13 to_form I21
(qp) mov.ret.mwh.ih b1 = r2, tag13 return_form, to_form I21

Description: The source operand is copied to the destination register.


In the from_form, the branch register specified by b2 is copied into GR r1. The NaT bit
corresponding to GR r1 is cleared.
In the to_form, the value in GR r2 is copied into BR b1. If the NaT bit corresponding to GR r2 is 1,
then a Register NaT Consumption fault is taken.
A set of hints can also be provided when moving to a branch register. These hints are very similar
to those provided on the brp instruction, and provide prediction information about a future branch
which may use the value being moved into BR b1. The return_form is used to provide the hint that
this value will be used in a return-type branch.
The values for the mwh whether hint completer are given in Table 2-39. For a description of the ih
hint completer see the Branch Prediction instruction and Table 2-13 on page 3:31.

Table 2-39. Move to BR Whether Hints


mwh Completer Move to BR Whether Hint
none Ignore all hints
sptk Static Taken
dptk Dynamic

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);
}
}

Interruptions: Illegal Operation fault Register NaT Consumption fault

3:160 Volume 3: Instruction Reference


mov cr

mov — Move Control Register


Format: (qp) mov r1 = cr3 from_form M33
(qp) mov cr3 = r2 to_form M32

Description: The source operand is copied to the destination register.


For the from_form, the control register specified by cr3 is read and the value copied into GR r1.
For the to_form, GR r2 is read and the value copied into CR cr3.
Control registers can only be accessed at the most privileged level, and when PSR.vm is 0. Reading
or writing an interruption control register (CR16-CR25), when the PSR.ic bit is one, will result in
an Illegal Operation fault.

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);

if (is_reserved_field(CR_TYPE, cr3, GR[r2]))


reserved_register_field_fault();
if ((cr3 == IFA) && impl_check_mov_ifa() &&
unimplemented_virtual_address(GR[r2], PSR.vm))
unimplemented_data_address_fault(0);
if (PSR.vm == 1)
virtualization_fault();
if (cr3 == EOI)
end_of_interrupt();

tmp_val = ignored_field_mask(CR_TYPE, cr3, GR[r2]);


CR[cr3] = tmp_val;
if (cr3 == IIPA)
last_IP = tmp_val;
}
}

Interruptions: Illegal Operation fault Reserved Register/Field fault


Privileged Operation fault Unimplemented Data Address fault
Register NaT Consumption fault Virtualization fault

Volume 3: Instruction Reference 3:161


mov cr

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.

3:162 Volume 3: Instruction Reference


mov fr

mov — Move Floating-point Register


Format: (qp) mov f1 = f3 pseudo-op of: (qp) fmerge.s f1 = f3, f3

Description: The value of FR f3 is copied to FR f1.

Operation: See “fmerge — Floating-point Merge” on page 3:75.

Volume 3: Instruction Reference 3:163


mov gr

mov — Move General Register


Format: (qp) mov r1 = r3 pseudo-op of: (qp) adds r1 = 0, r3

Description: The value of GR r3 is copied to GR r1.

Operation: See “add — Add” on page 3:14.

3:164 Volume 3: Instruction Reference


mov imm

mov — Move Immediate


Format: (qp) mov r1 = imm22 pseudo-op of: (qp) addl r1 = imm22, r0

Description: The immediate value, imm22, is sign extended to 64 bits and placed in GR r1.

Operation: See “add — Add” on page 3:14.

Volume 3: Instruction Reference 3:165


mov indirect

mov — Move Indirect Register


Format: (qp) mov r1 = ireg[r3] from_form M43
(qp) mov ireg[r3] = r2 to_form M42

Description: The source operand is copied to the destination register.


For move from indirect register, GR r3 is read and the value used as an index into the register file
specified by ireg (see Table 2-40 below). The indexed register is read and its value is copied into
GR r1.
For move to indirect register, GR r3 is read and the value used as an index into the register file
specified by ireg. GR r2 is read and its value copied into the indexed register.

Table 2-40. Indirect Register File Mnemonics


ireg Register File
cpuid Processor Identification Register
dbr Data Breakpoint Register
ibr Instruction Breakpoint Register
pkr Protection Key Register
pmc Performance Monitor Configuration Register
pmd Performance Monitor Data Register
rr Region Register

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.

3:166 Volume 3: Instruction Reference


mov indirect

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 (PSR.cpl!= 0 &&!(ireg == PMD_TYPE || ireg == CPUID_TYPE))


privileged_operation_fault(0);

if (GR[r3].nat)
register_nat_consumption_fault(0);

if (is_reserved_reg(ireg, tmp_index))
reserved_register_field_fault();

if (PSR.vm == 1 && ireg!= PMD_TYPE)


virtualization_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;

Volume 3: Instruction Reference 3:167


mov indirect

case RR_TYPE: RR[tmp_index]= tmp_val; break;


}
}
}

Interruptions: Illegal Operation fault Reserved Register/Field fault


Privileged Operation fault Virtualization fault
Register NaT Consumption fault

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.

3:168 Volume 3: Instruction Reference


mov ip

mov — Move Instruction Pointer


Format: (qp) mov r1 = ip I25

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;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:169


mov pr

mov — Move Predicates


Format: (qp) mov r1 = pr from_form I25
(qp) mov pr = r2, mask17 to_form I23
(qp) mov pr.rot = imm44 to_rotate_form I24

Description: The source operand is copied to the destination register.


For moving the predicates to a GR, PR i is copied to bit position i within GR r1.
For moving to the predicates, the source can either be a general register, or an immediate value. In
the to_form, the source operand is GR r2 and only those predicates specified by the immediate
value mask17 are written. The value mask17 is encoded in the instruction in an imm16 field such
that: imm16 = mask17 >> 1. Predicate register 0 is always one. The mask17 value is sign extended.
The most significant bit of mask17, therefore, is the mask bit for all of the rotating predicates. If
there is a deferred exception for GR r2 (the NaT bit is 1), a Register NaT Consumption fault is
taken.
In the to_rotate_form, only the 48 rotating predicates can be written. The source operand is taken
from the imm44 operand (which is encoded in the instruction in an imm28 field, such that: imm28 =
imm44 >> 16). The low 16-bits correspond to the static predicates. The immediate is sign extended to
set the top 21 predicates. Bit position i in the source operand is copied to PR i.
This instruction operates as if the predicate rotation base in the Current Frame Marker (CFM.rrb.pr)
were zero.

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};
}
}
}

Interruptions: Illegal Operation fault Register NaT Consumption fault

3:170 Volume 3: Instruction Reference


mov psr

mov — Move Processor Status Register


Format: (qp) mov r1 = psr from_form M36
(qp) mov psr.l = r2 to_form M35

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 (is_reserved_field(PSR_TYPE, PSR_MOVPART, GR[r2]))


reserved_register_field_fault();

if (PSR.vm == 1)
virtualization_fault();

PSR{31:0} = GR[r2]{31:0};
}
}

Interruptions: Illegal Operation fault Reserved Register/Field fault


Privileged Operation fault Virtualization fault
Register NaT Consumption fault

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.

Volume 3: Instruction Reference 3:171


mov um

mov — Move User Mask


Format: (qp) mov r1 = psr.um from_form M36
(qp) mov psr.um = r2 to_form M35

Description: The source operand is copied to the destination register.


For move from user mask, PSR{5:0} is read, zero-extend, and copied into GR r1.
For move to user mask, PSR{5:0} is written by bits {5:0} of GR r2. PSR.up can only be modified if
the secure performance monitor bit (PSR.sp) is zero. Otherwise PSR.up is not modified.
Writing a non-zero value into any other parts of the PSR results in a Reserved Register/Field fault.

Operation: if (PR[qp]) {
if (from_form) {
check_target_register(r1);

GR[r1] = zero_ext(PSR{5:0}, 6);


GR[r1].nat = 0;
} else { // to_form
if (GR[r2].nat)
register_nat_consumption_fault(0);

if (is_reserved_field(PSR_TYPE, PSR_UM, GR[r2]))


reserved_register_field_fault();

PSR{1:0} = GR[r2]{1:0};

if (PSR.sp == 0) // unsecured perf monitor


PSR{2} = GR[r2]{2};

PSR{5:3} = GR[r2]{5:3};
}
}

Interruptions: Illegal Operation fault Reserved Register/Field fault


Register NaT Consumption fault

Serialization: All user mask modifications are observed by the next instruction group.

3:172 Volume 3: Instruction Reference


movl

movl — Move Long Immediate


Format: (qp) movl r1 = imm64 X2

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;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:173


mux

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.

Table 2-41. Mux Permutations for 8-bit Elements


mbtype4 Function
@rev Reverse the order of the bytes
@mix Perform a Mix operation on the two halves of GR r2
@shuf Perform a Shuffle operation on the two halves of GR r2
@alt Perform an Alternate operation on the two halves of GR r2
@brcst Perform a Broadcast operation on the least significand byte of GR r2

Figure 2-26. Mux1 Operation (8-bit elements)

GR r2: GR r2:

GR r1: GR r1:

mux1 r1 = r2, @rev mux1 r1 = r2, @mix

GR r2: GR r2:

GR r1: GR r1:

mux1 r1 = r2, @shuf mux1 r1 = r2, @alt

GR r2:

GR r1:

mux1 r1 = r2, @brcst

3:174 Volume 3: Instruction Reference


mux

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).

Figure 2-27. Mux2 Examples (16-bit elements)

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)

Volume 3: Instruction Reference 3:175


mux

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}];

GR[r1] = concatenate4(res[3], res[2], res[1], res[0]);


}
GR[r1].nat = GR[r2].nat;
}

Interruptions: Illegal Operation fault

3:176 Volume 3: Instruction Reference


nop

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

Description: No operation is done.


The immediate, imm21 or imm62, can be used by software as a marker in program code. It is ignored
by hardware.
For the x_unit_form, the L slot of the bundle contains the upper 41 bits of imm62.
A nop.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]) {
; // no operation
}

Interruptions: None

Volume 3: Instruction Reference 3:177


or

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);

tmp_src = (register_form? GR[r2]: sign_ext(imm8, 8));


tmp_nat = (register_form? GR[r2].nat: 0);

GR[r1] = tmp_src | GR[r3];


GR[r1].nat = tmp_nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

3:178 Volume 3: Instruction Reference


pack

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.

Table 2-42. Pack Saturation Limits


Source Element Result Element Upper
Size Saturation Lower Limit
Width Width Limit
2 16 bit 8 bit signed 0x7f 0x80
2 16 bit 8 bit unsigned 0xff 0x00
4 32 bit 16 bit signed 0x7fff 0x8000

Figure 2-28. Pack Operation

GR r3: GR r2:

GR r1:

pack4

GR r3: GR r2:

GR r1:

pack2

Volume 3: Instruction Reference 3:179


pack

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);

for (i = 0; i < 8; i++) {


if (temp[i] > max)
temp[i] = max;

if (temp[i] < min)


temp[i] = min;
}

GR[r1] = concatenate8(temp[7], temp[6], temp[5], temp[4],


temp[3], temp[2], temp[1], temp[0]);

} 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);

for (i = 0; i < 4; i++) {


if (temp[i] > max)
temp[i] = max;

if (temp[i] < min)


temp[i] = min;
}

GR[r1] = concatenate4(temp[3], temp[2], temp[1], temp[0]);


}
GR[r1].nat = GR[r2].nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

3:180 Volume 3: Instruction Reference


padd

padd — Parallel Add


Format: (qp) padd1 r1 = r2, r3 one_byte_form, modulo_form A9
(qp) padd1.sss r1 = r2, r3 one_byte_form, sss_saturation_form A9
(qp) padd1.uus r1 = r2, r3 one_byte_form, uus_saturation_form A9
(qp) padd1.uuu r1 = r2, r3 one_byte_form, uuu_saturation_form A9
(qp) padd2 r1 = r2, r3 two_byte_form, modulo_form A9
(qp) padd2.sss r1 = r2, r3 two_byte_form, sss_saturation_form A9
(qp) padd2.uus r1 = r2, r3 two_byte_form, uus_saturation_form A9
(qp) padd2.uuu r1 = r2, r3 two_byte_form, uuu_saturation_form A9
(qp) padd4 r1 = r2, r3 four_byte_form, modulo_form A9

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.

Table 2-43. Parallel Add Saturation Completers


Completer Result r1 treated as Source r2 treated as Source r3 treated as
sss signed signed signed
uus unsigned unsigned signed
uuu unsigned unsigned unsigned

Table 2-44. Parallel Add Saturation Limits


Result r1 Signed Result r1 Unsigned
Size Element Width
Upper Limit Lower Limit Upper Limit Lower Limit
1 8 bit 0x7f 0x80 0xff 0x00
2 16 bit 0x7fff 0x8000 0xffff 0x0000

Figure 2-29. Parallel Add Examples

GR r3: GR r3:

GR r2: GR r2:

+ + + + + + + + + + + +

GR r1: GR r1:

padd1 padd2

Volume 3: Instruction Reference 3:181


padd

Operation: if (PR[qp]) {
check_target_register(r1);

if (one_byte_form) { // one-byte elements


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 (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) {
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) {
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;
}
}
GR[r1] = concatenate8(temp[7], temp[6], temp[5], temp[4],
temp[3], temp[2], temp[1], temp[0]);

} else if (two_byte_form) { // 2-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 (sss_saturation_form) {
max = sign_ext(0x7fff, 16);
min = sign_ext(0x8000, 16);

3:182 Volume 3: Instruction Reference


padd

for (i = 0; i < 4; i++) {


temp[i] = sign_ext(x[i], 16) + sign_ext(y[i], 16);
}
} else if (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) {
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;
}
}
GR[r1] = concatenate4(temp[3], temp[2], temp[1], temp[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++) { // modulo_form


temp[i] = zero_ext(x[i], 32) + zero_ext(y[i], 32);
}

GR[r1] = concatenate2(temp[1], temp[0]);


}

GR[r1].nat = GR[r2].nat || GR[r3].nat;


}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:183


pavg

pavg — Parallel Average


Format: (qp) pavg1 r1 = r2, r3 normal_form, one_byte_form A9
(qp) pavg1.raz r1 = r2, r3 raz_form, one_byte_form A9
(qp) pavg2 r1 = r2, r3 normal_form, two_byte_form A9
(qp) pavg2.raz r1 = r2, r3 raz_form, two_byte_form A9

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.

Figure 2-30. Parallel Average Example

GR r3:

GR r2:

+ + + + Shift Right 1 Bit


with Average in
16-bit Sum Low-order Bit
Plus
Carry Carry
Bit Sum Bits

Shift Right
1 Bit or

GR r1:

pavg2

3:184 Volume 3: Instruction Reference


pavg

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

Volume 3: Instruction Reference 3:185


pavg

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;
}

Interruptions: Illegal Operation fault

3:186 Volume 3: Instruction Reference


pavgsub

pavgsub — Parallel Average Subtract


Format: (qp) pavgsub1 r1 = r2, r3 one_byte_form A9
(qp) pavgsub2 r1 = r2, r3 two_byte_form A9

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.

Figure 2-32. Parallel Average Subtract Example

GR r3:

GR r2:

- - - - Shift Right 1 Bit


with Average in
16-bit Difference Low-order Bit
Plus
Carry Borrow
Bit Sum Bits

Shift Right or
1 Bit

GR r1:

pavgsub2

Volume 3: Instruction Reference 3:187


pavgsub

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};

for (i = 0; i < 8; i++) {


temp[i] = zero_ext(x[i], 8) - zero_ext(y[i], 8);
res[i] = (temp[i]{8:0} u>> 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};

for (i = 0; i < 4; i++) {


temp[i] = zero_ext(x[i], 16) - zero_ext(y[i], 16);
res[i] = (temp[i]{16:0} u>> 1) | (temp[i]{0});
}
GR[r1] = concatenate4(res[3], res[2], res[1], res[0]);
}
GR[r1].nat = GR[r2].nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

3:188 Volume 3: Instruction Reference


pcmp

pcmp — Parallel Compare


Format: (qp) pcmp1.prel r1 = r2, r3 one_byte_form A9
(qp) pcmp2.prel r1 = r2, r3 two_byte_form A9
(qp) pcmp4.prel r1 = r2, r3 four_byte_form A9

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.

Table 2-45. Pcmp Relations


prel Compare Relation (r2 prel r3)
eq r2 == r3
gt r2 > r3 (signed)

Figure 2-33. Parallel Compare Examples

GR r3: GR r3:

GR r2: GR r2:

> > > > > > > > = = = =


T F T T F F F T True False True True

GR r1: ff 00 ff ff 00 00 00 ff GR r1: 0xffff 0x0000 0xffff 0xffff

pcmp1.gt pcmp2.eq

GR r3:

GR r2:

= =
True False

GR r1: 0xffffffff 0x00000000

pcmp4.eq

Volume 3: Instruction Reference 3:189


pcmp

Operation: if (PR[qp]) {
check_target_register(r1);

if (one_byte_form) { // one-byte elements


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};
for (i = 0; i < 8; i++) {
if (prel == ‘eq’)
tmp_rel = x[i] == y[i];
else // ‘gt’
tmp_rel = greater_signed(sign_ext(x[i], 8),
sign_ext(y[i], 8));

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;
}

Interruptions: Illegal Operation fault

3:190 Volume 3: Instruction Reference


pmax

pmax — Parallel Maximum


Format: (qp) pmax1.u r1 = r2, r3 one_byte_form I2
(qp) pmax2 r1 = r2, r3 two_byte_form I2

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.

Figure 2-34. Parallel Maximum Examples

GR r3: GR r3:

GR r2: GR r2:

< < < < < < < < < < < <

T F T T F F F T True False True True

GR r1: GR r1:

pmax1.u pmax2

Operation: if (PR[qp]) {
check_target_register(r1);

if (one_byte_form) { // one-byte elements


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};
for (i = 0; i < 8; i++) {
res[i] = (zero_ext(x[i],8) < zero_ext(y[i],8))? y[i]: x[i];
}
GR[r1] = concatenate8(res[7], res[6], res[5], res[4],
res[3], res[2], res[1], res[0]);
} else { // 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++) {
res[i] = (sign_ext(x[i],16) < sign_ext(y[i],16))? y[i]: x[i];
}
GR[r1] = concatenate4(res[3], res[2], res[1], res[0]);
}
GR[r1].nat = GR[r2].nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:191


pmin

pmin — Parallel Minimum


Format: (qp) pmin1.u r1 = r2, r3 one_byte_form I2
(qp) pmin2 r1 = r2, r3 two_byte_form I2

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.

Figure 2-35. Parallel Minimum Examples

GR r3: GR r3:

GR r2: GR r2:

< < < < < < < < < < < <

T F T T F F F T True False True True

GR r1: GR r1:

pmin1.u pmin2

Operation: if (PR[qp]) {
check_target_register(r1);

if (one_byte_form) { // one-byte elements


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};
for (i = 0; i < 8; i++) {
res[i] = (zero_ext(x[i],8) < zero_ext(y[i],8))? x[i]: y[i];
}
GR[r1] = concatenate8(res[7], res[6], res[5], res[4],
res[3], res[2], res[1], res[0]);
} else { // 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++) {
res[i] = (sign_ext(x[i],16) < sign_ext(y[i],16))? x[i]: y[i];
}
GR[r1] = concatenate4(res[3], res[2], res[1], res[0]);
}
GR[r1].nat = GR[r2].nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

3:192 Volume 3: Instruction Reference


pmpy

pmpy — Parallel Multiply


Format: (qp) pmpy2.r r1 = r2, r3 right_form I2
(qp) pmpy2.l r1 = r2, r3 left_form I2

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.

Figure 2-36. Parallel Multiply Operation

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);
}

GR[r1].nat = GR[r2].nat || GR[r3].nat;


}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:193


pmpyshr

pmpyshr — Parallel Multiply and Shift Right


Format: (qp) pmpyshr2 r1 = r2, r3, count2 signed_form I1
(qp) pmpyshr2.u r1 = r2, r3, count2 unsigned_form I1

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.

Table 2-46. Parallel Multiply and Shift Right Shift Options


count2 Selected Bit Field from Each 32-bit Product
0 15:0
7 22:7
15 30:15
16 31:16

Figure 2-37. Parallel Multiply and Shift Right Operation

GR r3:
16-bit
Source
GR r2: Elements

* * * *

32-bit
Products

Shift Right
count2 Bits
16-bit
GR r1: Result
Elements
pmpyshr2

3:194 Volume 3: Instruction Reference


pmpyshr

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);

res[i] = temp[i]{(count2 + 15):count2};


}

GR[r1] = concatenate4(res[3], res[2], res[1], res[0]);


GR[r1].nat = GR[r2].nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:195


popcnt

popcnt — Population Count


Format: (qp) popcnt r1 = r3 I9

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;
}

Interruptions: Illegal Operation fault

3:196 Volume 3: Instruction Reference


probe

probe — Probe Access


Format: (qp) probe.r r1 = r3, r2 read_form, register_form M38
(qp) probe.w r1 = r3, r2 write_form, register_form M38
(qp) probe.r r1 = r3, imm2 read_form, immediate_form M39
(qp) probe.w r1 = r3, imm2 write_form, immediate_form M39
(qp) probe.r.fault r3, imm2 fault_form, read_form, immediate_form M40
(qp) probe.w.fault r3, imm2 fault_form, write_form, immediate_form M40
(qp) probe.rw.fault r3, imm2 fault_form, read_write_form, immediate_form M40

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.

Volume 3: Instruction Reference 3:197


probe

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 (GR[r3].nat || (register_form? GR[r2].nat: 0))


register_nat_consumption_fault(itype);

tmp_pl = (register_form)? GR[r2]{1:0}: imm2;


if (tmp_pl < PSR.cpl)
tmp_pl = PSR.cpl;

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;
}
}

Interruptions: Illegal Operation fault Data NaT Page Consumption fault


Register NaT Consumption fault Data Key Miss fault
Unimplemented Data Address fault Data Key Permission fault
Data Nested TLB fault Data Access Rights fault
Alternate Data TLB fault Data Dirty Bit fault
VHPT Data fault Data Access Bit fault
Data TLB fault Data Debug fault
Data Page Not Present fault

3:198 Volume 3: Instruction Reference


psad

psad — Parallel Sum of Absolute Difference


Format: (qp) psad1 r1 = r2, r3 I2

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.

Figure 2-38. Parallel Sum of Absolute Difference Example

GR r3:

GR r2:

- - - - - - - -

abs abs abs abs abs abs abs abs

+ + + +

+ +

GR r1:

psad1

Operation: if (PR[qp]) {
check_target_register(r1);

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};

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];
}

GR[r1].nat = GR[r2].nat || GR[r3].nat;


}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:199


pshl

pshl — Parallel Shift Left


Format: (qp) pshl2 r1 = r2, r3 two_byte_form, variable_form I7
(qp) pshl2 r1 = r2, count5 two_byte_form, fixed_form I8
(qp) pshl4 r1 = r2, r3 four_byte_form, variable_form I7
(qp) pshl4 r1 = r2, count5 four_byte_form, fixed_form I8

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.

Figure 2-39. Parallel Shift Left Examples

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);

shift_count = (variable_form? GR[r3]: count5);


tmp_nat = (variable_form? GR[r3].nat: 0);

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;
}

GR[r1].nat = GR[r2].nat || tmp_nat;


}

Interruptions: Illegal Operation fault

3:200 Volume 3: Instruction Reference


pshladd

pshladd — Parallel Shift Left and Add


Format: (qp) pshladd2 r1 = r2, count2, r3 A10

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);

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};

max = sign_ext(0x7fff, 16);


min = sign_ext(0x8000, 16);

for (i = 0; i < 4; i++) {


temp[i] = sign_ext(x[i], 16) << count2;

if (temp[i] > max)


res[i] = max;
else if (temp[i] < min)
res[i] = min;
else {
res[i] = temp[i] + sign_ext(y[i], 16);
if (res[i] > max)
res[i] = max;
if (res[i] < min)
res[i] = min;
}
}

GR[r1] = concatenate4(res[3], res[2], res[1], res[0]);


GR[r1].nat = GR[r2].nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:201


pshr

pshr — Parallel Shift Right


Format: (qp) pshr2 r1 = r3, r2 signed_form, two_byte_form, variable_form I5
(qp) pshr2 r1 = r3, count5 signed_form, two_byte_form, fixed_form I6
(qp) pshr2.u r1 = r3, r2 unsigned_form, two_byte_form, variable_form I5
(qp) pshr2.u r1 = r3, count5 unsigned_form, two_byte_form, fixed_form I6
(qp) pshr4 r1 = r3, r2 signed_form, four_byte_form, variable_form I5
(qp) pshr4 r1 = r3, count5 signed_form, four_byte_form, fixed_form I6
(qp) pshr4.u r1 = r3, r2 unsigned_form, four_byte_form, variable_form I5
(qp) pshr4.u r1 = r3, count5 unsigned_form, four_byte_form, fixed_form I6

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.

3:202 Volume 3: Instruction Reference


pshr

Operation: if (PR[qp]) {
check_target_register(r1);

shift_count = (variable_form? GR[r2]: count5);


tmp_nat = (variable_form? GR[r2].nat: 0);

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);
}
}

GR[r1].nat = GR[r3].nat || tmp_nat;


}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:203


pshradd

pshradd — Parallel Shift Right and Add


Format: (qp) pshradd2 r1 = r2, count2, r3 A10

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);

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};

max = sign_ext(0x7fff, 16);


min = sign_ext(0x8000, 16);

for (i = 0; i < 4; i++) {


temp[i] = shift_right_signed(sign_ext(x[i], 16), count2);

res[i] = temp[i] + sign_ext(y[i], 16);


if (res[i] > max)
res[i] = max;
if (res[i] < min)
res[i] = min;
}

GR[r1] = concatenate4(res[3], res[2], res[1], res[0]);


GR[r1].nat = GR[r2].nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

3:204 Volume 3: Instruction Reference


psub

psub — Parallel Subtract


Format: (qp) psub1 r1 = r2, r3 one_byte_form, modulo_form A9
(qp) psub1.sss r1 = r2, r3 one_byte_form, sss_saturation_form A9
(qp) psub1.uus r1 = r2, r3 one_byte_form, uus_saturation_form A9
(qp) psub1.uuu r1 = r2, r3 one_byte_form, uuu_saturation_form A9
(qp) psub2 r1 = r2, r3 two_byte_form, modulo_form A9
(qp) psub2.sss r1 = r2, r3 two_byte_form, sss_saturation_form A9
(qp) psub2.uus r1 = r2, r3 two_byte_form, uus_saturation_form A9
(qp) psub2.uuu r1 = r2, r3 two_byte_form, uuu_saturation_form A9
(qp) psub4 r1 = r2, r3 four_byte_form, modulo_form A9

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.

Table 2-47. Parallel Subtract Saturation Completers


Completer Result r1 treated as Source r2 treated as Source r3 treated as
sss signed signed signed
uus unsigned unsigned signed
uuu unsigned unsigned unsigned

Table 2-48. Parallel Subtract Saturation Limits


Result r1 Signed Result r1 Unsigned
Size Element Width
Upper Limit Lower Limit Upper Limit Lower Limit
1 8 bit 0x7f 0x80 0xff 0x00
2 16 bit 0x7fff 0x8000 0xffff 0x0000

Figure 2-40. Parallel Subtract Examples

GR r3: GR r3:

GR r2: GR r2:

- - - - - - - - - - - -

GR r1: GR r1:

psub1 psub2

Volume 3: Instruction Reference 3:205


psub

Operation: if (PR[qp]) {
check_target_register(r1);

if (one_byte_form) { // one-byte elements


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 (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;
}
}

GR[r1] = concatenate8(temp[7], temp[6], temp[5], temp[4],


temp[3], temp[2], temp[1], temp[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 (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

3:206 Volume 3: Instruction Reference


psub

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;
}
}

GR[r1] = concatenate4(temp[3], temp[2], temp[1], temp[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++) { // modulo_form


temp[i] = zero_ext(x[i], 32) - zero_ext(y[i], 32);
}

GR[r1] = concatenate2(temp[1], temp[0]);


}

GR[r1].nat = GR[r2].nat || GR[r3].nat;


}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:207


ptc.e

ptc.e — Purge Translation Cache Entry


Format: (qp) ptc.e r3 M47

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]);
}

Interruptions: Privileged Operation fault Virtualization fault


Register NaT Consumption fault

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.

3:208 Volume 3: Instruction Reference


ptc.g, ptc.ga

ptc.g, ptc.ga — Purge Global Translation Cache


Format: (qp) ptc.g r3, r2 global_form M45
(qp) ptc.ga r3, r2 global_alat_form M45

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);

Volume 3: Instruction Reference 3:209


ptc.g, ptc.ga

tlb_must_purge_itc_entries(tmp_rid, tmp_va, tmp_size);

if (global_alat_form) tmp_ptc_type = GLOBAL_ALAT_FORM;


else tmp_ptc_type = GLOBAL_FORM;

tlb_broadcast_purge(tmp_rid, tmp_va, tmp_size, tmp_ptc_type);


}

Interruptions: Machine Check abort Unimplemented Data Address fault


Privileged Operation fault Virtualization fault
Register NaT Consumption fault

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.

3:210 Volume 3: Instruction Reference


ptc.l

ptc.l — Purge Local Translation Cache


Format: (qp) ptc.l r3, r2 M45

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);
}

Interruptions: Machine Check abort Unimplemented Data Address fault


Privileged Operation fault Virtualization fault
Register NaT Consumption fault

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.

Volume 3: Instruction Reference 3:211


ptr

ptr — Purge Translation Register


Format: (qp) ptr.d r3, r2 data_form M45
(qp) ptr.i r3, r2 instruction_form M45

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.

3:212 Volume 3: Instruction Reference


ptr

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);
}
}

Interruptions: Privileged Operation fault Unimplemented Data Address fault


Register NaT Consumption fault Virtualization fault

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.

Volume 3: Instruction Reference 3:213


rfi

rfi — Return From Interruption


Format: rfi B8

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.

3:214 Volume 3: Instruction Reference


rfi

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) {

Volume 3: Instruction Reference 3:215


rfi

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);

Interruptions: Privileged Operation fault Unimplemented Instruction Address trap


Virtualization fault

Additional Faults on IA-32 target instructions


IA_32_Exception(GPFault)
Disabled FP Reg Fault if PSR.dfh is 1

Serialization: An implicit instruction and data serialization operation is performed.

3:216 Volume 3: Instruction Reference


rsm

rsm — Reset System Mask


Format: (qp) rsm imm24 M44

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 (is_reserved_field(PSR_TYPE, PSR_SM, imm24))


reserved_register_field_fault();

if (PSR.vm == 1)
virtualization_fault();

if (imm24{1}) PSR{1} = 0;) // be


if (imm24{2}) PSR{2} = 0;) // up
if (imm24{3}) PSR{3} = 0;) // ac
if (imm24{4}) PSR{4} = 0;) // mfl
if (imm24{5}) PSR{5} = 0;) // mfh
if (imm24{13}) PSR{13} = 0;) // ic
if (imm24{14}) PSR{14} = 0;) // i
if (imm24{15}) PSR{15} = 0;) // pk
if (imm24{17}) PSR{17} = 0;) // dt
if (imm24{18}) PSR{18} = 0;) // dfl
if (imm24{19}) PSR{19} = 0;) // dfh
if (imm24{20}) PSR{20} = 0;) // sp
if (imm24{21}) PSR{21} = 0;) // pp
if (imm24{22}) PSR{22} = 0;) // di
if (imm24{23}) PSR{23} = 0;) // si
}

Volume 3: Instruction Reference 3:217


rsm

Interruptions: Privileged Operation fault Virtualization fault


Reserved Register/Field 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.

3:218 Volume 3: Instruction Reference


rum

rum — Reset User Mask


Format: (qp) rum imm24 M44

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();

if (imm24{1}) PSR{1} = 0;) // be


if (imm24{2} && PSR.sp == 0) //non-secure perf monitor
PSR{2} = 0;) // up
if (imm24{3}) PSR{3} = 0;) // ac
if (imm24{4}) PSR{4} = 0;) // mfl
if (imm24{5}) PSR{5} = 0;) // mfh
}

Interruptions: Reserved Register/Field fault

Serialization: All user mask modifications are observed by the next instruction group.

Volume 3: Instruction Reference 3:219


setf

setf — Set Floating-point Value, Exponent, or Significand


Format: (qp) setf.s f1 = r2 single_form M18
(qp) setf.d f1 = r2 double_form M18
(qp) setf.exp f1 = r2 exponent_form M18
(qp) setf.sig f1 = r2 significand_form M18

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).

Figure 2-41. Function of setf.exp

63 18 17 0

GR r1

FR f1 s exponent 1000 ... 000

In the significand_form, the value in GR r2 is copied to 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).

Figure 2-42. Function of setf.sig

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.

3:220 Volume 3: Instruction Reference


setf

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);
}

Interruptions: Illegal Operation fault Disabled Floating-point Register fault

Volume 3: Instruction Reference 3:221


shl

shl — Shift Left


Format: (qp) shl r1= r2, r3 I7
(qp) shl r1 = r2, count6 pseudo-op of: (qp) dep.z r1 = r2, count6, 64-count6

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;

GR[r1].nat = GR[r2].nat || GR[r3].nat;


}

Interruptions: Illegal Operation fault

3:222 Volume 3: Instruction Reference


shladd

shladd — Shift Left and Add


Format: (qp) shladd r1 = r2, count2, r3 A2

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);

GR[r1] = (GR[r2] << count2) + GR[r3];


GR[r1].nat = GR[r2].nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:223


shladdp4

shladdp4 — Shift Left and Add Pointer


Format: (qp) shladdp4 r1 = r2, count2, r3 A2

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.

Figure 2-43. Shift Left and Add Pointer

GR r2: GR r3:

GR r1: 0 0

Operation: if (PR[qp]) {
check_target_register(r1);

tmp_res = (GR[r2] << count2) + GR[r3];


tmp_res = zero_ext(tmp_res{31:0}, 32);
tmp_res{62:61} = GR[r3]{31:30};
GR[r1] = tmp_res;
GR[r1].nat = GR[r2].nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

3:224 Volume 3: Instruction Reference


shr

shr — Shift Right


Format: (qp) shr r1 = r3, r2 signed_form I5
(qp) shr.u r1 = r3, r2 unsigned_form I5
(qp) shr r1 = r3, count6 pseudo-op of: (qp) extr r1 = r3, count6, 64-count6
(qp) shr.u r1 = r3, count6 pseudo-op of: (qp) extr.u r1 = r3, count6, 64-count6

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);
}

GR[r1].nat = GR[r2].nat || GR[r3].nat;


}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:225


shrp

shrp — Shift Right Pair


Format: (qp) shrp r1 = r2, r3, count6 I10

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.

Figure 2-44. Shift Right Pair

GR r2: GR r3:

GR r1:

Operation: if (PR[qp]) {
check_target_register(r1);

temp1 = shift_right_unsigned(GR[r3], count6);


temp2 = GR[r2] << (64 - count6);
GR[r1] = zero_ext(temp1, 64 - count6) | temp2;
GR[r1].nat = GR[r2].nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

3:226 Volume 3: Instruction Reference


srlz

srlz — Serialize
Format: (qp) srlz.i instruction_form M24
(qp) srlz.d data_form M24

Description: Instruction serialization (srlz.i) 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 are re-initiated after srlz.i completes.
The srlz.i instruction must be in an instruction group after the instruction group containing the
operation that is to be serialized. Operations dependent on the serialization must be in an instruction
group after the instruction group containing the srlz.i.
Data serialization (srlz.d) ensures:
• prior modifications to processor register resources that affect subsequent execution or data
memory accesses are observed.
The srlz.d instruction must be in an instruction group after the instruction group containing the
operation that is to be serialized. Operations dependent on the serialization must follow the srlz.d,
but they can be in the same instruction group as the srlz.d.
A srlz cannot be used to stall processor data memory references until prior data memory references,
or memory fences are visible or “accepted” by the external platform.
The following processor resources require a serialize to ensure side-effects are observed; CRs,
PSR, DBRs, IBRs, PMDs, PMCs, RRs, PKRs, TRs and TCs (refer to Section 3.2, “Serialization”
on page 2:15 for details).

Operation: if (PR[qp]) {
if (instruction_form)
instruction_serialize();
else // data_form
data_serialize();
}

Interruptions: None

Volume 3: Instruction Reference 3:227


ssm

ssm — Set System Mask


Format: (qp) ssm imm24 M44

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 (is_reserved_field(PSR_TYPE, PSR_SM, imm24))


reserved_register_field_fault();

if (PSR.vm == 1)
virtualization_fault();

if (imm24{1}) PSR{1} = 1;) // be


if (imm24{2}) PSR{2} = 1;) // up
if (imm24{3}) PSR{3} = 1;) // ac
if (imm24{4}) PSR{4} = 1;) // mfl
if (imm24{5}) PSR{5} = 1;) // mfh
if (imm24{13}) PSR{13} = 1;) // ic
if (imm24{14}) PSR{14} = 1;) // i
if (imm24{15}) PSR{15} = 1;) // pk
if (imm24{17}) PSR{17} = 1;) // dt
if (imm24{18}) PSR{18} = 1;) // dfl
if (imm24{19}) PSR{19} = 1;) // dfh
if (imm24{20}) PSR{20} = 1;) // sp
if (imm24{21}) PSR{21} = 1;) // pp
if (imm24{22}) PSR{22} = 1;) // di
if (imm24{23}) PSR{23} = 1;) // si
}

Interruptions: Privileged Operation fault Virtualization fault


Reserved Register/Field 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.

3:228 Volume 3: Instruction Reference


st

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.

Table 2-49. Store Types


sttype
Interpretation Special Store Operation
Completer
none Normal store
rel Ordered store An ordered store is performed with release semantics.

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.

Volume 3: Instruction Reference 3:229


st

Table 2-50. Store Hints


sthint Completer Interpretation
none Temporal locality, level 1
nta Non-temporal locality, all levels

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);

paddr = tlb_translate(GR[r3], size, itype, PSR.cpl, &mattr,


&tmp_unused);
if (spill_form && GR[r2].nat) {
natd_gr_write(GR[r2], paddr, size, UM.be, mattr, otype, sthint);
}
else {
if (sixteen_byte_form)
mem_write16(GR[r2], AR[CSD], paddr, UM.be, mattr, otype, sthint);
else
mem_write(GR[r2], paddr, size, UM.be, mattr, otype, sthint);
}

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);
}
}

Interruptions: Illegal Operation fault Data Key Miss fault


Register NaT Consumption fault Data Key Permission fault
Unimplemented Data Address fault Data Access Rights fault
Data Nested TLB fault Data Dirty Bit fault
Alternate Data TLB fault Data Access Bit fault
VHPT Data fault Data Debug fault
Data TLB fault Unaligned Data Reference fault
Data Page Not Present fault Unsupported Data Reference fault
Data NaT Page Consumption fault

3:230 Volume 3: Instruction Reference


stf

stf — Floating-point Store


Format: (qp) stffsz.sthint [r3] = f2 normal_form, no_base_update_form M9
(qp) stffsz.sthint [r3] = f2, imm9 normal_form, imm_base_update_form M10
(qp) stf8.sthint [r3] = f2 integer_form, no_base_update_form M9
(qp) stf8.sthint [r3] = f2, imm9 integer_form, imm_base_update_form M10
(qp) stf.spill.sthint [r3] = f2 spill_form, no_base_update_form M9
(qp) stf.spill.sthint [r3] = f2, imm9 spill_form, imm_base_update_form M10

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.

Volume 3: Instruction Reference 3:231


stf

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);

if (GR[r3].nat || (!spill_form && (FR[f2] == NATVAL)))


register_nat_consumption_fault(WRITE);

size = spill_form? 16: (integer_form? 8: fsz);


itype = WRITE;
if (size == 10) itype |= UNCACHE_OPT;

paddr = tlb_translate(GR[r3], size, itype, PSR.cpl, &mattr, &tmp_unused);


val = fp_fr_to_mem_format(FR[f2], size, integer_form);
mem_write(val, paddr, size, UM.be, mattr, UNORDERED, sthint);

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);
}
}

Interruptions: Illegal Operation fault Data NaT Page Consumption fault


Disabled Floating-point Register fault Data Key Miss fault
Register NaT Consumption fault Data Key Permission fault
Unimplemented Data Address fault Data Access Rights fault
Data Nested TLB fault Data Dirty Bit fault
Alternate Data TLB fault Data Access Bit fault
VHPT Data fault Data Debug fault
Data TLB fault Unaligned Data Reference fault
Data Page Not Present fault Unsupported Data Reference fault

3:232 Volume 3: Instruction Reference


sub

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);

tmp_src = (register_form? GR[r2]: sign_ext(imm8, 8));


tmp_nat = (register_form? GR[r2].nat: 0);

if (minus1_form)
GR[r1] = tmp_src - GR[r3] - 1;
else
GR[r1] = tmp_src - GR[r3];

GR[r1].nat = tmp_nat || GR[r3].nat;


}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:233


sum

sum — Set User Mask


Format: (qp) sum imm24 M44

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();

if (imm24{1}) PSR{1} = 1;) // be


if (imm24{2} && PSR.sp == 0) //non-secure perf monitor
PSR{2} = 1;) // up
if (imm24{3}) PSR{3} = 1;) // ac
if (imm24{4}) PSR{4} = 1;) // mfl
if (imm24{5}) PSR{5} = 1;) // mfh
}

Interruptions: Reserved Register/Field fault

Serialization: All user mask modifications are observed by the next instruction group.

3:234 Volume 3: Instruction Reference


sxt

sxt — Sign Extend


Format: (qp) sxtxsz r1 = r3 I29

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.

Table 2-51. xsz Mnemonic Values


xsz Mnemonic Bit Position
1 7
2 15
4 31

Operation: if (PR[qp]) {
check_target_register(r1);

GR[r1] = sign_ext(GR[r3],xsz * 8);


GR[r1].nat = GR[r3].nat;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:235


sync

sync — Memory Synchronization


Format: (qp) sync.i M24

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):

st [L1] = data //store into local instruction stream


fc.i L1 //flush stale datum from instruction/data cache
;; //require instruction boundary between fc.i and sync.i
sync.i //ensure local and remote data/inst caches
//are synchronized
;;
srlz.i //ensure sync has been observed by the local processor,
;; //ensure subsequent instructions observe
//modified memory
L1: target //instruction modified

Operation: if (PR[qp]) {
instruction_synchronize();
}

Interruptions: None

3:236 Volume 3: Instruction Reference


tak

tak — Translation Access Key


Format: (qp) tak r1 = r3 M46

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();

GR[r1] = tlb_access_key(GR[r3], itype);


GR[r1].nat = 0;
}

Interruptions: Illegal Operation fault Register NaT Consumption fault


Privileged Operation fault Virtualization fault

Volume 3: Instruction Reference 3:237


tbit

tbit — Test Bit


Format: (qp) tbit.trel.ctype p1, p2 = r3, pos6 I16

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

Table 2-53. Test Bit Relations for Parallel tbits


trel Test Relation
nz selected bit == 1
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.

3:238 Volume 3: Instruction Reference


tbit

Operation: if (PR[qp]) {
if (p1 == p2)
illegal_operation_fault();

if (trel == ‘nz’) // ‘nz’ - test for 1


tmp_rel = GR[r3]{pos6};
else // ‘z’ - test for 0
tmp_rel =!GR[r3]{pos6};

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;
}
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:239


tf

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.

Table 2-54. Test Feature Relations for Normal and unc tf


trel Test Relation Pseudo-op of
nz selected feature available z p1 ´ p2
z selected feature unavailable

Table 2-55. Test Feature Relations for Parallel tf


trel Test Relation
nz selected feature available
z selected feature unavailable

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.

Table 2-56. Test Feature Features Assignment


imm5 Feature Symbol Feature
32 - 63 none No features currently defined

Implementation of PSR.vm is optional. If it is implemented but the instruction is disabled, this


instruction takes Virtualization fault when executed with PSR.vm equals to 1.

3:240 Volume 3: Instruction Reference


tf

Operation: if (PR[qp]) {
if (p1 == p2)
illegal_operation_fault();
if (PSR.vm == 1 && vm_tf_disabled())
virtualization_fault();

tmp_rel = cpuid[4]{imm5};

if (trel == ‘z’) // ‘z’ - test for 0, not 1


tmp_rel =!tmp_rel;

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;
}
}

Interruptions: Illegal Operation fault Virtualization fault

Volume 3: Instruction Reference 3:241


thash

thash — Translation Hashed Entry Address


Format: (qp) thash r1 = r3 M46

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();

if (GR[r3].nat || unimplemented_virtual_address(GR[r3], PSR.vm)) {


GR[r1] = undefined();
GR[r1].nat = 1;
} else {
tmp_vr = GR[r3]{63:61};
tmp_va = GR[r3]{60:0};
GR[r1] = tlb_vhpt_hash(tmp_vr, tmp_va, RR[tmp_vr].rid,
RR[tmp_vr].ps);
GR[r1].nat = 0;
}
}

Interruptions: Illegal Operation fault Virtualization fault

3:242 Volume 3: Instruction Reference


tnat

tnat — Test NaT


Format: (qp) tnat.trel.ctype p1, p2 = r3 I17

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

Table 2-58. Test NaT Relations for Parallel tnats


trel Test Relation
nz selected bit == 1
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.

Volume 3: Instruction Reference 3:243


tnat

Operation: if (PR[qp]) {
if (p1 == p2)
illegal_operation_fault();

if (trel == ‘nz’) // ‘nz’ - test for 1


tmp_rel = GR[r3].nat;
else // ‘z’ - test for 0
tmp_rel =!GR[r3].nat;

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;
}
}

Interruptions: Illegal Operation fault

3:244 Volume 3: Instruction Reference


tpa

tpa — Translate to Physical Address


Format: (qp) tpa r1 = r3 M46

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);

GR[r1] = tlb_translate_nonaccess(GR[r3], itype);


GR[r1].nat = 0;
}

Interruptions: Illegal Operation fault Alternate Data TLB fault


Privileged Operation fault VHPT Data fault
Register NaT Consumption fault Data TLB fault
Unimplemented Data Address fault Data Page Not Present fault
Virtualization fault Data NaT Page Consumption fault
Data Nested TLB fault

Volume 3: Instruction Reference 3:245


ttag

ttag — Translation Hashed Entry Tag


Format: (qp) ttag r1 = r3 M46

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();

if (GR[r3].nat || unimplemented_virtual_address(GR[r3], PSR.vm)) {


GR[r1] = undefined();
GR[r1].nat = 1;
} else {
tmp_vr = GR[r3]{63:61};
tmp_va = GR[r3]{60:0};
GR[r1] = tlb_vhpt_tag(tmp_va, RR[tmp_vr].rid, RR[tmp_vr].ps);
GR[r1].nat = 0;
}
}

Interruptions: Illegal Operation fault Virtualization fault

3:246 Volume 3: Instruction Reference


unpack

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.

Volume 3: Instruction Reference 3:247


unpack

Figure 2-45. Unpack Operation

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:

3:248 Volume 3: Instruction Reference


unpack

Operation: if (PR[qp]) {
check_target_register(r1);

if (one_byte_form) { // one-byte elements


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 (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;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:249


vmsw

vmsw — Virtual Machine Switch


Format: vmsw.0 zero_form B8
vmsw.1 one_form B8

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 (!(PSR.it == 1 && itlb_ar() == 7) || vm_disabled())


virtualization_fault();

if (zero_form) {
PSR.vm = 0;
}
else {
PSR.vm = 1;
}

Interruptions: Illegal Operation fault Virtualization fault


Privileged Operation fault

3:250 Volume 3: Instruction Reference


xchg

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.

Table 2-59. Memory Exchange Size


sz Completer Bytes Accessed
1 1 byte
2 2 bytes
4 4 bytes
8 8 bytes

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);

paddr = tlb_translate(GR[r3], sz, SEMAPHORE, PSR.cpl, &mattr,


&tmp_unused);

if (!ma_supports_semaphores(mattr))
unsupported_data_reference_fault(SEMAPHORE, GR[r3]);

val = mem_xchg(GR[r2], paddr, sz, UM.be, mattr, ACQUIRE, ldhint);

alat_inval_multiple_entries(paddr, sz);

GR[r1] = zero_ext(val, sz * 8);


GR[r1].nat = 0;
}

Volume 3: Instruction Reference 3:251


xchg

Interruptions: Illegal Operation fault Data Key Miss fault


Register NaT Consumption fault Data Key Permission fault
Unimplemented Data Address fault Data Access Rights fault
Data Nested TLB fault Data Dirty Bit fault
Alternate Data TLB fault Data Access Bit fault
VHPT Data fault Data Debug fault
Data TLB fault Unaligned Data Reference fault
Data Page Not Present fault Unsupported Data Reference fault
Data NaT Page Consumption fault

3:252 Volume 3: Instruction Reference


xma

xma — Fixed-Point Multiply Add


Format: (qp) xma.l f1 = f3, f4, f2 low_form F2
(qp) xma.lu f1 = f3, f4, f2 pseudo-op of: (qp) xma.l f1 = f3, f4, f2
(qp) xma.h f1 = f3, f4, f2 high_form F2
(qp) xma.hu f1 = f3, f4, f2 high_unsigned_form F2

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;

Volume 3: Instruction Reference 3:253


xma

FR[f1].sign = FP_SIGN_POSITIVE;
}

fp_update_psr(f1);
}

Interruptions: Disabled Floating-point Register fault

3:254 Volume 3: Instruction Reference


xmpy

xmpy — Fixed-Point Multiply


Format: (qp) xmpy.l f1 = f3, f4 pseudo-op of: (qp) xma.l f1 = f3, f4, f0
(qp) xmpy.lu f1 = f3, f4 pseudo-op of: (qp) xma.l f1 = f3, f4, f0
(qp) xmpy.h f1 = f3, f4 pseudo-op of: (qp) xma.h f1 = f3, f4, f0
(qp) xmpy.hu f1 = f3, f4 pseudo-op of: (qp) xma.hu f1 = f3, f4, f0

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.

Operation: See “xma — Fixed-Point Multiply Add” on page 3:253.

Volume 3: Instruction Reference 3:255


xor

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);

tmp_src = (register_form? GR[r2]: sign_ext(imm8, 8));


tmp_nat = (register_form? GR[r2].nat: 0);

GR[r1] = tmp_src ^ GR[r3];


GR[r1].nat = tmp_nat || GR[r3].nat;
}

Interruptions: Illegal Operation fault

3:256 Volume 3: Instruction Reference


zxt

zxt — Zero Extend


Format: (qp) zxtxsz r1 = r3 I29

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);

GR[r1] = zero_ext(GR[r3],xsz * 8);


GR[r1].nat = GR[r3].nat;
}

Interruptions: Illegal Operation fault

Volume 3: Instruction Reference 3:257


3:258 Volume 3: Instruction Reference
3

Pseudo-Code Functions 3

This chapter contains a table of all pseudo-code functions used on the Itanium instruction pages.

Table 3-1. Pseudo-code Functions


Function Operation
xxx_fault(parameters...) There are several fault functions. Each fault function accepts parameters specific to
the fault, e.g., exception code values, virtual addresses, etc. If the fault is deferred for
speculative load exceptions the fault function will return with a deferral indication.
Otherwise, fault routines do not return and terminate the instruction sequence.
xxx_trap(parameters...) There are several trap functions. Each trap function accepts parameters specific to
the trap, e.g., trap code values, virtual addresses, etc. Trap routines do not return.
acceptance_fence() Ensures prior data memory references to uncached ordered-sequential memory
pages are “accepted” before subsequent data memory references are performed by
the processor.
alat_cmp(rtype, raddr) Returns a one if the implementation finds an ALAT entry which matches the register
type specified by rtype and the register address specified by raddr, else returns
zero. This function is implementation specific. Note that an implementation may
optionally choose to return zero (indicating no match) even if a matching entry exists
in the ALAT. This provides implementation flexibility in designing fast ALAT lookup
circuits.
alat_frame_update(delta_bof, delta_sof) Notifies the ALAT of a change in the bottom of frame and/or size of frame. This allows
management of the ALAT’s tag bits or other management functions it might need.
alat_inval() Invalidate all entries in the ALAT.
alat_inval_multiple_entries(paddr, size) The ALAT is queried using the physical memory address specified by paddr and the
access size specified by size. All matching ALAT entries are invalidated. No value is
returned.
alat_inval_single_entry(rtype, rega) The ALAT is queried using the register type specified by rtype and the register
address specified by rega. At most one matching ALAT entry is invalidated. No
value is returned.
alat_translate_address_on_hit(ldtype, Returns a one if the implementation requires that the requested check load should
rtype, raddr) translate the source address and take associated faults; returns a zero otherwise.
alat_read_memory_on_hit(ldtype, rtype, Returns a one if the implementation requires that the requested check load should
raddr) perform a memory access (requires prior address translation); returns a zero
otherwise.
alat_write(ldtype, rtype, raddr, paddr, Allocates a new ALAT entry or updates an existing entry using the load type specified
size) by ldtype, the register type specified by rtype, the register address specified by
raddr, the physical memory address specified by paddr, and the access size
specified by size. No value is returned. This function guarantees that at most only
one ALAT entry exists for a given raddr. Based on the load type ldtype, if a
ld.c.nc, ldf.c.nc, or ldfp.c.nc instruction's raddr matches an existing
ALAT entry's register tag, but the instruction's size and/or paddr are different than
that of the existing entry's, then this function may either preserve the existing entry, or
invalidate it and write a new entry with the instruction's specified size and paddr.
align_to_size_boundary(vaddr, size) Returns vaddr aligned to the boundary specified by size.
branch_predict(wh, ih, ret, target, tag) Implementation-dependent routine which updates the processor’s branch prediction
structures.

Volume 3: Pseudo-Code Functions 3:259


Table 3-1. Pseudo-code Functions (Continued)
Function Operation
check_branch_implemented(check_type) Implementation-dependent routine which returns TRUE or FALSE, depending on
whether a failing check instruction causes a branch (TRUE), or a Speculative
Operation fault (FALSE). The result may be different for different types of check
instructions: CHKS_GENERAL, CHKS_FLOAT, CHKA_GENERAL, CHKA_FLOAT. In
addition, the result may depend on other implementation-dependent parameters.
check_target_register(r1) If the r1 argument specifies an out-of-frame stacked register (as defined by CFM) or
r1 specifies GR0, an Illegal Operation fault is delivered, and this function does not
return.
check_target_register_sof(r1, newsof) If the r1 argument specifies an out-of-frame stacked register (as defined by the
newsof argument) or r1 specifies GR0, an Illegal Operation fault is delivered and
this function does not return.
concatenate2(x1, x2) Concatenates the lower 32 bits of the 2 arguments, and returns the 64-bit result.
concatenate4(x1, x2, x3, x4) Concatenates the lower 16 bits of the 4 arguments, and returns the 64-bit result.
concatenate8(x1, x2, x3, x4, x5, x6, x7, Concatenates the lower 8 bits of the 8 arguments, and returns the 64-bit result.
x8)
data_serialize() Ensures all prior register updates with side-effects are observed before subsequent
execution and data memory references are performed.
deliver_unmasked_pending_interrupt() This implementation-specific function checks whether any unmasked external
interrupts are pending, and if so, transfers control to the external interrupt vector.
execute_hint(hint) Executes the hint specified by hint.
fadd(fp_dp, fr2) Adds a floating-point register value to the infinitely precise product and return the
infinitely precise sum, ready for rounding.
fcmp_exception_fault_check(f2, f3, frel, Checks for all floating-point faulting conditions for the fcmp instruction.
sf, *tmp_fp_env)
fcvt_fx_exception_fault_check(fr2, Checks for all floating-point faulting conditions for the fcvt.fx, fcvt.fxu,
signed_form, trunc_form, sf *tmp_fp_env) fcvt.fx.trunc and fcvt.fxu.trunc instructions. It propagates NaNs.
fma_exception_fault_check(f2, f3, f4, pc, Checks for all floating-point faulting conditions for the fma instruction. It propagates
sf, *tmp_fp_env) NaNs and special IEEE results.
fminmax_exception_fault_check(f2, f3, sf, Checks for all floating-point faulting conditions for the famax, famin, fmax, and
*tmp_fp_env) fmin instructions.
fms_fnma_exception_fault_check(f2, f3, Checks for all floating-point faulting conditions for the fms and fnma instructions. It
f4, pc, sf, *tmp_fp_env) propagates NaNs and special IEEE results.
fmul(fr3, fr4) Performs an infinitely precise multiply of two floating-point register values.
followed_by_stop() Returns TRUE if the current instruction is followed by a stop; otherwise, returns
FALSE.
fp_check_target_register(f1) If the specified floating-point register identifier is 0 or 1, this function causes an illegal
operation fault.
fp_decode_fault(tmp_fp_env) Returns floating-point exception fault code values for ISR.code.
fp_decode_traps(tmp_fp_env) Returns floating-point trap code values for ISR.code.
fp_is_nan_or_inf(freg) Returns true if the floating-point exception_fault_check functions returned a IEEE
fault disabled default result or a propagated NaN.
fp_equal(fr1, fr2) IEEE standard equality relationship test.
fp_ieee_recip(num, den) Returns the true quotient for special sets of operands, or an approximation to the
reciprocal of the divisor to be used in the software divide algorithm.
fp_ieee_recip_sqrt(root) Returns the true square root result for special operands, or an approximation to the
reciprocal square root to be used in the software square root algorithm.
fp_is_nan(freg) Returns true when floating register contains a NaN.
fp_is_natval(freg) Returns true when floating register contains a NaTVal
fp_is_normal(freg) Returns true when floating register contains a normal number.
fp_is_pos_inf(freg) Returns true when floating register contains a positive infinity.

3:260 Volume 3: Pseudo-Code Functions


Table 3-1. Pseudo-code Functions (Continued)
Function Operation
fp_is_qnan(freg) Returns true when floating register contains a quiet NaN.
fp_is_snan(freg) Returns true when floating register contains a signalling NaN.
fp_is_unorm(freg) Returns true when floating register contains an unnormalized
number.
fp_is_unsupported(freg) Returns true when floating register contains an unsupported format.
fp_less_than(fr1, fr2) IEEE standard less-than relationship test.
fp_lesser_or_equal(fr1, fr2) IEEE standard less-than or equal-to relationship test
fp_normalize(fr1) Normalizes an unnormalized fp value. This function flushes to zero any unnormal
values which can not be represented in the register file
fp_raise_fault(tmp_fp_env) Checks the local instruction state for any faulting conditions which require an
interruption to be raised.
fp_raise_traps(tmp_fp_env) Checks the local instruction state for any trapping conditions which require an
interruption to be raised.
fp_reg_bank_conflict(f1, f2) Returns true if the two specified FRs are in the same bank.
fp_reg_disabled(f1, f2, f3, f4) Check for possible disabled floating-point register faults.
fp_reg_read(freg) Reads the FR and gives canonical double-extended denormals (and
pseudo-denormals) their true mathematical exponent. Other classes of operands are
unaltered.
fp_unordered(fr1, fr2) IEEE standard unordered relationship
fp_fr_to_mem_format(freg, size) Converts a floating-point value in register format to floating-point memory format. It
assumes that the floating-point value in the register has been previously rounded to
the correct precision which corresponds with the size parameter.
fpcmp_exception_fault_check(f2, f3, frel, Checks for all floating-point faulting conditions for the fpcmp instruction.
sf, *tmp_fp_env)
fpcvt_exception_fault_check(f2, Checks for all floating-point faulting conditions for the fpcvt.fx, fpcvt.fxu,
signed_form, trunc_form, sf, fpcvt.fx.trunc, and fpcvt.fxu.trunc instructions. It propagates NaNs.
*tmp_fp_env)
fpma_exception_fault_check(f2, f3, f4, sf, Checks for all floating-point faulting conditions for the fpma instruction. It propagates
*tmp_fp_env) NaNs and special IEEE results.
fpminmax_exception_fault_check(f2, f3, Checks for all floating-point faulting conditions for the fpmin, fpmax, fpamin and
sf, *tmp_fp_env) fpamax instructions.
fpms_fpnma_exception_fault_check(f2, Checks for all floating-point faulting conditions for the fpms and fpnma instructions.
f3, f4, sf, *tmp_fp_env) It propagates NaNs and special IEEE results.
fprcpa_exception_fault_check(f2, f3, sf, Checks for all floating-point faulting conditions for the fprcpa instruction. It
*tmp_fp_env, *limits_check) propagates NaNs and special IEEE results. It also indicates operand limit violations.
fprsqrta_exception_fault_check(f3, sf, Checks for all floating-point faulting conditions for the fprsqrta instruction. It
*tmp_fp_env, *limits_check) propagates NaNs and special IEEE results. It also indicates operand limit violations.
frcpa_exception_fault_check(f2, f3, sf, Checks for all floating-point faulting conditions for the frcpa instruction. It
*tmp_fp_env) propagates NaNs and special IEEE results.
frsqrta_exception_fault_check(f3, sf, Checks for all floating-point faulting conditions for the frsqrta instruction. It
*tmp_fp_env) propagates NaNs and special IEEE results
ignored_field_mask(regclass, reg, value) Boolean function that returns value with bits cleared to 0 corresponding to ignored
bits for the specified register and register type.
impl_check_mov_itir() Implementation-specific function that returns TRUE if ITIR is checked for reserved
fields and encodings on a mov to ITIR instruction.
impl_check_tlb_itir() Implementation-specific function that returns TRUE if all fields of ITIR are checked for
reserved encondings on a TLB insert instruction regardless of whether the translation
is present.

Volume 3: Pseudo-Code Functions 3:261


Table 3-1. Pseudo-code Functions (Continued)
Function Operation
impl_ia32_ar_reserved_ignored(ar3) Implementation-specific function which indicates how the reserved and ignored fields
in the specified IA-32 application register, ar3, behave. If it returns FALSE, the
reserved and/or ignored bits in the specified application register can be written, and
when read they return the value most-recently written. If it returns TRUE, attempts to
write a non-zero value to a reserved field in the specified application register cause a
Reserved Register/Field fault, and reads return 0; writing to an ignored field in the
specified application register is ignored, and reads return the constant value defined
for that field.
impl_itir_cwi_mask() Implementation-specific function that either returns the value passed to it or the value
passed to it masked with zeros in bit positions {63:32} and/or {1:0}.
impl_uia_fault_supported() Implementation-specific function that either returns TRUE if the processor reports
unimplemented instruction addresses with an Unimplemented Instruction Address
fault, and returns FALSE if the processor reports them with an Unimplemented
Instruction Address trap.
implemented_vm() Returns TRUE if the processor implements the PSR.vm bit.
instruction_implemented(inst) Implementation-dependent routine which returns TRUE or FALSE, depending on
whether inst is implemented.
instruction_serialize() Ensures all prior register updates with side-effects are observed before subsequent
instruction and data memory references are performed. Also ensures prior SYNC.i
operations have been observed by the instruction cache.
instruction_synchronize() Synchronizes the instruction and data stream for Flush Cache operations. This
function ensures that when prior Flush Cache operations are observed by the local
data cache they are observed by the local instruction cache, and when prior Flush
Cache operations are observed by another processor’s data cache they are observed
within the same processor’s instruction cache.
is_finite(freg) Returns true when floating register contains a finite number.
is_ignored_reg(regnum) Boolean function that returns true if regnum is an ignored application register,
otherwise false.
is_inf(freg) Returns true when floating register contains an infinite number.
is_interruption_cr(regnum) Boolean function that returns true if regnum is one of the Interruption Control
registers (see Section 3.3.5, “Interruption Control Registers” on page 2:31 in SDM),
otherwise false.
is_kernel_reg(ar_addr) Returns a one if ar_addr is the address of a kernel register application register
is_read_only_reg(rtype, raddr) Returns a one if the register addressed by raddr in the register bank of type rtype
is a read only register.
is_reserved_field(regclass, arg2, arg3) Returns true if the specified data would write a one in a reserved field.
is_reserved_reg(regclass, regnum) Returns true if register regnum is reserved in the regclass register file.
is_supported_hint(hint) Returns true if the implementation supports the specified hint. This function may
depend on factors other than the hint value, such as which execution unit it is
executed on or the slot number the instruction was encoded in.
itlb_ar() Returns the page access rights from the ITLB for the page addressed by the current
IP, or INVALID_AR if PSR.it is 0.
make_icache_coherent(paddr) The cache line addressed by the physical address paddr is flushed in an
implementation-specific manner that ensures that the instruction cache is coherent
with the data caches.
mem_flush(paddr) The line addressed by the physical address paddr is invalidated in all levels of the
memory hierarchy above memory and written back to memory if it is inconsistent with
memory.
mem_flush_pending_stores() The processor is instructed to start draining pending stores in write coalescing and
write buffers. This operation is a hint. There is no indication when prior stores have
actually been drained.

3:262 Volume 3: Pseudo-Code Functions


Table 3-1. Pseudo-code Functions (Continued)
Function Operation
mem_implicit_prefetch(vaddr, hint, type) Moves the line addressed by vaddr to the location of the memory hierarchy
specified by hint. This function is implementation dependent and can be ignored.
The type allows the implementation to distinguish prefetches for different instruction
types.
mem_promote(paddr, mtype, hint) Moves the line addressed by paddr to the highest level of the memory hierarchy
conditioned by the access hints specified by hint. Implementation dependent and
can be ignored.
mem_read(paddr, size, border, mattr, Returns the size bytes starting at the physical memory location specified by paddr
otype, hint) with byte order specified by border, memory attributes specified by mattr, and
access hint specified by hint. otype specifies the memory ordering attribute of this
access, and must be UNORDERED or ACQUIRE.
mem_read_pair(*low_value, *high_value, Reads the size / 2 bytes of memory starting at the physical memory address
paddr, size, border, mattr, otype, hint) specified by paddr into low_value, and the size / 2 bytes of memory starting at
the physical memory address specified by (paddr + size / 2) into high_value,
with byte order specified by border, memory attributes specified by mattr, and
access hint specified by hint. otype specifies the memory ordering attribute of this
access, and must be UNORDERED or ACQUIRE. No value is returned.
fp_mem_to_fr_format(mem, size) Converts a floating-point value in memory format to floating-point register format.
mem_write(value, paddr, size, border, Writes the least significant size bytes of value into memory starting at the physical
mattr, otype, hint) memory address specified by paddr with byte order specified by border, memory
attributes specified by mattr, and access hint specified by hint. otype specifies
the memory ordering attribute of this access, and must be UNORDERED or
RELEASE. No value is returned.
mem_write16(gr_value, ar_value, paddr, Writes the 8 bytes of gr_value into memory starting at the physical memory
border, mattr, otype, hint) address specified by paddr, and the 8 bytes of ar_value into memory starting at
the physical memory address specified by (paddr + 8), with byte order specified by
border, memory attributes specified by mattr, and access hint specified by hint.
otype specifies the memory ordering attribute of this access, and must be
UNORDERED or RELEASE. No value is returned.
mem_xchg(data, paddr, size, byte_order, Returns size bytes from memory starting at the physical address specified by paddr.
mattr, otype, hint) The read is conditioned by the locality hint specified by hint. After the read, the
least significant size bytes of data are written to size bytes in memory starting at
the physical address specified by paddr. The read and write are performed
atomically. Both the read and the write are conditioned by the memory attribute
specified by mattr and the byte ordering in memory is specified by byte_order.
otype specifies the memory ordering attribute of this access, and must be
ACQUIRE.
mem_xchg_add(add_val, paddr, size, Returns size bytes from memory starting at the physical address specified by
byte_order, mattr, otype, hint) paddr. The read is conditioned by the locality hint specified by hint. The least
significant size bytes of the sum of the value read from memory and add_val is
then written to size bytes in memory starting at the physical address specified by
paddr. The read and write are performed atomically. Both the read and the write are
conditioned by the memory attribute specified by mattr and the byte ordering in
memory is specified by byte_order. otype specifies the memory ordering
attribute of this access, and has the value ACQUIRE or RELEASE.
mem_xchg_cond(cmp_val, data, paddr, Returns size bytes from memory starting at the physical address specified by
size, byte_order, mattr, otype, hint) paddr. The read is conditioned by the locality hint specified by hint. If the value
read from memory is equal to cmp_val, then the least significant size bytes of
data are written to size bytes in memory starting at the physical address
specified by paddr. If the write is performed, the read and write are performed
atomically. Both the read and the write are conditioned by the memory attribute
specified by mattr and the byte ordering in memory is specified by byte_order.
otype specifies the memory ordering attribute of this access, and has the value
ACQUIRE or RELEASE.

Volume 3: Pseudo-Code Functions 3:263


Table 3-1. Pseudo-code Functions (Continued)
Function Operation
mem_xchg16_cond(cmp_val, gr_data, Returns 8 bytes from memory starting at the physical address specified by paddr.
ar_data, paddr, byte_order, mattr, otype, The read is conditioned by the locality hint specified by hint. If the value read from
hint) memory is equal to cmp_val, then the 8 bytes of gr_data are written to 8 bytes in
memory starting at the physical address specified by (paddr & ~0x8), and the 8
bytes of ar_data are written to 8 bytes in memory starting at the physical address
specified by ((paddr & ~0x8) + 8). If the write is performed, the read and write are
performed atomically. Both the read and the write are conditioned by the memory
attribute specified by mattr and the byte ordering in memory is specified by
byte_order. The byte ordering only affects the ordering of bytes within each of the
8-byte values stored. otype specifies the memory ordering attribute of this access,
and has the value ACQUIRE or RELEASE.
ordering_fence() Ensures prior data memory references are made visible before future data memory
references are made visible by the processor.
partially_implemented_ip() Implementation-dependent routine which returns TRUE if the implementation, on an
Unimplemented Instruction Address trap, writes IIP with the sign-extended virtual
address or zero-extended physical address for what would have been the next value
of IP. Returns FALSE if the implementation, on this trap, simply writes IIP with the full
address which would have been the next value of IP.
pr_phys_to_virt(phys_id) Returns the virtual register id of the predicate from the physical register id, phys_id
of the predicate.
rotate_regs() Decrements the Register Rename Base registers, effectively rotating the register
files. CFM.rrb.gr is decremented only if CFM.sor is non-zero.
rse_enable_current_frame_load() If the RSE load pointer (RSE.BSPLoad) is greater than AR[BSP], the RSE.CFLE bit
is set to indicate that mandatory RSE loads are allowed to restore registers in the
current frame (in no other case does the RSE spill or fill registers in the current
frame). This function does not perform mandatory RSE loads. This procedure does
not cause any interruptions.
rse_ensure_regs_loaded(number_of_byt All registers and NaT collections between AR[BSP] and
es) (AR[BSP]-number_of_bytes) which are not already in stacked registers are
loaded into the register stack with mandatory RSE loads. If the number of registers to
be loaded is greater than RSE.N_STACK_PHYS an Illegal Operation fault is raised.
All registers starting with backing store address (AR[BSP] - 8) and decrementing
down to and including backing store address (AR[BSP] - number_of_bytes) are made
part of the dirty partition. With exception of the current frame, all other stacked
registers are made part of the invalid partition. Note that number_of_bytes may
be zero. The resulting sequence of RSE loads may be interrupted. Mandatory RSE
loads may cause an interruption; see Table 6-6 “RSE Interruption Summary” on
page 2:138 in SDM.
rse_invalidate_non_current_regs() All registers outside the current frame are invalidated.
rse_load(type) Restores a register or NaT collection from the backing store (load_address =
RSE.BspLoad - 8). If load_address{8:3} is equal to 0x3f then a NaT
collection is loaded into a NaT dispersal register. (dispersal register may not
be the same as AR[RNAT].) If load_address{8:3} is not equal to 0x3f then the
register RSE.LoadReg - 1 is loaded and the NaT bit for that register is set to
dispersal_register{load_address{8:3}}. If the load is successful
RSE.BspLoad is decremented by 8. If the load is successful and a register was
loaded RSE.LoadReg is decremented by 1 (possibly wrapping in the stacked
registers). The load moves a register from the invalid partition to the current frame if
RSE.CFLE is 1, or to the clean partition if RSE.CFLE is 0. For mandatory RSE loads,
type is MANDATORY. Mandatory RSE loads may cause interruptions. See
Table 6-6 “RSE Interruption Summary” on page 2:138 in SDM.

3:264 Volume 3: Pseudo-Code Functions


Table 3-1. Pseudo-code Functions (Continued)
Function Operation
rse_new_frame(current_frame_size, A new frame is defined without changing any register renaming. The new frame size
new_frame_size) is completely defined by the new_frame_size parameter (successive calls are not
cumulative). If new_frame_size is larger than current_frame_size and the
number of registers in the invalid and clean partitions is less than the size of frame
growth then mandatory RSE stores are issued until enough registers are available.
The resulting sequence of RSE stores may be interrupted. Mandatory RSE stores
may cause interruptions; see Table 6-6 “RSE Interruption Summary” on page 2:138 in
SDM.
rse_preserve_frame(preserved_frame_si The number of registers specified by preserved_frame_size are marked to be
ze) preserved by the RSE. Register renaming causes the preserved_frame_size
registers after GR[32] to be renamed to GR[32]. AR[BSP] is updated to contain
the backing store address where the new GR[32] will be stored.
rse_restore_frame(preserved_sol, The first two parameters define how the current frame is about to be updated by a
growth, current_frame_size) branch return or rfi: preserved_sol defines how many registers need to be
restored below RSE.BOF; growth defines by how many registers the top of the
current frame will grow (growth will generally be negative). The number of registers
specified by preserved_sol are marked to be restored. Register renaming
causes the preserved_sol registers before GR[32] to be renamed to GR[32].
AR[BSP] is updated to contain the backing store address where the new GR[32]
will be stored. If the number of dirty and clean registers is less than
preserved_sol then mandatory RSE loads must be issued before the new
current frame is considered valid. This function does not perform mandatory RSE
loads. This function returns TRUE if the preserved frame grows beyond the invalid
and clean regions into the dirty region. In this case the third argument,
current_frame_size, is used to force the returned to frame to zero (see
Table 6-6 “RSE Interruption Summary” on page 2:138 in SDM).
rse_store(type) Saves a register or NaT collection to the backing store (store_address =
AR[BSPSTORE]). If store_address{8:3} is equal to 0x3f then the NaT collection
AR[RNAT] is stored. If store_address{8:3} is not equal to 0x3f then the register
RSE.StoreReg is stored and the NaT bit from that register is deposited in
AR[RNAT]{store_address{8:3}}. If the store is successful AR[BSPSTORE] is
incremented by 8. If the store is successful and a register was stored RSE.StoreReg
is incremented by 1 (possibly wrapping in the stacked registers). This store moves a
register from the dirty partition to the clean partition. For mandatory RSE stores,
type is MANDATORY. Mandatory RSE stores may cause interruptions. See
Table 6-6 “RSE Interruption Summary” on page 2:138 in SDM.
rse_update_internal_stack_pointers(new Given a new value for AR[BSPSTORE] (new_store_pointer) this function
_store_pointer) computes the new value for AR[BSP]. This value is equal to
new_store_pointer plus the number of dirty registers plus the number of
intervening NaT collections. This means that the size of the dirty partition is the same
before and after a write to AR[BSPSTORE]. All clean registers are moved to the
invalid partition.
sign_ext(value, pos) Returns a 64 bit number with bits pos-1 through 0 taken from value and bit pos-1
of value replicated in bit positions pos through 63. If pos is greater than or equal to
64, value is returned.
spontaneous_deferral(paddr, size, Implementation-dependent routine which optionally forces *defer to TRUE if all of
border, mattr, otype, hint, *defer) the following are true: spontaneous deferral is enabled, spontaneous deferral is
permitted by the programming model, and the processor determines it would be
advantageous to defer the speculative load (e.g., based on a miss in some particular
level of cache).
spontaneous_deferral_enabled() Implementation-dependent routine which returns TRUE or FALSE, depending on
whether spontaneous deferral of speculative loads is enabled or disabled in the
processor.

Volume 3: Pseudo-Code Functions 3:265


Table 3-1. Pseudo-code Functions (Continued)
Function Operation
tlb_access_key(vaddr, itype) This function returns, in bits 31:8, the access key from the TLB for the entry
corresponding to vaddr and itype; bits 63:32 and 7:0 return 0. If vaddr is an
unimplemented virtual address, or a matching present translation is not found, the
value 1 is returned.
tlb_broadcast_purge(rid, vaddr, size, Sends a broadcast purge DTC and ITC transaction to other processors in the
type) multiprocessor coherency domain, where the region identifier (rid), virtual address
(vaddr) and page size (size) specify the translation entry to purge. The operation
waits until all processors that receive the purge have completed the purge operation.
The purge type (type) specifies whether the ALAT on other processors should also
be purged in conjunction with the TC.
tlb_enter_privileged_code() This function determines the new privilege level for epc from the TLB entry for the
page containing this instruction. If 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.
tlb_grant_permission(vaddr, type, pl) Returns a boolean indicating if read, write access is granted for the specified virtual
memory address (vaddr) and privilege level (pl). The access type (type) specifies
either read or write. The following faults are checked:
• Data Nested TLB fault
• Alternate Data TLB fault
• VHPT Data fault
• Data TLB fault
• Data Page Not Present fault
• Data NaT Page Consumption fault
• Data Key Miss fault
If a fault is generated, this function does not return.
tlb_insert_data(slot, pte0, pte1, vaddr, rid, Inserts an entry into the DTLB, at the specified slot number. pte0, pte1
tr) compose the translation. vaddr and rid specify the virtual address and region
identifier for the translation. If tr is true the entry is placed in the TR section,
otherwise the TC section.
tlb_insert_inst(slot, pte0, pte1, vaddr, rid, Inserts an entry into the ITLB, at the specified slot number. pte0, pte1 compose
tr) the translation. vaddr and rid specify the virtual address and region identifier for
the translation. If tr is true, the entry is placed in the TR section, otherwise the TC
section.
tlb_may_purge_dtc_entries(rid, vaddr, May locally purge DTC entries that match the specified virtual address (vaddr),
size) region identifier (rid) and page size (size). May also invalidate entries that partially
overlap the parameters. The extent of purging is implementation dependent. If the
purge size is not supported, an implementation may generate a machine check abort
or over purge the translation cache up to and including removal of all entries from the
translation cache.
tlb_may_purge_itc_entries(rid, vaddr, May locally purge ITC entries that match the specified virtual address (vaddr),
size) region identifier (rid) and page size (size). May also invalidate entries that partially
overlap the parameters. The extent of purging is implementation dependent. If the
purge size is not supported, an implementation may generate a machine check abort
or over purge the translation cache up to and including removal of all entries from the
translation cache.

3:266 Volume 3: Pseudo-Code Functions


Table 3-1. Pseudo-code Functions (Continued)
Function Operation
tlb_must_purge_dtc_entries(rid, vaddr, Purges all local, possibly overlapping, DTC entries matching the specified region
size) identifier (rid), virtual address (vaddr) and page size (size). vaddr{63:61}
(VRN) is ignored in the purge, i.e all entries that match vaddr{60:0} must be purged
regardless of the VRN bits. If the purge size is not supported, an implementation may
generate a machine check abort or over purge the translation cache up to and
including removal of all entries from the translation cache. If the specified purge
values overlap with an existing DTR translation, an implementation may generate a
machine check abort.
tlb_must_purge_itc_entries(rid, vaddr, Purges all local, possibly overlapping, ITC entry matching the specified region
size) identifier (rid), virtual address (vaddr) and page size (size). vaddr{63:61}
(VRN) is ignored in the purge, i.e all entries that match vaddr{60:0} must be purged
regardless of the VRN bits. If the purge size is not supported, an implementation may
generate a machine check abort or over purge the translation cache up to and
including removal of all entries from the translation cache. If the specified purge
values overlap with an existing ITR translation, an implementation may generate a
machine check abort.
tlb_must_purge_dtr_entries(rid, vaddr, Purges all local, possibly overlapping, DTR entries matching the specified region
size) identifier (rid), virtual address (vaddr) and page size (size). vaddr{63:61}
(VRN) is ignored in the purge, i.e all entries that match vaddr{60:0} must be purged
regardless of the VRN bits. If the purge size is not supported, an implementation may
generate a machine check abort or over purge the translation cache up to and
including removal of all entries from the translation cache.
tlb_must_purge_itr_entries(rid, vaddr, Purges all local, possibly overlapping, ITR entry matching the specified region
size) identifier (rid), virtual address (vaddr) and page size (size). vaddr{63:61}
(VRN) is ignored in the purge, i.e all entries that match vaddr{60:0} must be purged
regardless of the VRN bits. If the purge size is not supported, an implementation may
generate a machine check abort or over purge the translation cache up to and
including removal of all entries from the translation cache.
tlb_purge_translation_cache(loop) Removes 1 to N translations from the local processor’s ITC and DTC. The number of
entries removed is implementation specific. The parameter loop is used to generate
an implementation-specific purge parameter.
tlb_replacement_algorithm(tlb) Returns the next ITC or DTC slot number to replace. Replacement algorithms are
implementation specific. tlb specifies to perform the algorithm on the ITC or DTC.
tlb_search_pkr(key) Searches for a valid protection key register with a matching protection key. The
search algorithm is implementation specific. Returns the PKR register slot number if
found, otherwise returns Not Found.

Volume 3: Pseudo-Code Functions 3:267


Table 3-1. Pseudo-code Functions (Continued)
Function Operation
tlb_translate(vaddr, size, type, cpl, *attr, Returns the translated data physical address for the specified virtual memory address
*defer) (vaddr) when translation enabled; otherwise, returns vaddr. size specifies the
size of the access, type specifies the type of access (e.g., read, write, advance,
spec). cpl specifies the privilege level for access checking purposes. *attr returns
the mapped physical memory attribute. If any fault conditions are detected and
deferred, tlb_translate returns with *defer set. If a fault is generated but the fault is
not deferred, tlb_translate does not return. tlb_translate checks the following faults:
• Unimplemented Data Address fault
• Data Nested TLB fault
• Alternate Data TLB fault
• VHPT Data fault
• Data TLB fault
• Data Page Not Present fault
• Data NaT Page Consumption fault
• Data Key Miss fault
• Data Key Permission fault
• Data Access Rights fault
• Data Dirty Bit fault
• Data Access Bit fault
• Data Debug fault
• Unaligned Data Reference fault
• Unsupported Data Reference fault
tlb_translate_nonaccess(vaddr, type) Returns the translated data physical address for the specified virtual memory address
(vaddr). type specifies the type of access (e.g., FC, TPA). If a fault is generated,
tlb_translate_nonaccess does not return. The following faults are checked:
• Unimplemented Data Address fault
• Virtualization fault (tpa only)
• Data Nested TLB fault
• Alternate Data TLB fault
• VHPT Data fault
• Data TLB fault
• Data Page Not Present fault
• Data NaT Page Consumption fault
• Data Access Rights fault (fc only)
tlb_vhpt_hash(vrn, vaddr61, rid, size) Generates a VHPT entry address for the specified virtual region number (vrn) and
61-bit virtual offset (vaddr61), region identifier (rid) and page size (size).
Tlb_vhpt_hash hashes vaddr, rid and size parameters to produce a hash index.
The hash index is then masked based on PTA.size and concatenated with PTA.base
to generate the VHPT entry address. The long format hash is implementation
specific.
tlb_vhpt_tag(vaddr, rid, size) Generates a VHPT tag identifier for the specified virtual address (vaddr), region
identifier (rid) and page size (size). Tlb_vhpt_tag hashes the vaddr, rid and
size parameters to produce translation identifier. The tag in conjunction with the
hash index is used to uniquely identify translations in the VHPT. Tag generation is
implementation specific. All processor models tag function must guarantee that bit 63
of the generated tag is zero (ti bit).
unimplemented_physical_address(paddr) Return TRUE if the presented physical address is unimplemented on this processor
model; FALSE otherwise. This function is model specific.
undefined() Returns an undefined 64-bit value.
undefined_behavior() Causes undefined processor behavior. Extent of undefined behavior is described in
Section 3.5, “Undefined Behavior” on page 1:41 in SDM.

3:268 Volume 3: Pseudo-Code Functions


Table 3-1. Pseudo-code Functions (Continued)
Function Operation
unimplemented_virtual_address(vaddr, Return TRUE if the presented virtual address is unimplemented on this processor
vm) model; FALSE otherwise. If vm is 1, one additional bit of virtual address is treated as
unimplemented. This function is model specific.
fp_update_fpsr(sf, tmp_fp_env) Copies a floating-point instruction’s local state into the global FPSR.
fp_update_psr(dest_freg) Conditionally sets PSR.mfl or PSR.mfh based on dest_freg.
vm_disabled() Returns TRUE if the processor implements the PSR.vm bit and the vmsw instruction
is disabled. See Section 3.4, “Processor Virtualization” on page 2:38 in SDM and
“PAL_PROC_GET_FEATURES – Get Processor Dependent Features (17)” on
page 2:429 for details.
zero_ext(value, pos) Returns a 64 bit unsigned number with bits pos-1 through 0 taken from value and
zeroes in bit positions pos through 63. If pos is greater than or equal to 64, value
is returned.

Volume 3: Pseudo-Code Functions 3:269


3:270 Volume 3: Pseudo-Code Functions
3

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.

Figure 4-1. Bundle Format


127 87 86 46 45 5 4 0
instruction slot 2 instruction slot 1 instruction slot 0 template
41 41 41 5

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).

Volume 3: Instruction Formats 3:271


Table 4-2. Template Field Encoding and Instruction Slot Mapping
Template Slot 0 Slot 1 Slot 2
00 M-unit I-unit I-unit
01 M-unit I-unit I-unit
02 M-unit I-unit I-unit
03 M-unit I-unit I-unit
04 M-unit L-unit X-unita
05 M-unit L-unit X-unita
06
07
08 M-unit M-unit I-unit
09 M-unit M-unit I-unit
0A M-unit M-unit I-unit
0B M-unit M-unit I-unit
0C M-unit F-unit I-unit
0D M-unit F-unit I-unit
0E M-unit M-unit F-unit
0F M-unit M-unit F-unit
10 M-unit I-unit B-unit
11 M-unit I-unit B-unit
12 M-unit B-unit B-unit
13 M-unit B-unit B-unit
14
15
16 B-unit B-unit B-unit
17 B-unit B-unit B-unit
18 M-unit M-unit B-unit
19 M-unit M-unit B-unit
1A
1B
1C M-unit F-unit B-unit
1D M-unit F-unit B-unit
1E
1F
a. The MLX template was formerly called MLI, and for compatibility, the X slot may encode break.i and nop.i in
addition to any X-unit instruction.

4.1 Format Summary


All instructions in the instruction set are 41 bits in length. The leftmost 4 bits (40:37) of each
instruction are the major opcode. Table 4-3 shows the major opcode assignments for each of the 5
instruction types — ALU (A), Integer (I), Memory (M), Floating-point (F), and Branch (B). Bundle
template bits are used to distinguish among the 4 columns, so the same major op values can be
reused in each column.

Unused major ops (appearing as blank entries in Table 4-3) behave in one of four ways:

3:272 Volume 3: Instruction Formats


• Ignored major ops (white entries in Table 4-3) execute as nop instructions.
• Reserved major ops (light gray in the gray scale version of Table 4-3, brown in the color
version) cause an Illegal Operation fault.
• Reserved if PR[qp] is 1 major ops (dark gray in the gray scale version of Table 4-3, 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 major ops (medium gray in the gray scale version of Table 4-3,
cyan 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. These differ
from the Reserved if PR[qp] is 1 major ops (purple) only in their RAW dependency behavior
(see “RAW Dependency Table” on page 3:356).

Table 4-3. Major Opcode Assignments


Major Instruction Type
Op
(Bits I/A M/A F B L+X
40:37)
0 0 0 0 0 0
Misc Sys/Mem Mgmt FP Misc Misc/Indirect Branch Misc
1 1 1 1 1
1 Sys/Mem Mgmt FP Misc Indirect Call
2 2 2 2 2
2 Indirect Predict/Nop
3 3 3 3 3
3
4 4 4 4 4
4 Deposit Int Ld +Reg/getf FP Compare IP-relative Branch
5 5 5 5 5
5 Shift/Test Bit Int Ld/St +Imm FP Class IP-rel Call
6 6 6 6 6
6 FP Ld/St +Reg/setf movl
7 7 7 7 7
7 MM Mpy/Shift FP Ld/St +Imm IP-relative Predict
8 8 8 e 8 8
8 ALU/MM ALU ALU/MM ALU fma
9 9 9 e 9 9
9 Add Imm22 Add Imm22 fma
A A A e A A
A fms
B B B e B B
B fms
C C C e C C
C Compare Compare fnma Long Branch
D D D e D D
D Compare Compare fnma Long Call
E E E e E E
E Compare Compare fselect/xma
F F F F e F F

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.

Volume 3: Instruction Formats 3:273


Table 4-4. Instruction Format Summary
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ALU A1 8 x2a ve x4 x2b r3 r2 r1 qp
Shift L and Add A2 8 x2a ve x4 ct2d r3 r2 r1 qp
ALU Imm8 A3 8 s x2a ve x4 x2b r3 imm7b r1 qp
Add Imm14 A4 8 s x2a ve imm6d r3 imm7b r1 qp
Add Imm22 A5 9 s imm9d imm5c r3 imm7b r1 qp
Compare A6 C-E tb x2 ta p2 r3 r2 c p1 qp
Compare to Zero A7 C-E tb x2 ta p2 r3 0 c p1 qp
Compare Imm8 A8 C-E s x2 ta p2 r3 imm7b c p1 qp
MM ALU A9 8 za x2a zb x4 x2b r3 r2 r1 qp
MM Shift and Add A10 8 za x2a zb x4 ct2d r3 r2 r1 qp
MM Multiply Shift I1 7 za x2a zb ve ct2d x2b r3 r2 r1 qp
MM Mpy/Mix/Pack I2 7 za x2a zb ve x2c x2b r3 r2 r1 qp
MM Mux1 I3 7 za x2a zb ve x2c x2b mbt4c r2 r1 qp
MM Mux2 I4 7 za x2a zb ve x2c x2b mht8c r2 r1 qp
Shift R Variable I5 7 za x2a zb ve x2c x2b r3 r2 r1 qp
MM Shift R Fixed I6 7 za x2a zb ve x2c x2b r3 count5b r1 qp
Shift L Variable I7 7 za x2a zb ve x2c x2b r3 r2 r1 qp
MM Shift L Fixed I8 7 za x2a zb ve x2c x2b ccount5c r2 r1 qp
Bit Strings I9 7 za x2a zb ve x2c x2b r3 0 r1 qp
Shift Right Pair I10 5 x2 x count6d r3 r2 r1 qp
Extract I11 5 x2 x len6d r3 pos6b y r1 qp
Dep.Z I12 5 x2 x len6d y cpos6c r2 r1 qp
Dep.Z Imm8 I13 5 s x2 x len6d y cpos6c imm7b r1 qp
Deposit Imm1 I14 5 s x2 x len6d r3 cpos6b r1 qp
Deposit I15 4 cpos6d len4d r3 r2 r1 qp
Test Bit I16 5 tb x2 ta p2 r3 pos6b y c p1 qp
Test NaT I17 5 tb x2 ta p2 r3 x y c p1 qp
Nop/Hint I18 0 i x3 x6 y imm20a qp
Break I19 0 i x3 x6 imm20a qp
Int Spec Check I20 0 s x3 imm13c r2 imm7a qp
Move to BR I21 0 x3 timm9c ih x wh r2 b1 qp
Move from BR I22 0 x3 x6 b2 r1 qp
Move to Pred I23 0 s x3 mask8c r2 mask7a qp
Move to Pred Imm44 I24 0 s x3 imm27a qp
Move from Pred/IP I25 0 x3 x6 r1 qp
Move to AR I26 0 x3 x6 ar3 r2 qp
Move to AR Imm8 I27 0 s x3 x6 ar3 imm7b qp
Move from AR I28 0 x3 x6 ar3 r1 qp
Sxt/Zxt/Czx I29 0 x3 x6 r3 r1 qp
Test Feature I30 5 tb x2 ta p2 0 x imm5b y c p1 qp
Int Load M1 4 m x6 hint x r3 r1 qp
Int Load +Reg M2 4 m x6 hint x r3 r2 r1 qp
Int Load +Imm M3 5 s x6 hint i r3 imm7b r1 qp
Int Store M4 4 m x6 hint x r3 r2 qp
Int Store +Imm M5 5 s x6 hint i r3 r2 imm7a qp
FP Load M6 6 m x6 hint x r3 f1 qp
FP Load +Reg M7 6 m x6 hint x r3 r2 f1 qp
FP Load +Imm M8 7 s x6 hint i r3 imm7b f1 qp
FP Store M9 6 m x6 hint x r3 f2 qp
FP Store +Imm M10 7 s x6 hint i r3 f2 imm7a qp
FP Load Pair M11 6 m x6 hint x r3 f2 f1 qp
FP Load Pair +Imm M12 6 m x6 hint x r3 f2 f1 qp
Line Prefetch M13 6 m x6 hint x r3 qp
Line Prefetch +Reg M14 6 m x6 hint x r3 r2 qp
Line Prefetch +Imm M15 7 s x6 hint i r3 imm7b qp
(Cmp &) Exchg M16 4 m x6 hint x r3 r2 r1 qp
Fetch & Add M17 4 m x6 hint x r3 s i2b r1 qp
Set FR M18 6 m x6 x r2 f1 qp
Get FR M19 4 m x6 x f2 r1 qp
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

3:274 Volume 3: Instruction Formats


Table 4-4. Instruction Format Summary (Continued)
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Int Spec Check M20 1 s x3 imm13c r2 imm7a qp
FP Spec Check M21 1 s x3 imm13c f2 imm7a qp
Int ALAT Check M22 0 s x3 imm20b r1 qp
FP ALAT Check M23 0 s x3 imm20b f1 qp
Sync/Srlz/ALAT M24 0 x3 x2 x4 qp
RSE Control M25 0 x3 x2 x4 0
Int ALAT Inval M26 0 x3 x2 x4 r1 qp
FP ALAT Inval M27 0 x3 x2 x4 f1 qp
Flush Cache M28 1 x x3 x6 r3 qp
Move to AR M29 1 x3 x6 ar3 r2 qp
Move to AR Imm8 M30 0 s x3 x2 x4 ar3 imm7b qp
Move from AR M31 1 x3 x6 ar3 r1 qp
Move to CR M32 1 x3 x6 cr3 r2 qp
Move from CR M33 1 x3 x6 cr3 r1 qp
Alloc M34 1 x3 sor sol sof r1 qp
Move to PSR M35 1 x3 x6 r2 qp
Move from PSR M36 1 x3 x6 r1 qp
Break M37 0 i x3 x2 x4 imm20a qp
Probe M38 1 x3 x6 r3 r2 r1 qp
Probe Imm2 M39 1 x3 x6 r3 i2b r1 qp
Probe Fault Imm2 M40 1 x3 x6 r3 i2b qp
TC Insert M41 1 x3 x6 r2 qp
Mv to Ind/TR Ins M42 1 x3 x6 r3 r2 qp
Mv from Ind M43 1 x3 x6 r3 r1 qp
Set/Reset Mask M44 0 i x3 i2d x4 imm21a qp
Translation Purge M45 1 x3 x6 r3 r2 qp
Translation Access M46 1 x3 x6 r3 r1 qp
TC Entry Purge M47 1 x3 x6 r3 qp
Nop/Hint M48 0 i x3 x2 x4 y imm20a qp
IP-Relative Branch B1 4 s d wh imm20b p btype qp
Counted Branch B2 4 s d wh imm20b p btype 0
IP-Relative Call B3 5 s d wh imm20b p b1 qp
Indirect Branch B4 0 d wh x6 b2 p btype qp
Indirect Call B5 1 d wh b2 p b1 qp
IP-Relative Predict B6 7 s ih t2e imm20b timm7a wh
Indirect Predict B7 2 ih t2e x6 b2 timm7a wh
Misc B8 0 x6 0
Break/Nop/Hint B9 0/2 i x6 imm20a qp
FP Arithmetic F1 8-D x sf f4 f3 f2 f1 qp
Fixed Multiply Add F2 E x x2 f4 f3 f2 f1 qp
FP Select F3 E x f4 f3 f2 f1 qp
FP Compare F4 4 rb sf ra p2 f3 f2 ta p1 qp
FP Class F5 5 fc2 p2 fclass7c f2 ta p1 qp
FP Recip Approx F6 0-1 q sf x p2 f3 f2 f1 qp
FP Recip Sqrt App F7 0-1 q sf x p2 f3 f1 qp
FP Min/Max/Pcmp F8 0-1 sf x x6 f3 f2 f1 qp
FP Merge/Logical F9 0-1 x x6 f3 f2 f1 qp
Convert FP to Fixed F10 0-1 sf x x6 f2 f1 qp
Convert Fixed to FP F11 0 x x6 f2 f1 qp
FP Set Controls F12 0 sf x x6 omask7c amask7b qp
FP Clear Flags F13 0 sf x x6 qp
FP Check Flags F14 0 s sf x x6 imm20a qp
Break F15 0 i x x6 imm20a qp
Nop/Hint F16 0 i x x6 y imm20a qp
Break X1 0 i x3 x6 imm20a qp imm41
Move Imm64 X2 6 i imm9d imm5c ic vc imm7b r1 qp imm41
Long Branch X3 C i d wh imm20b p btype qp imm39
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Volume 3: Instruction Formats 3:275


Table 4-4. Instruction Format Summary (Continued)
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Long Call X4 D i d wh imm20b p b1 qp imm39
Nop/Hint X5 0 i x3 x6 y imm20a qp imm41
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Table 4-5. Instruction Field Color Key


Field & Color
ALU Instruction Opcode Extension
Integer Instruction Opcode Hint Extension
Memory Instruction Immediate
Branch Instruction Indirect Source
Floating-point Instruction Predicate Destination
Integer Source Integer Destination
Memory Source Memory Source & Destination
Shift Source Shift Immediate
Special Register Source Special Register Destination
Floating-point Source Floating-point Destination
Branch Source Branch Destination
Address Source Branch Tag Immediate
Qualifying Predicate Reserved Instruction
Ignored Field/Instruction Reserved Inst if PR[qp] is 1
Reserved B-type Inst if PR[qp] is 1

Table 4-6. Instruction Field Names


Field Name Description
ar3 application register source/target
b1, b2 branch register source/target
btype branch type opcode extension
c complement compare relation opcode extension
ccount5c multimedia shift left complemented shift count immediate
count5b, count6d multimedia shift right/shift right pair shift count immediate
cposx deposit complemented bit position immediate
cr3 control register source/target
ct2d multimedia multiply shift/shift and add shift count immediate
d branch cache deallocation hint opcode extension
fn floating-point register source/target
fc2, fclass7c floating-point class immediate
hint memory reference hint opcode extension
i, i2b, i2d, immx immediate of length 1, 2, or x
ih branch importance hint opcode extension
len4d, len6d extract/deposit length immediate
m memory reference post-modify opcode extension
maskx predicate immediate mask
mbt4c, mht8c multimedia mux1/mux2 immediate
p sequential prefetch hint opcode extension
p1, p2 predicate register target

3:276 Volume 3: Instruction Formats


Table 4-6. Instruction Field Names (Continued)
Field Name Description
pos6b test bit/extract bit position immediate
q floating-point reciprocal/reciprocal square-root opcode extension
qp qualifying predicate register source
rn general register source/target
s immediate sign bit
sf floating-point status field opcode extension
sof, sol, sor alloc size of frame, size of locals, size of rotating immediates
ta, tb compare type opcode extension
t2e, timmx branch predict tag immediate
vx reserved opcode extension field
wh branch whether hint opcode extension
x, xn opcode extension of length 1 or n
y extract/deposit/test bit/test NaT/hint opcode extension
z a, z b multimedia operand size opcode extension

Table 4-7. Special Instruction Notations


Notation Description
e instruction ends an instruction group when taken, or for Reserved if PR[qp] is 1 (cyan)
encodings and non-branch instructions with a qualifying predicate, when its PR[qp] is
1, or for Reserved (brown) encodings, unconditionally
f 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
i instruction is allowed in the I slot of an MLI template
l instruction must be the last in an instruction group
p privileged instruction
t instruction is only allowed in instruction slot 2

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

Volume 3: Instruction Formats 3:277


specified by the qp field of the instruction (bits 5:0) is 1 and execute as a nop instruction if 0.
These differ from the Reserved if PR[qp] is 1 instructions (purple) only in their RAW
dependency behavior (see “RAW Dependency Table” on page 3:356).

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.

4.2 A-Unit Instruction Encodings

4.2.1 Integer ALU


All integer ALU instructions are encoded within major opcode 8 using a 2-bit opcode extension
field in bits 35:34 (x2a) and most have a second 2-bit opcode extension field in bits 28:27 (x2b), a
4-bit opcode extension field in bits 32:29 (x4), and a 1-bit reserved opcode extension field in bit 33
(ve). Table 4-8 shows the 2-bit x2a and 1-bit ve assignments, Table 4-9 shows the integer ALU
4-bit+2-bit assignments, and Table 4-12 on page 3:284 shows the multimedia ALU 1-bit+2-bit
assignments (which also share major opcode 8).

3:278 Volume 3: Instruction Formats


Table 4-8. Integer ALU 2-bit+1-bit Opcode Extensions

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

Table 4-9. Integer ALU 4-bit+2-bit Opcode Extensions

Opcode x2a ve x4 x2b


Bits Bits Bit Bits Bits 28:27
40:37 35:34 33 32:29 0 1 2 3
0 add A1 add +1 A1
1 sub -1 A1 sub A1
2 addp4 A1
3 and A1 andcm A1 or A1 xor A1
4 shladd A2
5
6 shladdp4 A2
7
8 0 0
8
9 sub – imm8 A3
A
B and – imm8 A3 andcm – imm8 A3 or – imm8 A3 xor – imm8 A3
C
D
E
F

4.2.1.1 Integer ALU – Register-Register


40 37 36 35 34 33 32 29 28 27 26 20 19 13 12 6 5 0

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

Volume 3: Instruction Formats 3:279


4.2.1.2 Shift Left and Add
40 37 36 35 34 33 32 29 28 27 26 20 19 13 12 6 5 0

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

4.2.1.3 Integer ALU – Immediate8-Register


40 37 36 35 34 33 32 29 28 27 26 20 19 13 12 6 5 0

A3 8 s x2a ve x4 x2b r3 imm7b r1 qp


4 1 2 1 4 2 7 7 7 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

4.2.1.4 Add Immediate14


40 37 36 35 34 33 32 27 26 20 19 13 12 6 5 0

A4 8 s x2a ve imm6d r3 imm7b r1 qp


4 1 2 1 6 7 7 7 6

Extension
Instruction Operands Opcode
x2a ve
adds 2
r1 = imm14, r3 8 0
addp4 3

4.2.1.5 Add Immediate22


40 37 36 35 27 26 22 21 20 19 13 12 6 5 0

A5 9 s imm9d imm5c r3 imm7b r1 qp


4 1 9 5 2 7 7 6

Instruction Operands Opcode


addl r1 = imm22, r3 9

3:280 Volume 3: Instruction Formats


4.2.2 Integer Compare
The integer compare instructions are encoded within major opcodes C - E using a 2-bit opcode
extension field (x2) in bits 35:34 and three 1-bit opcode extension fields in bits 33 (ta), 36 (tb), and
12 (c), as shown in Table 4-10. The integer compare immediate instructions are encoded within
major opcodes C - E using a 2-bit opcode extension field (x2) in bits 35:34 and two 1-bit opcode
extension fields in bits 33 (ta) and 12 (c), as shown in Table 4-11.

Table 4-10. Integer Compare Opcode Extensions

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

Table 4-11. Integer Compare Immediate Opcode Extensions

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

3 cmp4.eq.and – imm8 A8 cmp4.eq.or – imm8 A8 cmp4.eq.or.andcm – imm8


0
A8
1
cmp4.ne.and – imm8 A8 cmp4.ne.or – imm8 A8 cmp4.ne.or.andcm – imm8
1
A8

Volume 3: Instruction Formats 3:281


4.2.2.1 Integer Compare – Register-Register
40 37 36 35 34 33 32 27 26 20 19 13 12 11 6 5 0

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

3:282 Volume 3: Instruction Formats


4.2.2.2 Integer Compare to Zero – Register
40 37 36 35 34 33 32 27 26 20 19 13 12 11 6 5 0

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

Volume 3: Instruction Formats 3:283


4.2.2.3 Integer Compare – Immediate-Register
40 37 36 35 34 33 32 27 26 20 19 13 12 11 6 5 0

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.

Table 4-12. Multimedia ALU 2-bit+1-bit Opcode Extensions


Opcode x2a za zb
Bits 40:37 Bits 35:34 Bit 36 Bit 33
0 Multimedia ALU Size 1 (Table 4-13)
0
1 Multimedia ALU Size 2 (Table 4-14)
8 1
0 Multimedia ALU Size 4 (Table 4-15)
1
1

3:284 Volume 3: Instruction Formats


Table 4-13. Multimedia ALU Size 1 4-bit+2-bit Opcode Extensions

Opcode x2a za zb x4 x2b


Bits Bits Bit Bit Bits Bits 28:27
40:37 35:34 36 33 32:29 0 1 2 3
0 padd1 A9 padd1.sss A9 padd1.uuu A9 padd1.uus A9
1 psub1 A9 psub1.sss A9 psub1.uuu A9 psub1.uus A9
2 pavg1 A9 pavg1.raz A9
3 pavgsub1 A9
4
5
6
7
8 1 0 0
8
9 pcmp1.eq A9 pcmp1.gt A9
A
B
C
D
E
F

Table 4-14. Multimedia ALU Size 2 4-bit+2-bit Opcode Extensions

Opcode x2a za zb x4 x2b


Bits Bits Bit Bit Bits Bits 28:27
40:37 35:34 36 33 32:29 0 1 2 3
0 padd2 A9 padd2.sss A9 padd2.uuu A9 padd2.uus A9
1 psub2 A9 psub2.sss A9 psub2.uuu A9 psub2.uus A9
2 pavg2 A9 pavg2.raz A9
3 pavgsub2 A9
4 pshladd2 A10
5
6 pshradd2 A10
7
8 1 0 1
8
9 pcmp2.eq A9 pcmp2.gt A9
A
B
C
D
E
F

Volume 3: Instruction Formats 3:285


Table 4-15. Multimedia ALU Size 4 4-bit+2-bit Opcode Extensions

Opcode x2a za zb x4 x2b


Bits Bits Bit Bit Bits Bits 28:27
40:37 35:34 36 33 32:29 0 1 2 3
0 padd4 A9
1 psub4 A9
2
3
4
5
6
7
8 1 1 0
8
9 pcmp4.eq A9 pcmp4.gt A9
A
B
C
D
E
F

3:286 Volume 3: Instruction Formats


4.2.3.1 Multimedia ALU
40 37 36 35 34 33 32 29 28 27 26 20 19 13 12 6 5 0

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

4.2.3.2 Multimedia Shift and Add


40 37 36 35 34 33 32 29 28 27 26 20 19 13 12 6 5 0

A10 8 za x2a zb x4 ct2d r3 r2 r1 qp


4 1 2 1 4 2 7 7 7 6

Extension
Instruction Operands Opcode
x2a za zb x4
pshladd2 4
r1 = r2, count2, r3 8 1 0 1
pshradd2 6

Volume 3: Instruction Formats 3:287


4.3 I-Unit Instruction Encodings

4.3.1 Multimedia and Variable Shifts


All multimedia multiply/shift/max/min/mix/mux/pack/unpack and variable shift instructions are
encoded within major opcode 7 using two 1-bit opcode extension fields in bits 36 (za) and 33 (zb)
and a 1-bit reserved opcode extension in bit 32 (ve) as shown in Table 4-16. They also have a 2-bit
opcode extension field in bits 35:34 (x2a) and a 2-bit field in bits 29:28 (x2b) and most have a 2-bit
field in bits 31:30 (x2c) as shown in Table 4-17.

Table 4-16. Multimedia and Variable Shift 1-bit Opcode Extensions

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)

Table 4-17. Multimedia Opcode 7 Size 1 2-bit Opcode Extensions

Opcode za z b ve x2a x2b x2c


Bits Bit Bit Bit Bits Bits Bits 31:30
40:37 36 33 32 35:34 29:28 0 1 2 3
0
1
0
2
3
0
1
1
2
3
7 0 0 0
0 unpack1.h I2 mix1.r I2
1 pmin1.u I2 pmax1.u I2
2
2 unpack1.l I2 mix1.l I2
3 psad1 I2
0
1
3
2 mux1 I3
3

3:288 Volume 3: Instruction Formats


Table 4-18. Multimedia Opcode 7 Size 2 2-bit Opcode Extensions

Opcode za zb ve x2a x2b x2c


Bits Bit Bit Bit Bits Bits Bits 31:30
40:37 36 33 32 35:34 29:28 0 1 2 3
0 pshr2.u – var I5 pshl2 – var I7
1 pmpyshr2.u I1
0
2 pshr2 – var I5
3 pmpyshr2 I1
0
1 pshr2.u – fixed I6 popcnt I9
1
2
3 pshr2 – fixed I6
7 0 1 0
0 pack2.uss I2 unpack2.h I2 mix2.r I2
1 pmpy2.r I2
2
2 pack2.sss I2 unpack2.l I2 mix2.l I2
3 pmin2 I2 pmax2 I2 pmpy2.l I2
0
1 pshl2 – fixed I8
3
2 mux2 I4
3

Table 4-19. Multimedia Opcode 7 Size 4 2-bit Opcode Extensions

Opcode za zb ve x2a x2b x2c


Bits Bit Bit Bit Bits Bits Bits 31:30
40:37 36 33 32 35:34 29:28 0 1 2 3
0 pshr4.u – var I5 pshl4 – var I7
1
0
2 pshr4 – var I5
3
0
1 pshr4.u – fixed I6
1
2
3 pshr4 – fixed I6
7 1 0 0
0 unpack4.h I2 mix4.r I2
1
2
2 pack4.sss I2 unpack4.l I2 mix4.l I2
3
0
1 pshl4 – fixed I8
3
2
3

Volume 3: Instruction Formats 3:289


Table 4-20. Variable Shift Opcode 7 2-bit Opcode Extensions

Opcode za zb ve x2a x2b x2c


Bits Bit Bit Bit Bits Bits Bits 31:30
40:37 36 33 32 35:34 29:28 0 1 2 3
0 shr.u – var I5 shl – var I7
1
0
2 shr – var I5
3
0
1
1
2
3
7 1 1 0
0
1
2
2
3
0
1
3
2
3

4.3.1.1 Multimedia Multiply and Shift


40 37 36 35 34 33 32 31 30 29 28 27 26 20 19 13 12 6 5 0

I1 7 za x2a zb ve ct2d x2b r3 r2 r1 qp


4 1 2 1 1 2 2 1 7 7 7 6

Extension
Instruction Operands Opcode
za zb ve x2a x2b
pmpyshr2 3
r1 = r2, r3, count2 7 0 1 0 0
pmpyshr2.u 1

3:290 Volume 3: Instruction Formats


4.3.1.2 Multimedia Multiply/Mix/Pack/Unpack
40 37 36 35 34 33 32 31 30 29 28 27 26 20 19 13 12 6 5 0

I2 7 za x2a zb ve x2c x2b r3 r2 r1 qp


4 1 2 1 1 2 2 1 7 7 7 6

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

4.3.1.3 Multimedia Mux1


40 37 36 35 34 33 32 31 30 29 28 27 24 23 20 19 13 12 6 5 0

I3 7 za x2a zb ve x2c x2b mbt4c r2 r1 qp


4 1 2 1 1 2 2 4 4 7 7 6

Extension
Instruction Operands Opcode
za zb ve x2a x2b x2c
mux1 r1 = r2, mbtype4 7 0 0 0 3 2 2

4.3.1.4 Multimedia Mux2


40 37 36 35 34 33 32 31 30 29 28 27 20 19 13 12 6 5 0

I4 7 za x2a zb ve x2c x2b mht8c r2 r1 qp


4 1 2 1 1 2 2 8 7 7 6

Extension
Instruction Operands Opcode
za zb ve x2a x2b x2c
mux2 r1 = r2, mhtype8 7 0 1 0 3 2 2

Volume 3: Instruction Formats 3:291


4.3.1.5 Shift Right – Variable
40 37 36 35 34 33 32 31 30 29 28 27 26 20 19 13 12 6 5 0

I5 7 za x2a zb ve x2c x2b r3 r2 r1 qp


4 1 2 1 1 2 2 1 7 7 7 6

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

4.3.1.6 Multimedia Shift Right – Fixed


40 37 36 35 34 33 32 31 30 29 28 27 26 20 19 18 14 13 12 6 5 0

I6 7 za x2a zb ve x2c x2b r3 count5b r1 qp


4 1 2 1 1 2 2 1 7 1 5 1 7 6

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

4.3.1.7 Shift Left – Variable


40 37 36 35 34 33 32 31 30 29 28 27 26 20 19 13 12 6 5 0

I7 7 za x2a zb ve x2c x2b r3 r2 r1 qp


4 1 2 1 1 2 2 1 7 7 7 6

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

4.3.1.8 Multimedia Shift Left – Fixed


40 37 36 35 34 33 32 31 30 29 28 27 25 24 20 19 13 12 6 5 0

I8 7 za x2a zb ve x2c x2b ccount5c r2 r1 qp


4 1 2 1 1 2 2 3 5 7 7 6

Extension
Instruction Operands Opcode
za zb ve x2a x2b x2c
pshl2 0 1
r1 = r2, count5 7 0 3 1 1
pshl4 1 0

3:292 Volume 3: Instruction Formats


4.3.1.9 Bit Strings
40 37 36 35 34 33 32 31 30 29 28 27 26 20 19 13 12 6 5 0

I9 7 za x2a zb ve x2c x2b r3 0 r1 qp


4 1 2 1 1 2 2 1 7 7 7 6

Extension
Instruction Operands Opcode
za zb ve x2a x2b x2c
popcnt r1 = r3 7 0 1 0 1 1 2

4.3.2 Integer Shifts


The integer shift, test bit, and test NaT instructions are encoded within major opcode 5 using a 2-bit
opcode extension field in bits 35:34 (x2) and a 1-bit opcode extension field in bit 33 (x). The extract
and test bit instructions also have a 1-bit opcode extension field in bit 13 (y). Table 4-21 shows the
test bit, extract, and shift right pair assignments.

Table 4-21. Integer Shift/Test Bit/Test NaT 2-bit Opcode Extensions


y
Opcode x2 x Bit 13
Bits 40:37 Bits 35:34 Bit 33
0 1
0 Test Bit (Table 4-23) Test NaT/Test Feature (Table 4-23)
1 extr.u I11 extr I11
5 0
2
3 shrp I10

Most deposit instructions also have a 1-bit opcode extension field in bit 26 (y). Table 4-22 shows
these assignments.

Table 4-22. Deposit Opcode Extensions


y
Opcode x2 x Bit 26
Bits 40:37 Bits 35:34 Bit 33
0 1
0 Test Bit/Test NaT/Test Feature (Table 4-23)
1 dep.z I12 dep.z – imm8 I13
5 1
2
3 dep – imm1 I14

4.3.2.1 Shift Right Pair


40 37 36 35 34 33 32 27 26 20 19 13 12 6 5 0

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

Volume 3: Instruction Formats 3:293


4.3.2.2 Extract
40 37 36 35 34 33 32 27 26 20 19 14 13 12 6 5 0

I11 5 x2 x len6d r3 pos6b y r1 qp


4 1 2 1 6 7 6 1 7 6

Extension
Instruction Operands Opcode
x2 x y
extr.u 0
r1 = r3, pos6, len6 5 1 0
extr 1

4.3.2.3 Zero and Deposit


40 37 36 35 34 33 32 27 26 25 20 19 13 12 6 5 0

I12 5 x2 x len6d y cpos6c r2 r1 qp


4 1 2 1 6 1 6 7 7 6

Extension
Instruction Operands Opcode
x2 x y
dep.z r1 = r2, pos6, len6 5 1 1 0

4.3.2.4 Zero and Deposit Immediate8


40 37 36 35 34 33 32 27 26 25 20 19 13 12 6 5 0

I13 5 s x2 x len6d y cpos6c imm7b r1 qp


4 1 2 1 6 1 6 7 7 6

Extension
Instruction Operands Opcode
x2 x y
dep.z r1 = imm8, pos6, len6 5 1 1 1

4.3.2.5 Deposit Immediate1


40 37 36 35 34 33 32 27 26 20 19 14 13 12 6 5 0

I14 5 s x2 x len6d r3 cpos6b r1 qp


4 1 2 1 6 7 6 1 7 6

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

I15 4 cpos6d len4d r3 r2 r1 qp


4 6 4 7 7 7 6

Instruction Operands Opcode


dep r1 = r2, r3, pos6, len4 4

3:294 Volume 3: Instruction Formats


4.3.3 Test Bit
All test bit instructions are encoded within major opcode 5 using a 2-bit opcode extension field in
bits 35:34 (x2) plus five 1-bit opcode extension fields in bits 33 (ta), 36 (tb), 12 (c), 13 (y) and 19
(x). Table 4-23 summarizes these assignments.

Table 4-23. Test Bit Opcode Extensions

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

4.3.3.1 Test Bit


40 37 36 35 34 33 32 27 26 20 19 14 13 12 11 6 5 0

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

Volume 3: Instruction Formats 3:295


4.3.3.2 Test NaT
40 37 36 35 34 33 32 27 26 20 19 18 14 13 12 11 6 5 0

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

4.3.4 Miscellaneous I-Unit Instructions


The miscellaneous I-unit instructions are encoded in major opcode 0 using a 3-bit opcode extension
field (x3) in bits 35:33. Some also have a 6-bit opcode extension field (x6) in bits 32:27. Table 4-24
shows the 3-bit assignments and Table 4-25 summarizes the 6-bit assignments.

Table 4-24. Misc I-Unit 3-bit Opcode Extensions


Opcode x3
Bits 40:37 Bits 35:33
0 6-bit Ext (Table 4-25)
1 chk.s.i – int I20
2 mov to pr.rot – imm44 I24
3 mov to pr I23
0
4
5
6
7 mov to b I21

3:296 Volume 3: Instruction Formats


Table 4-25. Misc I-Unit 6-bit Opcode Extensions

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

4.3.4.1 Nop/Hint (I-Unit)

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.

Table 4-26. Misc I-Unit 1-bit Opcode Extensions


Opcode x3 x6 y
Bits 40:37 Bits 35:33 Bits 32:27 Bit 26
0 nop.i
0 0 01
1 hint.i
40 37 36 35 33 32 27 26 25 6 5 0

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

Volume 3: Instruction Formats 3:297


4.3.4.2 Break (I-Unit)
40 37 36 35 33 32 27 26 25 6 5 0

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

4.3.4.3 Integer Speculation Check (I-Unit)


40 37 36 35 33 32 20 19 13 12 6 5 0

I20 0 s x3 imm13c r2 imm7a qp


4 1 3 13 7 7 6

Extension
Instruction Operands Opcode
x3
chk.s.i r2, target25 0 1

3:298 Volume 3: Instruction Formats


4.3.5 GR/BR Moves
The GR/BR move instructions are encoded in major opcode 0. See “Miscellaneous I-Unit
Instructions” on page 3:296 for a summary of the opcode extensions. The mov to BR instruction
uses a 2-bit “whether” prediction hint field in bits 21:20 (wh) as shown in Table 4-27.

Table 4-27. Move to BR Whether Hint Completer


wh
mwh
Bits 21:20
0 .sptk
1 none
2 .dptk
3

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

4.3.5.2 Move from BR


40 37 36 35 33 32 27 26 16 15 13 12 6 5 0

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

Volume 3: Instruction Formats 3:299


4.3.6 GR/Predicate/IP Moves
The GR/Predicate/IP move instructions are encoded in major opcode 0. See “Miscellaneous I-Unit
Instructions” on page 3:296 for a summary of the opcode extensions.

4.3.6.1 Move to Predicates – Register


40 37 36 35 33 32 31 24 23 20 19 13 12 6 5 0

I23 0 s x3 mask8c r2 mask7a qp


4 1 3 1 8 4 7 7 6

Extension
Instruction Operands Opcode
x3
mov pr = r2, mask17 0 3

4.3.6.2 Move to Predicates – Immediate44


40 37 36 35 33 32 6 5 0

I24 0 s x3 imm27a qp
4 1 3 27 6

Extension
Instruction Operands Opcode
x3
mov pr.rot = imm44 0 2

4.3.6.3 Move from Predicates/IP


40 37 36 35 33 32 27 26 13 12 6 5 0

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

4.3.7 GR/AR Moves (I-Unit)


The I-Unit GR/AR move instructions are encoded in major opcode 0. (Some ARs are accessed
using system/memory management instructions on the M-unit. See “GR/AR Moves (M-Unit)” on
page 3:322.) See “Miscellaneous I-Unit Instructions” on page 3:296 for a summary of the I-Unit
GR/AR opcode extensions.

3:300 Volume 3: Instruction Formats


4.3.7.1 Move to AR – Register (I-Unit)
40 37 36 35 33 32 27 26 20 19 13 12 6 5 0

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

4.3.7.2 Move to AR – Immediate8 (I-Unit)


40 37 36 35 33 32 27 26 20 19 13 12 6 5 0

I27 0 s x3 x6 ar3 imm7b qp


4 1 3 6 7 7 7 6

Extension
Instruction Operands Opcode
x3 x6
mov.i ar3 = imm8 0 0 0A

4.3.7.3 Move from AR (I-Unit)


40 37 36 35 33 32 27 26 20 19 13 12 6 5 0

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

4.3.8 Sign/Zero Extend/Compute Zero Index


40 37 36 35 33 32 27 26 20 19 13 12 6 5 0

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

Volume 3: Instruction Formats 3:301


4.3.9 Test Feature
40 37 36 35 34 33 32 27 26 20 19 18 14 13 12 11 6 5 0

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

4.4 M-Unit Instruction Encodings

4.4.1 Loads and Stores


All load and store instructions are encoded within major opcodes 4, 5, 6, and 7 using a 6-bit opcode
extension field in bits 35:30 (x6). Instructions in major opcode 4 (integer load/store, semaphores,
and get FR) use two 1-bit opcode extension fields in bit 36 (m) and bit 27 (x) as shown in
Table 4-28. Instructions in major opcode 6 (floating-point load/store, load pair, and set FR) use two
1-bit opcode extension fields in bit 36 (m) and bit 27 (x) as shown in Table 4-29.

Table 4-28. Integer Load/Store/Semaphore/Get FR 1-bit Opcode Extensions


Opcode m x
Bits 40:37 Bit 36 Bit 27
0 0 Load/Store (Table 4-30)
0 1 Semaphore/get FR (Table 4-33)
4
1 0 Load +Reg (Table 4-31)
1 1

Table 4-29. Floating-point Load/Store/Load Pair/Set FR 1-bit Opcode Extensions


Opcode m x
Bits 40:37 Bit 36 Bit 27
0 0 FP Load/Store (Table 4-34)
0 1 FP Load Pair/set FR (Table 4-37)
6
1 0 FP Load +Reg (Table 4-35)
1 1 FP Load Pair +Imm (Table 4-38)

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

3:302 Volume 3: Instruction Formats


Table 4-34 on page 3:305, Table 4-35 on page 3:305, and Table 4-36 on page 3:306, the
floating-point load pair and set FR opcode extensions in Table 4-37 on page 3:306 and Table 4-38
on page 3:307.

Table 4-30. Integer Load/Store Opcode Extensions


x6
Opcode m x
Bits Bit Bit Bits Bits 31:30
40:37 36 27 35:32
0 1 2 3
0 ld1 M1 ld2 M1 ld4 M1 ld8 M1
1 ld1.s M1 ld2.s M1 ld4.s M1 ld8.s M1
2 ld1.a M1 ld2.a M1 ld4.a M1 ld8.a M1
3 ld1.sa M1 ld2.sa M1 ld4.sa M1 ld8.sa M1
4 ld1.bias M1 ld2.bias M1 ld4.bias M1 ld8.bias M1
5 ld1.acq M1 ld2.acq M1 ld4.acq M1 ld8.acq M1
6 ld8.fill M1
7
4 0 0
8 ld1.c.clr M1 ld2.c.clr M1 ld4.c.clr M1 ld8.c.clr M1
9 ld1.c.nc M1 ld2.c.nc M1 ld4.c.nc M1 ld8.c.nc M1
A ld1.c.clr.acq M1 ld2.c.clr.acq M1 ld4.c.clr.acq M1 ld8.c.clr.acq M1
B
C st1 M4 st2 M4 st4 M4 st8 M4
D st1.rel M4 st2.rel M4 st4.rel M4 st8.rel M4
E st8.spill M4
F

Table 4-31. Integer Load +Reg Opcode Extensions


x6
Opcode m x
Bits Bit Bit Bits Bits 31:30
40:37 36 27 35:32
0 1 2 3
0 ld1 M2 ld2 M2 ld4 M2 ld8 M2
1 ld1.s M2 ld2.s M2 ld4.s M2 ld8.s M2
2 ld1.a M2 ld2.a M2 ld4.a M2 ld8.a M2
3 ld1.sa M2 ld2.sa M2 ld4.sa M2 ld8.sa M2
4 ld1.bias M2 ld2.bias M2 ld4.bias M2 ld8.bias M2
5 ld1.acq M2 ld2.acq M2 ld4.acq M2 ld8.acq M2
6 ld8.fill M2
7
4 1 0
8 ld1.c.clr M2 ld2.c.clr M2 ld4.c.clr M2 ld8.c.clr M2
9 ld1.c.nc M2 ld2.c.nc M2 ld4.c.nc M2 ld8.c.nc M2
A ld1.c.clr.acq M2 ld2.c.clr.acq M2 ld4.c.clr.acq M2 ld8.c.clr.acq M2
B
C
D
E
F

Volume 3: Instruction Formats 3:303


Table 4-32. Integer Load/Store +Imm Opcode Extensions

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

Table 4-33. Semaphore/Get FR/16-Byte Opcode Extensions


x6
Opcode m x
Bits Bit Bit Bits Bits 31:30
40:37 36 27 35:32
0 1 2 3
cmpxchg1.acq cmpxchg2.acq cmpxchg4.acq cmpxchg8.acq M16
0
M16 M16 M16
1 cmpxchg1.rel M16 cmpxchg2.rel M16 cmpxchg4.rel M16 cmpxchg8.rel M16
2 xchg1 M16 xchg2 M16 xchg4 M16 xchg8 M16
3
fetchadd4.acq fetchadd8.acq M17
4
M17
5 fetchadd4.rel M17 fetchadd8.rel M17
6
7 getf.sig M19 getf.exp M19 getf.s M19 getf.d M19
4 0 1
cmp8xchg16.acq
8
M16
cmp8xchg16.rel
9
M16
A ld16 M1
B ld16.acq M1
C st16 M4
D st16.rel M4
E
F

3:304 Volume 3: Instruction Formats


Table 4-34. Floating-point Load/Store/Lfetch Opcode Extensions

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

Table 4-35. Floating-point Load/Lfetch +Reg Opcode Extensions


x6
Opcode m x
Bits Bit Bit Bits Bits 31:30
40:37 36 27 35:32
0 1 2 3
0 ldfe M7 ldf8 M7 ldfs M7 ldfd M7
1 ldfe.s M7 ldf8.s M7 ldfs.s M7 ldfd.s M7
2 ldfe.a M7 ldf8.a M7 ldfs.a M7 ldfd.a M7
3 ldfe.sa M7 ldf8.sa M7 ldfs.sa M7 ldfd.sa M7
4
5
6 ldf.fill M7
7
6 1 0
8 ldfe.c.clr M7 ldf8.c.clr M7 ldfs.c.clr M7 ldfd.c.clr M7
9 ldfe.c.nc M7 ldf8.c.nc M7 ldfs.c.nc M7 ldfd.c.nc M7
A
B lfetch M14 lfetch.excl M14 lfetch.fault M14 lfetch.fault.excl M14
C
D
E
F

Volume 3: Instruction Formats 3:305


Table 4-36. Floating-point Load/Store/Lfetch +Imm Opcode Extensions

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

Table 4-37. Floating-point Load Pair/Set FR Opcode Extensions


x6
Opcode m x
Bits Bit Bit Bits Bits 31:30
40:37 36 27 35:32
0 1 2 3
0 ldfp8 M11 ldfps M11 ldfpd M11
1 ldfp8.s M11 ldfps.s M11 ldfpd.s M11
2 ldfp8.a M11 ldfps.a M11 ldfpd.a M11
3 ldfp8.sa M11 ldfps.sa M11 ldfpd.sa M11
4
5
6
7 setf.sig M18 setf.exp M18 setf.s M18 setf.d M18
6 0 1
8 ldfp8.c.clr M11 ldfps.c.clr M11 ldfpd.c.clr M11
9 ldfp8.c.nc M11 ldfps.c.nc M11 ldfpd.c.nc M11
A
B
C
D
E
F

3:306 Volume 3: Instruction Formats


Table 4-38. Floating-point Load Pair +Imm Opcode Extensions

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.

Table 4-39. Load Hint Completer


hint
ldhint
Bits 29:28
0 none
1 .nt1
2
3 .nta

Table 4-40. Store Hint Completer


hint
sthint
Bits 29:28
0 none
1
2
3 .nta

Volume 3: Instruction Formats 3:307


4.4.1.1 Integer Load
40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

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

3:308 Volume 3: Instruction Formats


4.4.1.2 Integer Load – Increment by Register
40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

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

Volume 3: Instruction Formats 3:309


4.4.1.3 Integer Load – Increment by Immediate
40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

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

3:310 Volume 3: Instruction Formats


4.4.1.4 Integer Store
40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

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

4.4.1.5 Integer Store – Increment by Immediate


40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

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

Volume 3: Instruction Formats 3:311


4.4.1.6 Floating-point Load
40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

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

3:312 Volume 3: Instruction Formats


4.4.1.7 Floating-point Load – Increment by Register
40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

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

Volume 3: Instruction Formats 3:313


4.4.1.8 Floating-point Load – Increment by Immediate
40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

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

4.4.1.9 Floating-point Store


40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

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

3:314 Volume 3: Instruction Formats


4.4.1.10 Floating-point Store – Increment by Immediate
40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

M10 7 s x6 hint i r3 f2 imm7a qp


4 1 6 2 1 7 7 7 6

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

4.4.1.11 Floating-point Load Pair


40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

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

Volume 3: Instruction Formats 3:315


4.4.1.12 Floating-point Load Pair – Increment by Immediate
40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

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

4.4.2 Line Prefetch


The line prefetch instructions are encoded in major opcodes 6 and 7 along with the floating-point
load/store instructions. See “Loads and Stores” on page 3:302 for a summary of the opcode
extensions.

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.

Table 4-41. Line Prefetch Hint Completer


hint
lfhint
Bits 29:28
0 none
1 .nt1
2 .nt2
3 .nta

3:316 Volume 3: Instruction Formats


4.4.2.1 Line Prefetch
40 37 36 35 30 29 28 27 26 20 19 6 5 0

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

4.4.2.2 Line Prefetch – Increment by Register


40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

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

4.4.2.3 Line Prefetch – Increment by Immediate


40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

M15 7 s x6 hint i r3 imm7b qp


4 1 6 2 1 7 7 7 6

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

Volume 3: Instruction Formats 3:317


4.4.3 Semaphores
The semaphore instructions are encoded in major opcode 4 along with the integer load/store
instructions. See “Loads and Stores” on page 3:302 for a summary of the opcode extensions. These
instructions have the same cache locality opcode hint extension field in bits 29:28 (hint) as load
instructions. See Table 4-39, “Load Hint Completer” on page 3:307.

4.4.3.1 Exchange/Compare and Exchange


40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0

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

4.4.3.2 Fetch and Add – Immediate


40 37 36 35 30 29 28 27 26 20 19 16 15 14 13 12 6 5 0

M17 4 m x6 hint x r3 s i2b r1 qp


4 1 6 2 1 7 4 1 2 7 6

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

3:318 Volume 3: Instruction Formats


4.4.4 Set/Get FR
The set FR instructions are encoded in major opcode 6 along with the floating-point load/store
instructions. The get FR instructions are encoded in major opcode 4 along with the integer
load/store instructions. See “Loads and Stores” on page 3:302 for a summary of the opcode
extensions.

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

Volume 3: Instruction Formats 3:319


4.4.5 Speculation and Advanced Load Checks
The speculation and advanced load check instructions are encoded in major opcodes 0 and 1 along
with the system/memory management instructions. See “System/Memory Management” on
page 3:325 for a summary of the opcode extensions.

4.4.5.1 Integer Speculation Check (M-Unit)


40 37 36 35 33 32 20 19 13 12 6 5 0

M20 1 s x3 imm13c r2 imm7a qp


4 1 3 13 7 7 6

Extension
Instruction Operands Opcode
x3
chk.s.m r2, target25 1 1

4.4.5.2 Floating-point Speculation Check


40 37 36 35 33 32 20 19 13 12 6 5 0

M21 1 s x3 imm13c f2 imm7a qp


4 1 3 13 7 7 6

Extension
Instruction Operands Opcode
x3
chk.s f2, target25 1 3

4.4.5.3 Integer Advanced Load Check


40 37 36 35 33 32 13 12 6 5 0

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

4.4.5.4 Floating-point Advanced Load Check


40 37 36 35 33 32 13 12 6 5 0

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

3:320 Volume 3: Instruction Formats


4.4.6 Cache/Synchronization/RSE/ALAT
The cache/synchronization/RSE/ALAT instructions are encoded in major opcode 0 along with the
memory management instructions. See “System/Memory Management” on page 3:325 for a
summary of the opcode extensions.

4.4.6.1 Sync/Fence/Serialize/ALAT Control


40 37 36 35 33 32 31 30 27 26 6 5 0

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

4.4.6.2 RSE Control


40 37 36 35 33 32 31 30 27 26 6 5 0

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

4.4.6.3 Integer ALAT Entry Invalidate


40 37 36 35 33 32 31 30 27 26 13 12 6 5 0

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

Volume 3: Instruction Formats 3:321


4.4.6.4 Floating-point ALAT Entry Invalidate
40 37 36 35 33 32 31 30 27 26 13 12 6 5 0

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

4.4.6.5 Flush Cache


40 37 36 35 33 32 27 26 20 19 6 5 0

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

4.4.7 GR/AR Moves (M-Unit)


The M-Unit GR/AR move instructions are encoded in major opcode 0 along with the
system/memory management instructions. (Some ARs are accessed using system control
instructions on the I-unit. See “GR/AR Moves (I-Unit)” on page 3:300.) See “System/Memory
Management” on page 3:325 for a summary of the M-Unit GR/AR opcode extensions.

4.4.7.1 Move to AR – Register (M-Unit)


40 37 36 35 33 32 27 26 20 19 13 12 6 5 0

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

4.4.7.2 Move to AR – Immediate8 (M-Unit)


40 37 36 35 33 32 31 30 27 26 20 19 13 12 6 5 0

M30 0 s x3 x2 x4 ar3 imm7b qp


4 1 3 2 4 7 7 7 6

Extension
Instruction Operands Opcode
x3 x4 x2
mov.m ar3 = imm8 0 0 8 2

3:322 Volume 3: Instruction Formats


4.4.7.3 Move from AR (M-Unit)
40 37 36 35 33 32 27 26 20 19 13 12 6 5 0

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 GR/CR Moves


The GR/CR move instructions are encoded in major opcode 0 along with the system/memory
management instructions. See “System/Memory Management” on page 3:325 for a summary of the
opcode extensions.

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

4.4.8.2 Move from CR


40 37 36 35 33 32 27 26 20 19 13 12 6 5 0

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

Volume 3: Instruction Formats 3:323


4.4.9 Miscellaneous M-Unit Instructions
The miscellaneous M-unit instructions are encoded in major opcode 0 along with the
system/memory management instructions. See “System/Memory Management” on page 3:325 for
a summary of the opcode extensions.

4.4.9.1 Allocate Register Stack Frame


40 37 36 35 33 32 31 30 27 26 20 19 13 12 6 5 0

M34 1 x3 sor sol sof r1 qp


4 1 3 2 4 7 7 7 6

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

4.4.9.2 Move to PSR


40 37 36 35 33 32 27 26 20 19 13 12 6 5 0

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

4.4.9.3 Move from PSR


40 37 36 35 33 32 27 26 13 12 6 5 0

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

3:324 Volume 3: Instruction Formats


4.4.9.4 Break (M-Unit)
40 37 36 35 33 32 31 30 27 26 25 6 5 0

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

4.4.10 System/Memory Management


All system/memory management instructions are encoded within major opcodes 0 and 1 using a
3-bit opcode extension field (x3) in bits 35:33. Some instructions also have a 4-bit opcode
extension field (x4) in bits 30:27, or a 6-bit opcode extension field (x6) in bits 32:27. Most of the
instructions having a 4-bit opcode extension field also have a 2-bit extension field (x2) in bits
32:31. Table 4-42 shows the 3-bit assignments for opcode 0, Table 4-43 summarizes the 4-bit+2-bit
assignments for opcode 0, Table 4-44 shows the 3-bit assignments for opcode 1, and Table 4-45
summarizes the 6-bit assignments for opcode 1.

Table 4-42. Opcode 0 System/Memory Management 3-bit Opcode Extensions


Opcode x3
Bits 40:37 Bits 35:33
System/Memory Management 4-bit+2-bit Ext
0
(Table 4-43)
1
2
0 3
4 chk.a.nc – int M22
5 chk.a.clr – int M22
6 chk.a.nc – fp M23
7 chk.a.clr – fp M23

Volume 3: Instruction Formats 3:325


Table 4-43. Opcode 0 System/Memory Management 4-bit+2-bit Opcode Extensions

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

Table 4-44. Opcode 1 System/Memory Management 3-bit Opcode Extensions


x3
Opcode
Bits
Bits 40:37
35:33
0 System/Memory Management 6-bit Ext (Table 4-45)
1 chk.s.m – int M20
2
3 chk.s – fp M21
1
4
5
6 alloc M34
7

3:326 Volume 3: Instruction Formats


Table 4-45. Opcode 1 System/Memory Management 6-bit Opcode Extensions

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

4.4.10.1 Probe – Register


40 37 36 35 33 32 27 26 20 19 13 12 6 5 0

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

4.4.10.2 Probe – Immediate2


40 37 36 35 33 32 27 26 20 19 15 14 13 12 6 5 0

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

Volume 3: Instruction Formats 3:327


4.4.10.3 Probe Fault – Immediate2
40 37 36 35 33 32 27 26 20 19 15 14 13 12 6 5 0

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

4.4.10.4 Translation Cache Insert


40 37 36 35 33 32 27 26 20 19 13 12 6 5 0

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

4.4.10.5 Move to Indirect Register/Translation Register Insert


40 37 36 35 33 32 27 26 20 19 13 12 6 5 0

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

3:328 Volume 3: Instruction Formats


4.4.10.6 Move from Indirect Register
40 37 36 35 33 32 27 26 20 19 13 12 6 5 0

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

4.4.10.7 Set/Reset User/System Mask


40 37 36 35 33 32 31 30 27 26 6 5 0

M44 0 i x3 i2d x4 imm21a qp


4 1 3 2 4 21 6

Extension
Instruction Operands Opcode
x3 x4
sum 4
rum 5
imm24 0 0
ssm p 6
rsm p 7

4.4.10.8 Translation Purge


40 37 36 35 33 32 27 26 20 19 13 12 6 5 0

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

Volume 3: Instruction Formats 3:329


4.4.10.9 Translation Access
40 37 36 35 33 32 27 26 20 19 13 12 6 5 0

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

4.4.10.10 Purge Translation Cache Entry


40 37 36 35 33 32 27 26 20 19 6 5 0

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

4.4.11 Nop/Hint (M-Unit)


M-unit nop and hint instructions are encoded within major opcode 0 using a 3-bit opcode extension
field in bits 35:33 (x3), a 2-bit opcode extension field in bits 32:31 (x2), a 4-bit opcode extension
field in bits 30:27 (x4), and a 1-bit opcode extension field in bit 26 (y), as shown in Table 4-46.

Table 4-46. Misc M-Unit 1-bit Opcode Extensions


Opcode x3 x4 x2 y
Bits 40:37 Bits 35:33 Bits 30:27 Bits 32:31 Bit 26
0 nop.m
0 0 1 0
1 hint.m
40 37 36 35 33 32 31 30 27 26 25 6 5 0

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

4.5 B-Unit Instruction Encodings


The branch-unit includes branch, predict, and miscellaneous instructions.

3:330 Volume 3: Instruction Formats


4.5.1 Branches
Opcode 0 is used for indirect branch, opcode 1 for indirect call, opcode 4 for IP-relative branch, and
opcode 5 for IP-relative call.

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.

Table 4-47. IP-Relative Branch Types


Opcode btype
Bits 40:37 Bits 8:6
0 br.cond B1
e
1
2 br.wexit B1
3 br.wtop B1
4 e
4
5 br.cloop B2
6 br.cexit B2
7 br.ctop B2

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.

Table 4-48. Indirect/Miscellaneous Branch Opcode Extensions


x6
Opcode
Bits Bits 32:31
Bits 40:37
30:27 0 1 2 3
Indirect Branch e
0 break.b B9 epc B8
(Table 4-49)
e Indirect Return e
1
(Table 4-50)
2 cover B8 e e e

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.

Volume 3: Instruction Formats 3:331


Table 4-49. Indirect Branch Types
Opcode x6 btype
Bits 40:37 Bits 32:27 Bits 8:6
0 br.cond B4
1 br.ia B4
e
2
3 e
0 20 e
4
5 e

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.

Table 4-50. Indirect Return Branch Types


Opcode x6 btype
Bits 40:37 Bits 32:27 Bits 8:6
e
0
e
1
e
2
e
3
0 21
4 br.ret B4
e
5
e
6
e
7

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.

Table 4-51. Sequential Prefetch Hint Completer


p
ph
Bit 12
0 .few
1 .many

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.

Table 4-52. Branch Whether Hint Completer


wh
bwh
Bits 34:33
0 .sptk
1 .spnt
2 .dptk
3 .dpnt

3:332 Volume 3: Instruction Formats


Table 4-53. Indirect Call Whether Hint Completer
wh
bwh
Bits 34:32
0
1 .sptk
2
3 .spnt
4
5 .dptk
6
7 .dpnt

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.

Table 4-54. Branch Cache Deallocation Hint Completer


d
dh
Bit 35
0 none
1 .clr

4.5.1.1 IP-Relative Branch


40 37 36 35 34 33 32 13 12 11 9 8 6 5 0

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

4.5.1.2 IP-Relative Counted Branch


40 37 36 35 34 33 32 13 12 11 9 8 6 5 0

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

Volume 3: Instruction Formats 3:333


4.5.1.3 IP-Relative Call
40 37 36 35 34 33 32 13 12 11 9 8 6 5 0

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

4.5.1.4 Indirect Branch


40 37 36 35 34 33 32 27 26 16 15 13 12 11 9 8 6 5 0

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

br.cond.bwh.ph.dh e 0 See See See


20 Table 4-51 Table 4-52 Table 4-54
br.ia.bwh.ph.dh e b2 0 1 on on on
page 3:332 page 3:332 page 3:333
br.ret.bwh.ph.dh e 21 4

4.5.1.5 Indirect Call


40 37 36 35 34 32 31 16 15 13 12 11 9 8 6 5 0

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

4.5.2 Branch Predict/Nop/Hint


The branch predict, nop, and hint instructions are encoded in major opcodes 2 (Indirect
Predict/Nop/Hint) and 7 (IP-relative Predict). The indirect predict, nop, and hint instructions in
major opcode 2 use a 6-bit opcode extension field in bits 32:27 (x6). Table 4-55 summarizes these
assignments.

3:334 Volume 3: Instruction Formats


Table 4-55. Indirect Predict/Nop/Hint Opcode Extensions

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.

Table 4-56. Branch Importance Hint Completer


ih
Bit 23 or ih
Bit 35
0 none
1 .imp

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.

Table 4-57. IP-Relative Predict Whether Hint Completer


wh
ipwh
Bits 4:3
0 .sptk
1 .loop
2 .dptk
3 .exit

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.

Volume 3: Instruction Formats 3:335


Table 4-58. Indirect Predict Whether Hint Completer
wh
indwh
Bits 4:3
0 .sptk
1
2 .dptk
3

4.5.2.1 IP-Relative Predict


40 37 36 35 34 33 32 13 12 6 5 4 3 2 0

B6 7 s ih t2e imm20b timm7a wh


4 1 1 2 20 7 1 2 3

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

4.5.2.2 Indirect Predict


40 37 36 35 34 33 32 27 26 16 15 13 12 6 5 4 3 2 0

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

4.5.3 Miscellaneous B-Unit Instructions


The miscellaneous branch-unit instructions include a number of instructions encoded within major
opcode 0 using a 6-bit opcode extension field in bits 32:27 (x6) as described in Table 4-48 on
page 3:331.

3:336 Volume 3: Instruction Formats


4.5.3.1 Miscellaneous (B-Unit)
40 37 36 33 32 27 26 6 5 0

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

4.5.3.2 Break/Nop/Hint (B-Unit)


40 37 36 35 33 32 27 26 25 6 5 0

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

4.6 F-Unit Instruction Encodings


The floating-point instructions are encoded in major opcodes 8 – E for floating-point and
fixed-point arithmetic, opcode 4 for floating-point compare, opcode 5 for floating-point class, and
opcodes 0 and 1 for miscellaneous floating-point instructions.

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.

Table 4-59. Miscellaneous Floating-point 1-bit Opcode Extensions


Opcode x
Bits 40:37 Bit 33
0 6-bit Ext (Table 4-60)
0
1 Reciprocal Approximation (Table 4-62)
0 6-bit Ext (Table 4-61)
1
1 Reciprocal Approximation (Table 4-62)

Volume 3: Instruction Formats 3:337


Table 4-60. Opcode 0 Miscellaneous Floating-point 6-bit Opcode Extensions

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

Table 4-61. Opcode 1 Miscellaneous Floating-point 6-bit Opcode Extensions


x6
Opcode x
Bits Bit Bits Bits 32:31
40:37 33 30:27 0 1 2 3
0 fpmerge.s F9 fpcmp.eq F8
1 fpmerge.ns F9 fpcmp.lt F8
2 fpmerge.se F9 fpcmp.le F8
3 fpcmp.unord F8
4 fpmin F8 fpcmp.neq F8
5 fpmax F8 fpcmp.nlt F8
6 fpamin F8 fpcmp.nle F8
7 fpamax F8 fpcmp.ord F8
1 0
8 fpcvt.fx F10
9 fpcvt.fxu F10
A fpcvt.fx.trunc F10
B fpcvt.fxu.trunc F10
C
D
E
F

3:338 Volume 3: Instruction Formats


Table 4-62. Reciprocal Approximation 1-bit Opcode Extensions
Opcode x q
Bits 40:37 Bit 33 Bit 36
0 frcpa F6
0
1 frsqrta F7
1
0 fprcpa F6
1
1 fprsqrta F7

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.

Table 4-63. Floating-point Status Field Completer


sf
sf
Bits 35:34
0 .s0
1 .s1
2 .s2
3 .s3

Volume 3: Instruction Formats 3:339


4.6.1 Arithmetic
The floating-point arithmetic instructions are encoded within major opcodes 8 – D using a 1-bit
opcode extension field (x) in bit 36 and a 2-bit opcode extension field (sf) in bits 35:34. The opcode
and x assignments are shown in Table 4-64.

Table 4-64. Floating-point Arithmetic 1-bit Opcode Extensions


Opcode
x Bits 40:37
Bit 36
8 9 A B C D
0 fma F1 fma.d F1 fms F1 fms.d F1 fnma F1 fnma.d F1
1 fma.s F1 fpma F1 fms.s F1 fpms F1 fnma.s F1 fpnma F1

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.

Table 4-65. Fixed-point Multiply Add and Select Opcode Extensions


x2
Opcode x Bits 35:34
Bits 40:37 Bit 36
0 1 2 3
0 fselect F3
E
1 xma.l F2 xma.hu F2 xma.h F2

4.6.1.1 Floating-point Multiply Add


40 37 36 35 34 33 27 26 20 19 13 12 6 5 0

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

3:340 Volume 3: Instruction Formats


4.6.1.2 Fixed-point Multiply Add
40 37 36 35 34 33 27 26 20 19 13 12 6 5 0

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

4.6.2 Parallel Floating-point Select


40 37 36 35 34 33 27 26 20 19 13 12 6 5 0

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

4.6.3 Compare and Classify


The predicate setting floating-point compare instructions are encoded within major opcode 4 using
three 1-bit opcode extension fields in bits 33 (ra), 36 (rb), and 12 (ta), and a 2-bit opcode extension
field (sf) in bits 35:34. The opcode, ra, rb, and ta assignments are shown in Table 4-66. The sf
assignments are shown in Table 4-63 on page 3:339.

The parallel floating-point compare instructions are described on page 3:343.

Table 4-66. Floating-point Compare Opcode Extensions

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.

Table 4-67. Floating-point Class 1-bit Opcode Extensions


Opcode ta
Bits 40:37 Bit 12
0 fclass.m F5
5
1 fclass.m.unc F5

Volume 3: Instruction Formats 3:341


4.6.3.1 Floating-point Compare
40 37 36 35 34 33 32 27 26 20 19 13 12 11 6 5 0

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

4.6.3.2 Floating-point Class


40 37 36 35 34 33 32 27 26 20 19 13 12 11 6 5 0

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

4.6.4.1 Floating-point Reciprocal 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

3:342 Volume 3: Instruction Formats


4.6.4.2 Floating-point Reciprocal Square Root Approximation

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

4.6.5 Minimum/Maximum and Parallel Compare


There are two groups of Minimum/Maximum instructions. The first group, in major op 0, encodes
the full register variants. The second group, in major op 1, encodes the parallel variants. The
parallel compare instructions are all encoded in major op 1.
40 37 36 35 34 33 32 27 26 20 19 13 12 6 5 0

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

Volume 3: Instruction Formats 3:343


4.6.6 Merge and Logical
40 37 36 34 33 32 27 26 20 19 13 12 6 5 0

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

4.6.7.1 Convert Floating-point to Fixed-point


40 37 36 35 34 33 32 27 26 20 19 13 12 6 5 0

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

3:344 Volume 3: Instruction Formats


4.6.7.2 Convert Fixed-point to Floating-point
40 37 36 34 33 32 27 26 20 19 13 12 6 5 0

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

4.6.8 Status Field Manipulation

4.6.8.1 Floating-point Set Controls


40 37 36 35 34 33 32 27 26 20 19 13 12 6 5 0

F12 0 sf x x6 omask7c amask7b qp


4 1 2 1 6 7 7 7 6

Extension
Instruction Operands Opcode
x x6 sf
See Table 4-63 on
fsetc.sf amask7, omask7 0 0 04
page 3:339

4.6.8.2 Floating-point Clear Flags


40 37 36 35 34 33 32 27 26 6 5 0

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

4.6.8.3 Floating-point Check Flags


40 37 36 35 34 33 32 27 26 25 6 5 0

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

Volume 3: Instruction Formats 3:345


4.6.9 Miscellaneous F-Unit Instructions

4.6.9.1 Break (F-Unit)


40 37 36 35 34 33 32 27 26 25 6 5 0

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

4.6.9.2 Nop/Hint (F-Unit)

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.

Table 4-68. Misc F-Unit 1-bit Opcode Extensions


Opcode x x6 y
Bits 40:37 Bit:33 Bits 32:27 Bit 26
0 nop.f
0 0 01
1 hint.f
40 37 36 35 34 33 32 27 26 25 6 5 0

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

4.7 X-Unit Instruction Encodings


The X-unit instructions occupy two instruction slots, L+X. The major opcode, opcode extensions
and hints, qp, and small immediate fields occupy the X instruction slot. For movl, break.x, and
nop.x, the imm41 field occupies the L instruction slot. For brl, the imm39 field and a 2-bit Ignored
field occupy the L instruction slot.

4.7.1 Miscellaneous X-Unit Instructions


The miscellaneous X-unit instructions are encoded in major opcode 0 using a 3-bit opcode
extension field (x3) in bits 35:33 and a 6-bit opcode extension field (x6) in bits 32:27. Table 4-69
shows the 3-bit assignments and Table 4-70 summarizes the 6-bit assignments. These instructions
are executed by an I-unit.

3:346 Volume 3: Instruction Formats


Table 4-69. Misc X-Unit 3-bit Opcode Extensions
Opcode x3
Bits 40:37 Bits 35:33
0 6-bit Ext (Table 4-70)
1
2
3
0
4
5
6
7

Table 4-70. Misc X-Unit 6-bit Opcode Extensions

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

4.7.1.1 Break (X-Unit)


40 37 36 35 33 32 27 2625 6 5 0 40 0

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

4.7.2 Move Long Immediate64


The move long immediate instruction is encoded within major opcode 6 using a 1-bit reserved
opcode extension in bit 20 (vc) as shown in Table 4-71. This instruction is executed by an I-unit.

Volume 3: Instruction Formats 3:347


Table 4-71. Move Long 1-bit Opcode Extensions
Opcode vc
Bits 40:37 Bit 20
0 movl X2
6
1

40 37 3635 2726 22 21 2019 1312 6 5 0 40 0

X2 6 i imm9d imm5c ic vc imm7b r1 qp imm41


4 1 9 5 1 1 7 7 6 41

Extension
Instruction Operands Opcode
vc
movl i r1 = imm64 6 0

4.7.3 Long Branches


Long branches are executed by a B-unit. Opcode C is used for long branch and opcode D for long
call.

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.

Table 4-72. Long Branch Types


Opcode btype
Bits 40:37 Bits 8:6
0 brl.cond X3
1
2
3
C
4
5
6
7

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.

4.7.3.1 Long Branch


40 37 36 35 34 3332 1312 11 9 8 6 5 0 40 2 1 0

X3 C i d wh imm20b p btype qp imm39


4 1 1 2 20 1 3 3 6 39 2

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

3:348 Volume 3: Instruction Formats


4.7.3.2 Long Call
40 37 36 35 34 33 32 13 12 11 9 8 6 5 0 40 2 1 0

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

4.7.4 Nop/Hint (X-Unit)


X-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-73. These instructions are executed by an I-unit.

Table 4-73. Misc X-Unit 1-bit Opcode Extensions


Opcode x3 x6 y
Bits 40:37 Bits 35:33 Bits 32:27 Bit 26
0 nop.x
0 0 01
1 hint.x
40 37 36 35 33 32 27 2625 6 5 0 40 0

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

4.8 Immediate Formation


Table 4-74 shows, for each instruction format that has one or more immediates, how those
immediates are formed. In each equation, the symbol to the left of the equals is the assembly
language name for the immediate. The symbols to the right are the field names in the instruction
encoding.

Table 4-74. Immediate Formation


Instruction
Immediate Formation
Format
A2 count2 = ct2d + 1
A3 A8 I27 M30 imm8 = sign_ext(s << 7 | imm7b, 8)
A4 imm14 = sign_ext(s << 13 | imm6d << 7 | imm7b, 14)
A5 imm22 = sign_ext(s << 21 | imm5c << 16 | imm9d << 7 | imm7b, 22)
A10 count2 = (ct2d > 2)? reservedQPa: ct2d + 1

Volume 3: Instruction Formats 3:349


Table 4-74. Immediate Formation (Continued)
Instruction
Immediate Formation
Format
I1 count2 = (ct2d == 0)? 0: (ct2d == 1)? 7: (ct2d == 2)? 15: 16
mbtype4 = (mbt4c == 0)? @brcst: (mbt4c == 8)? @mix: (mbt4c == 9)? @shuf: (mbt4c ==
I3
0xA)? @alt: (mbt4c == 0xB)? @rev: reservedQPa
I4 mhtype8 = mht8c
I6 count5 = count5b
I8 count5 = 31 – ccount5c
I10 count6 = count6d
len6 = len6d + 1
I11
pos6 = pos6b
len6 = len6d + 1
I12
pos6 = 63 – cpos6c
len6 = len6d + 1
I13 pos6 = 63 – cpos6c
imm8 = sign_ext(s << 7 | imm7b, 8)
len6 = len6d + 1
I14 pos6 = 63 – cpos6b
imm1 = sign_ext(s, 1)
len4 = len4d + 1
I15
pos6 = 63 – cpos6d
I16 pos6 = pos6b
I18 I19 M37 M48 imm21 = i << 20 | imm20a
I21 tag13 = IP + (sign_ext(timm9c, 9) << 4)
I23 mask17 = sign_ext(s << 16 | mask8c << 8 | mask7a << 1, 17)
I24 imm44 = sign_ext(s << 43 | imm27a << 16, 44)
I30 imm5 = imm5b + 32
M3 M8 M15 imm9 = sign_ext(s << 8 | i << 7 | imm7b, 9)
M5 M10 imm9 = sign_ext(s << 8 | i << 7 | imm7a, 9)
M17 inc3 = sign_ext(((s)? –1: 1) * ((i2b == 3)? 1: 1 << (4 – i2b)), 6)
I20 M20 M21 target25 = IP + (sign_ext(s << 20 | imm13c << 7 | imm7a, 21) << 4)
M22 M23 target25 = IP + (sign_ext(s << 20 | imm20b, 21) << 4)
il = sol
M34 o = sof – sol
r = sor << 3
M39 M40 imm2 = i2b
M44 imm24 = i << 23 | i2d << 21 | imm21a
B1 B2 B3 target25 = IP + (sign_ext(s << 20 | imm20b, 21) << 4)
target25 = IP + (sign_ext(s << 20 | imm20b, 21) << 4)
B6
tag13 = IP + (sign_ext(t2e << 7 | timm7a, 9) << 4)
B7 tag13 = IP + (sign_ext(t2e << 7 | timm7a, 9) << 4)
B9 imm21 = i << 20 | imm20a
F5 fclass9 = fclass7c << 2 | fc2
amask7 = amask7b
F12
omask7 = omask7c
F14 target25 = IP + (sign_ext(s << 20 | imm20a, 21) << 4)
F15 F16 imm21 = i << 20 | imm20a
X1 X5 imm62 = imm41 << 21 | i << 20 | imm20a

3:350 Volume 3: Instruction Formats


Table 4-74. Immediate Formation (Continued)
Instruction
Immediate Formation
Format
X2 imm64 = i << 63 | imm41 << 22 | ic << 21 | imm5c << 16 | imm9d << 7 | imm7b
X3 X4 target64 = IP + ((i << 59 | imm39 << 20 | imm20b) << 4)

a. This encoding causes an Illegal Operation fault if the value of the qualifying predicate is 1.

Volume 3: Instruction Formats 3:351


3:352 Volume 3: Instruction Formats
3

Resource and Dependency Semantics 5

5.1 Reading and Writing Resources


An Itanium instruction is said to be a reader of a resource if the instruction’s qualifying predicate is
1 or it has no qualifying predicate or is one of the instructions that reads a resource even when its
qualifying predicate is 0, and the execution of the instruction depends on that resource.

An Itanium instruction is said to be an writer of a resource if the instruction’s qualifying predicate


is 1 or it has no qualifying predicate or writes the resource even when the qualifying predicate is 0,
and the execution of the instruction writes that resource.

An Itanium instruction is said to be a reader or writer of a resource even if it only sometimes


depends on that resource and it cannot be determined statically whether the resource will be read or
written. For example, cover only writes CR[IFS] when PSR.ic is 0, but for purposes of
dependency, it is treated as if it always writes the resource since this condition cannot be
determined statically. On the other hand, rsm conditionally writes several bits in the PSR
depending on a mask which is encoded as an immediate in the instruction. Since the PSR bits to be
written can be determined by examining the encoded instruction, the instruction is treated as only
writing those bits which have a corresponding mask bit set. All exceptions to these general rules are
described in this appendix.

5.2 Dependencies and Serialization


A RAW (Read-After-Write) dependency is a sequence of two events where the first is a writer of a
resource and the second is a reader of the same resource. Events may be instructions, interruptions,
or other ‘uses’ of the resource such as instruction stream fetches and VHPT walks. Table 5-2 covers
only dependencies based on instruction readers and writers.

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 WAR (Write-After-Read) dependency is a sequence of two instructions, where the first is a


reader of a resource and the second is a writer of the same resource. Such dependencies are always
allowed except as indicated in Table 5-4 and only those related to instruction readers and writers
are included.

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

Volume 3: Resource and Dependency Semantics 3:353


serialization required for the dependency to be observed and possible outcomes if the required
serialization is not met. Even when targeting code for machines which do not check for particular
disallowed dependencies, such code sequences are considered architecturally undefined and may
cause code to behave differently across processors, operating systems, or even separate executions
of the code sequence during the same program run. In some cases, different serializations may yield
different, but well-defined results.

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.

5.3 Resource and Dependency Table Format Notes


• The “Writers” and “Readers” columns of the dependency tables contain instruction class
names and instruction mnemonic prefixes as given in the format section of each instruction
page. To avoid ambiguity, instruction classes are shown in bold, while instruction mnemonic
prefixes are in regular font. For instruction mnemonic prefixes, all instructions that exactly
match the name specified or those that begin with the specified text and are followed by a ‘.’
and then followed by any other text will match.
• The dependency on a listed instruction is in effect no matter what values are encoded in the
instruction or what dynamic values occur in operands, unless a superscript is present or one of
the special case instruction rules in Section 5.3.1 applies. Instructions listed are still subject to
rules regarding qualifying predicates.
• Instruction classes are groups of related instructions. Such names appear in boldface for clarity.
The list of all instruction classes is contained in Table 5-5. Note that an instruction may appear
in multiple instruction classes, instruction classes may expand to contain other classes, and that
when fully expanded, a set of classes (e.g., the readers of some resource) may contain the same
instruction multiple times.
• The syntax ‘x\y’ where x and y are both instruction classes, indicates an unnamed instruction
class that includes all instructions in instruction class x but that are not in instruction class y.

3:354 Volume 3: Resource and Dependency Semantics


Similarly, the notation ‘x\y\z’ means all instructions in instruction class x, but that are not in
either instruction class y or instruction class z.
• Resources on separate rows of a table are independent resources. This means that there are no
serialization requirements for an event which references one of them followed by an event
which uses a different resource. In cases where resources are broken into subrows,
dependencies only apply between instructions within a subrow. Instructions that do not appear
in a subrow together have no dependencies (reader/writer or writer/writer dependencies) for
the resource in question, although they may still have dependencies on some other resource.
• The dependencies listed for pairs of instructions on each resource are not unique – the same
pair of instructions might also have a dependency on some other resource with a different
semantics of dependency. In cases where there are multiple resource dependencies for the same
pair of instructions, the most stringent semantics are assumed: instr overrides data which
overrides impliedF which overrides implied which overrides none.
• Arrays of numbered resources are represented in a single row of a table using the% notation as
a substitute for the number of the resource. In such cases, the semantics of the table are as if
each numbered resource had its own row in that table and is thus an independent resource. The
range of values that the% can take are given in the “Resource Name” column.
• An asterisk ‘*’ in the “Resource Name” column indicates that this resource may not have a
physical resource associated with it, but is added to enforce special dependencies.
• A pound sign ‘#’ in the “Resource Name” column indicates that this resource is an array of
resources that are indexed by a value in a GR. The number of individual elements in the array
is described in the detailed description of each resource.
• The “Semantics of Dependency” column describes the outcome given various serialization and
instruction group boundary conditions. The exact definition for each keyword is given in
Table 5-1.

Table 5-1. Semantics of Dependency Codes


Semantics of
Serialization Type Required Effects of Serialization Violation
Dependency Code
instr Instruction Serialization (See “Instruction Atomic: Any attempt to read a resource after one or
Serialization” on page 2:16). more insufficiently serialized writes is either the
data Data Serialization (See “Data Serialization” on value previously in the register (before any of the
page 2:16) unserialized writes) or the value of one of any
unserialized writes. Which value is returned is
implied Instruction Group Break. Writer and reader must be in unpredictable and multiple insufficiently serialized
separate instruction groups. (See “Instruction
reads may see different results. No fault will be
Sequencing Considerations” on page 1:36).
caused by the insufficient serialization.
impliedF Instruction Group Break (same as above). An undefined value is returned, or an Illegal
stop Stop. Writer and reader must be separated by a stop. Operation fault may be taken. If no fault is taken,
the value returned is unpredictable, and may be
unrelated to past writes, but will not be data which
could not be accessed by the current process (e.g.,
if PSR.cpl!= 0, the undefined value to return cannot
be read from some control register).
none None N/A
specific Implementation Specific
SC Special Case Described elsewhere in book, see referenced
section in the entry.

Volume 3: Resource and Dependency Semantics 3:355


5.3.1 Special Case Instruction Rules
The following rules apply to the specified instructions when they appear in Table 5-2, Table 5-3,
Table 5-4, or Table 5-5:
• An instruction always reads a given resource if its qualifying predicate is 1 and it appears in the
“Reader” column of the table (except as noted). An instruction always writes a given resource
if its qualifying predicate is 1 and it appears in the “Writer” column of the table (except as
noted). An instruction never reads or writes the specified resource if its qualifying predicate is
0 (except as noted). These rules include branches and their qualifying predicate. Instructions in
the unpredicatable-instructions class have no qualifying predicate and thus always read or
write their resources (except as noted).
• An instruction of type mov-from-PR reads all PRs if its PR[qp] is true. If the PR[qp] is false,
then only the PR[qp] is read.
• An instruction of type mov-to-PR writes only those PRs as indicated by the immediate mask
encoded in the instruction.
• A st8.spill only writes AR[UNAT]{X} where X equals the value in bits 8:3 of the store’s
data address. A ld8.fill instruction only reads AR[UNAT]{Y} where Y equals the value in
bits 8:3 of the load’s data address.
• Instructions of type mod-sched-brs always read AR[EC] and the rotating register base
registers in CFM, and always write AR[EC], the rotating register bases in CFM, and PR[63]
even if they do not change their values or if their PR[qp] is false.
• Instructions of type mod-sched-brs-counted always read and write AR[LC], even if they do
not change its value.
• For instructions of type pr-or-writers or pr-and-writers, if their completer is or.andcm, then
only the first target predicate is an or-compare and the second target predicate is an
and-compare. Similarly, if their completer is and.orcm, then only the second target predicate
is an or-compare and the first target predicate is an and-compare.
• rum and sum only read PSR.sp when the bit corresponding to PSR.up (bit 2) is set in the
immediate field of the instruction.

5.3.2 RAW Dependency Table


Table 5-2 architecturally defines the following information:
• A list of all architecturally-defined, independently-writable resources in the Itanium
architecture. Each row represents an ‘atomic’ resource. Thus, for each row in the table,
hardware will probably require a separate write-enable control signal.
• For each resource, a complete list of readers and writers.
• For each instruction, a complete list of all resources read and written. Such a list can be
obtained by taking the union of all the rows in which each instruction appears.

3:356 Volume 3: Resource and Dependency Semantics


Table 5-2. RAW Dependencies Organized by Resource
Semantics of
Resource Name Writers Readers
Dependency
ALAT chk.a.clr, mem-readers-alat, none
mem-readers-alat, mem-writers, chk-a,
mem-writers, invala-all invala.e
AR[BSP] br.call, brl.call, br.ret, cover, br.call, brl.call, br.ia, br.ret, cover, impliedF
mov-to-AR-BSPSTORE, rfi flushrs, loadrs,
mov-from-AR-BSP, rfi
AR[BSPSTORE] alloc, loadrs, flushrs, alloc, br.ia, flushrs, impliedF
mov-to-AR-BSPSTORE mov-from-AR-BSPSTORE
AR[CCV] mov-to-AR-CCV br.ia, cmpxchg, impliedF
mov-from-AR-CCV
AR[CFLG] mov-to-AR-CFLG br.ia, mov-from-AR-CFLG impliedF
AR[CSD] ld16, mov-to-AR-CSD br.ia, cmp8xchg16, impliedF
mov-from-AR-CSD, st16
AR[EC] mod-sched-brs, br.ret, br.call, brl.call, br.ia, mod-sched-brs, impliedF
mov-to-AR-EC mov-from-AR-EC
AR[EFLAG] mov-to-AR-EFLAG br.ia, mov-from-AR-EFLAG impliedF
AR[FCR] mov-to-AR-FCR br.ia, mov-from-AR-FCR impliedF
AR[FDR] mov-to-AR-FDR br.ia, mov-from-AR-FDR impliedF
AR[FIR] mov-to-AR-FIR br.ia, mov-from-AR-FIR impliedF
AR[FPSR].sf0.controls mov-to-AR-FPSR, fsetc.s0 br.ia, fp-arith-s0, fcmp-s0, fpcmp-s0, impliedF
fsetc, mov-from-AR-FPSR
AR[FPSR].sf1.controls mov-to-AR-FPSR, fsetc.s1 br.ia, fp-arith-s1, fcmp-s1, fpcmp-s1,
mov-from-AR-FPSR
AR[FPSR].sf2.controls mov-to-AR-FPSR, fsetc.s2 br.ia, fp-arith-s2, fcmp-s2, fpcmp-s2,
mov-from-AR-FPSR
AR[FPSR].sf3.controls mov-to-AR-FPSR, fsetc.s3 br.ia, fp-arith-s3, fcmp-s3, fpcmp-s3,
mov-from-AR-FPSR
AR[FPSR].sf0.flags fp-arith-s0, fclrf.s0, fcmp-s0, br.ia, fchkf, impliedF
fpcmp-s0, mov-to-AR-FPSR mov-from-AR-FPSR
AR[FPSR].sf1.flags fp-arith-s1, fclrf.s1, fcmp-s1, br.ia, fchkf.s1,
fpcmp-s1, mov-to-AR-FPSR mov-from-AR-FPSR
AR[FPSR].sf2.flags fp-arith-s2, fclrf.s2, fcmp-s2, br.ia, fchkf.s2,
fpcmp-s2, mov-to-AR-FPSR mov-from-AR-FPSR
AR[FPSR].sf3.flags fp-arith-s3, fclrf.s3, fcmp-s3, br.ia, fchkf.s3,
fpcmp-s3, mov-to-AR-FPSR mov-from-AR-FPSR
AR[FPSR].traps mov-to-AR-FPSR br.ia, fp-arith, fchkf, fcmp, fpcmp, impliedF
mov-from-AR-FPSR
AR[FPSR].rv mov-to-AR-FPSR br.ia, fp-arith, fchkf, fcmp, fpcmp, impliedF
mov-from-AR-FPSR
AR[FSR] mov-to-AR-FSR br.ia, mov-from-AR-FSR impliedF
AR[ITC] mov-to-AR-ITC br.ia, mov-from-AR-ITC impliedF
AR[K%], mov-to-AR-K1 br.ia, mov-from-AR-K1 impliedF
% in 0 - 7
AR[LC] mod-sched-brs-counted, br.ia, mod-sched-brs-counted, impliedF
mov-to-AR-LC mov-from-AR-LC

Volume 3: Resource and Dependency Semantics 3:357


Table 5-2. RAW Dependencies Organized by Resource (Continued)
Semantics of
Resource Name Writers Readers
Dependency
AR[PFS] br.call, brl.call alloc, br.ia, br.ret, epc, impliedF
mov-from-AR-PFS
mov-to-AR-PFS alloc, br.ia, epc, impliedF
mov-from-AR-PFS
br.ret none
AR[RNAT] alloc, flushrs, loadrs, alloc, br.ia, flushrs, loadrs, impliedF
mov-to-AR-RNAT, mov-from-AR-RNAT
mov-to-AR-BSPSTORE
AR[RSC] mov-to-AR-RSC alloc, br.ia, flushrs, loadrs, impliedF
mov-from-AR-RSC,
mov-from-AR-BSPSTORE,
mov-to-AR-RNAT,
mov-from-AR-RNAT,
mov-to-AR-BSPSTORE
AR[SSD] mov-to-AR-SSD br.ia, mov-from-AR-SSD impliedF
AR[UNAT]{%}, mov-to-AR-UNAT, st8.spill br.ia, ld8.fill, impliedF
% in 0 - 63 mov-from-AR-UNAT
AR%, none br.ia, mov-from-AR-rv1 none
% in 8-15, 20, 22-23, 31,
33-35, 37-39, 41-43, 45-47,
67-111
AR%, mov-to-AR-ig1 br.ia, mov-from-AR-ig1 impliedF
% in 48-63, 112-127
BR%, br.call1, brl.call1 indirect-brs1, indirect-brp1, impliedF
% in 0 - 7 mov-from-BR1
mov-to-BR1 indirect-brs1 none
1,
indirect-brp impliedF
mov-from-BR1
CFM mod-sched-brs mod-sched-brs impliedF
cover, alloc, rfi, loadrs, br.ret, br.call, impliedF
brl.call
cfm-readers2 impliedF
br.call, brl.call, br.ret, clrrrb, cover, cfm-readers impliedF
rfi
alloc cfm-readers none
CPUID# none mov-from-IND-CPUID3 specific
CR[CMCV] mov-to-CR-CMCV mov-from-CR-CMCV data
CR[DCR] mov-to-CR-DCR mov-from-CR-DCR, data
mem-readers-spec
CR[EOI] mov-to-CR-EOI none SC Section
5.8.3.4, “End of
External
Interrupt
Register (EOI –
CR67)” on
page 2:117
CR[IFA] mov-to-CR-IFA itc.i, itc.d, itr.i, itr.d implied
mov-from-CR-IFA data

3:358 Volume 3: Resource and Dependency Semantics


Table 5-2. RAW Dependencies Organized by Resource (Continued)
Semantics of
Resource Name Writers Readers
Dependency
CR[IFS] mov-to-CR-IFS mov-from-CR-IFS data
rfi implied
cover rfi, mov-from-CR-IFS implied
CR[IHA] mov-to-CR-IHA mov-from-CR-IHA data
CR[IIM] mov-to-CR-IIM mov-from-CR-IIM data
CR[IIP] mov-to-CR-IIP mov-from-CR-IIP data
rfi implied
CR[IIPA] mov-to-CR-IIPA mov-from-CR-IIPA data
CR[IPSR] mov-to-CR-IPSR mov-from-CR-IPSR data
rfi implied
CR[IRR%], mov-from-CR-IVR mov-from-CR-IRR1 data
% in 0 - 3
CR[ISR] mov-to-CR-ISR mov-from-CR-ISR data
CR[ITIR] mov-to-CR-ITIR mov-from-CR-ITIR data
itc.i, itc.d, itr.i, itr.d implied
CR[ITM] mov-to-CR-ITM mov-from-CR-ITM data
CR[ITV] mov-to-CR-ITV mov-from-CR-ITV data
CR[IVA] mov-to-CR-IVA mov-from-CR-IVA instr
CR[IVR] none mov-from-CR-IVR SC Section
5.8.3.2,
“External
Interrupt Vector
Register (IVR –
CR65)” on
page 2:116
CR[LID] mov-to-CR-LID mov-from-CR-LID SC Section
5.8.3.1, “Local
ID (LID –
CR64)” on
page 2:115
CR[LRR%], mov-to-CR-LRR1 mov-from-CR-LRR1 data
% in 0 - 1
CR[PMV] mov-to-CR-PMV mov-from-CR-PMV data
CR[PTA] mov-to-CR-PTA mov-from-CR-PTA, mem-readers, data
mem-writers, non-access, thash
CR[TPR] mov-to-CR-TPR mov-from-CR-TPR, data
mov-from-CR-IVR
mov-to-PSR-l17, ssm17 SC Section
5.8.3.3, “Task
Priority Register
(TPR – CR66)”
on page 2:117
rfi implied
CR%, none mov-from-CR-rv1 none
% in 3-7, 10-15, 18, 26-63,
75-79, 82-127

Volume 3: Resource and Dependency Semantics 3:359


Table 5-2. RAW Dependencies Organized by Resource (Continued)
Semantics of
Resource Name Writers Readers
Dependency
DBR# mov-to-IND-DBR3 mov-from-IND-DBR3 impliedF
probe-all, lfetch-all, data
mem-readers, mem-writers
DTC ptc.e, ptc.g, ptc.ga, ptc.l, ptr.i, ptr.d, mem-readers, mem-writers, data
itc.i, itc.d, itr.i, itr.d non-access
itc.i, itc.d, itr.i, itr.d ptc.e, ptc.g, ptc.ga, ptc.l, ptr.i, ptr.d, itc.i, impliedF
itc.d, itr.i, itr.d
ptc.e, ptc.g, ptc.ga, ptc.l, ptr.i, ptr.d ptc.e, ptc.g, ptc.ga, ptc.l, ptr.i, ptr.d none
itc.i, itc.d, itr.i, itr.d impliedF
DTC_LIMIT* ptc.g, ptc.ga ptc.g, ptc.ga impliedF
DTR itr.d mem-readers, mem-writers, data
non-access
ptc.g, ptc.ga, ptc.l, ptr.d, itr.d impliedF
ptr.d mem-readers, mem-writers, data
non-access
ptc.g, ptc.ga, ptc.l, ptr.d none
itr.d, itc.d impliedF
FR%, none fr-readers1 none
% in 0 - 1
FR%, fr-writers1\ldf-c1\ldfp-c1 fr-readers1 impliedF
1 1
% in 2 - 127 ldf-c , ldfp-c fr-readers1 none
GR0 none gr-readers1 none
GR%, ld-c1,13 gr-readers1 none
% in 1 - 127 1 1,13 1
gr-writers \ld-c gr-readers impliedF
IBR# mov-to-IND-IBR3 mov-from-IND-IBR3 impliedF
InService* mov-to-CR-EOI mov-from-CR-IVR data
mov-from-CR-IVR mov-from-CR-IVR impliedF
mov-to-CR-EOI mov-to-CR-EOI impliedF
IP all all none
ITC ptc.e, ptc.g, ptc.ga, ptc.l, ptr.i, ptr.d epc, vmsw instr
itc.i, itc.d, itr.i, itr.d impliedF
ptr.i, ptr.d, ptc.e, ptc.g, ptc.ga, ptc.l none
itc.i, itc.d, itr.i, itr.d epc, vmsw instr
itc.d, itc.i, itr.d, itr.i, ptr.d, ptr.i, ptc.g, impliedF
ptc.ga, ptc.l
ITC_LIMIT* ptc.g, ptc.ga ptc.g, ptc.ga impliedF
ITR itr.i itr.i, itc.i, ptc.g, ptc.ga, ptc.l, ptr.i impliedF
epc, vmsw instr
ptr.i itc.i, itr.i impliedF
ptc.g, ptc.ga, ptc.l, ptr.i none
epc, vmsw instr
memory mem-writers mem-readers none

3:360 Volume 3: Resource and Dependency Semantics


Table 5-2. RAW Dependencies Organized by Resource (Continued)
Semantics of
Resource Name Writers Readers
Dependency
PKR# mov-to-IND-PKR3 mem-readers, mem-writers, data
mov-from-IND-PKR4, probe-all
mov-to-IND-PKR4 none
mov-from-IND-PKR3 impliedF
mov-to-IND-PKR3 impliedF
PMC# mov-to-IND-PMC3 mov-from-IND-PMC3 impliedF
3
mov-from-IND-PMD SC Section
7.2.1, “Generic
Performance
Counter
Registers” for
PMC[0].fr on
page 2:148
PMD# mov-to-IND-PMD3 mov-from-IND-PMD3 impliedF
1
PR0 pr-writers pr-readers-br1, none
pr-readers-nobr-nomovpr1,
mov-from-PR12,
mov-to-PR12
1
PR%, pr-writers , pr-readers-nobr-nomovpr1, impliedF
7 mov-from-PR,
% in 1 - 15 mov-to-PR-allreg
mov-to-PR12
1
pr-writers-fp pr-readers-br1 impliedF
1
pr-writers-int , pr-readers-br1 none
mov-to-PR-allreg7
PR%, pr-writers1, pr-readers-nobr-nomovpr1, impliedF
7, mov-from-PR,
% in 16 - 62 mov-to-PR-allreg
mov-to-PR-rotreg mov-to-PR12
pr-writers-fp1 pr-readers-br1 impliedF
1 1
pr-writers-int , pr-readers-br none
mov-to-PR-allreg7,
mov-to-PR-rotreg
PR63 mod-sched-brs, pr-readers-nobr-nomovpr1, impliedF
1, mov-from-PR,
pr-writers
mov-to-PR-allreg7, mov-to-PR12
mov-to-PR-rotreg
pr-writers-fp1, pr-readers-br1 impliedF
mod-sched-brs
pr-writers-int1, pr-readers-br1 none
mov-to-PR-allreg7,
mov-to-PR-rotreg

Volume 3: Resource and Dependency Semantics 3:361


Table 5-2. RAW Dependencies Organized by Resource (Continued)
Semantics of
Resource Name Writers Readers
Dependency
PSR.ac user-mask-writers-partial7, mem-readers, mem-writers implied
mov-to-PSR-um
sys-mask-writers-partial7, mem-readers, mem-writers data
mov-to-PSR-l
user-mask-writers-partial7, mov-from-PSR, impliedF
mov-to-PSR-um, mov-from-PSR-um
sys-mask-writers-partial7,
mov-to-PSR-l
rfi mem-readers, mem-writers, impliedF
mov-from-PSR, mov-from-PSR-um
PSR.be user-mask-writers-partial7, mem-readers, mem-writers implied
mov-to-PSR-um
sys-mask-writers-partial7, mem-readers, mem-writers data
mov-to-PSR-l
user-mask-writers-partial7, mov-from-PSR, impliedF
mov-to-PSR-um, mov-from-PSR-um
sys-mask-writers-partial7,
mov-to-PSR-l
rfi mem-readers, mem-writers, impliedF
mov-from-PSR, mov-from-PSR-um
PSR.bn bsw, rfi gr-readers10, gr-writers10 impliedF
PSR.cpl epc, br.ret priv-ops, br.call, brl.call, epc, implied
mov-from-AR-ITC,
mov-to-AR-ITC,
mov-to-AR-RSC,
mov-to-AR-K,
mov-from-IND-PMD,
probe-all, mem-readers,
mem-writers, lfetch-all
rfi priv-ops, br.call, brl.call, epc, impliedF
mov-from-AR-ITC,
mov-to-AR-ITC,
mov-to-AR-RSC,
mov-to-AR-K,
mov-from-IND-PMD,
probe-all, mem-readers,
mem-writers, lfetch-all
PSR.da rfi mem-readers, lfetch-all, mem-writers, impliedF
probe-fault
PSR.db mov-to-PSR-l lfetch-all, mem-readers, data
mem-writers, probe-fault
mov-from-PSR impliedF
rfi lfetch-all, mem-readers, impliedF
mem-writers,
mov-from-PSR, probe-fault
PSR.dd rfi lfetch-all, mem-readers, probe-fault, impliedF
mem-writers

3:362 Volume 3: Resource and Dependency Semantics


Table 5-2. RAW Dependencies Organized by Resource (Continued)
Semantics of
Resource Name Writers Readers
Dependency
PSR.dfh sys-mask-writers-partial7, fr-readers8, fr-writers8 data
mov-to-PSR-l mov-from-PSR impliedF
rfi fr-readers8, fr-writers8, impliedF
mov-from-PSR
PSR.dfl sys-mask-writers-partial7, fr-writers8, fr-readers8 data
mov-to-PSR-l mov-from-PSR impliedF
rfi fr-writers8, fr-readers8, impliedF
mov-from-PSR
PSR.di sys-mask-writers-partial7, br.ia data
mov-to-PSR-l mov-from-PSR impliedF
rfi br.ia, mov-from-PSR impliedF
7
PSR.dt sys-mask-writers-partial , mem-readers, mem-writers, data
mov-to-PSR-l non-access
mov-from-PSR impliedF
rfi mem-readers, mem-writers, impliedF
non-access, mov-from-PSR
PSR.ed rfi lfetch-all, impliedF
mem-readers-spec
PSR.i sys-mask-writers-partial7, mov-from-PSR impliedF
mov-to-PSR-l, rfi
PSR.ia rfi all none
7,
PSR.ic sys-mask-writers-partial mov-from-PSR impliedF
mov-to-PSR-l cover, itc.i, itc.d, itr.i, itr.d, data
mov-from-interruption-CR,
mov-to-interruption-CR
rfi mov-from-PSR, cover, itc.i, itc.d, itr.i, impliedF
itr.d, mov-from-interruption-CR,
mov-to-interruption-CR
PSR.id rfi all none
PSR.is br.ia, rfi none none
PSR.it rfi branches, mov-from-PSR, chk, epc, impliedF
fchkf, vmsw
PSR.lp mov-to-PSR-l mov-from-PSR impliedF
br.ret data
rfi mov-from-PSR, br.ret impliedF
PSR.mc rfi mov-from-PSR impliedF
PSR.mfh fr-writers9, mov-from-PSR-um, impliedF
user-mask-writers-partial7, mov-from-PSR
mov-to-PSR-um,
sys-mask-writers-partial7,
mov-to-PSR-l, rfi
PSR.mfl fr-writers9, mov-from-PSR-um, impliedF
user-mask-writers-partial7, mov-from-PSR
mov-to-PSR-um,
sys-mask-writers-partial7,
mov-to-PSR-l, rfi

Volume 3: Resource and Dependency Semantics 3:363


Table 5-2. RAW Dependencies Organized by Resource (Continued)
Semantics of
Resource Name Writers Readers
Dependency
PSR.pk sys-mask-writers-partial7, lfetch-all, mem-readers, data
mov-to-PSR-l mem-writers, probe-all
mov-from-PSR impliedF
rfi lfetch-all, mem-readers, impliedF
mem-writers, mov-from-PSR,
probe-all
PSR.pp sys-mask-writers-partial7, mov-from-PSR impliedF
mov-to-PSR-l, rfi
PSR.ri rfi all none
PSR.rt mov-to-PSR-l mov-from-PSR impliedF
alloc, flushrs, loadrs data
rfi mov-from-PSR, alloc, flushrs, loadrs impliedF
PSR.si sys-mask-writers-partial7, mov-from-PSR impliedF
mov-to-PSR-l mov-from-AR-ITC data
rfi mov-from-AR-ITC, mov-from-PSR impliedF
PSR.sp sys-mask-writers-partial7, mov-from-PSR impliedF
mov-to-PSR-l mov-from-IND-PMD, data
mov-to-PSR-um, rum, sum
rfi mov-from-IND-PMD, mov-from-PSR, impliedF
mov-to-PSR-um, rum, sum
PSR.ss rfi all impliedF
PSR.tb mov-to-PSR-l branches, chk, fchkf data
mov-from-PSR impliedF
rfi branches, chk, fchkf, mov-from-PSR impliedF
PSR.up user-mask-writers-partial7, mov-from-PSR-um, impliedF
mov-to-PSR-um, mov-from-PSR
sys-mask-writers-partial7,
mov-to-PSR-l, rfi
PSR.vm vmsw mem-readers, mem-writers, implied
mov-from-AR-ITC,
mov-from-IND-CPUID,
mov-to-AR-ITC, priv-ops\vmsw, cover,
thash, ttag
rfi mem-readers, mem-writers, impliedF
mov-from-AR-ITC,
mov-from-IND-CPUID,
mov-to-AR-ITC, priv-ops\vmsw, cover,
thash, ttag
RR# mov-to-IND-RR6 mem-readers, mem-writers, itc.i, itc.d, data
itr.i, itr.d, non-access, ptc.g, ptc.ga,
ptc.l, ptr.i, ptr.d, thash, ttag
mov-from-IND-RR6 impliedF
14
RSE rse-writers rse-readers14 impliedF

3:364 Volume 3: Resource and Dependency Semantics


5.3.3 WAW Dependency Table
General rules specific to the WAW table:
• All resources require at most an instruction group break to provide sequential behavior.
• Some resources require no instruction group break to provide sequential behavior.
• There are a few special cases that are described in greater detail elsewhere in the manual and
are indicated with an SC (special case) result.
• Each sub-row of writers represents a group of instructions that when taken in pairs in any
combination has the dependency result indicated. If the column is split in sub-columns, then
the dependency semantics apply to any pair of instructions where one is chosen from left
sub-column and one is chosen from the right sub-column.

Table 5-3. WAW Dependencies Organized by Resource


Semantics of
Resource Name Writers
Dependency
ALAT mem-readers-alat, mem-writers, chk.a.clr, none
invala-all
AR[BSP] br.call, brl.call, br.ret, cover, mov-to-AR-BSPSTORE, rfi impliedF
AR[BSPSTORE] alloc, loadrs, flushrs, mov-to-AR-BSPSTORE impliedF
AR[CCV] mov-to-AR-CCV impliedF
AR[CFLG] mov-to-AR-CFLG impliedF
AR[CSD] ld16, mov-to-AR-CSD impliedF
AR[EC] br.ret, mod-sched-brs, mov-to-AR-EC impliedF
AR[EFLAG] mov-to-AR-EFLAG impliedF
AR[FCR] mov-to-AR-FCR impliedF
AR[FDR] mov-to-AR-FDR impliedF
AR[FIR] mov-to-AR-FIR impliedF
AR[FPSR].sf0.controls mov-to-AR-FPSR, fsetc.s0 impliedF
AR[FPSR].sf1.controls mov-to-AR-FPSR, fsetc.s1 impliedF
AR[FPSR].sf2.controls mov-to-AR-FPSR, fsetc.s2 impliedF
AR[FPSR].sf3.controls mov-to-AR-FPSR, fsetc.s3 impliedF
AR[FPSR].sf0.flags fp-arith-s0, fcmp-s0, fpcmp-s0 none
fclrf.s0, fcmp-s0, fp-arith-s0, fclrf.s0, mov-to-AR-FPSR impliedF
fpcmp-s0, mov-to-AR-FPSR
AR[FPSR].sf1.flags fp-arith-s1, fcmp-s1, fpcmp-s1 none
fclrf.s1, fcmp-s1, fp-arith-s1, fclrf.s1, mov-to-AR-FPSR impliedF
fpcmp-s1, mov-to-AR-FPSR
AR[FPSR].sf2.flags fp-arith-s2, fcmp-s2, fpcmp-s2 none
fclrf.s2, fcmp-s2, fp-arith-s2, fclrf.s2, mov-to-AR-FPSR impliedF
fpcmp-s2, mov-to-AR-FPSR
AR[FPSR].sf3.flags fp-arith-s3, fcmp-s3, fpcmp-s3 none
fclrf.s3, fcmp-s3, fp-arith-s3, fclrf.s3, mov-to-AR-FPSR impliedF
fpcmp-s3, mov-to-AR-FPSR
AR[FPSR].rv mov-to-AR-FPSR impliedF
AR[FPSR].traps mov-to-AR-FPSR impliedF
AR[FSR] mov-to-AR-FSR impliedF
AR[ITC] mov-to-AR-ITC impliedF

Volume 3: Resource and Dependency Semantics 3:365


Table 5-3. WAW Dependencies Organized by Resource (Continued)
Semantics of
Resource Name Writers
Dependency
AR[K%], mov-to-AR-K1 impliedF
% in 0 - 7
AR[LC] mod-sched-brs-counted, mov-to-AR-LC impliedF
AR[PFS] br.call, brl.call none
br.call, brl.call mov-to-AR-PFS impliedF
AR[RNAT] alloc, flushrs, loadrs, impliedF
mov-to-AR-RNAT,
mov-to-AR-BSPSTORE
AR[RSC] mov-to-AR-RSC impliedF
AR[SSD] mov-to-AR-SSD impliedF
AR[UNAT]{%}, mov-to-AR-UNAT, st8.spill impliedF
% in 0 - 63
AR%, none none
% in 8-15, 20, 22-23, 31,
33-35, 37-39, 41-43, 45-47,
67-111
AR%, mov-to-AR-ig1 impliedF
% in 48 - 63, 112-127
BR%, br.call1, brl.call1 mov-to-BR1 impliedF
% in 0 - 7 1
mov-to-BR impliedF
br.call1, brl.call1 none
CFM mod-sched-brs, br.call, brl.call, br.ret, alloc, clrrrb, cover, rfi impliedF
CPUID# none none
CR[CMCV] mov-to-CR-CMCV impliedF
CR[DCR] mov-to-CR-DCR impliedF
CR[EOI] mov-to-CR-EOI SC Section
5.8.3.4, “End of
External Interrupt
Register (EOI –
CR67)” on
page 2:117
CR[IFA] mov-to-CR-IFA impliedF
CR[IFS] mov-to-CR-IFS, cover impliedF
CR[IHA] mov-to-CR-IHA impliedF
CR[IIM] mov-to-CR-IIM impliedF
CR[IIP] mov-to-CR-IIP impliedF
CR[IIPA] mov-to-CR-IIPA impliedF
CR[IPSR] mov-to-CR-IPSR impliedF
CR[IRR%], mov-from-CR-IVR impliedF
% in 0 - 3
CR[ISR] mov-to-CR-ISR impliedF
CR[ITIR] mov-to-CR-ITIR impliedF
CR[ITM] mov-to-CR-ITM impliedF
CR[ITV] mov-to-CR-ITV impliedF
CR[IVA] mov-to-CR-IVA impliedF
CR[IVR] none SC
CR[LID] mov-to-CR-LID SC

3:366 Volume 3: Resource and Dependency Semantics


Table 5-3. WAW Dependencies Organized by Resource (Continued)
Semantics of
Resource Name Writers
Dependency
CR[LRR%], mov-to-CR-LRR1 impliedF
% in 0 - 1
CR[PMV] mov-to-CR-PMV impliedF
CR[PTA] mov-to-CR-PTA impliedF
CR[TPR] mov-to-CR-TPR impliedF
CR%, none none
% in 3-7, 10-15, 18, 26-63,
75-79, 82-127
DBR# mov-to-IND-DBR3 impliedF
DTC ptc.e, ptc.g, ptc.ga, ptc.l, ptr.i, ptr.d none
ptc.e, ptc.g, ptc.ga, ptc.l, ptr.i, ptr.d, itc.i, itc.d, itr.i, itr.d impliedF
itc.i, itc.d, itr.i, itr.d
DTC_LIMIT* ptc.g, ptc.ga impliedF
DTR itr.d impliedF
itr.d ptr.d impliedF
ptr.d none
FR%, none none
% in 0 - 1
FR%, fr-writers1, ldf-c1, ldfp-c1 impliedF
% in 2 - 127
GR0 none none
GR%, ld-c1, gr-writers1 impliedF
% in 1 - 127
IBR# mov-to-IND-IBR3 impliedF
InService* mov-to-CR-EOI, mov-from-CR-IVR SC
IP all none
ITC ptc.e, ptc.g, ptc.ga, ptc.l, ptr.i, ptr.d none
ptc.e, ptc.g, ptc.ga, ptc.l, ptr.i, ptr.d, itc.i, itc.d, itr.i, itr.d impliedF
itc.i, itc.d, itr.i, itr.d
ITR itr.i itr.i, ptr.i impliedF
ptr.i none
memory mem-writers none
PKR# mov-to-IND-PKR3 mov-to-IND-PKR4 none
mov-to-IND-PKR3 impliedF
PMC# mov-to-IND-PMC3 impliedF
3
PMD# mov-to-IND-PMD impliedF
PR0 pr-writers1 none
PR%, pr-and-writers1 none
% in 1 - 15 pr-or-writers1 none
1, pr-unc-writers-fp1,
pr-unc-writers-fp impliedF
pr-unc-writers-int1, pr-unc-writers-int1,
pr-norm-writers-fp1, pr-norm-writers-fp1,
pr-norm-writers-int1, pr-norm-writers-int1,
pr-and-writers1, pr-or-writers1,
mov-to-PR-allreg7 mov-to-PR-allreg7

Volume 3: Resource and Dependency Semantics 3:367


Table 5-3. WAW Dependencies Organized by Resource (Continued)
Semantics of
Resource Name Writers
Dependency
PR%, pr-and-writers1 none
% in 16 - 62 1
pr-or-writers none
pr-unc-writers-fp1, pr-unc-writers-fp1, impliedF
pr-unc-writers-int1, pr-unc-writers-int1,
pr-norm-writers-fp1, pr-norm-writers-fp1,
pr-norm-writers-int1, pr-norm-writers-int1,
pr-and-writers1, pr-or-writers1,
mov-to-PR-allreg7, mov-to-PR-allreg7,
mov-to-PR-rotreg mov-to-PR-rotreg
PR63 pr-and-writers1 none
pr-or-writers1 none
mod-sched-brs, mod-sched-brs, impliedF
pr-unc-writers-fp1, pr-unc-writers-fp1,
pr-unc-writers-int1, pr-unc-writers-int1,
pr-norm-writers-fp1, pr-norm-writers-fp1,
pr-norm-writers-int1, pr-norm-writers-int1,
pr-and-writers1, pr-or-writers1,
mov-to-PR-allreg7, mov-to-PR-allreg7,
mov-to-PR-rotreg mov-to-PR-rotreg
PSR.ac user-mask-writers-partial7, mov-to-PSR-um, impliedF
sys-mask-writers-partial7, mov-to-PSR-l, rfi
PSR.be user-mask-writers-partial7, mov-to-PSR-um, impliedF
sys-mask-writers-partial7, mov-to-PSR-l, rfi
PSR.bn bsw, rfi impliedF
PSR.cpl epc, br.ret, rfi impliedF
PSR.da rfi impliedF
PSR.db mov-to-PSR-l, rfi impliedF
PSR.dd rfi impliedF
PSR.dfh sys-mask-writers-partial7, mov-to-PSR-l, rfi impliedF
PSR.dfl sys-mask-writers-partial7, mov-to-PSR-l, rfi impliedF
PSR.di sys-mask-writers-partial7, mov-to-PSR-l, rfi impliedF
7,
PSR.dt sys-mask-writers-partial mov-to-PSR-l, rfi impliedF
PSR.ed rfi impliedF
PSR.i sys-mask-writers-partial7, mov-to-PSR-l, rfi impliedF
PSR.ia rfi impliedF
PSR.ic sys-mask-writers-partial7, mov-to-PSR-l, rfi impliedF
PSR.id rfi impliedF
PSR.is br.ia, rfi impliedF
PSR.it rfi impliedF
PSR.lp mov-to-PSR-l, rfi impliedF
PSR.mc rfi impliedF
PSR.mfh fr-writers9 none
user-mask-writers-partial7, user-mask-writers-partial7, impliedF
mov-to-PSR-um, fr-writers9, mov-to-PSR-um,
sys-mask-writers-partial7, sys-mask-writers-partial7,
mov-to-PSR-l, rfi mov-to-PSR-l, rfi

3:368 Volume 3: Resource and Dependency Semantics


Table 5-3. WAW Dependencies Organized by Resource (Continued)
Semantics of
Resource Name Writers
Dependency
PSR.mfl fr-writers9 none
7, user-mask-writers-partial7,
user-mask-writers-partial impliedF
mov-to-PSR-um, fr-writers9, mov-to-PSR-um,
sys-mask-writers-partial7, sys-mask-writers-partial7,
mov-to-PSR-l, rfi mov-to-PSR-l, rfi
PSR.pk sys-mask-writers-partial7, mov-to-PSR-l, rfi impliedF
PSR.pp sys-mask-writers-partial7, mov-to-PSR-l, rfi impliedF
PSR.ri rfi impliedF
PSR.rt mov-to-PSR-l, rfi impliedF
7,
PSR.si sys-mask-writers-partial mov-to-PSR-l, rfi impliedF
PSR.sp sys-mask-writers-partial7, mov-to-PSR-l, rfi impliedF
PSR.ss rfi impliedF
PSR.tb mov-to-PSR-l, rfi impliedF
7
PSR.up user-mask-writers-partial , mov-to-PSR-um, impliedF
sys-mask-writers-partial7, mov-to-PSR-l, rfi
PSR.vm rfi, vmsw impliedF
RR# mov-to-IND-RR6 impliedF
RSE rse-writers14 impliedF

5.3.4 WAR Dependency Table


A general rule specific to the WAR table:
1. WAR dependencies are always allowed within instruction groups except for the entry in
Table 5-4 below. The readers and subsequent writers specified must be separated by a stop in
order to have defined behavior.
Table 5-4. WAR Dependencies Organized by Resource
Resource Name Readers Writers Semantics of Dependency
PR63 pr-readers-br1 mod-sched-brs stop

5.3.5 Listing of Rules Referenced in Dependency Tables


The following rules restrict the specific instances in which some of the instructions in the tables
cause a dependency and must be applied where referenced to correctly interpret those entries. Rules
only apply to the instance of the instruction class, or instruction mnemonic prefix where the rule is
referenced as a superscript. If the rule is referenced in Table 5-5 where instruction classes are
defined, then it applies to all instances of the instruction class.

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.

Volume 3: Resource and Dependency Semantics 3:369


Rule 3. These instructions use a general register value to determine the specific indirect register
accessed. These instructions only access the register resource specified by the value in bits
{7:0} of the dynamic value of the index register.

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 5. All rules are implementation specific.

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.

3:370 Volume 3: Resource and Dependency Semantics


5.4 Support Tables

Table 5-5. Instruction Classes


Class Events/Instructions
all predicatable-instructions, unpredicatable-instructions
branches indirect-brs, ip-rel-brs
cfm-readers fr-readers, fr-writers, gr-readers, gr-writers, mod-sched-brs,
predicatable-instructions, pr-writers, alloc, br.call, brl.call, br.ret, cover, loadrs, rfi, chk-a,
invala.e
chk-a chk.a.clr, chk.a.nc
cmpxchg cmpxchg1, cmpxchg2, cmpxchg4, cmpxchg8, cmp8xchg16
czx czx1, czx2
fcmp-s0 fcmp[Field(sf)==s0]
fcmp-s1 fcmp[Field(sf)==s1]
fcmp-s2 fcmp[Field(sf)==s2]
fcmp-s3 fcmp[Field(sf)==s3]
fetchadd fetchadd4, fetchadd8
fp-arith fadd, famax, famin, fcvt.fx, fcvt.fxu, fcvt.xuf, fma, fmax, fmin, fmpy, fms, fnma, fnmpy, fnorm,
fpamax, fpamin, fpcvt.fx, fpcvt.fxu, fpma, fpmax, fpmin, fpmpy, fpms, fpnma, fpnmpy, fprcpa,
fprsqrta, frcpa, frsqrta, fsub
fp-arith-s0 fp-arith[Field(sf)==s0]
fp-arith-s1 fp-arith[Field(sf)==s1]
fp-arith-s2 fp-arith[Field(sf)==s2]
fp-arith-s3 fp-arith[Field(sf)==s3]
fp-non-arith fabs, fand, fandcm, fclass, fcvt.xf, fmerge, fmix, fneg, fnegabs, for, fpabs, fpmerge, fpack,
fpneg, fpnegabs, fselect, fswap, fsxt, fxor, xma
fpcmp-s0 fpcmp[Field(sf)==s0]
fpcmp-s1 fpcmp[Field(sf)==s1]
fpcmp-s2 fpcmp[Field(sf)==s2]
fpcmp-s3 fpcmp[Field(sf)==s3]
fr-readers fp-arith, fp-non-arith, mem-writers-fp, pr-writers-fp, chk.s[Format in {M21}], getf
fr-writers fp-arith, fp-non-arith\fclass, mem-readers-fp, setf
gr-readers gr-readers-writers, mem-readers, mem-writers, chk.s, cmp, cmp4, fc, itc.i, itc.d, itr.i, itr.d,
mov-to-AR-gr, mov-to-BR, mov-to-CR, mov-to-IND, mov-from-IND, mov-to-PR-allreg,
mov-to-PSR-l, mov-to-PSR-um, probe-all, ptc.e, ptc.g, ptc.ga, ptc.l, ptr.i, ptr.d, setf, tbit,
tnat
gr-readers-writers mov-from-IND, add, addl, addp4, adds, and, andcm, czx, dep\dep[Format in {I13}], extr,
mem-readers-int, ld-all-postinc, lfetch-postinc, mix, mux, or, pack, padd, pavg,
pavgsub, pcmp, pmax, pmin, pmpy, pmpyshr, popcnt, probe-nofault, psad, pshl,
pshladd, pshr, pshradd, psub, shl, shladd, shladdp4, shr, shrp, st-postinc, sub, sxt, tak,
thash, tpa, ttag, unpack, xor, zxt
gr-writers alloc, dep, getf, gr-readers-writers, mem-readers-int, mov-from-AR, mov-from-BR,
mov-from-CR, mov-from-PR, mov-from-PSR, mov-from-PSR-um, mov-ip, movl
indirect-brp brp[Format in {B7}]
indirect-brs br.call[Format in {B5}], br.cond[Format in {B4}], br.ia, br.ret
invala-all invala[Format in {M24}], invala.e
ip-rel-brs mod-sched-brs, br.call[Format in {B3}], brl.call, brl.cond, br.cond[Format in {B1}], br.cloop
ld ld1, ld2, ld4, ld8, ld8.fill, ld16
ld-a ld1.a, ld2.a, ld4.a, ld8.a

Volume 3: Resource and Dependency Semantics 3:371


Table 5-5. Instruction Classes (Continued)
Class Events/Instructions
ld-all-postinc ld[Format in {M2 M3}], ldfp[Format in {M12}], ldf[Format in {M7 M8}]
ld-c ld-c-nc, ld-c-clr
ld-c-clr ld1.c.clr, ld2.c.clr, ld4.c.clr, ld8.c.clr, ld-c-clr-acq
ld-c-clr-acq ld1.c.clr.acq, ld2.c.clr.acq, ld4.c.clr.acq, ld8.c.clr.acq
ld-c-nc ld1.c.nc, ld2.c.nc, ld4.c.nc, ld8.c.nc
ld-s ld1.s, ld2.s, ld4.s, ld8.s
ld-sa ld1.sa, ld2.sa, ld4.sa, ld8.sa
ldf ldfs, ldfd, ldfe, ldf8, ldf.fill
ldf-a ldfs.a, ldfd.a, ldfe.a, ldf8.a
ldf-c ldf-c-nc, ldf-c-clr
ldf-c-clr ldfs.c.clr, ldfd.c.clr, ldfe.c.clr, ldf8.c.clr
ldf-c-nc ldfs.c.nc, ldfd.c.nc, ldfe.c.nc, ldf8.c.nc
ldf-s ldfs.s, ldfd.s, ldfe.s, ldf8.s
ldf-sa ldfs.sa, ldfd.sa, ldfe.sa, ldf8.sa
ldfp ldfps, ldfpd, ldfp8
ldfp-a ldfps.a, ldfpd.a, ldfp8.a
ldfp-c ldfp-c-nc, ldfp-c-clr
ldfp-c-clr ldfps.c.clr, ldfpd.c.clr, ldfp8.c.clr
ldfp-c-nc ldfps.c.nc, ldfpd.c.nc, ldfp8.c.nc
ldfp-s ldfps.s, ldfpd.s, ldfp8.s
ldfp-sa ldfps.sa, ldfpd.sa, ldfp8.sa
lfetch-all lfetch
lfetch-fault lfetch[Field(lftype)==fault]
lfetch-nofault lfetch[Field(lftype)==]
lfetch-postinc lfetch[Format in {M14 M15}]
mem-readers mem-readers-fp, mem-readers-int
mem-readers-alat ld-a, ldf-a, ldfp-a, ld-sa, ldf-sa, ldfp-sa, ld-c, ldf-c, ldfp-c
mem-readers-fp ldf, ldfp
mem-readers-int cmpxchg, fetchadd, xchg, ld
mem-readers-spec ld-s, ld-sa, ldf-s, ldf-sa, ldfp-s, ldfp-sa
mem-writers mem-writers-fp, mem-writers-int
mem-writers-fp stf
mem-writers-int cmpxchg, fetchadd, xchg, st
mix mix1, mix2, mix4
mod-sched-brs br.cexit, br.ctop, br.wexit, br.wtop
mod-sched-brs-counted br.cexit, br.cloop, br.ctop
mov-from-AR mov-from-AR-M, mov-from-AR-I, mov-from-AR-IM
mov-from-AR-BSP mov-from-AR-M[Field(ar3) == BSP]
mov-from-AR-BSPSTORE mov-from-AR-M[Field(ar3) == BSPSTORE]
mov-from-AR-CCV mov-from-AR-M[Field(ar3) == CCV]
mov-from-AR-CFLG mov-from-AR-M[Field(ar3) == CFLG]
mov-from-AR-CSD mov-from-AR-M[Field(ar3) == CSD]
mov-from-AR-EC mov-from-AR-I[Field(ar3) == EC]
mov-from-AR-EFLAG mov-from-AR-M[Field(ar3) == EFLAG]
mov-from-AR-FCR mov-from-AR-M[Field(ar3) == FCR]

3:372 Volume 3: Resource and Dependency Semantics


Table 5-5. Instruction Classes (Continued)
Class Events/Instructions
mov-from-AR-FDR mov-from-AR-M[Field(ar3) == FDR]
mov-from-AR-FIR mov-from-AR-M[Field(ar3) == FIR]
mov-from-AR-FPSR mov-from-AR-M[Field(ar3) == FPSR]
mov-from-AR-FSR mov-from-AR-M[Field(ar3) == FSR]
mov-from-AR-I mov_ar[Format in {I28}]
mov-from-AR-ig mov-from-AR-IM[Field(ar3) in {48-63 112-127}]
mov-from-AR-IM mov_ar[Format in {I28 M31}]
mov-from-AR-ITC mov-from-AR-M[Field(ar3) == ITC]
mov-from-AR-K mov-from-AR-M[Field(ar3) in {K0 K1 K2 K3 K4 K5 K6 K7}]
mov-from-AR-LC mov-from-AR-I[Field(ar3) == LC]
mov-from-AR-M mov_ar[Format in {M31}]
mov-from-AR-PFS mov-from-AR-I[Field(ar3) == PFS]
mov-from-AR-RNAT mov-from-AR-M[Field(ar3) == RNAT]
mov-from-AR-RSC mov-from-AR-M[Field(ar3) == RSC]
mov-from-AR-rv none
mov-from-AR-SSD mov-from-AR-M[Field(ar3) == SSD]
mov-from-AR-UNAT mov-from-AR-M[Field(ar3) == UNAT]
mov-from-BR mov_br[Format in {I22}]
mov-from-CR mov_cr[Format in {M33}]
mov-from-CR-CMCV mov-from-CR[Field(cr3) == CMCV]
mov-from-CR-DCR mov-from-CR[Field(cr3) == DCR]
mov-from-CR-EOI mov-from-CR[Field(cr3) == EOI]
mov-from-CR-IFA mov-from-CR[Field(cr3) == IFA]
mov-from-CR-IFS mov-from-CR[Field(cr3) == IFS]
mov-from-CR-IHA mov-from-CR[Field(cr3) == IHA]
mov-from-CR-IIM mov-from-CR[Field(cr3) == IIM]
mov-from-CR-IIP mov-from-CR[Field(cr3) == IIP]
mov-from-CR-IIPA mov-from-CR[Field(cr3) == IIPA]
mov-from-CR-IPSR mov-from-CR[Field(cr3) == IPSR]
mov-from-CR-IRR mov-from-CR[Field(cr3) in {IRR0 IRR1 IRR2 IRR3}]
mov-from-CR-ISR mov-from-CR[Field(cr3) == ISR]
mov-from-CR-ITIR mov-from-CR[Field(cr3) == ITIR]
mov-from-CR-ITM mov-from-CR[Field(cr3) == ITM]
mov-from-CR-ITV mov-from-CR[Field(cr3) == ITV]
mov-from-CR-IVA mov-from-CR[Field(cr3) == IVA]
mov-from-CR-IVR mov-from-CR[Field(cr3) == IVR]
mov-from-CR-LID mov-from-CR[Field(cr3) == LID]
mov-from-CR-LRR mov-from-CR[Field(cr3) in {LRR0 LRR1}]
mov-from-CR-PMV mov-from-CR[Field(cr3) == PMV]
mov-from-CR-PTA mov-from-CR[Field(cr3) == PTA]
mov-from-CR-rv none
mov-from-CR-TPR mov-from-CR[Field(cr3) == TPR]
mov-from-IND mov_indirect[Format in {M43}]
mov-from-IND-CPUID mov-from-IND[Field(ireg) == cpuid]
mov-from-IND-DBR mov-from-IND[Field(ireg) == dbr]

Volume 3: Resource and Dependency Semantics 3:373


Table 5-5. Instruction Classes (Continued)
Class Events/Instructions
mov-from-IND-IBR mov-from-IND[Field(ireg) == ibr]
mov-from-IND-PKR mov-from-IND[Field(ireg) == pkr]
mov-from-IND-PMC mov-from-IND[Field(ireg) == pmc]
mov-from-IND-PMD mov-from-IND[Field(ireg) == pmd]
mov-from-IND-priv mov-from-IND[Field(ireg) in {dbr ibr pkr pmc rr}]
mov-from-IND-RR mov-from-IND[Field(ireg) == rr]
mov-from-interruption-CR mov-from-CR-ITIR, mov-from-CR-IFS, mov-from-CR-IIM, mov-from-CR-IIP,
mov-from-CR-IPSR, mov-from-CR-ISR, mov-from-CR-IFA, mov-from-CR-IHA,
mov-from-CR-IIPA
mov-from-PR mov_pr[Format in {I25}]
mov-from-PSR mov_psr[Format in {M36}]
mov-from-PSR-um mov_um[Format in {M36}]
mov-ip mov_ip[Format in {I25}]
mov-to-AR mov-to-AR-M, mov-to-AR-I
mov-to-AR-BSP mov-to-AR-M[Field(ar3) == BSP]
mov-to-AR-BSPSTORE mov-to-AR-M[Field(ar3) == BSPSTORE]
mov-to-AR-CCV mov-to-AR-M[Field(ar3) == CCV]
mov-to-AR-CFLG mov-to-AR-M[Field(ar3) == CFLG]
mov-to-AR-CSD mov-to-AR-M[Field(ar3) == CSD]
mov-to-AR-EC mov-to-AR-I[Field(ar3) == EC]
mov-to-AR-EFLAG mov-to-AR-M[Field(ar3) == EFLAG]
mov-to-AR-FCR mov-to-AR-M[Field(ar3) == FCR]
mov-to-AR-FDR mov-to-AR-M[Field(ar3) == FDR]
mov-to-AR-FIR mov-to-AR-M[Field(ar3) == FIR]
mov-to-AR-FPSR mov-to-AR-M[Field(ar3) == FPSR]
mov-to-AR-FSR mov-to-AR-M[Field(ar3) == FSR]
mov-to-AR-gr mov-to-AR-M[Format in {M29}], mov-to-AR-I[Format in {I26}]
mov-to-AR-I mov_ar[Format in {I26 I27}]
mov-to-AR-ig mov-to-AR-IM[Field(ar3) in {48-63 112-127}]
mov-to-AR-IM mov_ar[Format in {I26 I27 M29 M30}]
mov-to-AR-ITC mov-to-AR-M[Field(ar3) == ITC]
mov-to-AR-K mov-to-AR-M[Field(ar3) in {K0 K1 K2 K3 K4 K5 K6 K7}]
mov-to-AR-LC mov-to-AR-I[Field(ar3) == LC]
mov-to-AR-M mov_ar[Format in {M29 M30}]
mov-to-AR-PFS mov-to-AR-I[Field(ar3) == PFS]
mov-to-AR-RNAT mov-to-AR-M[Field(ar3) == RNAT]
mov-to-AR-RSC mov-to-AR-M[Field(ar3) == RSC]
mov-to-AR-SSD mov-to-AR-M[Field(ar3) == SSD]
mov-to-AR-UNAT mov-to-AR-M[Field(ar3) == UNAT]
mov-to-BR mov_br[Format in {I21}]
mov-to-CR mov_cr[Format in {M32}]
mov-to-CR-CMCV mov-to-CR[Field(cr3) == CMCV]
mov-to-CR-DCR mov-to-CR[Field(cr3) == DCR]
mov-to-CR-EOI mov-to-CR[Field(cr3) == EOI]
mov-to-CR-IFA mov-to-CR[Field(cr3) == IFA]

3:374 Volume 3: Resource and Dependency Semantics


Table 5-5. Instruction Classes (Continued)
Class Events/Instructions
mov-to-CR-IFS mov-to-CR[Field(cr3) == IFS]
mov-to-CR-IHA mov-to-CR[Field(cr3) == IHA]
mov-to-CR-IIM mov-to-CR[Field(cr3) == IIM]
mov-to-CR-IIP mov-to-CR[Field(cr3) == IIP]
mov-to-CR-IIPA mov-to-CR[Field(cr3) == IIPA]
mov-to-CR-IPSR mov-to-CR[Field(cr3) == IPSR]
mov-to-CR-IRR mov-to-CR[Field(cr3) in {IRR0 IRR1 IRR2 IRR3}]
mov-to-CR-ISR mov-to-CR[Field(cr3) == ISR]
mov-to-CR-ITIR mov-to-CR[Field(cr3) == ITIR]
mov-to-CR-ITM mov-to-CR[Field(cr3) == ITM]
mov-to-CR-ITV mov-to-CR[Field(cr3) == ITV]
mov-to-CR-IVA mov-to-CR[Field(cr3) == IVA]
mov-to-CR-IVR mov-to-CR[Field(cr3) == IVR]
mov-to-CR-LID mov-to-CR[Field(cr3) == LID]
mov-to-CR-LRR mov-to-CR[Field(cr3) in {LRR0 LRR1}]
mov-to-CR-PMV mov-to-CR[Field(cr3) == PMV]
mov-to-CR-PTA mov-to-CR[Field(cr3) == PTA]
mov-to-CR-TPR mov-to-CR[Field(cr3) == TPR]
mov-to-IND mov_indirect[Format in {M42}]
mov-to-IND-CPUID mov-to-IND[Field(ireg) == cpuid]
mov-to-IND-DBR mov-to-IND[Field(ireg) == dbr]
mov-to-IND-IBR mov-to-IND[Field(ireg) == ibr]
mov-to-IND-PKR mov-to-IND[Field(ireg) == pkr]
mov-to-IND-PMC mov-to-IND[Field(ireg) == pmc]
mov-to-IND-PMD mov-to-IND[Field(ireg) == pmd]
mov-to-IND-priv mov-to-IND
mov-to-IND-RR mov-to-IND[Field(ireg) == rr]
mov-to-interruption-CR mov-to-CR-ITIR, mov-to-CR-IFS, mov-to-CR-IIM, mov-to-CR-IIP, mov-to-CR-IPSR,
mov-to-CR-ISR, mov-to-CR-IFA, mov-to-CR-IHA, mov-to-CR-IIPA
mov-to-PR mov-to-PR-allreg, mov-to-PR-rotreg
mov-to-PR-allreg mov_pr[Format in {I23}]
mov-to-PR-rotreg mov_pr[Format in {I24}]
mov-to-PSR-l mov_psr[Format in {M35}]
mov-to-PSR-um mov_um[Format in {M35}]
mux mux1, mux2
non-access fc, lfetch, probe-all, tpa, tak
none -
pack pack2, pack4
padd padd1, padd2, padd4
pavg pavg1, pavg2
pavgsub pavgsub1, pavgsub2
pcmp pcmp1, pcmp2, pcmp4
pmax pmax1, pmax2
pmin pmin1, pmin2
pmpy pmpy2

Volume 3: Resource and Dependency Semantics 3:375


Table 5-5. Instruction Classes (Continued)
Class Events/Instructions
pmpyshr pmpyshr2
pr-and-writers pr-gen-writers-int[Field(ctype) in {and andcm}],
pr-gen-writers-int[Field(ctype) in {or.andcm and.orcm}]
pr-gen-writers-fp fclass, fcmp
pr-gen-writers-int cmp, cmp4, tbit, tf, tnat
pr-norm-writers-fp pr-gen-writers-fp[Field(ctype)==]
pr-norm-writers-int pr-gen-writers-int[Field(ctype)==]
pr-or-writers pr-gen-writers-int[Field(ctype) in {or orcm}],
pr-gen-writers-int[Field(ctype) in {or.andcm and.orcm}]
pr-readers-br br.call, br.cond, brl.call, brl.cond, br.ret, br.wexit, br.wtop, break.b, hint.b, nop.b,
ReservedBQP
pr-readers-nobr-nomovpr add, addl, addp4, adds, and, andcm, break.f, break.i, break.m, break.x, chk.s, chk-a, cmp,
cmp4, cmpxchg, czx, dep, extr, fp-arith, fp-non-arith, fc, fchkf, fclrf, fcmp, fetchadd,
fpcmp, fsetc, fwb, getf, hint.f, hint.i, hint.m, hint.x, invala-all, itc.i, itc.d, itr.i, itr.d, ld, ldf, ldfp,
lfetch-all, mf, mix, mov-from-AR-M, mov-from-AR-IM, mov-from-AR-I, mov-to-AR-M,
mov-to-AR-I, mov-to-AR-IM, mov-to-BR, mov-from-BR, mov-to-CR, mov-from-CR,
mov-to-IND, mov-from-IND, mov-ip, mov-to-PSR-l, mov-to-PSR-um, mov-from-PSR,
mov-from-PSR-um, movl, mux, nop.f, nop.i, nop.m, nop.x, or, pack, padd, pavg,
pavgsub, pcmp, pmax, pmin, pmpy, pmpyshr, popcnt, probe-all, psad, pshl, pshladd,
pshr, pshradd, psub, ptc.e, ptc.g, ptc.ga, ptc.l, ptr.d, ptr.i, ReservedQP, rsm, setf, shl,
shladd, shladdp4, shr, shrp, srlz.i, srlz.d, ssm, st, stf, sub, sum, sxt, sync, tak, tbit, tf, thash,
tnat, tpa, ttag, unpack, xchg, xma, xmpy, xor, zxt
pr-unc-writers-fp pr-gen-writers-fp[Field(ctype)==unc]11, fprcpa11, fprsqrta11, frcpa11, frsqrta11
pr-unc-writers-int pr-gen-writers-int[Field(ctype)==unc]11
pr-writers pr-writers-int, pr-writers-fp
pr-writers-fp pr-norm-writers-fp, pr-unc-writers-fp
pr-writers-int pr-norm-writers-int, pr-unc-writers-int, pr-and-writers, pr-or-writers
predicatable-instructions mov-from-PR, mov-to-PR, pr-readers-br, pr-readers-nobr-nomovpr
priv-ops mov-to-IND-priv, bsw, itc.i, itc.d, itr.i, itr.d, mov-to-CR, mov-from-CR, mov-to-PSR-l,
mov-from-PSR, mov-from-IND-priv, ptc.e, ptc.g, ptc.ga, ptc.l, ptr.i, ptr.d, rfi, rsm, ssm, tak,
tpa, vmsw
probe-all probe-fault, probe-nofault
probe-fault probe[Format in {M40}]
probe-nofault probe[Format in {M38 M39}]
psad psad1
pshl pshl2, pshl4
pshladd pshladd2
pshr pshr2, pshr4
pshradd pshradd2
psub psub1, psub2, psub4
ReservedBQP -15
ReservedQP -16
rse-readers alloc, br.call, br.ia, br.ret, brl.call, cover, flushrs, loadrs, mov-from-AR-BSP,
mov-from-AR-BSPSTORE, mov-to-AR-BSPSTORE, mov-from-AR-RNAT,
mov-to-AR-RNAT, rfi
rse-writers alloc, br.call, br.ia, br.ret, brl.call, cover, flushrs, loadrs, mov-to-AR-BSPSTORE, rfi
st st1, st2, st4, st8, st8.spill, st16
st-postinc stf[Format in {M10}], st[Format in {M5}]
stf stfs, stfd, stfe, stf8, stf.spill

3:376 Volume 3: Resource and Dependency Semantics


Table 5-5. Instruction Classes (Continued)
Class Events/Instructions
sxt sxt1, sxt2, sxt4
sys-mask-writers-partial rsm, ssm
unpack unpack1, unpack2, unpack4
unpredicatable-instructions alloc, br.cloop, br.ctop, br.cexit, br.ia, brp, bsw, clrrrb, cover, epc, flushrs, loadrs, rfi, vmsw
user-mask-writers-partial rum, sum
xchg xchg1, xchg2, xchg4, xchg8
zxt zxt1, zxt2, zxt4

Volume 3: Resource and Dependency Semantics 3:377


3:378 Volume 3: Resource and Dependency Semantics
Part II: IA-32 Instruction Set
Descriptions
3

Base IA-32 Instruction Reference 1

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.

For all IA-32 the following relationships hold:


• Writes – Writes of any IA-32 general purpose, floating-point or SSE, MMX technology
registers by IA-32 instructions are reflected in the Itanium registers defined to hold that IA-32
state when IA-32 instruction set completes execution.
• Reads – Reads of any IA-32 general purpose, floating-point or SSE, MMX technology
registers by IA-32 instructions see the state of the Itanium registers defined to hold the IA-32
state after entering the IA-32 instruction set.
• State mappings – IA-32 numeric instructions are controlled by and reflect their status in FCW,
FSW, FTW, FCS, FIP, FOP, FDS and FEA. On exit from the IA-32 instruction set, Itanium
numeric status and control resources defined to hold IA-32 state reflect the results of all IA-32
prior numeric instructions in FCR, FSR, FIR and FDR. Itanium numeric status and control
resources defined to hold IA-32 state are honored by IA-32 numeric instructions when entering
the IA-32 instruction set.

1.1 Additional Intel® Itanium® Faults


The following fault behavior is defined for all IA-32 instructions in the Itanium System
Environment:
• IA-32 Faults – All IA-32 faults are performed as defined in the IA-32 Intel® Architecture
Software Developer’s Manual, unless otherwise noted. IA-32 faults are delivered on the
IA_32_Exception interruption vector.
• IA-32 GPFault – Null segments are signified by the segment descriptor register’s P-bit being
set to zero. IA-32 memory references through DSD, ESD, FSD, and GSD with the P-bit set to
zero result in an IA-32 GPFault.
• Itanium Low FP Reg Fault – If PSR.dfl is 1, execution of any IA-32 MMX technology, SSE
or floating-point instructions results in a Disabled FP Register fault (regardless of whether
FR2-31 is referenced).

Volume 3: Base IA-32 Instruction Reference 3:381


• Itanium High FP Reg Fault – If PSR.dfh is 1, execution of the first target IA-32 instruction
following an br.ia or rfi results in a Disabled FP Register fault (regardless of whether
FR32-127 is referenced).
• Itanium Instruction Mem Faults – The following additional Itanium memory faults can be
generated on each virtual page referenced when fetching IA-32 or MMX technology or SSE
instructions for execution:
• Alternative instruction TLB fault
• VHPT instruction fault
• Instruction TLB fault
• Instruction Page Not Present fault
• Instruction NaT Page Consumption Abort
• Instruction Key Miss fault
• Instruction Key Permission fault
• Instruction Access Rights fault
• Instruction Access Bit fault
• Itanium Data Mem Faults – The following additional Itanium memory faults can be
generated on each virtual page touched when reading or writing memory operands from the
IA-32 instruction set including MMX technology and SSE instructions:
• Nested TLB fault
• Alternative data TLB fault
• VHPT data fault
• 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 Dirty bit fault
• Data Access bit fault

1.2 Interpreting the IA-32 Instruction Reference Pages


This section describes the information contained in the various sections of the instruction reference
pages that make up the majority of this chapter. It also explains the notational conventions and
abbreviations used in these sections.

1.2.1 IA-32 Instruction Format


The following is an example of the format used for each Intel architecture instruction description in
this chapter.

3:382 Volume 3: Base IA-32 Instruction Reference


CMC—Complement Carry Flag

Opcode Instruction Description


F5 CMC Complement carry flag

1.2.1.1 Opcode Column

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

1.2.1.2 Instruction Column

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.

Volume 3: Base IA-32 Instruction Reference 3:383


• rel16 and rel32 – A relative address within the same code segment as the instruction
assembled. The rel16 symbol applies to instructions with an operand-size attribute of 16 bits;
the rel32 symbol applies to instructions with an operand-size attribute of 32 bits.
• ptr16:16 and ptr16:32 – A far pointer, typically in a code segment different from that of the
instruction. The notation 16:16 indicates that the value of the pointer has two parts. The value
to the left of the colon is a 16-bit selector or value destined for the code segment register. The
value to the right corresponds to the offset within the destination segment. The ptr16:16
symbol is used when the instruction's operand-size attribute is 16 bits; the ptr16:32 symbol is
used when the operand-size attribute is 32 bits.
• r8 – One of the byte general-purpose registers AL, CL, DL, BL, AH, CH, DH, or BH.
• r16 – One of the word general-purpose registers AX, CX, DX, BX, SP, BP, SI, or DI.
• r32 – One of the doubleword general-purpose registers EAX, ECX, EDX, EBX, ESP, EBP,
ESI, or EDI.
• imm8 – An immediate byte value. The imm8 symbol is a signed number between –128 and
+127 inclusive. For instructions in which imm8 is combined with a word or doubleword
operand, the immediate value is sign-extended to form a word or doubleword. The upper byte
of the word is filled with the topmost bit of the immediate value.
• imm16 – An immediate word value used for instructions whose operand-size attribute is
16 bits. This is a number between –32,768 and +32,767 inclusive.
• imm32 – An immediate doubleword value used for instructions whose operand-size
attribute is 32 bits. It allows the use of a number between +2,147,483,647 and
-2,147,483,648 inclusive.
• r/m8 – A byte operand that is either the contents of a byte general-purpose register (AL, BL,
CL, DL, AH, BH, CH, and DH), or a byte from memory.
• r/m16 – A word general-purpose register or memory operand used for instructions whose
operand-size attribute is 16 bits. The word general-purpose registers are: AX, BX, CX, DX, SP,
BP, SI, and DI. The contents of memory are found at the address provided by the effective
address computation.
• r/m32 – A doubleword general-purpose register or memory operand used for instructions
whose operand-size attribute is 32 bits. The doubleword general-purpose registers are: EAX,
EBX, ECX, EDX, ESP, EBP, ESI, and EDI. The contents of memory are found at the address
provided by the effective address computation.
• m – A 16- or 32-bit operand in memory.
• m8 – A byte operand in memory, usually expressed as a variable or array name, but pointed to
by the DS:(E)SI or ES:(E)DI registers. This nomenclature is used only with the string
instructions and the XLAT instruction.
• m16 – A word operand in memory, usually expressed as a variable or array name, but pointed
to by the DS:(E)SI or ES:(E)DI registers. This nomenclature is used only with the string
instructions.
• m32 – A doubleword operand in memory, usually expressed as a variable or array name, but
pointed to by the DS:(E)SI or ES:(E)DI registers. This nomenclature is used only with the
string instructions.
• m64 – A memory quadword operand in memory. This nomenclature is used only with the
CMPXCHG8B instruction.
• m16:16, m16:32 – A memory operand containing a far pointer composed of two numbers. The
number to the left of the colon corresponds to the pointer's segment selector. The number to the
right corresponds to its offset.

3:384 Volume 3: Base IA-32 Instruction Reference


• m16&32, m16&16, m32&32 – A memory operand consisting of data item pairs whose sizes
are indicated on the left and the right side of the ampersand. All memory addressing modes are
allowed. The m16&16 and m32&32 operands are used by the BOUND instruction to provide
an operand containing an upper and lower bounds for array indices. The m16&32 operand is
used by LIDT and LGDT to provide a word with which to load the limit field, and a
doubleword with which to load the base field of the corresponding GDTR and IDTR registers.
• moffs8, moffs16, moffs32 – A simple memory variable (memory offset) of type byte, word, or
doubleword used by some variants of the MOV instruction. The actual address is given by a
simple offset relative to the segment base. No ModR/M byte is used in the instruction. The
number shown with moffs indicates its size, which is determined by the address-size attribute
of the instruction.
• Sreg – A segment register. The segment register bit assignments are ES=0, CS=1, SS=2,
DS=3, FS=4, and GS=5.
• m32real, m64real, m80real – A single-, double-, and extended-real (respectively)
floating-point operand in memory.
• m16int, m32int, m64int – A word-, short-, and long-integer (respectively) floating-point
operand in memory.
• ST or ST(0) – The top element of the FPU register stack.
• ST(i) – The ith element from the top of the FPU register stack. (i = 0 through 7).
• mm – An MMX technology register. The 64-bit MMX technology registers are: MM0 through
MM7.
• mm/m32 – The low order 32 bits of an MMX technology register or a 32-bit memory operand.
The 64-bit MMX technology registers are: MM0 through MM7. The contents of memory are
found at the address provided by the effective address computation.
• mm/m64 – An MMX technology register or a 64-bit memory operand. The 64-bit MMX
technology registers are: MM0 through MM7. The contents of memory are found at the
address provided by the effective address computation.

1.2.1.3 Description Column

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 “*)”.

Volume 3: Base IA-32 Instruction Reference 3:385


• Compound statements are enclosed in keywords, such as IF, THEN, ELSE, and FI for an if
statement, DO and OD for a do statement, or CASE... OF and ESAC for a case statement.
• A register name implies the contents of the register. A register name enclosed in brackets
implies the contents of the location whose address is contained in that register. For example,
ES:[DI] indicates the contents of the location whose ES segment relative address is in register
DI. [SI] indicates the contents of the address contained in register SI relative to SI’s default
segment (DS) or overridden segment.
• Parentheses around the “E” in a general-purpose register name, such as (E)SI, indicates that an
offset is read from the SI register if the current address-size attribute is 16 or is read from the
ESI register if the address-size attribute is 32.
• Brackets are also used for memory operands, where they mean that the contents of the memory
location is a segment-relative offset. For example, [SRC] indicates that the contents of the
source operand is a segment-relative offset.
• A ←B; indicates that the value of B is assigned to A.
• The symbols =, ≠, ≥, and ≤are relational operators used to compare two values, meaning equal,
not equal, greater or equal, less or equal, respectively. A relational expression such as A = B is
TRUE if the value of A is equal to B; otherwise it is FALSE.
• The expression “<< COUNT” and “>> COUNT” indicates that the destination operand should
be shifted left or right, respectively, by the number of bits indicated by the count operand.

The following identifiers are used in the algorithmic descriptions:


• OperandSize and AddressSize – The OperandSize identifier represents the operand-size
attribute of the instruction, which is either 16 or 32 bits. The AddressSize identifier represents
the address-size attribute, which is either 16 or 32 bits. For example, the following
pseudo-code indicates that the operand-size attribute depends on the form of the CMPS
instruction used.

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.

The following functions are used in the algorithmic descriptions:


• ZeroExtend(value) – Returns a value zero-extended to the operand-size attribute of the
instruction. For example, if the operand-size attribute is 32, zero extending a byte value of -10
converts the byte from F6H to a doubleword value of 000000F6H. If the value passed to the
ZeroExtend function and the operand-size attribute are the same size, ZeroExtend returns the
value unaltered.

3:386 Volume 3: Base IA-32 Instruction Reference


• SignExtend(value) – Returns a value sign-extended to the operand-size attribute of the
instruction. For example, if the operand-size attribute is 32, sign extending a byte containing
the value -10 converts the byte from F6H to a doubleword value of FFFFFFF6H. If the value
passed to the SignExtend function and the operand-size attribute are the same size, SignExtend
returns the value unaltered.
• SaturateSignedWordToSignedByte – Converts a signed 16-bit value to a signed 8-bit value.
If the signed 16-bit value is less than -128, it is represented by the saturated value -128 (80H);
if it is greater than 127, it is represented by the saturated value 127 (7FH).
• SaturateSignedDwordToSignedWord – Converts a signed 32-bit value to a signed 16-bit
value. If the signed 32-bit value is less than -32768, it is represented by the saturated value
-32768 (8000H); if it is greater than 32767, it is represented by the saturated value 32767
(7FFFH).
• SaturateSignedWordToUnsignedByte – Converts a signed 16-bit value to an unsigned 8-bit
value. If the signed 16-bit value is less than zero, it is represented by the saturated value zero
(00H); if it is greater than 255, it is represented by the saturated value 255 (FFH).
• SaturateToSignedByte – Represents the result of an operation as a signed 8-bit value. If the
result is less than -128, it is represented by the saturated value -128 (80H); if it is greater than
127, it is represented by the saturated value 127 (7FH).
• SaturateToSignedWord – Represents the result of an operation as a signed 16-bit value. If the
result is less than -32768, it is represented by the saturated value -32768 (8000H); if it is
greater than 32767, it is represented by the saturated value 32767 (7FFFH).
• SaturateToUnsignedByte – Represents the result of an operation as a signed 8-bit value. If the
result is less than zero it is represented by the saturated value zero (00H); if it is greater than
255, it is represented by the saturated value 255 (FFH).
• SaturateToUnsignedWord – Represents the result of an operation as a signed 16-bit value. If
the result is less than zero it is represented by the saturated value zero (00H); if it is greater
than 65535, it is represented by the saturated value 65535 (FFFFH).
• LowOrderWord(DEST * SRC) – Multiplies a word operand by a word operand and stores
the least significant word of the doubleword result in the destination operand.
• HighOrderWord(DEST * SRC) – Multiplies a word operand by a word operand and stores
the most significant word of the doubleword result in the destination operand.
• Push(value) – Pushes a value onto the stack. The number of bytes pushed is determined by the
operand-size attribute of the instruction.
• Pop() – Removes the value from the top of the stack and returns it. The statement EAX ←
Pop(); assigns to EAX the 32-bit value from the top of the stack. Pop will return either a word
or a doubleword depending on the operand-size attribute.
• PopRegisterStack – Marks the FPU ST(0) register as empty and increments the FPU register
stack pointer (TOP) by 1.
• Switch-Tasks – Performs a task switch.
• Bit(BitBase, BitOffset) – Returns the value of a bit within a bit string, which is a sequence of
bits in memory or a register. Bits are numbered from low-order to high-order within registers
and within memory bytes. If the base operand is a register, the offset can be in the range 0..31.
This offset addresses a bit within the indicated register. An example, the function Bit[EAX, 21]
is illustrated in Figure 1-1.

Volume 3: Base IA-32 Instruction Reference 3:387


Figure 1-1. Bit Offset for BIT[EAX,21]

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.

Figure 1-2. Memory Bit Indexing

7 5 0 7 0 7 0

BitBase +1 BitBase BitBase -1


BitOffset = +13

7 0 7 0 7 5 0

BitBase BitBase -1 BitBase -2


BitOffset = -11

1.2.3 Flags Affected


The “Flags Affected” section lists the flags in the EFLAGS register that are affected by the
instruction. When a flag is cleared, it is equal to 0; when it is set, it is equal to 1. The arithmetic and
logical instructions usually assign values to the status flags in a uniform manner (see Appendix A,
EFLAGS Cross-Reference, in the IA-32 Intel® Architecture Software Developer’s Manual, Volume
1). Non-conventional assignments are described in the “Operation” section. The values of flags
listed as undefined may be changed by the instruction in an indeterminate manner. Flags that are
not listed are unchanged by the instruction.

1.2.4 FPU Flags Affected


The floating-point instructions have an “FPU Flags Affected” section that describes how each
instruction can affect the four condition code flags of the FPU status word.

3:388 Volume 3: Base IA-32 Instruction Reference


1.2.5 Protected Mode Exceptions
The “Protected Mode Exceptions” section lists the exceptions that can occur when the instruction is
executed in protected mode and the reasons for the exceptions. Each exception is given a
mnemonic that consists of a pound sign (#) followed by two letters and an optional error code in
parentheses. For example, #GP(0) denotes a general protection exception with an error code of 0.
Table 1-2 associates each two-letter mnemonic with the corresponding interrupt vector number and
exception name. See Chapter 5, Interrupt and Exception Handling, in the IA-32 Intel® Architecture
Software Developer’s Manual, Volume 3, for a detailed description of the exceptions.

Application programmers should consult the documentation provided with their operating systems
to determine the actions taken when exceptions occur.

1.2.6 Real-address Mode Exceptions


The “Real-Address Mode Exceptions” section lists the exceptions that can occur when the
instruction is executed in real-address mode.

Table 1-2. Exception Mnemonics, Names, and Vector Numbers


Vector
Mnemonic Name Source
No.
0 #DE Divide Error DIV and IDIV instructions.
1 #DB Debug Any code or data reference.
3 #BP Breakpoint INT 3 instruction.
4 #OF Overflow INTO instruction.
5 #BR BOUND Range Exceeded BOUND instruction.
6 #UD Invalid Opcode (Undefined Opcode) UD2 instruction or reserved opcode.a
7 #NM Device Not Available (No Math Floating-point or WAIT/FWAIT instruction.
Coprocessor)
8 #DF Double Fault Any instruction that can generate an
exception, an NMI, or an INTR.
10 #TS Invalid TSS Task switch or TSS access.
11 #NP Segment Not Present Loading segment registers or accessing
system segments.
12 #SS Stack Segment Fault Stack operations and SS register loads.
13 #GP General Protection Any memory reference and other protection
checks.
14 #PF Page Fault Any memory reference.
16 #MF Floating-point Error (Math Fault) Floating-point or WAIT/FWAIT instruction.
17 #AC Alignment Check Any data reference in memory.b
18 #MC Machine Check Model dependent.c

a. The UD2 instruction was introduced in the Pentium® Pro processor.


b. This exception was introduced in the Intel® 486 processor.
c. This exception was introduced in the Pentium processor and enhanced in the Pentium Pro processor.

Volume 3: Base IA-32 Instruction Reference 3:389


1.2.7 Virtual-8086 Mode Exceptions
The “Virtual-8086 Mode Exceptions” section lists the exceptions that can occur when the
instruction is executed in virtual-8086 mode.

1.2.8 Floating-point Exceptions


The “Floating-point Exceptions” section lists additional exceptions that can occur when a
floating-point instruction is executed in any mode. All of these exception conditions result in a
floating-point error exception (#MF, vector number 16) being generated. Table 1-3 associates each
one- or two-letter mnemonic with the corresponding exception name. See “Floating-Point
Exception Conditions” in Chapter 7 of the IA-32 Intel® Architecture Software Developer’s Manual,
Volume 1, for a detailed description of these exceptions.

Table 1-3. Floating-point Exception Mnemonics and Names


Vector
Mnemonic Name Source
No.
16 Floating-point invalid operation:
#IS - Stack overflow or underflow - FPU stack overflow or underflow
#IA - Invalid arithmetic operation - Invalid FPU arithmetic operation
16 #Z Floating-point divide-by-zero FPU divide-by-zero
16 #D Floating-point denormalized operation Attempting to operate on a denormal
number
16 #O Floating-point numeric overflow FPU numeric overflow
16 #U Floating-point numeric underflow FPU numeric underflow
16 #P Floating-point inexact result (precision) Inexact result (precision)

1.3 IA-32 Base Instruction Reference


The remainder of this chapter provides detailed descriptions of each of the Intel architecture
instructions.

3:390 Volume 3: Base IA-32 Instruction Reference


AAA—ASCII Adjust After Addition
Opcode Instruction Description
37 AAA ASCII adjust AL after addition

Description

Adjusts the sum of two unpacked BCD values to create an unpacked BCD result. The AL register is
the implied source and destination operand for this instruction. The AAA instruction is only useful
when it follows an ADD instruction that adds (binary addition) two unpacked BCD values and
stores a byte result in the AL register. The AAA instruction then adjusts the contents of the AL
register to contain the correct 1-digit unpacked BCD result.

If the addition produces a decimal carry, the AH register 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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

Exceptions (All Operating Modes)

None.

Volume 3: Base IA-32 Instruction Reference 3:391


AAD—ASCII Adjust AX Before Division
Opcode Instruction Description
D5 0A AAD ASCII adjust AX before division

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

Exceptions (All Operating Modes)

None.

3:392 Volume 3: Base IA-32 Instruction Reference


AAM—ASCII Adjust AX After Multiply
Opcode Instruction Description
D4 0A AAM ASCII adjust AX after multiply

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

Exceptions (All Operating Modes)

None.

Volume 3: Base IA-32 Instruction Reference 3:393


AAS—ASCII Adjust AL After Subtraction
Opcode Instruction Description
3F AAS ASCII adjust AL after subtraction

Description

Adjusts the result of the subtraction of two unpacked BCD values to create a unpacked BCD result.
The AL register is the implied source and destination operand for this instruction. The AAS
instruction is only useful when it follows a SUB instruction that subtracts (binary subtraction) one
unpacked BCD value from another and stores a byte result in the AL register. The AAA instruction
then adjusts the contents of the AL register to contain the correct 1-digit unpacked BCD result.

If the subtraction produced a decimal carry, the AH register 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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

Exceptions (All Operating Modes)

None.

3:394 Volume 3: Base IA-32 Instruction Reference


ADC—Add with Carry
Opcode Instruction Description
14 ib ADC AL,imm8 Add with carry imm8 to AL
15 iw ADC AX,imm16 Add with carry imm16 to AX
15 id ADC EAX,imm32 Add with carry imm32 to EAX
80 /2 ib ADC r/m8,imm8 Add with carry imm8 to r/m8
81 /2 iw ADC r/m16,imm16 Add with carry imm16 to r/m16
81 /2 id ADC r/m32,imm32 Add with CF imm32 to r/m32
83 /2 ib ADC r/m16,imm8 Add with CF sign-extended imm8 to r/m16
83 /2 ib ADC r/m32,imm8 Add with CF sign-extended imm8 into r/m32
10 /r ADC r/m8,r8 Add with carry byte register to r/m8
11 /r ADC r/m16,r16 Add with carry r16 to r/m16
11 /r ADC r/m32,r32 Add with CF r32 to r/m32
12 /r ADC r8,r/m8 Add with carry r/m8 to byte register
13 /r ADC r16,r/m16 Add with carry r/m16 to r16
13 /r ADC r32,r/m32 Add with CF r/m32 to r32

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

DEST ←DEST + SRC + CF;

Flags Affected

The OF, SF, ZF, AF, CF, and PF flags are set according to the result.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: Base IA-32 Instruction Reference 3:395


ADC—Add with Carry (Continued)

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:396 Volume 3: Base IA-32 Instruction Reference


ADD—Add
Opcode Instruction Description
04 ib ADD AL,imm8 Add imm8 to AL
05 iw ADD AX,imm16 Add imm16 to AX
05 id ADD EAX,imm32 Add imm32 to EAX
80 /0 ib ADD r/m8,imm8 Add imm8 to r/m8
81 /0 iw ADD r/m16,imm16 Add imm16 to r/m16
81 /0 id ADD r/m32,imm32 Add imm32 to r/m32
83 /0 ib ADD r/m16,imm8 Add sign-extended imm8 to r/m16
83 /0 ib ADD r/m32,imm8 Add sign-extended imm8 to r/m32
00 /r ADD r/m8,r8 Add r8 to r/m8
01 /r ADD r/m16,r16 Add r16 to r/m16
01 /r ADD r/m32,r32 Add r32 to r/m32
02 /r ADD r8,r/m8 Add r/m8 to r8
03 /r ADD r16,r/m16 Add r/m16 to r16
03 /r ADD r32,r/m32 Add r/m32 to r32

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: Base IA-32 Instruction Reference 3:397


ADD—Add (Continued)

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#SS(0)If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:398 Volume 3: Base IA-32 Instruction Reference


AND—Logical AND
Opcode Instruction Description
24 ib AND AL,imm8 AL AND imm8
25 iw AND AX,imm16 AX AND imm16
25 id AND EAX,imm32 EAX AND imm32
80 /4 ib AND r/m8,imm8 r/m8 AND imm8
81 /4 iw AND r/m16,imm16 r/m16 AND imm16
81 /4 id AND r/m32,imm32 r/m32 AND imm32
83 /4 ib AND r/m16,imm8 r/m16 AND imm8
83 /4 ib AND r/m32,imm8 r/m32 AND imm8
20 /r AND r/m8,r8 r/m8 AND r8
21 /r AND r/m16,r16 r/m16 AND r16
21 /r AND r/m32,r32 r/m32 AND r32
22 /r AND r8,r/m8 r8 AND r/m8
23 /r AND r16,r/m16 r16 AND r/m16
23 /r AND r32,r/m32 r32 AND r/m32

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the destination operand points to a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.

Volume 3: Base IA-32 Instruction Reference 3:399


AND—Logical AND (Continued)
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:400 Volume 3: Base IA-32 Instruction Reference


ARPL—Adjust RPL Field of Segment Selector
Opcode Instruction Description
63 /r ARPL r/m16,r16 Adjust RPL of r/m16 to not less than RPL of r16

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: Base IA-32 Instruction Reference 3:401


ARPL—Adjust RPL Field of Segment Selector (Continued)

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#UD The ARPL instruction is not recognized in real address mode.

Virtual 8086 Mode Exceptions


#UD The ARPL instruction is not recognized in virtual 8086 mode.

3:402 Volume 3: Base IA-32 Instruction Reference


BOUND—Check Array Index Against Bounds
Opcode Instruction Description
62 /r BOUND r16,m16&16 Check if r16 (array index) is within bounds specified by m16&16
62 /r BOUND r32,m32&32 Check if r32 (array index) is within bounds specified by m16&16

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: Base IA-32 Instruction Reference 3:403


BOUND—Check Array Index Against Bounds (Continued)

Protected Mode Exceptions


#BR If the bounds test fails.
#UD If second operand is not a memory location.
#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 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.

Real Address Mode Exceptions


#BR If the bounds test fails.
#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#BR If the bounds test fails.
#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:404 Volume 3: Base IA-32 Instruction Reference


BSF—Bit Scan Forward
Opcode Instruction Description
0F BC BSF r16,r/m16 Bit scan forward on r/m16
0F BC BSF r32,r/m32 Bit scan forward on r/m32

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: Base IA-32 Instruction Reference 3:405


BSF—Bit Scan Forward (Continued)

Protected Mode Exceptions


#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 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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:406 Volume 3: Base IA-32 Instruction Reference


BSR—Bit Scan Reverse
Opcode Instruction Description
0F BD BSR r16,r/m16 Bit scan reverse on r/m16
0F BD BSR r32,r/m32 Bit scan reverse on r/m32

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: Base IA-32 Instruction Reference 3:407


BSR—Bit Scan Reverse (Continued)

Protected Mode Exceptions


#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 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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:408 Volume 3: Base IA-32 Instruction Reference


BSWAP—Byte Swap
Opcode Instruction Description
0F C8+rd BSWAP r32 Reverses the byte order of a 32-bit register.

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

Exceptions (All Operating Modes)

None.

Intel Architecture Compatibility Information

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.

Volume 3: Base IA-32 Instruction Reference 3:409


BT—Bit Test
Opcode Instruction Description
0F A3 BT r/m16,r16 Store selected bit in CF flag
0F A3 BT r/m32,r32 Store selected bit in CF flag
0F BA /4 ib BT r/m16,imm8 Store selected bit in CF flag
0F BA /4 ib BT r/m32,imm8 Store selected bit in CF flag

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.

3:410 Volume 3: Base IA-32 Instruction Reference


BT—Bit Test (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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 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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:411


BTC—Bit Test and Complement
Opcode Instruction Description
0F BB BTC r/m16,r16 Store selected bit in CF flag and complement
0F BB BTC r/m32,r32 Store selected bit in CF flag and complement
0F BA /7 ib BTC r/m16,imm8 Store selected bit in CF flag and complement
0F BA /7 ib BTC r/m32,imm8 Store selected bit in CF flag and complement

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

3:412 Volume 3: Base IA-32 Instruction Reference


BTC—Bit Test and Complement (Continued)

Protected Mode Exceptions


#GP(0) If the destination operand points to a non-writable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:413


BTR—Bit Test and Reset
Opcode Instruction Description
0F B3 BTR r/m16,r16 Store selected bit in CF flag and clear
0F B3 BTR r/m32,r32 Store selected bit in CF flag and clear
0F BA /6 ib BTR r/m16,imm8 Store selected bit in CF flag and clear
0F BA /6 ib BTR r/m32,imm8 Store selected bit in CF flag and clear

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

3:414 Volume 3: Base IA-32 Instruction Reference


BTR—Bit Test and Reset (Continued)

Protected Mode Exceptions


#GP(0) If the destination operand points to a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:415


BTS—Bit Test and Set
Opcode Instruction Description
0F AB BTS r/m16,r16 Store selected bit in CF flag and set
0F AB BTS r/m32,r32 Store selected bit in CF flag and set
0F BA /5 ib BTS r/m16,imm8 Store selected bit in CF flag and set
0F BA /5 ib BTS r/m32,imm8 Store selected bit in CF flag and set

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

3:416 Volume 3: Base IA-32 Instruction Reference


BTS—Bit Test and Set (Continued)

Protected Mode Exceptions


#GP(0) If the destination operand points to a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS 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.

Volume 3: Base IA-32 Instruction Reference 3:417


CALL—Call Procedure
Opcode Instruction Description
E8 cw CALL rel16 Call near, displacement relative to next instruction
E8 cd CALL rel32 Call near, displacement relative to next instruction
FF /2 CALL r/m16 Call near, r/m16 indirect
FF /2 CALL r/m32 Call near, r/m32 indirect
9A cd CALL ptr16:16 Call far, to full pointer given
9A cp CALL ptr16:32 Call far, to full pointer given
FF /3 CALL m16:16 Call far, address at r/m16
FF /3 CALL m16:32 Call far, address at r/m32

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.

This instruction can be used to execute four different types of calls:


• Near call – A call to a procedure within the current code segment (the segment currently
pointed to by the CS register), sometimes referred to as an intrasegment call.
• Far call – A call to a procedure located in a different segment than the current code segment,
sometimes referred to as an intersegment call.
• Inter-privilege-level far call – A far call to a procedure in a segment at a different privilege
level than that of the currently executing program or procedure. Results in an
IA-32_Intercept(Gate) in Itanium System Environment.
• Task switch – A call to a procedure located in a different task. Results in an
IA-32_Intercept(Gate) in Itanium System Environment.

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.

3:418 Volume 3: Base IA-32 Instruction Reference


CALL—Call Procedure (Continued)
When executing a near call, 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 calls.

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).

Volume 3: Base IA-32 Instruction Reference 3:419


CALL—Call Procedure (Continued)
Executing a task switch with the CALL instruction, is similar to executing a call through a call gate.
Here the target operand specifies the segment selector of the task gate for the task being switched to
and the address of the procedure being called in the task. The task gate in turn points to the TSS for
the task, which contains the segment selectors for the task’s code and stack segments. The CALL
instruction can also specify the segment selector of the TSS directly. See the IA-32 Intel®
Architecture Software Developer’s Manual, Volume 3 the for detailed information on the mechanics
of a task switch.

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);

3:420 Volume 3: Base IA-32 Instruction Reference


CALL—Call Procedure (Continued)

CS ←DEST[31:16]; (* DEST is ptr16:16 or [m16:16] *)


EIP ←DEST[15:0]; (* DEST is ptr16:16 or [m16:16] *)
EIP ←EIP 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 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)

Volume 3: Base IA-32 Instruction Reference 3:421


CALL—Call Procedure (Continued)

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;

3:422 Volume 3: Base IA-32 Instruction Reference


CALL—Call Procedure (Continued)

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 *)

Volume 3: Base IA-32 Instruction Reference 3:423


CALL—Call Procedure (Continued)

IF stack does not have room for parameters plus 4 bytes


THEN #SS(0); FI;
IF IP not within code segment limit THEN #GP(0); FI;
CS:IP ←CallGate(CS:instruction pointer)
(* segment descriptor information also loaded *)
Push(oldCS:oldIP); (* return address to calling procedure *)
FI;
CS(RPL) ←CPL
END;

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;

3:424 Volume 3: Base IA-32 Instruction Reference


CALL—Call Procedure (Continued)

Flags Affected

All flags are affected if a task switch occurs; no flags are affected if a task switch does not occur.

Additional Itanium System Environment Exceptions


Itanium Mem Faults VHPT 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
IA-32_Intercept Gate Intercept for CALLs through CALL Gates, Task Gates and Task
Segments
IA_32_Exception Taken Branch Debug Exception if PSR.tb is 1

Protected Mode Exceptions


#GP(0) If target offset in destination operand is beyond the new code segment limit.
If the segment selector in the destination operand is null.
If the code segment selector in the gate is null.
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.
#GP(selector) If code segment or gate or TSS selector index is outside descriptor table
limits.
If the segment descriptor pointed to by the segment selector in the destination
operand is not for a conforming-code segment, nonconforming-code
segment, call gate, task gate, or task state segment.
If the DPL for a nonconforming-code segment is not equal to the CPL or the
RPL for the segment’s segment selector is greater than the CPL.
If the DPL for a conforming-code segment is greater than the CPL.
If the DPL from a call-gate, task-gate, or TSS segment descriptor is less than
the CPL or than the RPL of the call-gate, task-gate, or TSS’s segment selector.
If the segment descriptor for a segment selector from a call gate does not
indicate it is a code segment.
If the segment selector from a call gate is beyond the descriptor table limits.
If the DPL for a code-segment obtained from a call gate is greater than the
CPL.
If the segment selector for a TSS has its local/global bit set for local.
If a TSS segment descriptor specifies that the TSS is busy or not available.
#SS(0) If pushing the return address, parameters, or stack segment pointer onto the
stack exceeds the bounds of the stack segment, when no stack switch occurs.
If a memory operand effective address is outside the SS segment limit.

Volume 3: Base IA-32 Instruction Reference 3:425


CALL—Call Procedure (Continued)
#SS(selector) If pushing the return address, parameters, or stack segment pointer onto the
stack exceeds the bounds of the stack segment, when a stack switch occurs.
If the SS register is being loaded as part of a stack switch and the segment
pointed to is marked not present.
If stack segment does not have room for the return address, parameters, or
stack segment pointer, when stack switch occurs.
#NP(selector) If a code segment, data segment, stack segment, call gate, task gate, or TSS
is not present.
#TS(selector) If the new stack segment selector and ESP are beyond the end of the TSS.
If the new stack segment selector is null.
If the RPL of the new stack segment selector in the TSS is not equal to the
DPL of the code segment being accessed.
If DPL of the stack segment descriptor for the new stack segment is not equal
to the DPL of the code segment descriptor.
If the new stack segment is not a writable data segment.
If segment-selector index for stack segment is outside descriptor table limits.
#PF(fault-code) If a page fault occurs.
#AC(0) If an unaligned memory access occurs when the CPL is 3 and alignment
checking is enabled.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the target offset is beyond the code segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the target offset is beyond the code segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If an unaligned memory access occurs when alignment checking is enabled.

3:426 Volume 3: Base IA-32 Instruction Reference


CBW/CWDE—Convert Byte to Word/Convert Word to Doubleword
Opcode Instruction Description
98 CBW AX ←sign-extend of AL
98 CWDE EAX ←sign-extend of AX

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

Exceptions (All Operating Modes)

None.

Volume 3: Base IA-32 Instruction Reference 3:427


CDQ—Convert Double to Quad
See entry for CWD/CDQ — Convert Word to Double/Convert Double to Quad.

3:428 Volume 3: Base IA-32 Instruction Reference


CLC—Clear Carry Flag
Opcode Instruction Description
F8 CLC Clear CF flag

Description

Clears the CF flag in the EFLAGS register.

Operation
CF ←0;

Flags Affected

The CF flag is cleared to 0. The OF, ZF, SF, AF, and PF flags are unaffected.

Exceptions (All Operating Modes)

None.

Volume 3: Base IA-32 Instruction Reference 3:429


CLD—Clear Direction Flag
Opcode Instruction Description
FC CLD Clear DF flag

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.

Exceptions (All Operating Modes)

None.

3:430 Volume 3: Base IA-32 Instruction Reference


CLI—Clear Interrupt Flag
Opcode Instruction Description
FA CLI Clear interrupt flag; interrupts disabled when interrupt flag
cleared

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;

Volume 3: Base IA-32 Instruction Reference 3:431


CLI—Clear Interrupt Flag (Continued)

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept System Flag Intercept Trap if CFLG.ii is 1 and the IF flag changes state.

Protected Mode Exceptions


#GP(0) If the CPL is greater (has less privilege) than the IOPL of the current program
or procedure.

Real Address Mode Exceptions

None.

Virtual 8086 Mode Exceptions


#GP(0) If the CPL is greater (has less privilege) than the IOPL of the current program
or procedure.

3:432 Volume 3: Base IA-32 Instruction Reference


CLTS—Clear Task-Switched Flag in CR0
Opcode Instruction Description
0F 06 CLTS Clears TS flag in CR0

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

The TS flag in CR0 register is cleared.

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept fault.

Protected Mode Exceptions


#GP(0) If the CPL is greater than 0.

Real Address Mode Exceptions

None.

Virtual 8086 Mode Exceptions


#GP(0) If the CPL is greater than 0.

Volume 3: Base IA-32 Instruction Reference 3:433


CMC—Complement Carry Flag
Opcode Instruction Description
F5 CMC Complement CF flag

Description

Complements the CF flag in the EFLAGS register.

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.

Exceptions (All Operating Modes)

None.

3:434 Volume 3: Base IA-32 Instruction Reference


CMOVcc—Conditional Move
Opcode Instruction Description
0F 47 cw/cd CMOVA r16, r/m16 Move if above (CF=0 and ZF=0)
0F 47 cw/cd CMOVA r32, r/m32 Move if above (CF=0 and ZF=0)
0F 43 cw/cd CMOVAE r16, r/m16 Move if above or equal (CF=0)
0F 43 cw/cd CMOVAE r32, r/m32 Move if above or equal (CF=0)
0F 42 cw/cd CMOVB r16, r/m16 Move if below (CF=1)
0F 42 cw/cd CMOVB r32, r/m32 Move if below (CF=1)
0F 46 cw/cd CMOVBE r16, r/m16 Move if below or equal (CF=1 or ZF=1)
0F 46 cw/cd CMOVBE r32, r/m32 Move if below or equal (CF=1 or ZF=1)
0F 42 cw/cd CMOVC r16, r/m16 Move if carry (CF=1)
0F 42 cw/cd CMOVC r32, r/m32 Move if carry (CF=1)
0F 44 cw/cd CMOVE r16, r/m16 Move if equal (ZF=1)
0F 44 cw/cd CMOVE r32, r/m32 Move if equal (ZF=1)
0F 4F cw/cd CMOVG r16, r/m16 Move if greater (ZF=0 and SF=OF)
0F 4F cw/cd CMOVG r32, r/m32 Move if greater (ZF=0 and SF=OF)
0F 4D cw/cd CMOVGE r16, r/m16 Move if greater or equal (SF=OF)
0F 4D cw/cd CMOVGE r32, r/m32 Move if greater or equal (SF=OF)
0F 4C cw/cd CMOVL r16, r/m16 Move if less (SF<>OF)
0F 4C cw/cd CMOVL r32, r/m32 Move if less (SF<>OF)
0F 4E cw/cd CMOVLE r16, r/m16 Move if less or equal (ZF=1 or SF<>OF)
0F 4E cw/cd CMOVLE r32, r/m32 Move if less or equal (ZF=1 or SF<>OF)
0F 46 cw/cd CMOVNA r16, r/m16 Move if not above (CF=1 or ZF=1)
0F 46 cw/cd CMOVNA r32, r/m32 Move if not above (CF=1 or ZF=1)
0F 42 cw/cd CMOVNAE r16, r/m16 Move if not above or equal (CF=1)
0F 42 cw/cd CMOVNAE r32, r/m32 Move if not above or equal (CF=1)
0F 43 cw/cd CMOVNB r16, r/m16 Move if not below (CF=0)
0F 43 cw/cd CMOVNB r32, r/m32 Move if not below (CF=0)
0F 47 cw/cd CMOVNBE r16, r/m16 Move if not below or equal (CF=0 and ZF=0)
0F 47 cw/cd CMOVNBE r32, r/m32 Move if not below or equal (CF=0 and ZF=0)
0F 43 cw/cd CMOVNC r16, r/m16 Move if not carry (CF=0)
0F 43 cw/cd CMOVNC r32, r/m32 Move if not carry (CF=0)
0F 45 cw/cd CMOVNE r16, r/m16 Move if not equal (ZF=0)
0F 45 cw/cd CMOVNE r32, r/m32 Move if not equal (ZF=0)
0F 4E cw/cd CMOVNG r16, r/m16 Move if not greater (ZF=1 or SF<>OF)
0F 4E cw/cd CMOVNG r32, r/m32 Move if not greater (ZF=1 or SF<>OF)
0F 4C cw/cd CMOVNGE r16, r/m16 Move if not greater or equal (SF<>OF)
0F 4C cw/cd CMOVNGE r32, r/m32 Move if not greater or equal (SF<>OF)
0F 4D cw/cd CMOVNL r16, r/m16 Move if not less (SF=OF)
0F 4D cw/cd CMOVNL r32, r/m32 Move if not less (SF=OF)
0F 4F cw/cd CMOVNLE r16, r/m16 Move if not less or equal (ZF=0 and SF=OF)
0F 4F cw/cd CMOVNLE r32, r/m32 Move if not less or equal (ZF=0 and SF=OF)

Volume 3: Base IA-32 Instruction Reference 3:435


CMOVcc—Conditional Move (Continued)
Opcode Instruction Description
0F 41 cw/cd CMOVNO r16, r/m16 Move if not overflow (OF=0)
0F 41 cw/cd CMOVNO r32, r/m32 Move if not overflow (OF=0)
0F 4B cw/cd CMOVNP r16, r/m16 Move if not parity (PF=0)
0F 4B cw/cd CMOVNP r32, r/m32 Move if not parity (PF=0)
0F 49 cw/cd CMOVNS r16, r/m16 Move if not sign (SF=0)
0F 49 cw/cd CMOVNS r32, r/m32 Move if not sign (SF=0)
0F 45 cw/cd CMOVNZ r16, r/m16 Move if not zero (ZF=0)
0F 45 cw/cd CMOVNZ r32, r/m32 Move if not zero (ZF=0)
0F 40 cw/cd CMOVO r16, r/m16 Move if overflow (OF=0)
0F 40 cw/cd CMOVO r32, r/m32 Move if overflow (OF=0)
0F 4A cw/cd CMOVP r16, r/m16 Move if parity (PF=1)
0F 4A cw/cd CMOVP r32, r/m32 Move if parity (PF=1)
0F 4A cw/cd CMOVPE r16, r/m16 Move if parity even (PF=1)
0F 4A cw/cd CMOVPE r32, r/m32 Move if parity even (PF=1)
0F 4B cw/cd CMOVPO r16, r/m16 Move if parity odd (PF=0)
0F 4B cw/cd CMOVPO r32, r/m32 Move if parity odd (PF=0)
0F 48 cw/cd CMOVS r16, r/m16 Move if sign (SF=1)
0F 48 cw/cd CMOVS r32, r/m32 Move if sign (SF=1)
0F 44 cw/cd CMOVZ r16, r/m16 Move if zero (ZF=1)
0F 44 cw/cd CMOVZ r32, r/m32 Move if zero (ZF=1)

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.

3:436 Volume 3: Base IA-32 Instruction Reference


CMOVcc—Conditional Move (Continued)
The CMOVcc instructions are new for the Pentium Pro processor family; however, they may not be
supported by all the processors in the family. Software can determine if the CMOVcc instructions
are supported by checking the processor’s feature information with the CPUID instruction (see
“CPUID—CPU Identification” on page 0:448).

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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 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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Volume 3: Base IA-32 Instruction Reference 3:437


CMOVcc—Conditional Move (Continued)

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:438 Volume 3: Base IA-32 Instruction Reference


CMP—Compare Two Operands
Opcode Instruction Description
3C ib CMP AL, imm8 Compare imm8 with AL
3D iw CMP AX, imm16 Compare imm16 with AX
3D id CMP EAX, imm32 Compare imm32 with EAX
80 /7 ib CMP r/m8, imm8 Compare imm8 with r/m8
81 /7 iw CMP r/m16, imm16 Compare imm16 with r/m16
81 /7 id CMP r/m32,imm32 Compare imm32 with r/m32
83 /7 ib CMP r/m16,imm8 Compare imm8 with r/m16
83 /7 ib CMP r/m32,imm8 Compare imm8 with r/m32
38 /r CMP r/m8,r8 Compare r8 with r/m8
39 /r CMP r/m16,r16 Compare r16 with r/m16
39 /r CMP r/m32,r32 Compare r32 with r/m32
3A /r CMP r8,r/m8 Compare r/m8 with r8
3B /r CMP r16,r/m16 Compare r/m16 with r16
3B /r CMP r32,r/m32 Compare r/m32 with r32

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: Base IA-32 Instruction Reference 3:439


CMP—Compare Two Operands (Continued)

Protected Mode Exceptions


#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 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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:440 Volume 3: Base IA-32 Instruction Reference


CMPS/CMPSB/CMPSW/CMPSD—Compare String Operands
Opcode Instruction Description
A6 CMPS DS:(E)SI, ES:(E)DI Compares byte at address DS:(E)SI with byte at address
ES:(E)DI and sets the status flags accordingly
A7 CMPS DS:SI, ES:DI Compares byte at address DS:SI with byte at address
ES:DI and sets the status flags accordingly
A7 CMPS DS:ESI, ES:EDI Compares byte at address DS:ESI with byte at address
ES:EDI and sets the status flags accordingly
A6 CMPSB Compares byte at address DS:(E)SI with byte at address
ES:(E)DI and sets the status flags accordingly
A7 CMPSW Compares byte at address DS:SI with byte at address
ES:DI and sets the status flags accordingly
A7 CMPSD Compares byte at address DS:ESI with byte at address
ES:EDI and sets the status flags accordingly

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.

Volume 3: Base IA-32 Instruction Reference 3:441


CMPS/CMPSB/CMPSW/CMPSD—Compare String Operands (Continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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 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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

3:442 Volume 3: Base IA-32 Instruction Reference


CMPS/CMPSB/CMPSW/CMPSD—Compare String Operands (Continued)

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:443


CMPXCHG—Compare and Exchange
Opcode Instruction Description
0F B0/r CMPXCHG r/m8,r8 Compare AL with r/m8. If equal, ZF is set and r8 is loaded into
r/m8. Else, clear ZF and load r/m8 into AL.
0F B1/r CMPXCHG r/m16,r16 Compare AX with r/m16. If equal, ZF is set and r16 is loaded
into r/m16. Else, clear ZF and load r/m16 into AL
0F B1/r CMPXCHG r/m32,r32 Compare EAX with r/m32. If equal, ZF is set and r32 is loaded
into r/m32. Else, clear ZF and load r/m32 into AL

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*)

IF Itanium System Environment AND External_Atomic_Lock_Required AND DCR.lc


THEN IA-32_Intercept(LOCK,CMPXCHG);
IF accumulator = DEST
THEN
ZF ←1
DEST ←SRC
ELSE
ZF ←0
accumulator ←DEST
FI;

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.

3:444 Volume 3: Base IA-32 Instruction Reference


CMPXCHG—Compare and Exchange (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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
IA-32_Intercept Lock Intercept – If an external atomic bus lock is required to complete this
operation and DCR.lc is 1, no atomic transaction occurs, this instruction is
faulted and an IA-32_Intercept(Lock) fault is generated. The software lock
handler is responsible for the emulation of this instruction.

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Intel Architecture Compatibility

This instruction is not supported on Intel processors earlier than the Intel486 processors.

Volume 3: Base IA-32 Instruction Reference 3:445


CMPXCHG8B—Compare and Exchange 8 Bytes
Opcode Instruction Description
0F C7 /1 m64 CMPXCHG8B m64 Compare EDX:EAX with m64. If equal, set ZF and load
ECX:EBX into m64. Else, clear ZF and load m64 into
EDX:EAX.

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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
IA-32_Intercept Lock Intercept – If an external atomic bus lock is required to complete this
operation and DCR.lc is 1, no atomic transaction occurs, this instruction is
faulted and an IA-32_Intercept(Lock) fault is generated. The software lock
handler is responsible for the emulation of this instruction

3:446 Volume 3: Base IA-32 Instruction Reference


CMPXCHG8B—Compare and Exchange 8 Bytes (Continued)

Protected Mode Exceptions


#UD If the destination operand is not a memory location.
#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Intel Architecture Compatibility

This instruction is not supported on Intel processors earlier than the Pentium processors.

Volume 3: Base IA-32 Instruction Reference 3:447


CPUID—CPU Identification
Opcode Instruction Description
0F A2 CPUID Returns processor identification and feature information in the
EAX, EBX, ECX, and EDX registers, according to the input
value entered initially in the EAX register.

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.

Table 1-4. Information Returned by CPUID Instruction


Initial EAX Value Information Provided about the Processor
Basic CPUID Information
0 EAX Maximum CPUID Input Value
EBX 756E6547H “Genu” (G in BL)
ECX 6C65746EH “ntel” (n in CL)
EDX 49656E69H “ineI” (i in DL)
1H EAX Version Information (Type, Family, Model, and Stepping ID)
EBX Bits 7-0: Brand Indexa
Bits 15-8: CLFLUSH line size (Value * 8 = cache line size in bytes)
Bits 23-16: Number of logical processors per physical processor
Bits 31-24: Local APIC IDb
ECX Reserved
EDX Feature Information (see Table 1-5)
2H EAX Cache and TLB Information
EBX Cache and TLB Information
ECX Cache and TLB Information
EDX Cache and TLB Information

3:448 Volume 3: Base IA-32 Instruction Reference


Table 1-4. Information Returned by CPUID Instruction
Initial EAX Value Information Provided about the Processor
Extended Function CPUID Information
8000000H EAX Maximum Input Value for Extended Function CPUID Information
EBX Reserved
ECX Reserved
EDX Reserved
8000001H EAX Extended Processor Signature and Extended Feature Bits. (Currently
reserved.)
EBX Reserved
ECX Reserved
EDX Reserved
8000002H EAX Processor Brand String
EBX Processor Brand String Continued
ECX Processor Brand String Continued
EDX Processor Brand String Continued
8000003H EAX Processor Brand String Continued
EBX Processor Brand String Continued
ECX Processor Brand String Continued
EDX Processor Brand String Continued
a. This field is not supported for processors based on Itanium architecture, zero (unsupported encoding) is
returned.
b. This field is invalid for processors based on Itanium architecture, reserved value is returned.

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.

Figure 1-3. Version Information in Registers EAX

31 28 27 20 19 16 15 14 13 12 11 8 7 43 0

Extended Family Extended Stepping


EAX Family Model
Model ID

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.

Volume 3: Base IA-32 Instruction Reference 3:449


CPUID—CPU Identification (Continued)
When the input value in EAX is 1, three unrelated pieces of information are returned to the EBX
register:
• Brand index (low byte of EBX) – this number provides an entry into a brand string table that
contains brand strings for IA-32 processors. Please refer to AP-485, Intel® Processor
Identification and the CPUID Instruction (Order Number 241618) for information on brand
indices.
Note:The Brand index field is not supported for processors based on Itanium architecture,
zero (unsupported encoding) is returned.
• CLFLUSH instruction cache line size (second byte of EBX) – this number indicates the size of
the cache line flushed with CLFLUSH instruction in 8-byte increments. This field is valid only
when the CLFSH feature flag is set.
• Local APIC ID (high byte of EBX) – this number is the 8-bit ID that is assigned to the local
APIC on the processor during power up.
Note:The local APIC ID field is invalid for processors based on the Itanium architecture,
reserved value is returned. Software should check the feature flags to make sure
they are not running on processors based on the Itanium architecture before inter-
preting the return value in this field.

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.

Table 1-5. Feature Flags Returned in EDX Register


Bit Mnemonic Description
0 FPU Floating Point Unit On-Chip. The processor contains an x87 FPU.
1 VME Virtual 8086 Mode Enhancements. Virtual 8086 mode
enhancements, including CR4.VME for controlling the feature,
CR4.PVI for protected mode virtual interrupts, software interrupt
indirection, expansion of the TSS with the software indirection bitmap,
and EFLAGS.VIF and EFLAGS.VIP flags.
2 DE Debugging Extensions. Support for I/O breakpoints, including
CR4.DE for controlling the feature, and optional trapping of accesses
to DR4 and DR5.
3 PSE Page Size Extension. Large pages of size 4Mbyte are supported,
including CR4.PSE for controlling the feature, the defined dirty bit in
PDE (Page Directory Entries), optional reserved bit trapping in CR3,
PDEs, and PTEs.
4 TSC Time Stamp Counter. The RDTSC instruction is supported, including
CR4.TSD for controlling privilege.
5 MSR Model Specific Registers RDMSR and WRMSR Instructions. The
RDMSR and WRMSR instructions are supported. Some of the MSRs
are implementation dependent.

3:450 Volume 3: Base IA-32 Instruction Reference


Table 1-5. Feature Flags Returned in EDX Register (Continued)
Bit Mnemonic Description
6 PAE Physical Address Extension. Physical addresses greater than 32
bits are supported: extended page table entry formats, an extra level
in the page translation tables is defined, 2 Mbyte pages are supported
instead of 4 Mbyte pages if PAE bit is 1. The actual number of address
bits beyond 32 is not defined, and is implementation specific.
7 MCE Machine Check Exception. Exception 18 is defined for Machine
Checks, including CR4.MCE for controlling the feature. This feature
does not define the model-specific implementations of machine-check
error logging, reporting, and processor shutdowns. Machine Check
exception handlers may have to depend on processor version to do
model-specific processing of the exception, or test for the presence of
the Machine Check feature.
8 CX8 CMPXCHG8B Instruction. The compare-and-exchange 8 bytes (64
bits) instruction is supported (implicitly locked and atomic).
9 APIC APIC On-Chip. The processor contains an Advanced Programmable
Interrupt Controller (APIC), responding to memory mapped
commands in the physical address range FFFE0000H to FFFE0FFFH
(by default – some processors permit the APIC to be relocated).
10 Reserved Reserved.
11 SEP SYSENTER and SYSEXIT Instructions. The SYSENTER and
SYSEXIT and associated MSRs are supported.
12 MTRR Memory Type Range Registers. MTRRs are supported. The
MTRRcap MSR contains feature bits that describe what memory
types are supported, how many variable MTRRs are supported, and
whether fixed MTRRs are supported.
13 PGE PTE Global Bit. The global bit in page directory entries (PDEs) and
page table entries (PTEs) is supported, indicating TLB entries that are
common to different processes and need not be flushed. The
CR4.PGE bit controls this feature.
14 MCA Machine Check Architecture. The Machine Check Architecture,
which provides a compatible mechanism for error reporting is
supported. The MCG_CAP MSR contains feature bits describing how
many banks of error reporting MSRs are supported.
15 CMOV Conditional Move Instructions. The conditional move instruction
CMOV is supported. In addition, if x87 FPU is present as indicated by
the CPUID.FPU feature bit, then the FCOMI and FCMOV instructions
are supported.
16 PAT Page Attribute Table. Page Attribute Table is supported. This feature
augments the Memory Type Range Registers (MTRRs), allowing an
operating system to specify attributes of memory on a 4K granularity
through a linear address.
17 PSE-36 32-Bit Page Size Extension. Extended 4-MByte pages that are
capable of addressing physical memory beyond 4 GBytes are
supported. This feature indicates that the upper four bits of the
physical address of the 4-MByte page is encoded by bits 13-16 of the
page directory entry.
18 PSN Processor Serial Number. The processor supports the 96-bit
processor identification number feature and the feature is enabled.
19 CLFSH CLFLUSH Instruction. CLFLUSH Instruction is supported.
20 NX Execute Disable Bit.
21 DS Debug Store. The processor supports the ability to write debug
information into a memory resident buffer. This feature is used by the
branch trace store (BTS) and precise event-based sampling (PEBS)
facilities.

Volume 3: Base IA-32 Instruction Reference 3:451


Table 1-5. Feature Flags Returned in EDX Register (Continued)
Bit Mnemonic Description
22 ACPI Thermal Monitor and Software Controlled Clock Facilities. The
processor implements internal MSRs that allow processor
temperature to be monitored and processor performance to be
modulated in predefined duty cycles under software control.
23 MMX Intel MMX Technology. The processor supports the Intel MMX
technology.
24 FXSR FXSAVE and FXRSTOR Instructions. The FXSAVE and FXRSTOR
instructions are supported for fast save and restore of the floating
point context. Presence of this bit also indicates that CR4.OSFXSR is
available for an operating system to indicate that it supports the
FXSAVE and FXRSTOR instructions
25 SSE SSE. The processor supports the SSE extensions.
26 SSE2 SSE2. The processor supports the SSE2 extensions.
27 SS Self Snoop. The processor supports the management of conflicting
memory types by performing a snoop of its own cache structure for
transactions issued to the bus.
28 HTT Hyper-Threading Technology. The processor implements
Hyper-Threading technology.
29 TM Thermal Monitor. The processor implements the thermal monitor
automatic thermal control circuitry (TCC).
30 Processor based on the Intel The processor is based on the Intel Itanium architecture and is
Itanium architecture capable of executing the Intel Itanium instruction set. IA-32 application
level software MUST also check with the running operating system to
see if the system can also support Itanium architecture-based code
before switching to the Intel Itanium instruction set.
31 PBE Pending Break Enable. The processor supports the use of the
FERR#/PBE# pin when the processor is in the stop-clock state
(STPCLK# is asserted) to signal the processor that an interrupt is
pending and that the processor should return to normal operation to
handle the interrupt. Bit 10 (PBE enable) in the IA32_MISC_ENABLE
MSR enables this capability.

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.

CPUID performs instruction serialization and a memory fence operation.

3:452 Volume 3: Base IA-32 Instruction Reference


CPUID—CPU Identification (Continued)

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;

Volume 3: Base IA-32 Instruction Reference 3:453


EDX ←Processor Name;
BREAK;
DEFAULT: (* EAX > highest value recognized by CPUID *)
EAX ←Reserved, Undefined;
EBX ←Reserved, Undefined;
ECX ←Reserved, Undefined;
EDX ←Reserved, Undefined;
BREAK;
ESAC;

memory_fence();
instruction_serialize();

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

Exceptions (All Operating Modes)

None.

Intel Architecture Compatibility

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.

3:454 Volume 3: Base IA-32 Instruction Reference


CWD/CDQ—Convert Word to Doubleword/Convert Doubleword to
Quadword
Opcode Instruction Description
99 CWD DX:AX ←sign-extend of AX
99 CDQ EDX:EAX ←sign-extend of EAX

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;

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

Flags Affected

None.

Exceptions (All Operating Modes)

None.

Volume 3: Base IA-32 Instruction Reference 3:455


CWDE—Convert Word to Doubleword
See entry for CBW/CWDE—Convert Byte to Word/Convert Word to Doubleword.

3:456 Volume 3: Base IA-32 Instruction Reference


DAA—Decimal Adjust AL after Addition
Opcode Instruction Description
27 DAA Decimal adjust AL after addition

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

ADD AL, BL Before: AL=79H BL=35H EFLAGS(OSZAPC)=XXXXXX


After: AL=AEH BL=35H EFLAGS(0SZAPC)=110000
DAA Before: AL=79H BL=35H EFLAGS(OSZAPC)=110000
After: AL=AEH BL=35H EFLAGS(0SZAPC)=X00111

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

Exceptions (All Operating Modes)

None.

Volume 3: Base IA-32 Instruction Reference 3:457


DAS—Decimal Adjust AL after Subtraction
Opcode Instruction Description
2F DAS Decimal adjust AL after subtraction

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

SUB AL, BL Before: AL=35H BL=47H EFLAGS(OSZAPC)=XXXXXX


After: AL=EEH BL=47H EFLAGS(0SZAPC)=010111
DAA Before: AL=EEH BL=47H EFLAGS(OSZAPC)=010111
After: AL=88H BL=47H EFLAGS(0SZAPC)=X10111

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

Exceptions (All Operating Modes)

None.

3:458 Volume 3: Base IA-32 Instruction Reference


DEC—Decrement by 1
Opcode Instruction Description
FE /1 DEC r/m8 Decrement r/m8 by 1
FF /1 DEC r/m16 Decrement r/m16 by 1
FF /1 DEC r/m32 Decrement r/m32 by 1
48+rw DEC r16 Decrement r16 by 1
48+rd DEC r32 Decrement r32 by 1

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Volume 3: Base IA-32 Instruction Reference 3:459


DEC—Decrement by 1 (Continued)

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:460 Volume 3: Base IA-32 Instruction Reference


DIV—Unsigned Divide
Opcode Instruction Description
F6 /6 DIV r/m8 Unsigned divide AX by r/m8; AL ←Quotient,
AH ←Remainder
F7 /6 DIV r/m16 Unsigned divide DX:AX by r/m16; AX ←Quotient,
DX ←Remainder
F7 /6 DIV r/m32 Unsigned divide EDX:EAX by r/m32 doubleword;
EAX ←Quotient, EDX ←Remainder

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;

Volume 3: Base IA-32 Instruction Reference 3:461


DIV—Unsigned Divide (Continued)
ELSE (* quadword/doubleword operation *)
temp ←EDX:EAX / SRC;
IF temp > FFFFFFFFH
THEN #DE; (* divide error *) ;
ELSE
EAX ←temp;
EDX ←EDX:EAX MOD SRC;
FI;
FI;
FI;

Flags Affected

The CF, OF, SF, ZF, AF, and PF flags are undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#DE If the source operand (divisor) is 0
If the quotient is too large for the designated register.
#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 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.

Real Address Mode Exceptions


#DE If the source operand (divisor) is 0.
If the quotient is too large for the designated register.
#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.

3:462 Volume 3: Base IA-32 Instruction Reference


DIV—Unsigned Divide (Continued)

Virtual 8086 Mode Exceptions


#DE If the source operand (divisor) is 0.
If the quotient is too large for the designated register.
#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS 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.

Volume 3: Base IA-32 Instruction Reference 3:463


ENTER—Make Stack Frame for Procedure Parameters
Opcode Instruction Description
C8 iw 00 ENTER imm16,0 Create a stack frame for a procedure
C8 iw 01 ENTER imm16,1 Create a nested stack frame for a procedure
C8 iw ib ENTER imm16,imm8 Create a nested stack frame for a procedure

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;

3:464 Volume 3: Base IA-32 Instruction Reference


ENTER—Make Stack Frame for Procedure Parameters (Continued)

Push([EBP]); (* doubleword push *)

ELSE (* StackSize = 16*)


BP ←BP −4;
Push([BP]); (* doubleword push *)
FI;
ELSE (* OperandSize = 16 *)
IF StackSize = 32
THEN
EBP ←EBP −2;
Push([EBP]); (* word push *)
ELSE (* StackSize = 16*)
BP ←BP −2;
Push([BP]); (* word push *)
FI;
FI;
OD;
IF OperandSize = 32
THEN
Push(FrameTemp); (* doubleword push *)
ELSE (* OperandSize = 16 *)
Push(FrameTemp); (* word push *)
FI;
GOTO CONTINUE;
FI;
CONTINUE:
IF StackSize = 32
THEN
EBP ←FrameTemp
ESP ←EBP −Size;
ELSE (* StackSize = 16*)
BP ←FrameTemp
SP ←BP −Size;
FI;
END;

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

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

Volume 3: Base IA-32 Instruction Reference 3:465


ENTER—Make Stack Frame for Procedure Parameters (Continued)

Protected Mode Exceptions


#SS(0) If the new value of the SP or ESP register is outside the stack segment limit.
#PF(fault-code) If a page fault occurs.

Real Address Mode Exceptions

None.

Virtual 8086 Mode Exceptions

None.

3:466 Volume 3: Base IA-32 Instruction Reference


F2XM1—Compute 2x-1
Opcode Instruction Description
D9 F0 F2XM1 Replace ST(0) with (2ST(0) - 1)

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:

ST(0) SRC ST(0) DEST


-1.0 to −0 −0.5 to −0
−0 −0
+0 +0
+0 to +1.0 +0 to 1.0

Values other than 2 can be exponentiated using the following formula:


xy = 2(y ∗ log2x)

Operation
ST(0) ←(2ST(0) −1);

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact-result exception (#P) is generated:
0 = not roundup; 1 = roundup.
C0, C2, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

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.

Volume 3: Base IA-32 Instruction Reference 3:467


F2XM1—Compute 2x-1 (Continued)

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:468 Volume 3: Base IA-32 Instruction Reference


FABS—Absolute Value
Opcode Instruction Description
D9 E1 FABS Replace ST with its absolute value.

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.

ST(0) SRC ST(0) DEST


−• +∞
−F +F
−0 +0
+0 +0
+F +F
+∞ +∞
NaN NaN

Note:
Fmeans finite-real number.

Operation
ST(0) ←|ST(0)|

FPU Flags Affected


C1 Set to 0 if stack underflow occurred; otherwise, cleared to 0.
C0, C2, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Floating-point Exceptions
#IS Stack underflow occurred.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

Volume 3: Base IA-32 Instruction Reference 3:469


FADD/FADDP/FIADD—Add
Opcode Instruction Description
D8 /0 FADD m32 real Add m32real to ST(0) and store result in ST(0)
DC /0 FADD m64real Add m64real to ST(0) and store result in ST(0)
D8 C0+i FADD ST(0), ST(i) Add ST(0) to ST(i) and store result in ST(0)
DC C0+i FADD ST(i), ST(0) Add ST(i) to ST(0) and store result in ST(i)
DE C0+i FADDP ST(i), ST(0) Add ST(0) to ST(i), store result in ST(i), and pop the register
stack
DE C1 FADDP Add ST(0) to ST(1), store result in ST(1), and pop the register
stack
DA /0 FIADD m32int Add m32int to ST(0) and store result in ST(0)
DE /0 FIADD m16int Add m16int to ST(0) and store result in ST(0)

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:

FADD ST(0), ST(0);

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.

3:470 Volume 3: Base IA-32 Instruction Reference


FADD/FADDP/FIADD—Add (Continued)
. DEST
-• −F −0 +0 +F +∞ NaN
-∞ -∞ -∞ -∞ -∞ -∞ * NaN
−F or −I -∞ −F SRC SRC ±F or ±0 +∞ NaN
SRC −0 -∞ DEST −0 ±0 DEST +∞ NaN
+0 -∞ DEST ±0 +0 DEST +∞ NaN
+For +I -∞ ±F or ±0 SRC SRC +F +∞ NaN
+∞ * +∞ +∞ +∞ +∞ +∞ NaN
NaN NaN NaN NaN NaN NaN NaN NaN

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact-result exception (#P) is generated:
0 = not roundup; 1 = roundup.
C0, C2, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: Base IA-32 Instruction Reference 3:471


FADD/FADDP/FIADD—Add (Continued)

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.

Protected Mode Exceptions


#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 contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:472 Volume 3: Base IA-32 Instruction Reference


FBLD—Load Binary Coded Decimal
Opcode Instruction Description
DF /4 FBLD m80 dec Convert BCD value to real and push onto the FPU stack.

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);

FPU Flags Affected


C1 Set to 1 if stack overflow occurred; otherwise, cleared to 0.
C0, C2, C3 Undefined.

Floating-point Exceptions
#IS Stack overflow occurred.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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 contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

Volume 3: Base IA-32 Instruction Reference 3:473


FBLD—Load Binary Coded Decimal (Continued)

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:474 Volume 3: Base IA-32 Instruction Reference


FBSTP—Store BCD Integer and Pop
Opcode Instruction Description
DF /6 FBSTP m80bcd Store ST(0) in m80bcd and pop ST(0).

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;

Volume 3: Base IA-32 Instruction Reference 3:475


FBSTP—Store BCD Integer and Pop (Continued)

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact exception (#P) is generated: 0 = not
roundup; 1 = roundup.
C0, C2, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

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.

Protected Mode Exceptions


#GP(0) If a segment register is being loaded with a segment selector that points to a
nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

3:476 Volume 3: Base IA-32 Instruction Reference


FBSTP—Store BCD Integer and Pop (Continued)

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:477


FCHS—Change Sign
Opcode Instruction Description
D9 E0 FCHS Complements sign of ST(0)

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.

ST(0) SRC ST(0) DEST


−• +∞
−F +F
−0 +0
+0 −0
+F −F
+∞ −•
NaN NaN

Note:
Fmeans finite-real number.

Operation
SignBit(ST(0)) ←NOT (SignBit(ST(0)))

FPU Flags Affected


C1 Set to 0 if stack underflow occurred; otherwise, cleared to 0.
C0, C2, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Floating-point Exceptions
#IS Stack underflow occurred.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:478 Volume 3: Base IA-32 Instruction Reference


FCLEX/FNCLEX—Clear Exceptions
Opcode Instruction Description
9B DB E2 FCLEX Clear floating-point exception flags after checking for pending
unmasked floating-point exceptions.
DB E2 FNCLEX Clear floating-point exception flags without checking for
pending unmasked floating-point exceptions.

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;

FPU Flags Affected

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set. /

Volume 3: Base IA-32 Instruction Reference 3:479


FCMOVcc—Floating-point Conditional Move
Opcode Instruction Description
DA C0+i FCMOVB ST(0), ST(i) Move if below (CF=1)
DA C8+i FCMOVE ST(0), ST(i) Move if equal (ZF=1)
DA D0+i FCMOVBE ST(0), ST(i) Move if below or equal (CF=1 or ZF=1)
DA D8+i FCMOVU ST(0), ST(i) Move if unordered (PF=1)
DB C0+i FCMOVNB ST(0), ST(i) Move if not below (CF=0)
DB C8+i FCMOVNE ST(0), ST(i) Move if not equal (ZF=0)
DB D0+i FCMOVNBE ST(0), ST(i) Move if not below or equal (CF=0 and ZF=0)
DB D8+i FCMOVNU ST(0), ST(i) Move if not unordered (PF=0)

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
C0, C2, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Floating-point Exceptions
#IS Stack underflow occurred.

Integer Flags Affected

None.

3:480 Volume 3: Base IA-32 Instruction Reference


FCMOVcc—Floating-point Conditional Move (Continued)

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

Volume 3: Base IA-32 Instruction Reference 3:481


FCOM/FCOMP/FCOMPP—Compare Real
Opcode Instruction Description
D8 /2 FCOM m32real Compare ST(0) with m32real.
DC /2 FCOM m64real Compare ST(0) with m64real.
D8 D0+i FCOM ST(i) Compare ST(0) with ST(i).
D8 D1 FCOM Compare ST(0) with ST(1).
D8 /3 FCOMP m32real Compare ST(0) with m32real and pop register stack.
DC /3 FCOMP m64real Compare ST(0) with m64real and pop register stack.
D8 D8+i FCOMP ST(i) Compare ST(0) with ST(i) and pop register stack.
D8 D9 FCOMP Compare ST(0) with ST(1) and pop register stack.
DE D9 FCOMPP Compare ST(0) with ST(1) and pop register stack twice.

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

a. Flags not set if unmasked invalid-arithmetic-operand (#IA) exception is


generated.

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.

3:482 Volume 3: Base IA-32 Instruction Reference


FCOM/FCOMP/FCOMPP—Compare Real (Continued)

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred; otherwise, cleared to 0.
C0, C2, C3 See table on previous page.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

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.

Volume 3: Base IA-32 Instruction Reference 3:483


FCOM/FCOMP/FCOMPP—Compare Real (Continued)

Protected Mode Exceptions


#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 contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:484 Volume 3: Base IA-32 Instruction Reference


FCOMI/FCOMIP/ FUCOMI/FUCOMIP—Compare Real and Set EFLAGS
Opcode Instruction Description
DB F0+i FCOMI ST, ST(i) Compare ST(0) with ST(i) and set status flags accordingly
DF F0+i FCOMIP ST, ST(i) Compare ST(0) with ST(i), set status flags accordingly, and pop
register stack
DB E8+i FUCOMI ST, ST(i) Compare ST(0) with ST(i), check for ordered values, and set
status flags accordingly
DF E8+i FUCOMIP ST, ST(i) Compare ST(0) with ST(i), check for ordered values, set status
flags accordingly, and pop register stack

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

a. Flags not set if unmasked invalid-arithmetic- operand


(#IA) exception is generated.

The FCOMI/FCOMIP instructions perform the same operation as the FUCOMI/FUCOMIP


instructions. The only difference is how they handle QNaN operands. The FCOMI/FCOMIP
instructions set the status flags to “unordered” and generate an invalid-arithmetic-operand
exception (#IA) when either or both of the operands is a NaN value (SNaN or QNaN) or is in an
unsupported format.

The FUCOMI/FUCOMIP instructions perform the same operation as the FCOMI/FCOMIP


instructions, except that they do not generate an invalid-arithmetic-operand exception for QNaNs.

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.

Volume 3: Base IA-32 Instruction Reference 3:485


FCOMI/FCOMIP/ FUCOMI/FUCOMIP—Compare Real and Set EFLAGS
(Continued)

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred; otherwise, cleared to 0.
C0, C2, C3 Not affected.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

3:486 Volume 3: Base IA-32 Instruction Reference


FCOMI/FCOMIP/ FUCOMI/FUCOMIP—Compare Real and Set EFLAGS
(Continued)

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.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set./

Volume 3: Base IA-32 Instruction Reference 3:487


FCOS—Cosine
Opcode Instruction Description
D9 FF FCOS Replace ST(0) with its cosine

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.

ST(0) SRC ST(0) DEST


−∞ *
−F −1 to +1
−0 +1
+0 +1
+F −1 to +1
+∞ *
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;
ST(0) ←cosine(ST(0));
ELSE (*source operand is out-of-range *)
C2 ←1;
FI;

3:488 Volume 3: Base IA-32 Instruction Reference


FCOS—Cosine (Continued)

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact-result exception (#P) is generated:
0 = not roundup; 1 = roundup.
Undefined if C2 is 1.
C2 Set to 1 if source operand is outside the range −263 to +263; otherwise, cleared
to 0.
C0, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

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.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

Volume 3: Base IA-32 Instruction Reference 3:489


FDECSTP—Decrement Stack-Top Pointer
Opcode Instruction Description
D9 F6 FDECSTP Decrement TOP field in FPU status word.

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;

FPU Flags Affected

The C1 flag is set to 0; otherwise, cleared to 0. The C0, C2, and C3 flags are undefined.

Floating-point Exceptions

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:490 Volume 3: Base IA-32 Instruction Reference


FDIV/FDIVP/FIDIV—Divide
Opcode Instruction Description
D8 /6 FDIV m32real Divide ST(0) by m32real and store result in ST(0)
DC /6 FDIV m64real Divide ST(0) by m64real and store result in ST(0)
D8 F0+i FDIV ST(0), ST(i) Divide ST(0) by ST(i) and store result in ST(0)
DC F8+i FDIV ST(i), ST(0) Divide ST(i) by ST(0) and store result in ST(i)
DE F8+i FDIVP ST(i), ST(0) Divide ST(i) by ST(0), store result in ST(i), and pop the register
stack
DE F9 FDIVP Divide ST(1) by ST(0), store result in ST(1), and pop the
register stack
DA /6 FIDIV m32int Divide ST(0) by m32int and store result in ST(0)
DE /6 FIDIV m16int Divide ST(0) by m64int and store result in ST(0)

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.

Volume 3: Base IA-32 Instruction Reference 3:491


FDIV/FDIVP/FIDIV—Divide (Continued)
DEST
-• −F −0 +0 +F +∞ NaN
-∞ * +0 +0 −0 −0 * NaN
−F +∞ +F +0 −0 −F -• NaN
−I +∞ +F +0 −0 −F -• NaN
SRC −0 +∞ ** * * ** -• NaN
+0 -• ** * * ** +∞ NaN
+I -• −F −0 +0 +F +∞ NaN
+F -• −F −0 +0 +F +∞ NaN
+∞ * −0 −0 +0 +0 * NaN
NaN NaN NaN NaN NaN NaN NaN NaN

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact-result exception (#P) is generated:
0 = not roundup; 1 = roundup.
C0, C2, C3 Undefined.

3:492 Volume 3: Base IA-32 Instruction Reference


FDIV/FDIVP/FIDIV—Divide (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

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.

Protected Mode Exceptions


#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 contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:493


FDIVR/FDIVRP/FIDIVR—Reverse Divide
Opcode Instruction Description
D8 /7 FDIVR m32real Divide m32real by ST(0) and store result in ST(0)
DC /7 FDIVR m64real Divide m64real by ST(0) and store result in ST(0)
D8 F8+i FDIVR ST(0), ST(i) Divide ST(i) by ST(0) and store result in ST(0)
DC F0+i FDIVR ST(i), ST(0) Divide ST(0) by ST(i) and store result in ST(i)
DE F0+i FDIVRP ST(i), ST(0) Divide ST(0) by ST(i), store result in ST(i), and pop the register
stack
DE F1 FDIVRP Divide ST(0) by ST(1), store result in ST(1), and pop the
register stack
DA /7 FIDIVR m32int Divide m32int by ST(0) and store result in ST(0)
DE /7 FIDIVR m16int Divide m64int by ST(0) and store result in ST(0)

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.

3:494 Volume 3: Base IA-32 Instruction Reference


FDIVR/FDIVRP/FIDIVR—Reverse Divide (Continued)
DEST
−∞ −F −0 +0 +F +∞ NaN
−∞ * +∞ +∞ -• −∞ * NaN
SRC −F +0 +F ** ** -F −0 NaN
−I +0 +F ** ** -F −0 NaN
−0 +0 +0 * * −0 −0 NaN
+0 −0 −0 * * +0 +0 NaN
+I −0 -F ** ** +F +∞ NaN
+F −0 -F ** ** +F +∞ NaN
+∞ * −∞ −∞ +∞ +∞ * NaN
NaN NaN NaN NaN NaN NaN NaN NaN

Notes:
Fmeans finite-real number.
Imeans integer.
*indicates floating-point invalid-arithmetic-operand (#IA) exception.
**indicates floating-point zero-divide (#Z) exception.

When the source operand is an integer 0, it is treated as a +0.

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact-result exception (#P) is generated:
0 = not roundup; 1 = roundup.
C0, C2, C3 Undefined.

Volume 3: Base IA-32 Instruction Reference 3:495


FDIVR/FDIVRP/FIDIVR—Reverse Divide (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

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.

Protected Mode Exceptions


#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 contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:496 Volume 3: Base IA-32 Instruction Reference


FFREE—Free Floating-point Register
Opcode Instruction Description
DD C0+i FFREE ST(i) Sets tag for ST(i) to empty

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;

FPU Flags Affected

C0, C1, C2, C3 undefined.

Floating-point Exceptions

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

Volume 3: Base IA-32 Instruction Reference 3:497


FICOM/FICOMP—Compare Integer
Opcode Instruction Description
DE /2 FICOM m16int Compare ST(0) with m16int
DA /2 FICOM m32int Compare ST(0) with m32int
DE /3 FICOMP m16int Compare ST(0) with m16int and pop stack register
DA /3 FICOMP m32int Compare ST(0) with m32int and pop stack register

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 sign of zero is ignored, so that -0.0 = +0.0.

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred; otherwise, set to 0.
C0, C2, C3 See table on previous page.

3:498 Volume 3: Base IA-32 Instruction Reference


FICOM/FICOMP—Compare Integer (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

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.

Protected Mode Exceptions


#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 contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:499


FILD—Load Integer
Opcode Instruction Description
DF /0 FILD m16int Push m16int onto the FPU register stack.
DB /0 FILD m32int Push m32int onto the FPU register stack.
DF /5 FILD m64int Push m64int onto the FPU register stack.

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);

FPU Flags Affected


C1 Set to 1 if stack overflow occurred; cleared to 0 otherwise.
C0, C2, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Floating-point Exceptions
#IS Stack overflow occurred.

Protected Mode Exceptions


#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 contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

3:500 Volume 3: Base IA-32 Instruction Reference


FILD—Load Integer (Continued)

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:501


FINCSTP—Increment Stack-Top Pointer
Opcode Instruction Description
D9 F7 FINCSTP Increment the TOP field in the FPU status register

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;

FPU Flags Affected

The C1 flag is set to 0; otherwise, generates an #IS fault. The C0, C2, and C3 flags are undefined.

Floating-point Exceptions

#IS

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:502 Volume 3: Base IA-32 Instruction Reference


FINIT/FNINIT—Initialize Floating-point Unit
Opcode Instruction Description
9B DB E3 FINIT Initialize FPU after checking for pending unmasked
floating-point exceptions.
DB E3 FNINIT Initialize FPU without checking for pending unmasked
floating-point exceptions.

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;

FPU Flags Affected

C0, C1, C2, C3 cleared to 0.

Floating-point Exceptions

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

Volume 3: Base IA-32 Instruction Reference 3:503


FIST/FISTP—Store Integer
Opcode Instruction Description
DF /2 FIST m16int Store ST(0) in m16int
DB /2 FIST m32int Store ST(0) in m32int
DF /3 FISTP m16int Store ST(0) in m16int and pop register stack
DB /3 FISTP m32int Store ST(0) in m32int and pop register stack
DF /7 FISTP m64int Store ST(0) in m64int and pop register stack

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.

3:504 Volume 3: Base IA-32 Instruction Reference


FIST/FISTP—Store Integer (Continued)

Operation
DEST ←Integer(ST(0));
IF instruction = FISTP
THEN
PopRegisterStack;
FI;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction of if the inexact exception (#P) is generated:
0 = not roundup; 1 = roundup.
Cleared to 0 otherwise.
C0, C2, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT register Consumption Abort.
Itanium Mem Faults VHPT 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

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.

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

Volume 3: Base IA-32 Instruction Reference 3:505


FIST/FISTP—Store Integer (Continued)

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:506 Volume 3: Base IA-32 Instruction Reference


FLD—Load Real
Opcode Instruction Description
D9 /0 FLD m32real Push m32real onto the FPU register stack.
DD /0 FLD m64real Push m64real onto the FPU register stack.
DB /5 FLD m80real Push m80real onto the FPU register stack.
D9 C0+i FLD ST(i) Push ST(i) onto the FPU register stack.

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;

FPU Flags Affected


C1 Set to 1 if stack overflow occurred; otherwise, cleared to 0.
C0, C2, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

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)

Volume 3: Base IA-32 Instruction Reference 3:507


Protected Mode Exceptions
#GP(0) If destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:508 Volume 3: Base IA-32 Instruction Reference


FLD1/FLDL2T/FLDL2E/FLDPI/FLDLG2/FLDLN2/FLDZ—Load Constant
Opcode Instruction Description
D9 E8 FLD1 Push +1.0 onto the FPU register stack.
D9 E9 FLDL2T Push log210 onto the FPU register stack.
D9 EA FLDL2E Push log2e onto the FPU register stack.
D9 EB FLDPI Push π onto the FPU register stack.
D9 EC FLDLG2 Push log102 onto the FPU register stack.
D9 ED FLDLN2 Push loge2 onto the FPU register stack.
D9 EE FLDZ Push +0.0 onto the FPU register stack.

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;

FPU Flags Affected


C1 Set to 1 if stack overflow occurred; otherwise, cleared to 0.
C0, C2, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1.

Floating-point Exceptions
#IS Stack overflow occurred.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Volume 3: Base IA-32 Instruction Reference 3:509


FLD1/FLDL2T/FLDL2E/FLDPI/FLDLG2/FLDLN2/FLDZ—Load Constant
(Continued)

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

Intel Architecture Compatibility Information

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.

3:510 Volume 3: Base IA-32 Instruction Reference


FLDCW—Load Control Word
Opcode Instruction Description
D9 /5 FLDCW m2byte Load FPU control word from m2byte.

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;

FPU Flags Affected

C0, C1, C2, C3 undefined.

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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.
#NM EM or TS in CR0 is set.
#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.

Volume 3: Base IA-32 Instruction Reference 3:511


FLDCW—Load Control Word (Continued)

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:512 Volume 3: Base IA-32 Instruction Reference


FLDENV—Load FPU Environment
Opcode Instruction Description
D9 /4 FLDENV m14/28byte Load FPU environment from m14byte or m28byte.

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);

FPU Flags Affected

The C0, C1, C2, C3 flags are loaded.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1.
Itanium Mem Faults VHPT 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

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.

Volume 3: Base IA-32 Instruction Reference 3:513


FLDENV—Load FPU Environment (Continued)

Protected Mode Exceptions


#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.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:514 Volume 3: Base IA-32 Instruction Reference


FMUL/FMULP/FIMUL—Multiply
Opcode Instruction Description
D8 /1 FMUL m32real Multiply ST(0) by m32real and store result in ST(0)
DC /1 FMUL m64real Multiply ST(0) by m64real and store result in ST(0)
D8 C8+i FMUL ST(0), ST(i) Multiply ST(0) by ST(i) and store result in ST(0)
DC C8+i FMUL ST(i), ST(0) Multiply ST(i) by ST(0) and store result in ST(i)
DE C8+i FMULP ST(i), ST(0) Multiply ST(i) by ST(0), store result in ST(i), and pop the
register stack
DE C9 FMULP Multiply ST(0) by ST(1), store result in ST(0), and pop the
register stack
DA /1 FIMUL m32int Multiply m32int by ST(0) and store result in ST(0)
DE /1 FIMUL m16int Multiply m16int by ST(0) and store result in ST(0)

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.

Volume 3: Base IA-32 Instruction Reference 3:515


FMUL/FMULP/FIMUL—Multiply (Continued)
DEST
−∞ −F −0 +0 +F +∞ NaN
−∞ +∞ +∞ * * −∞ −∞ NaN
−F +∞ +F +0 −0 −F −∞ NaN
−I +∞ +F +0 −0 −F −∞ NaN
SRC −0 * +0 +0 −0 −0 * NaN
+0 * −0 −0 +0 +0 * NaN
+I −∞ −F −0 +0 +F +∞ NaN
+F −∞ −F −0 +0 +F +∞ NaN
+∞ −∞ −∞ * * +∞ +∞ NaN
NaN NaN NaN NaN NaN NaN NaN NaN

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact-result exception (#P) fault is
generated: 0 = not roundup; 1 = roundup.
C0, C2, C3 Undefined.

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.

3:516 Volume 3: Base IA-32 Instruction Reference


FMUL/FMULP/FIMUL—Multiply (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:517


FNOP—No Operation
Opcode Instruction Description
D9 D0 FNOP No operation is performed.

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.

FPU Flags Affected

C0, C1, C2, C3 undefined.

Floating-point Exceptions

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:518 Volume 3: Base IA-32 Instruction Reference


FPATAN—Partial Arctangent
Opcode Instruction Description
D9 F3 FPATAN Replace ST(1) with arctan(ST(1)/ ST(0)) and pop the register
stack

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.

Table 1-6. FPATAN Zeros and NaNs


ST(0)
-• −F −0 +0 +F +∞ NaN
-• −3π/ 4 −π/2 −π/2 −π/2 −π/2 −π/4 NaN
ST(1) −F -p −π to −π/ 2 −π/2 −π/2 −π/ 2 to −0 -0 NaN
−0 -p -p -p −0 −0 −0 NaN
+0 +π +π +π +0 +0 +0 NaN
+F +π +π to +π/ 2 +π/ 2 +π/ 2 +π/ 2 to +0 +0 NaN
+∞ +3π/ 4 +π/ 2 +π/ 2 +π/ 2 +π/ 2 +π/4 NaN
NaN NaN NaN NaN NaN NaN NaN NaN

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact-result exception (#P) is generated:
0 = not roundup; 1 = roundup.
C0, C2, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Volume 3: Base IA-32 Instruction Reference 3:519


FPATAN—Partial Arctangent (Continued)

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.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

Intel Architecture Compatibility Information

The source operands for this instruction are restricted for the 80287 math coprocessor to the
following range:

0 ≤|ST(1)| < |ST(0)| < +∞

3:520 Volume 3: Base IA-32 Instruction Reference


FPREM—Partial Remainder
Opcode Instruction Description
D9 F8 FPREM Replace ST(0) with the remainder obtained on dividing ST(0)
by ST(1)

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:

Remainder = ST(0) −(N ∗ ST(1))

Here, N is an integer value that is obtained by truncating the real-number quotient of


[ST(0) / ST(1)] toward zero. The sign of the remainder is the same as the sign of the dividend. The
magnitude of the remainder is less than that 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.

Table 1-7. FPREM Zeros and NaNs


ST(1)
−∞ −F −0 +0 +F +∞ NaN
−∞ * * * * * * NaN
ST(0) −F ST(0) −F or −0 ** ** −F or −0 ST(0) NaN
−0 −0 −0 * * −0 −0 NaN
+0 +0 +0 * * +0 +0 NaN
+F ST(0) +F or +0 ** ** +F or +0 ST(0) NaN
+∞ * * * * * * NaN
NaN NaN NaN NaN NaN NaN NaN NaN

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.

Volume 3: Base IA-32 Instruction Reference 3:521


FPREM—Partial Remainder (Continued)
The FPREM instruction gets its name “partial remainder” because of the way it computes the
remainder. This instructions arrives at a remainder through iterative subtraction. It can, however,
reduce the exponent of ST(0) by no more than 63 in one execution of the instruction. If the
instruction succeeds in producing a remainder that is less than the modulus, the operation is
complete and the C2 flag in the FPU status word is cleared. Otherwise, C2 is set, and the result in
ST(0) is called the partial remainder. The exponent of the partial remainder will be less than the
exponent of the original dividend by at least 32. Software can re-execute the instruction (using the
partial remainder in ST(0) as the dividend) until C2 is cleared.
Note: While executing such a remainder-computation loop, a higher-priority interrupting routine
that needs the FPU can force a context switch in-between the instructions in the loop.

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;

FPU Flags Affected


C0 Set to bit 2 (Q2) of the quotient.
C1 Set to 0 if stack underflow occurred; otherwise, set to least significant bit of
quotient (Q0).
C2 Set to 0 if reduction complete; set to 1 if incomplete.
C3 Set to bit 1 (Q1) of the quotient.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

3:522 Volume 3: Base IA-32 Instruction Reference


FPREM—Partial Remainder (Continued)

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.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

Volume 3: Base IA-32 Instruction Reference 3:523


FPREM1—Partial Remainder
Opcode Instruction Description
D9 F5 FPREM1 Replace ST(0) with the IEEE remainder obtained on dividing
ST(0) by ST(1)

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:

Remainder = ST(0) −(N ∗ ST(1))

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.

Table 1-8. FPREM1 Zeros and NaNs


ST(1)
−∞ −F −0 +0 +F +∞ NaN
−∞ * * * * * * NaN
ST(0) −F ST(0) −F or −0 ** ** −F or −0 ST(0) NaN
−0 −0 −0 * * −0 −0 NaN
+0 +0 +0 * * +0 +0 NaN
+F ST(0) +F or +0 ** ** +F or +0 ST(0) NaN
+∞ * * * * * * NaN
NaN NaN NaN NaN NaN NaN NaN NaN

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).

3:524 Volume 3: Base IA-32 Instruction Reference


FPREM1—Partial Remainder (Continued)
Like the FPREM instruction, the FPREM1 computes the remainder through iterative subtraction,
but can reduce the exponent of ST(0) by no more than 63 in one execution of the instruction. If the
instruction succeeds in producing a remainder that is less than one half the modulus, the operation
is complete and the C2 flag in the FPU status word is cleared. Otherwise, C2 is set, and the result in
ST(0) is called the partial remainder. The exponent of the partial remainder will be less than the
exponent of the original dividend by at least 32. Software can re-execute the instruction (using the
partial remainder in ST(0) as the dividend) until C2 is cleared.
Note: While executing such a remainder-computation loop, a higher-priority interrupting routine
that needs the FPU can force a context switch in-between the instructions in the loop.

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;

FPU Flags Affected


C0 Set to bit 2 (Q2) of the quotient.
C1 Set to 0 if stack underflow occurred; otherwise, set to least significant bit of
quotient (Q0).
C2 Set to 0 if reduction complete; set to 1 if incomplete.
C3 Set to bit 1 (Q1) of the quotient.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Volume 3: Base IA-32 Instruction Reference 3:525


FPREM1—Partial Remainder (Continued)

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.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:526 Volume 3: Base IA-32 Instruction Reference


FPTAN—Partial Tangent
Opcode Instruction Clocks Description
D9 F2 FPTAN 17-173 Replace ST(0) with its tangent and push 1 onto
the FPU stack.

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.

ST(0) SRC ST(0) DEST


−∞ *
−F −F to +F
−0 −0
+0 +0
+F −F to +F
+∞ *
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π.

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;

Volume 3: Base IA-32 Instruction Reference 3:527


FPTAN—Partial Tangent (Continued)

FPU Flags Affected


C1 Set to 0 if stack underflow occurred; set to 1 if stack overflow occurred.
Indicates rounding direction if the inexact-result exception (#P) is generated:
0 = not roundup; 1 = roundup.
C2 Set to 1 if source operand is outside the range −263 to +263; otherwise, cleared
to 0.
C0, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

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.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:528 Volume 3: Base IA-32 Instruction Reference


FRNDINT—Round to Integer
Opcode Instruction Description
D9 FC FRNDINT Round ST(0) to an integer.

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));

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact-result exception (#P) is generated:
0 = not roundup; 1 = roundup.
C0, C2, C3 Undefined.

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

Volume 3: Base IA-32 Instruction Reference 3:529


FRSTOR—Restore FPU State
Opcode Instruction Description
DD /4 FRSTOR m94/108byte Load FPU state from m94byte or m108byte.

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));

FPU Flags Affected

The C0, C1, C2, C3 flags are loaded.

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.

3:530 Volume 3: Base IA-32 Instruction Reference


FRSTOR—Restore FPU State (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:531


FSAVE/FNSAVE—Store FPU State
Opcode Instruction Description
9B DD /6 FSAVE m94/108byte Store FPU state to m94byte or m108byte after checking for pending
unmasked floating-point exceptions. Then re-initialize the FPU.
DD /6 FNSAVE m94/108byte Store FPU environment to m94byte or m108byte without checking
for pending unmasked floating-point exceptions. Then re-initialize
the FPU.

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;

3:532 Volume 3: Base IA-32 Instruction Reference


FSAVE/FNSAVE—Store FPU State (Continued)

FPUStatusWord ←0;
FPUTagWord ←FFFFH;
FPUDataPointer ←0;
FPUInstructionPointer ←0;
FPULastInstructionOpcode ←0;

FPU Flags Affected

The C0, C1, C2, and C3 flags are saved and then cleared.

Floating-point Exceptions

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Volume 3: Base IA-32 Instruction Reference 3:533


FSAVE/FNSAVE—Store FPU State (Continued)

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Intel Architecture Compatibility Information

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.

3:534 Volume 3: Base IA-32 Instruction Reference


FSCALE—Scale
Opcode Instruction Description
D9 FD FSCALE Scale ST(0) by ST(1).

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.

Volume 3: Base IA-32 Instruction Reference 3:535


FSCALE—Scale (Continued)

Operation
ST(0) ←ST(0) ∗ 2ST(1);

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact-result exception (#P) is generated:
0 = not roundup; 1 = roundup.
C0, C2, C3 Undefined.

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:536 Volume 3: Base IA-32 Instruction Reference


FSIN—Sine
Opcode Instruction Description
D9 FE FSIN Replace ST(0) with its sine.

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.

SRC (ST(0)) DEST (ST(0))


−∞ *
−F −1 to +1
−0 −0
+0 +0
+F −1 to +1
+∞ *
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 I
IF ST(0) < 263
THEN
C2 ←0;
ST(0) ←sin(ST(0));
ELSE (* source operand out of range *)
C2 ←1;
FI:

Volume 3: Base IA-32 Instruction Reference 3:537


FSIN—Sine (Continued)

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact-result exception (#P) is generated:
0 = not roundup; 1 = roundup.
C2 Set to 1 if source operand is outside the range −263 to +263; otherwise, cleared
to 0.
C0, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

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.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:538 Volume 3: Base IA-32 Instruction Reference


FSINCOS—Sine and Cosine
Opcode Instruction Description
D9 FB FSINCOS Compute the sine and cosine of ST(0); replace ST(0) with the
sine, and push the cosine onto the register stack.

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:

Volume 3: Base IA-32 Instruction Reference 3:539


FSINCOS—Sine and Cosine (Continued)

FPU Flags Affected


C1 Set to 0 if stack underflow occurred; set to 1 of stack overflow occurs.
Indicates rounding direction if the inexact-result exception (#P) is generated:
0 = not roundup; 1 = roundup.
C2 Set to 1 if source operand is outside the range −263 to +263; otherwise, cleared
to 0.
C0, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

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.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:540 Volume 3: Base IA-32 Instruction Reference


FSQRT—Square Root
Opcode Instruction Description
D9 FA FSQRT Calculates square root of ST(0) and stores the result in ST(0)

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.

SRC (ST(0)) DEST (ST(0))


−∞ *
−F *
−0 −0
+0 +0
+F +F
+∞ +∞
NaN NaN

Notes:
Fmeans finite-real number.
*indicates floating-point invalid-arithmetic-operand (#IA) exception.

Operation
ST(0) ←SquareRoot(ST(0));

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if inexact-result exception (#P) is generated:
0 = not roundup; 1 = roundup.
C0, C2, C3 Undefined.

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.

Volume 3: Base IA-32 Instruction Reference 3:541


FSQRT—Square Root (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:542 Volume 3: Base IA-32 Instruction Reference


FST/FSTP—Store Real
Opcode Instruction Description
D9 /2 FST m32real Copy ST(0) to m32real
DD /2 FST m64real Copy ST(0) to m64real
DD D0+i FST ST(i) Copy ST(0) to ST(i)
D9 /3 FSTP m32real Copy ST(0) to m32real and pop register stack
DD /3 FSTP m64real Copy ST(0) to m64real and pop register stack
DB /7 FSTP m80real Copy ST(0) to m80real and pop register stack
DD D8+i FSTP ST(i) Copy ST(0) to ST(i) and pop register stack

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;

Volume 3: Base IA-32 Instruction Reference 3:543


FST/FSTP—Store Real (Continued)

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction of if the floating-point inexact exception (#P) is
generated: 0 = not roundup; 1 = roundup.
C0, C2, C3 Undefined.

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

3:544 Volume 3: Base IA-32 Instruction Reference


FST/FSTP—Store Real (Continued)

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:545


FSTCW/FNSTCW—Store Control Word
Opcode Instruction Description
9B D9 /7 FSTCW m2byte Store FPU control word to m2byte after checking for pending
unmasked floating-point exceptions.
D9 /7 FNSTCW m2byte Store FPU control word to m2byte without checking for pending
unmasked floating-point exceptions.

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;

FPU Flags Affected

The C0, C1, C2, and C3 flags are undefined.

Floating-point Exceptions

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

3:546 Volume 3: Base IA-32 Instruction Reference


FSTCW/FNSTCW—Store Control Word (Continued)

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:547


FSTENV/FNSTENV—Store FPU Environment
Opcode Instruction Description
9B D9 /6 FSTENV m14/28byte Store FPU environment to m14byte or m28byte after checking
for pending unmasked floating-point exceptions. Then mask all
floating-point exceptions.
D9 /6 FNSTENV m14/28byte Store FPU environment to m14byte or m28byte without
checking for pending unmasked floating-point exceptions. Then
mask all floating-point exceptions.

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;

FPU Flags Affected

The C0, C1, C2, and C3 are undefined.

Floating-point Exceptions

None.

3:548 Volume 3: Base IA-32 Instruction Reference


FSTENV/FNSTENV—Store FPU Environment (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:549


FSTSW/FNSTSW—Store Status Word
Opcode Instruction Description
9B DD /7 FSTSW m2byte Store FPU status word at m2byte after checking for pending
unmasked floating-point exceptions.
9B DF E0 FSTSW AX Store FPU status word in AX register after checking for pending
unmasked floating-point exceptions.
DD /7 FNSTSW m2byte Store FPU status word at m2byte without checking for pending
unmasked floating-point exceptions.
DF E0 FNSTSW AX Store FPU status word in AX register without checking for
pending unmasked floating-point exceptions.

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;

FPU Flags Affected

The C0, C1, C2, and C3 are undefined.

Floating-point Exceptions

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1.
Itanium Mem Faults VHPT 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

3:550 Volume 3: Base IA-32 Instruction Reference


FSTSW/FNSTSW—Store Status Word (Continued)

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:551


FSUB/FSUBP/FISUB—Subtract
Opcode Instruction Description
D8 /4 FSUB m32real Subtract m32real from ST(0) and store result in ST(0)
DC /4 FSUB m64real Subtract m64real from ST(0) and store result in ST(0)
D8 E0+i FSUB ST(0), ST(i) Subtract ST(i) from ST(0) and store result in ST(0)
DC E8+i FSUB ST(i), ST(0) Subtract ST(0) from ST(i) and store result in ST(i)
DE E8+i FSUBP ST(i), ST(0) Subtract ST(0) from ST(i), store result in ST(i), and pop register
stack
DE E9 FSUBP Subtract ST(0) from ST(1), store result in ST(1), and pop
register stack
DA /4 FISUB m32int Subtract m32int from ST(0) and store result in ST(0)
DE /4 FISUB m16int Subtract m16int from ST(0) and store result in ST(0)

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.

3:552 Volume 3: Base IA-32 Instruction Reference


FSUB/FSUBP/FISUB—Subtract (Continued)
Table 1-9. FSUB Zeros and NaNs
SRC
−∞ −F or −I −0 +0 +F or +I +∞ NaN
−∞ * −∞ −∞ −∞ −∞ −∞ NaN
−F +∞ ±F or ±0 DEST DEST −F −∞ NaN
DEST −0 +∞ −SRC ±0 −0 −SRC −∞ NaN
+0 +∞ −SRC +0 ±0 −SRC −∞ NaN
+F +∞ +F DEST DEST ±F or ±0 −∞ NaN
+∞ +∞ +∞ +∞ +∞ +∞ * NaN
NaN NaN NaN NaN NaN NaN NaN NaN

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact-result exception (#P) fault is
generated: 0 = not roundup; 1 = roundup.
C0, C2, C3 Undefined.

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.

Volume 3: Base IA-32 Instruction Reference 3:553


FSUB/FSUBP/FISUB—Subtract (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:554 Volume 3: Base IA-32 Instruction Reference


FSUBR/FSUBRP/FISUBR—Reverse Subtract

Opcode Instruction Description


D8 /5 FSUBR m32real Subtract ST(0) from m32real and store result in ST(0)
DC /5 FSUBR m64real Subtract ST(0) from m64real and store result in ST(0)
D8 E8+i FSUBR ST(0), ST(i) Subtract ST(0) from ST(i) and store result in ST(0)
DC E0+i FSUBR ST(i), ST(0) Subtract ST(i) from ST(0) and store result in ST(i)
DE E0+i FSUBRP ST(i), ST(0) Subtract ST(0) from ST(i), store result in ST(i), and pop register
stack
DE E1 FSUBRP Subtract ST(1) from ST(0), store result in ST(1), and pop
register stack
DA /5 FISUBR m32int Subtract ST(0) from m32int and store result in ST(0)
DE /5 FISUBR m16int Subtract ST(0) from m16int and store result in ST(0)

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).

Volume 3: Base IA-32 Instruction Reference 3:555


FSUBR/FSUBRP/FISUBR—Reverse Subtract (Continued)
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.

Table 1-10. FSUBR Zeros and NaNs


SRC
−∞ −F −0 +0 +F +∞ NaN
−∞ * +∞ +∞ +∞ +∞ +∞ NaN

DEST −F or −I −∞ ±F or ±0 −DEST −DEST +F +∞ NaN

−0 −∞ SRC ±0 +0 SRC +∞ NaN


+0 −∞ SRC −0 ±0 SRC +∞ NaN
+F or +I −∞ −F −DEST −DEST ±F or ±0 +∞ NaN
+∞ −∞ −∞ −∞ −∞ −∞ * NaN
NaN NaN NaN NaN NaN NaN NaN NaN

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact-result exception (#P) fault is
generated: 0 = not roundup; 1 = roundup.
C0, C2, C3 Undefined.

3:556 Volume 3: Base IA-32 Instruction Reference


FSUBR/FSUBRP/FISUBR—Reverse Subtract (Continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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.
#NM EM or TS in CR0 is set.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NM EM or TS in CR0 is set.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:557


FTST—TEST
Opcode Instruction Description
D9 E4 FTST Compare ST(0) with 0.0.

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.”)

The sign of zero is ignored, so that -0.0 = +0.0.

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred; otherwise, cleared to 0.
C0, C2, C3 See above table.

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

3:558 Volume 3: Base IA-32 Instruction Reference


FTST—TEST (Continued)

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

Volume 3: Base IA-32 Instruction Reference 3:559


FUCOM/FUCOMP/FUCOMPP—Unordered Compare Real
Opcode Instruction Description
DD E0+i FUCOM ST(i) Compare ST(0) with ST(i)
DD E1 FUCOM Compare ST(0) with ST(1)
DD E8+i FUCOMP ST(i) Compare ST(0) with ST(i) and pop register stack
DD E9 FUCOMP Compare ST(0) with ST(1) and pop register stack
DA E9 FUCOMPP Compare ST(0) with ST(1) and pop register stack twice

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.

As with the FCOM instructions, if the operation results in an invalid-arithmetic-operand exception


being raised, the condition code flags are set only if the exception is masked.

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

3:560 Volume 3: Base IA-32 Instruction Reference


FUCOM/FUCOMP/FUCOMPP—Unordered Compare Real (Continued)

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
C0, C2, C3 See table on previous page.

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

Volume 3: Base IA-32 Instruction Reference 3:561


FWAIT—Wait
See entry for WAIT.

3:562 Volume 3: Base IA-32 Instruction Reference


FXAM—Examine
Opcode Instruction Description
D9 E5 FXAM Classify value or number in ST(0)

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;

FPU Flags Affected


C1 Sign of value in ST(0).
C0, C2, C3 See table above.

Floating-point Exceptions

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Volume 3: Base IA-32 Instruction Reference 3:563


FXAM—Examine (Continued)

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:564 Volume 3: Base IA-32 Instruction Reference


FXCH—Exchange Register Contents
Opcode Instruction Description
D9 C8+i FXCH ST(i) Exchange the contents of ST(0) and ST(i)
D9 C9 FXCH Exchange the contents of ST(0) and ST(1)

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred; otherwise, cleared to 0.
C0, C2, C3 Undefined.

Floating-point Exceptions
#IS Stack underflow occurred.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Volume 3: Base IA-32 Instruction Reference 3:565


FXCH—Exchange Register Contents (Continued)

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:566 Volume 3: Base IA-32 Instruction Reference


FXTRACT—Extract Exponent and Significand
Opcode Instruction Description
D9 F4 FXTRACT Separate value in ST(0) into exponent and significand, store
exponent in ST(0), and push the significand onto the register
stack.

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred; set to 1 if stack overflow occurred.
C0, C2, C3 Undefined.

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

Volume 3: Base IA-32 Instruction Reference 3:567


FXTRACT—Extract Exponent and Significand (Continued)

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:568 Volume 3: Base IA-32 Instruction Reference


FYL2X—Compute y × log2x
Opcode Instruction Description
D9 F1 FYL2X Replace ST(1) with (ST(1) ∗ log2ST(0)) and pop the register
stack

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.

Table 1-11. FYL2X Zeros and NaNs


ST(0)
−∞ −F +0 +0 +F +∞ NaN
−∞ * * +∞ +∞ +∞ −∞ NaN
ST(1) −F * * ** ** ±F −∞ NaN
−0 * * * * +0 * NaN
+0 * * * * +0 * NaN
+F * * ** ** ±F +∞ NaN
+∞ * * −∞ −∞ −∞ +∞ NaN
NaN NaN NaN NaN NaN NaN NaN NaN

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;

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact-result exception (#P) is generated:
0 = not roundup; 1 = roundup.
C0, C2, C3 Undefined.

Volume 3: Base IA-32 Instruction Reference 3:569


FYL2X—Compute y × log2x (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

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.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:570 Volume 3: Base IA-32 Instruction Reference


FYL2XP1—Compute y ∗ log2(x +1)
Opcode Instruction Description
D9 F9 FYL2XP1 Replace ST(1) with ST(1) ∗ log2(ST(0) + 1.0) and pop the
register stack

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:

Table 1-12. FYL2XP1 Zeros and NaNs


ST(0)
−∞ −(1 − ( 2 ⁄ 2)) to −0 −0 +0 +0 to +(1 −( 2 ⁄ 2)) +∞ NaN
−∞ * +∞ * * −∞ −∞ NaN
ST(1) −F * +F +0 −0 −F −∞ NaN
−0 * +0 +0 −0 −0 * NaN
+0 * −0 −0 +0 +0 * NaN
+F * −F −0 +0 +F +∞ NaN
+∞ * −∞ * * +∞ +∞ NaN
NaN NaN NaN NaN NaN NaN NaN NaN

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:

scale factor = logn 2

Operation
I
ST(1) ←ST(1) ∗ log2(ST(0) + 1.0);
PopRegisterStack;

Volume 3: Base IA-32 Instruction Reference 3:571


FYL2XP1—Compute y ∗ log2(x +1) (Continued)

FPU Flags Affected


C1 Set to 0 if stack underflow occurred.
Indicates rounding direction if the inexact-result exception (#P) is generated:
0 = not roundup; 1 = roundup.
C0, C2, C3 Undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.

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.

Protected Mode Exceptions


#NM EM or TS in CR0 is set.

Real Address Mode Exceptions


#NM EM or TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM EM or TS in CR0 is set.

3:572 Volume 3: Base IA-32 Instruction Reference


HLT—Halt
Opcode Instruction Description
F4 HLT Halt

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept.

Protected Mode Exceptions


#GP(0) If the current privilege level is not 0.

Real Address Mode Exceptions

None.

Virtual 8086 Mode Exceptions


#GP(0) If the current privilege level is not 0.

Volume 3: Base IA-32 Instruction Reference 3:573


IDIV—Signed Divide
Opcode Instruction Description
F6 /7 IDIV r/m8 Signed divide AX (where AH must contain sign-extension of
AL) by r/m byte. (Results: AL=Quotient, AH=Remainder)
F7 /7 IDIV r/m16 Signed divide DX:AX (where DX must contain sign-extension
of AX) by r/m word. (Results: AX=Quotient, DX=Remainder)
F7 /7 IDIV r/m32 Signed divide EDX:EAX (where EDX must contain
sign-extension of EAX) by r/m doubleword. (Results:
EAX=Quotient, EDX=Remainder)

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:

Table 1-13. IDIV Operands


Quotient
Operand Size Dividend Divisor Quotient Remainder
Range
Word/byte AX r/m8 AL AH −128 to +127
Doubleword/word DX:AX r/m16 AX DX −32,768 to +32,767
Quadword/doubleword EDX:EAX r/m32 EAX EDX −231 to 232 −1

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

3:574 Volume 3: Base IA-32 Instruction Reference


IDIV—Signed Divide (Continued)

temp ←DX:AX / SRC; (* signed division *)


IF (temp > 7FFFH) OR (temp < 8000H)
(* if a positive result is greater than 7FFFH *)
(* or a negative result is less than 8000H *)
THEN #DE; (* divide error *) ;
ELSE
AX ←temp;
DX ←DX:AX SignedModulus SRC;
FI;
ELSE (* quadword/doubleword operation *)
temp ←EDX:EAX / SRC; (* signed division *)
IF (temp > 7FFFFFFFH) OR (temp < 80000000H)
(* if a positive result is greater than 7FFFFFFFH *)
(* or a negative result is less than 80000000H *)
THEN #DE; (* divide error *) ;
ELSE
EAX ←temp;
EDX ←EDXE:AX SignedModulus SRC;
FI;
FI;
FI;

Flags Affected

The CF, OF, SF, ZF, AF, and PF flags are undefined.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#DE If the source operand (divisor) is 0.

The signed result (quotient) is too large for the destination.


#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.

Volume 3: Base IA-32 Instruction Reference 3:575


IDIV—Signed Divide (Continued)

Real Address Mode Exceptions


#DE If the source operand (divisor) is 0.

The signed result (quotient) is too large for the destination.


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#DE If the source operand (divisor) is 0.

The signed result (quotient) is too large for the destination.


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:576 Volume 3: Base IA-32 Instruction Reference


IMUL—Signed Multiply
Opcode Instruction Description
F6 /5 IMUL r/m8 AX←AL ∗ r/m byte
F7 /5 IMUL r/m16 DX:AX ←AX ∗ r/m word
F7 /5 IMUL r/m32 EDX:EAX ←EAX ∗ r/m doubleword
0F AF /r IMUL r16,r/m16 word register ←word register ∗ r/m word
0F AF /r IMUL r32,r/m32 doubleword register ←doubleword register ∗ r/m doubleword
6B /r ib IMUL r16,r/m16,imm8 word register ←r/m16 ∗ sign-extended immediate byte
6B /r ib IMUL r32,r/m32,imm8 doubleword register ←r/m32 ∗ sign-extended immediate byte
6B /r ib IMUL r16,imm8 word register ←word register ∗ sign-extended immediate byte
6B /r ib IMUL r32,imm8 doubleword register ←doubleword register ∗ sign-extended
immediate byte
69 /r iw IMUL r16,r/ word register ←r/m16 ∗ immediate word
m16,imm16
69 /r id IMUL r32,r/ doubleword register ←r/m32 ∗ immediate doubleword
m32,imm32
69 /r iw IMUL r16,imm16 word register ←r/m16 ∗ immediate word
69 /r id IMUL r32,imm32 doubleword register ←r/m32 ∗ immediate doubleword

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.

Volume 3: Base IA-32 Instruction Reference 3:577


IMUL—Signed Multiply (Continued)
The three forms of the IMUL instruction are similar in that the length of the product is calculated to
twice the length of the operands. With the one-operand form, the product is stored exactly in the
destination. With the two- and three- operand forms, however, result is truncated to the length of
the destination before it is stored in the destination register. Because of this truncation, the CF or
OF flag should be tested to ensure that no significant bits are lost.

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;

3:578 Volume 3: Base IA-32 Instruction Reference


IMUL—Signed Multiply (Continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:579


IN—Input from Port
Opcode Instruction Description
E4 ib IN AL,imm8 Input byte from imm8 I/O port address into AL
E5 ib IN AX,imm8 Input byte from imm8 I/O port address into AX
E5 ib IN EAX,imm8 Input byte from imm8 I/O port address into EAX
EC IN AL,DX Input byte from I/O port in DX into AL
ED IN AX,DX Input word from I/O port in DX into AX
ED IN EAX,DX Input doubleword from I/O port in DX into EAX

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 *)

3:580 Volume 3: Base IA-32 Instruction Reference


IN—Input from Port (Continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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
IA_32_Exception Debug traps for data breakpoints and single step
IA_32_Exception Alignment faults
#GP(0) Referenced Port is to an unimplemented virtual address or PSR.dt is zero.

Protected Mode Exceptions


#GP(0) If the CPL is greater than (has less privilege) the I/O privilege level (IOPL)
and any of the corresponding I/O permission bits in TSS for the I/O port being
accessed is 1 when CFLG.io is 1.

Real Address Mode Exceptions

None.

Virtual 8086 Mode Exceptions


#GP(0) If any of the I/O permission bits in the TSS for the I/O port being accessed is
1.

Volume 3: Base IA-32 Instruction Reference 3:581


INC—Increment by 1
Opcode Instruction Description
FE /0 INC r/m8 Increment r/m byte by 1
FF /0 INC r/m16 Increment r/m word by 1
FF /0 INC r/m32 Increment r/m doubleword by 1
40+ rw INC r16 Increment word register by 1
40+ rd INC r32 Increment doubleword register by 1

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the operand is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

3:582 Volume 3: Base IA-32 Instruction Reference


INC—Increment by 1 (Continued)

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:583


INS/INSB/INSW/INSD—Input from Port to String
Opcode Instruction Description
6C INS ES:(E)DI, DX Input byte from port DX into ES:(E)DI
6D INS ES:DI, DX Input word from port DX into ES:DI
6D INS ES:EDI, DX Input doubleword from port DX into ES:EDI
6C INSB Input byte from port DX into ES:(E)DI
6D INSW Input word from port DX into ES:DI
6D INSD Input doubleword from port DX into ES:EDI

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.

3:584 Volume 3: Base IA-32 Instruction Reference


INS/INSB/INSW/INSD—Input from Port to String (Continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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
IA_32_Exception Debug traps for data breakpoints and single step
IA_32_Exception Alignment faults
#GP(0) Referenced Port is to an unimplemented virtual address or PSR.dt is zero.

Volume 3: Base IA-32 Instruction Reference 3:585


INS/INSB/INSW/INSD—Input from Port to String (Continued)

Protected Mode Exceptions


#GP(0) If the CPL is greater than (has less privilege) the I/O privilege level (IOPL)
and any of the corresponding I/O permission bits in TSS for the I/O port being
accessed is 1 and when CFLG.io is 1.
If the destination is located in a nonwritable segment.
If an illegal memory operand effective address in the ES segments is given.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If any of the I/O permission bits in the TSS for the I/O port being accessed is
1.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:586 Volume 3: Base IA-32 Instruction Reference


INTn/INTO/INT3—Call to Interrupt Procedure
Opcode Instruction Description
CC INT3 Interrupt 3—trap to debugger
CD ib INT imm8 Interrupt vector numbered by immediate byte
CE INTO Interrupt 4—if overflow flag is 1

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).

Volume 3: Base IA-32 Instruction Reference 3:587


INTn/INTO/INT3—Call to Interrupt Procedure (Continued)
Table 1-14. INT Cases
PE 0 1 1 1 1 1 1 1
VM – – – – – 0 1 1
IOPL – – – – – – <3 =3
DPL/CPL – DPL< – DPL> DPL= DPL< – –
RELATIONSHIP CPL CPL CPL or C CPL & NC

INTERRUPT TYPE – S/W – – – – – –


GATE TYPE – – Task Trap or Trap or Trap or Trap or Trap or
Interrupt Interrupt Interrupt Interrupt Interrupt
REAL-ADDRESS-MODE Y
PROTECTED-MODE Y Y Y Y Y Y Y
TRAP-OR-INTERRUPT-G Y Y Y Y Y
ATE
INTER-PRIVILEGE-LEVEL Y
-INTERRUPT
INTRA-PRIVILEGE-LEVE Y
L-INTERRUPT
INTERRUPT-FROM-VIRT Y
UAL-8086-MODE
TASK-GATE Y
#GP Y Y Y

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;

3:588 Volume 3: Base IA-32 Instruction Reference


INTn/INTO/INT3—Call to Interrupt Procedure (Continued)

/*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;

TASK-GATE: (* PE=1, task gate *)


Read segment selector in task gate (IDT descriptor);
IF 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

Volume 3: Base IA-32 Instruction Reference 3:589


INTn/INTO/INT3—Call to Interrupt Procedure (Continued)

THEN #NP(TSS selector);


FI;
SWITCH-TASKS (with nesting) to TSS;
IF interrupt caused by fault with error code
THEN
IF stack limit does not allow push of two bytes
THEN #SS(0);
FI;
Push(error code);
FI;
IF EIP not within code segment limit
THEN #GP(0);
FI;
END;
TRAP-OR-INTERRUPT-GATE
Read segment selector for trap or interrupt gate (IDT descriptor);
IF segment selector for code segment is null
THEN #GP(0H + EXT); (* null selector with EXT flag set *)
FI;
IF segment selector is not within its descriptor table limits
THEN #GP(selector + EXT);
FI;
Read trap or interrupt handler descriptor;
IF descriptor does not indicate a code segment
OR code segment descriptor DPL > CPL
THEN #GP(selector + EXT);
FI;
IF trap or interrupt gate segment is not present,
THEN #NP(selector + EXT);
FI;
IF code segment is non-conforming AND DPL < CPL
THEN IF VM=0
THEN
GOTO INTER-PRIVILEGE-LEVEL-INTERRUPT;
(* PE=1, interrupt or trap gate, nonconforming *)
(* code segment, DPL<CPL, VM=0 *)
ELSE (* VM=1 *)
IF code segment DPL ≠ 0 THEN #GP(new code segment selector); FI;
GOTO INTERRUPT-FROM-VIRTUAL-8086-MODE;
(* PE=1, interrupt or trap gate, DPL<CPL, VM=1 *)
FI;
ELSE (* PE=1, interrupt or trap gate, DPL ≥ CPL *)
IF VM=1 THEN #GP(new code segment selector); FI;
IF code segment is conforming OR code segment DPL = CPL
THEN
GOTO INTRA-PRIVILEGE-LEVEL-INTERRUPT;
ELSE
#GP(CodeSegmentSelector + EXT);
(* PE=1, interrupt or trap gate, nonconforming *)
(* code segment, DPL>CPL *)
FI;
FI;
END;

3:590 Volume 3: Base IA-32 Instruction Reference


INTn/INTO/INT3—Call to Interrupt Procedure (Continued)
INTER-PRIVILEGE-LEVEL-INTERRUPT
(* PE=1, interrupt or trap gate, non-conforming code segment, DPL<CPL *)
(* Check segment selector and descriptor for stack of new privilege level in current TSS *)
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 segment selector is null THEN #TS(EXT); FI;
IF segment selector index is not within its descriptor table limits
OR segment selector's RPL ≠ DPL of code segment,
THEN #TS(SS selector + EXT);
FI;
Read segment descriptor for stack segment in GDT or LDT;
IF stack segment DPL ≠ DPL of code segment,
OR stack segment does not indicate writable data segment,
THEN #TS(SS selector + EXT);
FI;
IF stack segment not present THEN #SS(SS selector+EXT); FI;
IF 32-bit gate
THEN
IF new stack does not have room for 24 bytes (error code pushed)
OR 20 bytes (no error code pushed)
THEN #SS(segment selector + EXT);
FI;
ELSE (* 16-bit gate *)
IF new stack does not have room for 12 bytes (error code pushed)
OR 10 bytes (no error code pushed);
THEN #SS(segment selector + EXT);
FI;
FI;
IF instruction pointer is not within code segment limits THEN #GP(0); FI;
SS:ESP ←TSS(SS:ESP) (* segment descriptor information also loaded *)
IF 32-bit gate
THEN
CS:EIP ←Gate(CS:EIP); (* segment descriptor information also loaded *)
ELSE (* 16-bit gate *)
CS:IP ←Gate(CS:IP); (* segment descriptor information also loaded *)
FI;
IF 32-bit gate
THEN
Push(far pointer to old stack); (* old SS and ESP, 3 words padded to 4 *);
Push(EFLAGS);
Push(far pointer to return instruction); (* old CS and EIP, 3 words padded to 4*);
Push(ErrorCode); (* if needed, 4 bytes *)

Volume 3: Base IA-32 Instruction Reference 3:591


INTn/INTO/INT3—Call to Interrupt Procedure (Continued)
ELSE(* 16-bit gate *)
Push(far pointer to old stack); (* old SS and SP, 2 words *);
Push(EFLAGS);
Push(far pointer to return instruction); (* old CS and IP, 2 words *);
Push(ErrorCode); (* if needed, 2 bytes *)
FI;
CPL ←CodeSegmentDescriptor(DPL);
CS(RPL) ←CPL;
IF interrupt gate
THEN IF ←0 (* interrupt flag to 0 (disabled) *); FI;
TF ←0;
VM ←0;
RF ←0;
NT ←0;
I END;
INTERRUPT-FROM-VIRTUAL-8086-MODE:
(* Check segment selector and descriptor for privilege level 0 stack in current TSS *)
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 segment selector is null THEN #TS(EXT); FI;
IF segment selector index is not within its descriptor table limits
OR segment selector's RPL ≠ DPL of code segment,
THEN #TS(SS selector + EXT);
FI;
Access segment descriptor for stack segment in GDT or LDT;
IF stack segment DPL ≠ DPL of code segment,
OR stack segment does not indicate writable data segment,
THEN #TS(SS selector + EXT);
FI;
IF stack segment not present THEN #SS(SS selector+EXT); FI;
IF 32-bit gate
THEN
IF new stack does not have room for 40 bytes (error code pushed)
OR 36 bytes (no error code pushed);
THEN #SS(segment selector + EXT);
FI;
ELSE (* 16-bit gate *)
IF new stack does not have room for 20 bytes (error code pushed)
OR 18 bytes (no error code pushed);
THEN #SS(segment selector + EXT);
FI;
FI;

3:592 Volume 3: Base IA-32 Instruction Reference


INTn/INTO/INT3—Call to Interrupt Procedure (Continued)
IF instruction pointer is not within code segment limits THEN #GP(0); FI;

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;

Volume 3: Base IA-32 Instruction Reference 3:593


INTn/INTO/INT3—Call to Interrupt Procedure (Continued)
SS:ESP ←TSS(SS0:ESP0); (* Change to level 0 stack segment *)
(* Following pushes are 16 bits for 16-bit gate and 32 bits for 32-bit gates *)
(* Segment selector pushes in 32-bit mode are padded to two words *)
Push(GS);
Push(FS);
Push(DS);
Push(ES);
Push(TempSS);
Push(TempESP);
Push(TempEFlags);
Push(CS);
Push(EIP);
GS ←0; (*segment registers nullified, invalid in protected mode *)
FS ←0;
DS ←0;
ES ←0;
CS ←Gate(CS);
IF OperandSize=32
THEN
EIP ←Gate(instruction pointer);
ELSE (* OperandSize is 16 *)
EIP ←Gate(instruction pointer) AND 0000FFFFH;
FI;
(* Starts execution of new routine in Protected Mode *)
END;

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;

3:594 Volume 3: Base IA-32 Instruction Reference


INTn/INTO/INT3—Call to Interrupt Procedure (Continued)
ELSE (* 16-bit gate *)
IF current stack does not have room for 8 bytes (error code pushed)
OR 6 bytes (no error code pushed); THEN #SS(0);
FI;
IF instruction pointer not within code segment limit THEN #GP(0); FI;
IF 32-bit gate
THEN
Push (EFLAGS);
Push (far pointer to return instruction); (* 3 words padded to 4 *)
CS:EIP ←Gate(CS:EIP); (* segment descriptor information also loaded *)
Push (ErrorCode); (* if any *)
ELSE (* 16-bit gate *)
Push (FLAGS);
Push (far pointer to return location); (* 2 words *)
CS:IP ←Gate(CS:IP); (* segment descriptor information also loaded *)
Push (ErrorCode); (* if any *)
FI;
CS(RPL) ←CPL;
IF interrupt gate
THEN
IF ←0; FI;
TF ←0;
NT ←0;
VM ←0;
RF ←0;
FI;
END;

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.)

Additional Itanium System Environment Exceptions


IA_32_Exception If INT3 or INTO form, vector numbers are 3 and 4 respectively.
IA-32_Interrupt If INT n form, vector number is N.

Protected Mode Exceptions


#GP(0) If the instruction pointer in the IDT or in the interrupt-, trap-, or task gate is
beyond the code segment limits.
#GP(selector) If the segment selector in the interrupt-, trap-, or task gate is null.
If a interrupt-, trap-, or task gate, code segment, or TSS segment selector
index is outside its descriptor table limits.
If the interrupt vector is outside the IDT limits.
If an IDT descriptor is not an interrupt-, trap-, or task-descriptor.
If an interrupt is generated by the INTn instruction and the DPL of an
interrupt-, trap-, or task-descriptor is less than the CPL.

Volume 3: Base IA-32 Instruction Reference 3:595


INTn/INTO/INT3—Call to Interrupt Procedure (Continued)
If the segment selector in an interrupt- or trap-gate does not point to a segment
descriptor for a code segment.
If the segment selector for a TSS has its local/global bit set for local.
If a TSS segment descriptor specifies that the TSS is busy or not available.
#SS(0) If pushing the return address, flags, or error code onto the stack exceeds the
bounds of the stack segment and no stack switch occurs.
#SS(selector) If the SS register is being loaded and the segment pointed to is marked not
present.
If pushing the return address, flags, error code, or stack segment pointer
exceeds the bounds of the stack segment.
#NP(selector) If code segment, interrupt-, trap-, or task gate, or TSS is not present.
#TS(selector) If the RPL of the stack segment selector in the TSS is not equal to the DPL of
the code segment being accessed by the interrupt or trap gate.
If DPL of the stack segment descriptor pointed to by the stack segment
selector in the TSS is not equal to the DPL of the code segment descriptor for
the interrupt or trap gate.
If the stack segment selector in the TSS is null.
If the stack segment for the TSS is not a writable data segment.
If segment-selector index for stack segment is outside descriptor table limits.
#PF(fault-code) If a page fault occurs.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the interrupt vector is outside the IDT limits.
#SS If stack limit violation on push.
If pushing the return address, flags, or error code onto the stack exceeds the
bounds of the stack segment when a stack switch occurs.

Virtual 8086 Mode Exceptions


#GP(0) (For INTn instruction) If the IOPL is less than 3 and the DPL of the interrupt-,
trap-, or task-gate descriptor is not equal to 3.
If the instruction pointer in the IDT or in the interrupt-, trap-, or task gate is
beyond the code segment limits.
#GP(selector) If the segment selector in the interrupt-, trap-, or task gate is null.
If a interrupt-, trap-, or task gate, code segment, or TSS segment selector
index is outside its descriptor table limits.
If the interrupt vector is outside the IDT limits.
If an IDT descriptor is not an interrupt-, trap-, or task-descriptor.

3:596 Volume 3: Base IA-32 Instruction Reference


INTn/INTO/INT3—Call to Interrupt Procedure (Continued)
If an interrupt is generated by the INTn instruction and the DPL of an
interrupt-, trap-, or task-descriptor is less than the CPL.
If the segment selector in an interrupt- or trap-gate does not point to a segment
descriptor for a code segment.
If the segment selector for a TSS has its local/global bit set for local.
#SS(selector) If the SS register is being loaded and the segment pointed to is marked not
present.
If pushing the return address, flags, error code, stack segment pointer, or data
segments exceeds the bounds of the stack segment.
#NP(selector) If code segment, interrupt-, trap-, or task gate, or TSS is not present.
#TS(selector) If the RPL of the stack segment selector in the TSS is not equal to the DPL of
the code segment being accessed by the interrupt or trap gate.
If DPL of the stack segment descriptor for the TSS’s stack segment is not
equal to the DPL of the code segment descriptor for the interrupt or trap gate.
If the stack segment selector in the TSS is null.
If the stack segment for the TSS is not a writable data segment.
If segment-selector index for stack segment is outside descriptor table limits.
#PF(fault-code) If a page fault occurs.
#BP If the INT3 instruction is executed.
#OF If the INTO instruction is executed and the OF flag is set.

Volume 3: Base IA-32 Instruction Reference 3:597


INVD—Invalidate Internal Caches
Opcode Instruction Description
0F 08 INVD Flush internal caches; initiate flushing of external caches.

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept

Protected Mode Exceptions


#GP(0) If the current privilege level is not 0.

Real Address Mode Exceptions

None.

Virtual 8086 Mode Exceptions


#GP(0) The INVD instruction cannot be executed at the virtual 8086 mode.

3:598 Volume 3: Base IA-32 Instruction Reference


INVD—Invalidate Internal Caches (Continued)

Intel Architecture Compatibility

This instruction is not supported on Intel architecture processors earlier than the Intel486 processor.

Volume 3: Base IA-32 Instruction Reference 3:599


INVLPG—Invalidate TLB Entry
Opcode Instruction Description
0F 01/7 INVLPG m Invalidate TLB Entry for page that contains m

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept

Protected Mode Exceptions


#GP(0) If the current privilege level is not 0.
#UD Operand is a register.

Real Address Mode Exceptions

None.

Virtual 8086 Mode Exceptions


#GP(0) The INVLPG instruction cannot be executed at the virtual 8086 mode.

Intel Architecture Compatibility

This instruction is not supported on Intel architecture processors earlier than the Intel486 processor.

3:600 Volume 3: Base IA-32 Instruction Reference


IRET/IRETD—Interrupt Return
Opcode Instruction Description
CF IRET Interrupt return (16-bit operand size)
CF IRETD Interrupt return (32-bit operand size)

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.

Return from nested task (task switch)

All forms of IRET result in an IA-32_Intercept(Inst,IRET) in the Itanium System


Environment.

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.

IRET performs an instruction serialization and a memory fence operation.

Volume 3: Base IA-32 Instruction Reference 3:601


IRET/IRETD—Interrupt Return (Continued)

Operation

IF(Itanium System Environment)


THEN IA-32_Intercept(Inst,IRET);
IF PE = 0
THEN
GOTO REAL-ADDRESS-MODE:;
ELSE
GOTO PROTECTED-MODE;
FI;

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);

3:602 Volume 3: Base IA-32 Instruction Reference


IRET/IRETD—Interrupt Return (Continued)
FI;
tempEIP ←Pop();
tempCS ←Pop();
tempEFLAGS ←Pop();
tempEIP ←tempEIP AND FFFFH;
tempEFLAGS ←tempEFLAGS AND FFFFH;
FI;
IF tempEFLAGS(VM) = 1 AND CPL=0
THEN
GOTO RETURN-TO-VIRTUAL-8086-MODE;
(* PE=1, VM=1 in EFLAGS image *)
ELSE
GOTO PROTECTED-MODE-RETURN;
(* PE=1, VM=0 in EFLAGS image *)
FI;

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;

Volume 3: Base IA-32 Instruction Reference 3:603


IRET/IRETD—Interrupt Return (Continued)
CS ←Pop(); (* 16-bit pop *)
TempFlags <- Pop();
FLAGS = (FLAGS AND 3000H) OR (TempFLags AND 4FD5H)
(*IOPL unmodified*)
FI;
ELSE (*IOPL < 3*)
IF OperandSize = 16
THEN
IF ((STACK.TF !-0) OR (EFLAGS.VIP=1 AND STACK.IF=1))
THEN #GP(0);
ELSE
IP <- Pop(); (*Word Pops*)
CS <- Pop(0);
TempFlags <- Pop();
(*FLAGS IOPL, IF and TF are not modified*)
FLAGS = (FLAGS AND 3302H) OR (TempFlags AND 4CD5H)
EFLAGS.VIF <- TempFlags.IF;
FI;
ELSE (*OperandSize = 32 *)
#GP(0);
FI;
FI;

END;

RETURN-TO-VIRTUAL-8086-MODE:

(* Interrupted procedure was in virtual-8086 mode: PE=1, VM=1 in flags image *)


IF top 24 bytes of stack are not within stack segment limits
THEN #SS(0);
FI;
IF instruction pointer not within code segment limits
THEN #GP(0);
FI;
CS ←tempCS;
EIP ←tempEIP;
EFLAGS ←tempEFLAGS
TempESP ←Pop();
TempSS ←Pop();
ES ←Pop(); (* pop 2 words; throw away high-order word *)
DS ←Pop(); (* pop 2 words; throw away high-order word *)
FS ←Pop(); (* pop 2 words; throw away high-order word *)
GS ←Pop(); (* pop 2 words; throw away high-order word *)
SS:ESP ←TempSS:TempESP;
(* Resume execution in Virtual 8086 mode *)
END;

TASK-RETURN: (* PE=1, VM=1, NT=1 *)


Read segment selector in link field of current TSS;
IF local/global bit is set to local
OR index not within GDT limits
THEN #GP(TSS selector);
FI;
Access TSS for task specified in link field of current TSS;

3:604 Volume 3: Base IA-32 Instruction Reference


IRET/IRETD—Interrupt Return (Continued)
IF TSS descriptor type is not TSS or if the TSS is marked not busy
THEN #GP(TSS selector);
FI;
IF TSS not present
THEN #NP(TSS selector);
FI;
SWITCH-TASKS (without nesting) to TSS specified in link field of current TSS;
Mark the task just abandoned as NOT BUSY;
IF EIP is not within code segment limit
THEN #GP(0);
FI;
END;

PROTECTED-MODE-RETURN: (* PE=1, VM=0 in flags image *)


IF return code segment selector is null THEN GP(0); FI;
IF return code segment selector addrsses descriptor beyond descriptor table limit
THEN GP(selector; FI;
Read segment descriptor pointed to by the return code segment selector
IF return code segment descriptor is not a code segment THEN #GP(selector); FI;
IF return code segment selector RPL < CPL THEN #GP(selector); FI;
IF return code segment descriptor is conforming
AND return code segment DPL > return code segment selector RPL
THEN #GP(selector); FI;
IF return code segment descriptor is not present THEN #NP(selector); FI:
IF return code segment selector RPL > CPL
THEN GOTO RETURN-OUTER-PRIVILEGE-LEVEL;
ELSE GOTO RETURN-TO-SAME-PRIVILEGE-LEVEL
FI;
END;

RETURN-TO-SAME-PRIVILEGE-LEVEL: (* PE=1, VM=0 in flags image, RPL=CPL *)


IF EIP is not within code segment limits THEN #GP(0); FI;
EIP ←tempEIP;
CS ←tempCS; (* segment descriptor information also loaded *)
EFLAGS (CF, PF, AF, ZF, SF, TF, DF, OF, NT) ←tempEFLAGS;
IF OperandSize=32
THEN
EFLAGS(RF, AC, ID) ←tempEFLAGS;
FI;
IF CPL ≤IOPL
THEN
EFLAGS(IF) ←tempEFLAGS;
FI;
IF CPL = 0
THEN
EFLAGS(IOPL) ←tempEFLAGS;
IF OperandSize=32
THEN EFLAGS(VM, VIF, VIP) ←tempEFLAGS;
FI;
FI;

END;

RETURN-TO-OUTER-PRIVILGE-LEVEL:

Volume 3: Base IA-32 Instruction Reference 3:605


IRET/IRETD—Interrupt Return (Continued)

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:

3:606 Volume 3: Base IA-32 Instruction Reference


IRET/IRETD—Interrupt Return (Continued)

Flags Affected

All the flags and fields in the EFLAGS register are potentially modified, depending on the mode of
operation of the processor.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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
IA-32_Intercept Instruction Intercept Trap for ALL forms of IRET.

Protected Mode Exceptions


#GP(0) If the return code or stack segment selector is null.
If the return instruction pointer is not within the return code segment limit.
#GP(selector) If a segment selector index is outside its descriptor table limits.
If the return code segment selector RPL is greater than the CPL.
If the DPL of a conforming-code segment is greater than the return code
segment selector RPL.
If the DPL for a nonconforming-code segment is not equal to the RPL of the
code segment selector.
If the stack segment descriptor DPL is not equal to the RPL of the return code
segment selector.
If the stack segment is not a writable data segment.
If the stack segment selector RPL is not equal to the RPL of the return code
segment selector.
If the segment descriptor for a code segment does not indicate it is a code
segment.
If the segment selector for a TSS has its local/global bit set for local.
If a TSS segment descriptor specifies that the TSS is busy or not available.
#SS(0) If the top bytes of stack are not within stack limits.
#NP(selector) If the return code or stack segment is not present.
#PF(fault-code) If a page fault occurs.
#AC(0) If an unaligned memory reference occurs when the CPL is 3 and alignment
checking is enabled.

Real Address Mode Exceptions


#GP If the return instruction pointer is not within the return code segment limit.
#SS If the top bytes of stack are not within stack limits.

Volume 3: Base IA-32 Instruction Reference 3:607


IRET/IRETD—Interrupt Return (Continued)

Virtual 8086 Mode Exceptions


#GP(0) If the return instruction pointer is not within the return code segment limit.
IF IOPL not equal to 3
#PF(fault-code) If a page fault occurs.
#SS(0) If the top bytes of stack are not within stack limits.
#AC(0) If an unaligned memory reference occurs and alignment checking is enabled.

3:608 Volume 3: Base IA-32 Instruction Reference


Jcc—Jump if Condition Is Met
Opcode Instruction Description
77 cb JA rel8 Jump short if above (CF=0 and ZF=0)
73 cb JAE rel8 Jump short if above or equal (CF=0)
72 cb JB rel8 Jump short if below (CF=1)
76 cb JBE rel8 Jump short if below or equal (CF=1 or ZF=1)
72 cb JC rel8 Jump short if carry (CF=1)
E3 cb JCXZ rel8 Jump short if CX register is 0
E3 cb JECXZ rel8 Jump short if ECX register is 0
74 cb JE rel8 Jump short if equal (ZF=1)
7F cb JG rel8 Jump short if greater (ZF=0 and SF=OF)
7D cb JGE rel8 Jump short if greater or equal (SF=OF)
7C cb JL rel8 Jump short if less (SF<>OF)
7E cb JLE rel8 Jump short if less or equal (ZF=1 or SF<>OF)
76 cb JNA rel8 Jump short if not above (CF=1 or ZF=1)
72 cb JNAE rel8 Jump short if not above or equal (CF=1)
73 cb JNB rel8 Jump short if not below (CF=0)
77 cb JNBE rel8 Jump short if not below or equal (CF=0 and ZF=0)
73 cb JNC rel8 Jump short if not carry (CF=0)
75 cb JNE rel8 Jump short if not equal (ZF=0)
7E cb JNG rel8 Jump short if not greater (ZF=1 or SF<>OF)
7C cb JNGE rel8 Jump short if not greater or equal (SF<>OF)
7D cb JNL rel8 Jump short if not less (SF=OF)
7F cb JNLE rel8 Jump short if not less or equal (ZF=0 and SF=OF)
71 cb JNO rel8 Jump short if not overflow (OF=0)
7B cb JNP rel8 Jump short if not parity (PF=0)
79 cb JNS rel8 Jump short if not sign (SF=0)
75 cb JNZ rel8 Jump short if not zero (ZF=0)
70 cb JO rel8 Jump short if overflow (OF=1)
7A cb JP rel8 Jump short if parity (PF=1)
7A cb JPE rel8 Jump short if parity even (PF=1)
7B cb JPO rel8 Jump short if parity odd (PF=0)
78 cb JS rel8 Jump short if sign (SF=1)
74 cb JZ rel8 Jump short if zero (ZF = 1)
0F 87 cw/cd JA rel16/32 Jump near if above (CF=0 and ZF=0)
0F 83 cw/cd JAE rel16/32 Jump near if above or equal (CF=0)
0F 82 cw/cd JB rel16/32 Jump near if below (CF=1)
0F 86 cw/cd JBE rel16/32 Jump near if below or equal (CF=1 or ZF=1)
0F 82 cw/cd JC rel16/32 Jump near if carry (CF=1)
0F 84 cw/cd JE rel16/32 Jump near if equal (ZF=1)
0F 84 cw/cd JZ rel16/32 Jump near if 0 (ZF=1)
0F 8F cw/cd JG rel16/32 Jump near if greater (ZF=0 and SF=OF)

Volume 3: Base IA-32 Instruction Reference 3:609


Jcc—Jump if Condition Is Met (Continued)
Opcode Instruction Description
0F 8D cw/cd JGE rel16/32 Jump near if greater or equal (SF=OF)
0F 8C cw/cd JL rel16/32 Jump near if less (SF<>OF)
0F 8E cw/cd JLE rel16/32 Jump near if less or equal (ZF=1 or SF<>OF)
0F 86 cw/cd JNA rel16/32 Jump near if not above (CF=1 or ZF=1)
0F 82 cw/cd JNAE rel16/32 Jump near if not above or equal (CF=1)
0F 83 cw/cd JNB rel16/32 Jump near if not below (CF=0)
0F 87 cw/cd JNBE rel16/32 Jump near if not below or equal (CF=0 and ZF=0)
0F 83 cw/cd JNC rel16/32 Jump near if not carry (CF=0)
0F 85 cw/cd JNE rel16/32 Jump near if not equal (ZF=0)
0F 8E cw/cd JNG rel16/32 Jump near if not greater (ZF=1 or SF<>OF)
0F 8C cw/cd JNGE rel16/32 Jump near if not greater or equal (SF<>OF)
0F 8D cw/cd JNL rel16/32 Jump near if not less (SF=OF)
0F 8F cw/cd JNLE rel16/32 Jump near if not less or equal (ZF=0 and SF=OF)
0F 81 cw/cd JNO rel16/32 Jump near if not overflow (OF=0)
0F 8B cw/cd JNP rel16/32 Jump near if not parity (PF=0)
0F 89 cw/cd JNS rel16/32 Jump near if not sign (SF=0)
0F 85 cw/cd JNZ rel16/32 Jump near if not zero (ZF=0)
0F 80 cw/cd JO rel16/32 Jump near if overflow (OF=1)
0F 8A cw/cd JP rel16/32 Jump near if parity (PF=1)
0F 8A cw/cd JPE rel16/32 Jump near if parity even (PF=1)
0F 8B cw/cd JPO rel16/32 Jump near if parity odd (PF=0)
0F 88 cw/cd JS rel16/32 Jump near if sign (SF=1)
0F 84 cw/cd JZ rel16/32 Jump near if 0 (ZF=1)

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.

3:610 Volume 3: Base IA-32 Instruction Reference


Jcc—Jump if Condition Is Met (Continued)
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 JA (jump if above) instruction and the
JNBE (jump if not below or equal) instruction are alternate mnemonics for the opcode 77H.

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;

To accomplish this far jump, use the following two instructions:

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.

Additional Itanium System Environment Exceptions


IA_32_Exception Taken Branch Debug Exception if PSR.tb is 1

Protected Mode Exceptions


#GP(0) If the offset being jumped to is beyond the limits of the CS segment.

Volume 3: Base IA-32 Instruction Reference 3:611


Jcc—Jump if Condition Is Met (Continued)

Real Address Mode Exceptions


#GP If the offset being jumped to is beyond the limits of the CS segment or is
outside of the effective address space from 0 to FFFFH. This condition can
occur if 32-address size override prefix is used.

Virtual 8086 Mode Exceptions


#GP(0) If the offset being jumped to is beyond the limits of the CS segment or is
outside of the effective address space from 0 to FFFFH. This condition can
occur if 32-address size override prefix is used.

3:612 Volume 3: Base IA-32 Instruction Reference


JMP—Jump
Opcode Instruction Description
EB cb JMP rel8 Jump near, relative address
E9 cw JMP rel16 Jump near, relative address
E9 cd JMP rel32 Jump near, relative address
FF /4 JMP r/m16 Jump near, indirect address
FF /4 JMP r/m32 Jump near, indirect address
EA cd JMP ptr16:16 Jump far, absolute address
EA cp JMP ptr16:32 Jump far, absolute address
FF /5 JMP m16:16 Jump far, indirect address
FF /5 JMP m16:32 Jump far, indirect address

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.

Volume 3: Base IA-32 Instruction Reference 3:613


JMP—Jump (Continued)
When executing a far jump, the processor jumps to the code segment and address specified with the
target operand. 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.

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.

The JMP instruction cannot be used to perform inter-privilege level jumps.

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.

3:614 Volume 3: Base IA-32 Instruction Reference


JMP—Jump (Continued)

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;

Volume 3: Base IA-32 Instruction Reference 3:615


JMP—Jump (Continued)
CONFORMING-CODE-SEGMENT:
IF DPL > CPL THEN #GP(segment selector); FI;
IF segment not present THEN #NP(segment selector); 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;

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:

IF call gate DPL < CPL


OR call gate DPL < call gate segment-selector RPL
THEN #GP(call gate selector); FI;
IF call gate not present THEN #NP(call gate selector); FI;
IF Itanium System Environment THEN IA-32_Intercept(Gate,JMP);
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 is conforming and DPL > CPL
OR code-segment segment descriptor is non-conforming and DPL ≠ CPL
THEN #GP(code segment selector); FI;
IF code segment is not present THEN #NP(code-segment selector); FI;
IF instruction pointer is not within code-segment limit THEN #GP(0); FI;
tempEIP ←DEST(offset);
IF GateSize=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;

3:616 Volume 3: Base IA-32 Instruction Reference


JMP—Jump (Continued)

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.

Additional Itanium System Environment Exceptions


Itanium Mem Faults VHPT 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
IA-32_Intercept Gate Intercept for JMP through CALL Gates, Task Gates and Task Segments
IA_32_Exception Taken Branch Debug Exception if PSR.tb is 1

Protected Mode Exceptions


#GP(0) If offset in target operand, call gate, or TSS is beyond the code segment limits.
If the segment selector in the destination operand, call gate, task gate, or TSS
is null.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.

Volume 3: Base IA-32 Instruction Reference 3:617


JMP—Jump (Continued)
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#GP(selector) If segment selector index is outside descriptor table limits.
If the segment descriptor pointed to by the segment selector in the destination
operand is not for a conforming-code segment, nonconforming-code
segment, call gate, task gate, or task state segment.
If the DPL for a nonconforming-code segment is not equal to the CPL
(When not using a call gate.) If the RPL for the segment’s segment selector is
greater than the CPL.
If the DPL for a conforming-code segment is greater than the CPL.
If the DPL from a call-gate, task-gate, or TSS segment descriptor is less than
the CPL or than the RPL of the call-gate, task-gate, or TSS’s segment selector.
If the segment descriptor for selector in a call gate does not indicate it is a
code segment.
If the segment descriptor for the segment selector in a task gate does not
indicate available TSS.
If the segment selector for a TSS has its local/global bit set for local.
If a TSS segment descriptor specifies that the TSS is busy or not available.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NP (selector) If the code segment being accessed is not present.
If call gate, task gate, or TSS not present.
#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. (Only occurs when fetching target from
memory.)

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If the target operand is beyond the code segment limits.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.
(Only occurs when fetching target from memory.)

3:618 Volume 3: Base IA-32 Instruction Reference


JMPE—Jump to Intel® Itanium® Instruction Set
Opcode Instruction Description
0F 00 /6 JMPE r/m16 Jump to Intel Itanium instruction set, indirect address specified by
r/m16
0F 00 /6 JMPE r/m32 Jump to Intel Itanium instruction set, indirect address specified by
r/m32
0F B8 JMPE disp16 Jump to Intel Itanium instruction set, absolute address specified by
addr16
0F B8 JMPE disp32 Jump to Intel Itanium instruction set, absolute address specified by
addr32

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.

JMPE does not perform a memory fence or serialization operation.

Successful execution of JMPE clears EFLAG.rf and PSR.id to zero.

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.

Volume 3: Base IA-32 Instruction Reference 3:619


JMPE—Jump to Intel® Itanium® Instruction Set (Continued)

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;

if (PSR.tb) //taken branch trap


IA_32_Exception(Debug);
}

Flags Affected

None (other than EFLAG.rf)

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Fault.
Disabled ISA Disabled Instruction Set Transition Fault, if PSR.di is 1
IA_32_Exception Floating-point Error, if any floating-point exceptions are pending
IA_32_Exception Taken Branch trap, if PSR.tb is 1.

IA-32 System Environment Exceptions (All Operating Modes)


#UD JMPE raises an invalid opcode exception at privilege levels 1, 2 and 3.
Privilege level 0 results in termination of the IA-32 System Environment on
a processor based on the Itanium architecture.

3:620 Volume 3: Base IA-32 Instruction Reference


LAHF—Load Status Flags into AH Register
Opcode Instruction Description
9F LAHF Load: AH = EFLAGS(SF:ZF:0:AF:0:PF:1:CF)

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).

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

Exceptions (All Operating Modes)

None.

Volume 3: Base IA-32 Instruction Reference 3:621


LAR—Load Access Rights Byte
Opcode Instruction Description
0F 02 /r LAR r16,r/m16 r16 ←r/m16 masked by FF00H
0F 02 /r LAR r32,r/m32 r32 ←r/m32 masked by 00FxFF00H

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.

The LAR instruction can only be executed in protected mode.

3:622 Volume 3: Base IA-32 Instruction Reference


LAR—Load Access Rights Byte (Continued)
Table 1-15. LAR Descriptor Validity
Type Name Valid
0 Reserved No
1 Available 16-bit TSS Yes
2 LDT Yes
3 Busy 16-bit TSS Yes
4 16-bit call gate Yes
5 16-bit/32-bit task gate Yes
6 16-bit trap gate No
7 16-bit interrupt gate No
8 Reserved No
9 Available 32-bit TSS Yes
A Reserved No
B Busy 32-bit TSS Yes
C 32-bit call gate Yes
D Reserved No
E 32-bit trap gate No
F 32-bit interrupt gate No

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: Base IA-32 Instruction Reference 3:623


LAR—Load Access Rights Byte (Continued)

Protected Mode Exceptions


#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. (Only occurs when fetching target from
memory.)

Real Address Mode Exceptions


#UD The LAR instruction is not recognized in real address mode.

Virtual 8086 Mode Exceptions


#UD The LAR instruction cannot be executed in virtual 8086 mode.

3:624 Volume 3: Base IA-32 Instruction Reference


LDS/LES/LFS/LGS/LSS—Load Far Pointer
Opcode Instruction Description
C5 /r LDS r16,m16:16 Load DS:r16 with far pointer from memory
C5 /r LDS r32,m16:32 Load DS:r32 with far pointer from memory
0F B2 /r LSS r16,m16:16 Load SS:r16 with far pointer from memory
0F B2 /r LSS r32,m16:32 Load SS:r32 with far pointer from memory
C4 /r LES r16,m16:16 Load ES:r16 with far pointer from memory
C4 /r LES r32,m16:32 Load ES:r32 with far pointer from memory
0F B4 /r LFS r16,m16:16 Load FS:r16 with far pointer from memory
0F B4 /r LFS r32,m16:32 Load FS:r32 with far pointer from memory
0F B5 /r LGS r16,m16:16 Load GS:r16 with far pointer from memory
0F B5 /r LGS r32,m16:32 Load GS:r32 with far pointer from memory

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]);

Volume 3: Base IA-32 Instruction Reference 3:625


LDS/LES/LFS/LGS/LSS—Load Far Pointer (Continued)

ELSE IF DS, ES, FS, or GS is loaded with non-null segment selector


THEN IF Segment selector index is not within descriptor table limits
OR Access rights indicate segment neither data nor readable code segment
OR (Segment is data or nonconforming-code segment
AND both RPL and CPL > DPL)
THEN #GP(selector);
FI;
ELSE IF Segment marked not present
THEN #NP(selector);
FI;
SegmentRegister ←SegmentSelector(SRC) AND RPL;
SegmentRegister ←SegmentDescriptor([SRC]);
ELSE IF DS, ES, FS or GS is loaded with a null selector:
SegmentRegister ←NullSelector;
SegmentRegister(DescriptorValidBit) ←0; (*hidden flag; not accessible by software*)
FI;
FI;
IF (Real-Address or Virtual 8086 Mode)
THEN
SS ←SegmentSelector(SRC);
FI;
DEST ←Offset(SRC);

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#UD If source operand is not a memory location.
#GP(0) If a null selector is loaded into the SS register.
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.
#GP(selector) If the SS register is being loaded and any of the following is true: the segment
selector index is not within the descriptor table limits, the segment selector
RPL is not equal to CPL, the segment is a nonwritable data segment, or DPL
is not equal to CPL.

3:626 Volume 3: Base IA-32 Instruction Reference


LDS/LES/LFS/LGS/LSS—Load Far Pointer (Continued)
If the DS, ES, FS, or GS register is being loaded with a non-null segment
selector and any of the following is true: the segment selector index is not
within descriptor table limits, the segment is neither a data nor a readable
code segment, or the segment is a data or nonconforming-code segment and
both RPL and CPL are greater than DPL.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#SS(selector) If the SS register is being loaded and the segment is marked not present.
#NP(selector) If DS, ES, FS, or GS register is being loaded with a non-null segment selector
and the segment is marked not present.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#UD If source operand is not a memory location.

Virtual 8086 Mode Exceptions


#UD If source operand is not a memory location.
#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:627


LEA—Load Effective Address
Opcode Instruction Description
8D /r LEA r16,m Store effective address for m in register r16
8D /r LEA r32,m Store effective address for m in register r32

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.

Table 1-16. LEA Address and Operand Sizes


Operand Size Address Size Action Performed
16 16 16-bit effective address is calculated and stored in requested 16-bit
register destination.
16 32 32-bit effective address is calculated. The lower 16 bits of the address
are stored in the requested 16-bit register destination.
32 16 16-bit effective address is calculated. The 16-bit address is
zero-extended and stored in the requested 32-bit register destination.
32 32 32-bit effective address is calculated and stored in the requested
32-bit register destination.

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;

3:628 Volume 3: Base IA-32 Instruction Reference


LEA—Load Effective Address (Continued)

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

Protected Mode Exceptions


#UD If source operand is not a memory location.

Real Address Mode Exceptions


#UD If source operand is not a memory location.

Virtual 8086 Mode Exceptions


#UD If source operand is not a memory location.

Volume 3: Base IA-32 Instruction Reference 3:629


LEAVE—High Level Procedure Exit
Opcode Instruction Description
C9 LEAVE Set SP to BP, then pop BP
C9 LEAVE Set ESP to EBP, then pop EBP

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#SS(0) If the EBP register points to a location that is not within the limits of the
current stack segment.

3:630 Volume 3: Base IA-32 Instruction Reference


LEAVE—High Level Procedure Exit (Continued)

Real Address Mode Exceptions


#GP If the EBP register points to a location outside of the effective address space
from 0 to 0FFFFH.

Virtual 8086 Mode Exceptions


#GP(0) If the EBP register points to a location outside of the effective address space
from 0 to 0FFFFH.

Volume 3: Base IA-32 Instruction Reference 3:631


LES—Load Full Pointer
See entry for LDS/LES/LFS/LGS/LSS.

3:632 Volume 3: Base IA-32 Instruction Reference


LFS—Load Full Pointer
See entry for LDS/LES/LFS/LGS/LSS.

Volume 3: Base IA-32 Instruction Reference 3:633


LGDT/LIDT—Load Global/Interrupt Descriptor Table Register
Opcode Instruction Description
0F 01 /2 LGDT m16&32 Load m into GDTR
0F 01 /3 LIDT m16&32 Load m into IDTR

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.

3:634 Volume 3: Base IA-32 Instruction Reference


LGDT/LIDT—Load Global/Interrupt Descriptor Table Register (Continued)

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept for LIDT and LGDT

Protected Mode Exceptions


#UD If source operand is not a memory location.
#GP(0) If the current privilege level is not 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.

Real Address Mode Exceptions


#UD If source operand is not a memory location.
#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#UD If source operand is not a memory location.
#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.

Volume 3: Base IA-32 Instruction Reference 3:635


LGS—Load Full Pointer
See entry for LDS/LES/LFS/LGS/LSS.

3:636 Volume 3: Base IA-32 Instruction Reference


LLDT—Load Local Descriptor Table Register
Opcode Instruction Description
0F 00 /2 LLDT r/m16 Load segment selector r/m16 into LDTR

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 operand-size attribute has no effect on this instruction.

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);

IF SRC(Offset) > descriptor table limit THEN #GP(segment selector); FI;


Read segment descriptor;
IF SegmentDescriptor(Type) ≠ LDT THEN #GP(segment selector); FI;
IF segment descriptor is not present THEN #NP(segment selector);
LDTR(SegmentSelector) ←SRC;
LDTR(SegmentDescriptor) ←GDTSegmentDescriptor;

Flags Affected

None.

Additional Itanium System Environment Exceptions


IA-32_Intercept Instruction Intercept

Protected Mode Exceptions


#GP(0) If the current privilege level is not 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 contains a null segment selector.

Volume 3: Base IA-32 Instruction Reference 3:637


LLDT—Load Local Descriptor Table Register (Continued)
#GP(selector) If the selector operand does not point into the Global Descriptor Table or if
the entry in the GDT is not a Local Descriptor Table.
Segment selector is beyond GDT limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#NP(selector) If the LDT descriptor is not present.
#PF(fault-code) If a page fault occurs.

Real Address Mode Exceptions


#UD The LLDT instruction is not recognized in real address mode.

Virtual 8086 Mode Exceptions


#UD The LLDT instruction is recognized in virtual 8086 mode.

3:638 Volume 3: Base IA-32 Instruction Reference


LIDT—Load Interrupt Descriptor Table Register
See entry for LGDT/LIDT—Load Global Descriptor Table Register/Load Interrupt Descriptor
Table Register.

Volume 3: Base IA-32 Instruction Reference 3:639


LMSW—Load Machine Status Word
Opcode Instruction Description
0F 01 /6 LMSW r/m16 Loads r/m16 in machine status word of CR0

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.

This instruction is a serializing instruction.

Operation
IF Itanium System Environment THEN IA-32_Intercept(INST,LMSW);
CR0[0:3] ←SRC[0:3];

Flags Affected

None.

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept

Protected Mode Exceptions


#GP(0) If the current privilege level is not 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.

3:640 Volume 3: Base IA-32 Instruction Reference


LMSW—Load Machine Status Word (Continued)

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If the current privilege level is not 0.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.

Volume 3: Base IA-32 Instruction Reference 3:641


LOCK—Assert LOCK# Signal Prefix
Opcode Instruction Description
F0 LOCK Asserts LOCK# signal for duration of the accompanying
instruction

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.

Additional Itanium System Environment Exceptions


Itanium Mem Faults VHPT 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
IA-32_Intercept Lock Intercept – If an external atomic bus lock is required to complete this
operation and DCR.lc is 1, no atomic transaction occurs, the instruction is
faulted and an IA-32_Intercept(Lock) fault is generated. The software lock
handler is responsible for the emulation of the instruction.

Protected Mode Exceptions


#UD If the LOCK prefix is used with an instruction not listed in the “Description”
section above. Other exceptions can be generated by the instruction that the
LOCK prefix is being applied to.

3:642 Volume 3: Base IA-32 Instruction Reference


LOCK—Assert LOCK# Signal Prefix (Continued)

Real Address Mode Exceptions


#UD If the LOCK prefix is used with an instruction not listed in the “Description”
section above. Other exceptions can be generated by the instruction that the
LOCK prefix is being applied to.

Virtual 8086 Mode Exceptions


#UD If the LOCK prefix is used with an instruction not listed in the “Description”
section above. Other exceptions can be generated by the instruction that the
LOCK prefix is being applied to.

Volume 3: Base IA-32 Instruction Reference 3:643


LODS/LODSB/LODSW/LODSD—Load String Operand
Opcode Instruction Description
AC LODS DS:(E)SI Load byte at address DS:(E)SI into AL
AD LODS DS:SI Load word at address DS:SI into AX
AD LODS DS:ESI Load doubleword at address DS:ESI into EAX
AC LODSB Load byte at address DS:(E)SI into AL
AD LODSW Load word at address DS:SI into AX
AD LODSD Load doubleword at address DS:ESI into EAX

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

3:644 Volume 3: Base IA-32 Instruction Reference


LODS/LODSB/LODSW/LODSD—Load String Operand (Continued)

THEN ESI ←4;


ELSE ESI ←-4;

FI;
FI;
FI;

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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 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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:645


LOOP/LOOPcc—Loop According to ECX Counter
Opcode Instruction Description
E2 cb LOOP rel8 Decrement count; jump short if count ≠ 0
E1 cb LOOPE rel8 Decrement count; jump short if count ≠ 0 and ZF=1
E1 cb LOOPZ rel8 Decrement count; jump short if count ≠ 0 and ZF=1
E0 cb LOOPNE rel8 Decrement count; jump short if count ≠ 0 and ZF=0
E0 cb LOOPNZ rel8 Decrement count; jump short if count ≠ 0 and ZF=0

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;

IF instruction in not LOOP


THEN
IF (instruction = LOOPE) OR (instruction = LOOPZ)
THEN
IF (ZF =1) AND (Count ≠ 0)
THEN BranchCond ←1;
ELSE BranchCond ←0;
FI;
FI;
IF (instruction = LOOPNE) OR (instruction = LOOPNZ)

3:646 Volume 3: Base IA-32 Instruction Reference


LOOP/LOOPcc—Loop According to ECX Counter (Continued)

THEN
IF (ZF =0 ) AND (Count ≠ 0)

THEN BranchCond ←1;


ELSE BranchCond ←0;
FI;
FI;
ELSE (* instruction = LOOP *)
IF (Count ≠ 0)
THEN BranchCond ←1;
ELSE BranchCond ←0;
FI;
FI;
IF BranchCond = 1
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);
ELSE
Terminate loop and continue program execution at EIP;
FI;

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
IA_32_Exception Taken Branch Debug Exception if PSR.tb is 1

Protected Mode Exceptions


#GP(0) If the offset jumped to is beyond the limits of the code segment.

Real Address Mode Exceptions

None.

Virtual 8086 Mode Exceptions

None.

Volume 3: Base IA-32 Instruction Reference 3:647


LSL—Load Segment Limit
Opcode Instruction Description
0F 03 /r LSL r16,r/m16 Load: r16 ←segment limit, selector r/m16
0F 03 /r LSL r32,r/m32 Load: r32 ←segment limit, selector r/m32)

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.

3:648 Volume 3: Base IA-32 Instruction Reference


LSL—Load Segment Limit (Continued)
Type Name Valid
0 Reserved No
1 Available 16-bit TSS Yes
2 LDT Yes
3 Busy 16-bit TSS Yes
4 16-bit call gate No
5 16-bit/32-bit task gate No
6 16-bit trap gate No
7 16-bit interrupt gate No
8 Reserved No
9 Available 32-bit TSS Yes
A Reserved No
B Busy 32-bit TSS Yes
C 32-bit call gate No
D Reserved No
E 32-bit trap gate No
F 32-bit interrupt gate No

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.

Volume 3: Base IA-32 Instruction Reference 3:649


LSL—Load Segment Limit (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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.

Real Address Mode Exceptions


#UD The LSL instruction is not recognized in real address mode.

Virtual 8086 Mode Exceptions


#UD The LSL instruction is not recognized in virtual 8086 mode.

3:650 Volume 3: Base IA-32 Instruction Reference


LSS—Load Full Pointer
See entry for LDS/LES/LFS/LGS/LSS.

Volume 3: Base IA-32 Instruction Reference 3:651


LTR—Load Task Register
Opcode Instruction Description
0F 00 /3 LTR r/m16 Load r/m16 into TR

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.

The operand-size attribute has no effect on this instruction.

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept.

Protected Mode Exceptions


#GP(0) If the current privilege level is not 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.

3:652 Volume 3: Base IA-32 Instruction Reference


LTR—Load Task Register (Continued)
#GP(selector) If the source selector points to a segment that is not a TSS or to one for a task
that is already busy.
If the selector points to LDT or is beyond the GDT limit.
#NP(selector) If the TSS is marked not present.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.

Real Address Mode Exceptions


#UD The LTR instruction is not recognized in real address mode.

Virtual 8086 Mode Exceptions


#UD The LTR instruction is not recognized in virtual 8086 mode.

Volume 3: Base IA-32 Instruction Reference 3:653


MOV—Move
Opcode Instruction Description
88 /r MOV r/m8,r8 Move r8 to r/m8
89 /r MOV r/m16,r16 Move r16 to r/m16
89 /r MOV r/m32,r32 Move r32 to r/m32
8A /r MOV r8,r/m8 Move r/m8 to r8
8B /r MOV r16,r/m16 Move r/m16 to r16
8B /r MOV r32,r/m32 Move r/m32 to r32
8C /r MOV r/m16,Sreg** Move segment register to r/m16
8E /r MOV Sreg,r/m16 Move r/m16 to segment register
A0 MOV AL,moffs8* Move byte at (seg:offset) to AL
A1 MOV AX,moffs16* Move word at (seg:offset) to AX
A1 MOV EAX,moffs32* Move doubleword at (seg:offset) to EAX
A2 MOV moffs8*,AL Move AL to (seg:offset)
A3 MOV moffs16*,AX Move AX to (seg:offset)
A3 MOV moffs32*,EAX Move EAX to (seg:offset)
B0+ rb MOV r8,imm8 Move imm8 to r8
B8+ rw MOV r16,imm16 Move imm16 to r16
B8+ rd MOV r32,imm32 Move imm32 to r32
C6 /0 MOV r/m8,imm8 Move imm8 to r/m8
C7 /0 MOV r/m16,imm16 Move imm16 to r/m16
C7 /0 MOV r/m32,imm32 Move imm32 to r/m32

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.

3:654 Volume 3: Base IA-32 Instruction Reference


MOV—Move (Continued)
If the destination operand is a segment register (DS, ES, FS, GS, or SS), the source operand must
be a valid segment selector. In protected mode, moving a segment selector into a segment register
automatically causes the segment descriptor information associated with that segment selector to be
loaded into the hidden (shadow) part of the segment register. While loading this information, the
segment selector and segment descriptor information is validated (see the “Operation” algorithm
below). The segment descriptor data is obtained from the GDT or LDT entry for the specified
segment selector.

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;

Volume 3: Base IA-32 Instruction Reference 3:655


MOV—Move (Continued)

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept System Flag Intercept trap for Move to SS
Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If attempt is made to load SS register with null segment selector.
If the destination operand is in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#GP(selector) If segment selector index is outside descriptor table limits.
If the SS register is being loaded and the segment selector's RPL and the
segment descriptor’s DPL are not equal to the CPL.
If the SS register is being loaded and the segment pointed to is a nonwritable
data segment.
If the DS, ES, FS, or GS register is being loaded and the segment pointed to
is not a data or readable code segment.

3:656 Volume 3: Base IA-32 Instruction Reference


MOV—Move (Continued)
If the DS, ES, FS, or GS register is being loaded and the segment pointed to
is a data or nonconforming code segment, but both the RPL and the CPL are
greater than the DPL.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#SS(selector) If the SS register is being loaded and the segment pointed to is marked not
present.
#NP If the DS, ES, FS, or GS register is being loaded and the segment pointed to
is marked not present.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.
#UD If attempt is made to load the CS register.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#UD If attempt is made to load the CS register.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.
#UD If attempt is made to load the CS register.

Volume 3: Base IA-32 Instruction Reference 3:657


MOV—Move to/from Control Registers
Opcode Instruction Description
0F 22 /r MOV CR0,r32 Move r32 to CR0
0F 22 /r MOV CR2,r32 Move r32 to CR2
0F 22 /r MOV CR3,r32 Move r32 to CR3
0F 22 /r MOV CR4,r32 Move r32 to CR4
0F 20 /r MOV r32,CR0 Move CR0 to r32
0F 20 /r MOV r32,CR2 Move CR2 to r32
0F 20 /r MOV r32,CR3 Move CR3 to r32
0F 20 /r MOV r32,CR4 Move CR4 to r32

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.

These instructions have the following side effects:


• When writing to control register CR3, all non-global TLB entries are flushed (see the IA-32
Intel® Architecture Software Developer’s Manual, Volume 3.
• When modifying any of the paging flags in the control registers (PE and PG in register CR0
and PGE, PSE, and PAE in register CR4), all TLB entries are flushed, including global entries.
This operation is implementation specific for the Pentium Pro processor. Software should not
depend on this functionality in future Intel architecture processors.
• If the PG flag is set to 1 and control register CR4 is written to set the PAE flag to 1 (to enable
the physical address extension mode), the pointers (PDPTRs) in the page-directory pointers
table will be loaded into the processor (into internal, non-architectural registers).
• If the PAE flag is set to 1 and the PG flag set to 1, writing to control register CR3 will cause the
PDPTRs to be reloaded into the processor.
• If the PAE flag is set to 1 and control register CR0 is written to set the PG flag, the PDPTRs are
reloaded into the processor.

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.

3:658 Volume 3: Base IA-32 Instruction Reference


MOV—Move to/from Control Registers (Continued)

Additional Itanium System Environment Exceptions


IA-32_Intercept Move To CR#, Mandatory Instruction Intercept.
Move From CR#, read the virtualized control register values, CR0{15:6}
return zeros.

Protected Mode Exceptions


#GP(0) If the current privilege level is not 0.
If an attempt is made to write a 1 to any reserved bit in CR4.
If an attempt is made to write reserved bits in the page-directory pointers table
(used in the extended physical addressing mode) when the PAE flag in control
register CR4 and the PG flag in control register CR0 are set to 1.

Real Address Mode Exceptions


#GP If an attempt is made to write a 1 to any reserved bit in CR4.

Virtual 8086 Mode Exceptions


#GP(0) These instructions cannot be executed in virtual 8086 mode.

Volume 3: Base IA-32 Instruction Reference 3:659


MOV—Move to/from Debug Registers
Opcode Instruction Description
0F 21/r MOV r32, DR0-DR3 Move debug registers to r32
0F 21/r MOV r32, DR4-DR5 Move debug registers to r32
0F 21/r MOV r32, DR6-DR7 Move debug registers to r32
0F 23 /r MOV DR0-DR3, r32 Move r32 to debug registers
0F 23 /r MOV DR4-DR5, r32 Move r32 to debug registers
0F 23 /r MOV DR6-DR7,r32 Move r32 to debug registers

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.)

The instructions must be executed at privilege level 0 or in real-address mode.

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept.

Protected Mode Exceptions


#GP(0) If the current privilege level is not 0.
#UD If the DE (debug extensions) bit of CR4 is set and a MOV instruction is
executed involving DR4 or DR5.

3:660 Volume 3: Base IA-32 Instruction Reference


MOV—Move to/from Debug Registers (Continued)
#DB If any debug register is accessed while the GD flag in debug register DR7 is
set.

Real Address Mode Exceptions


#UD If the DE (debug extensions) bit of CR4 is set and a MOV instruction is
executed involving DR4 or DR5.
#DB If any debug register is accessed while the GD flag in debug register DR7 is
set.

Virtual 8086 Mode Exceptions


#GP(0) The debug registers cannot be loaded or read when in virtual 8086 mode.

Volume 3: Base IA-32 Instruction Reference 3:661


MOVS/MOVSB/MOVSW/MOVSD—Move Data from String to String
Opcode Instruction Description
A4 MOVS ES:(E)DI, DS:(E)SI Move byte at address DS:(E)SI to address ES:(E)DI
A5 MOVS ES:DI,DS:SI Move word at address DS:SI to address ES:DI
A5 MOVS ES:EDI, DS:ESI Move doubleword at address DS:ESI to address ES:EDI
A4 MOVSB Move byte at address DS:(E)SI to address ES:(E)DI
A5 MOVSW Move word at address DS:SI to address ES:DI
A5 MOVSD Move doubleword at address DS:ESI to address ES:EDI

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;

3:662 Volume 3: Base IA-32 Instruction Reference


MOVS/MOVSB/MOVSW/MOVSD—Move Data from String to String
(Continued)

FI;
ELSE (* doubleword move*)
THEN IF DF = 0

THEN EDI ←4;


ELSE EDI ←-4;
FI;
FI;

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:663


MOVSX—Move with Sign-Extension
Opcode Instruction Description
0F BE /r MOVSX r16,r/m8 Move byte to word with sign-extension
0F BE /r MOVSX r32,r/m8 Move byte to doubleword, sign-extension
0F BF /r MOVSX r32,r/m16 Move word to doubleword, sign-extension

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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 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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.

3:664 Volume 3: Base IA-32 Instruction Reference


MOVZX—Move with Zero-Extend
Opcode Instruction Description
0F B6 /r MOVZX r16,r/m8 Move byte to word with zero-extension
0F B6 /r MOVZX r32,r/m8 Move byte to doubleword, zero-extension
0F B7 /r MOVZX r32,r/m16 Move word to doubleword, zero-extension

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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 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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Volume 3: Base IA-32 Instruction Reference 3:665


MOVZX—Move with Zero-Extend (Continued)

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:666 Volume 3: Base IA-32 Instruction Reference


MUL—Unsigned Multiplication of AL, AX, or EAX
Opcode Instruction Description
F6 /4 MUL r/m8 Unsigned multiply (AX ←AL ∗ r/m8)
F7 /4 MUL r/m16 Unsigned multiply (DX:AX ←AX ∗ r/m16)
F7 /4 MUL r/m32 Unsigned multiply (EDX:EAX ←EAX ∗ r/m32)

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.

: Operand Size Source 1 Source 2 Destination


Byte AL r/m8 AX
Word AX r/m16 DX:AX
Doubleword EAX r/m32 EDX:EAX

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: Base IA-32 Instruction Reference 3:667


MUL—Unsigned Multiplication of AL, AX, or EAX (Continued)

Protected Mode Exceptions


#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 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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:668 Volume 3: Base IA-32 Instruction Reference


NEG—Two's Complement Negation
Opcode Instruction Description
F6 /3 NEG r/m8 Two's complement negate r/m8
F7 /3 NEG r/m16 Two's complement negate r/m16
F7 /3 NEG r/m32 Two's complement negate r/m32

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Volume 3: Base IA-32 Instruction Reference 3:669


NEG—Two's Complement Negation (Continued)

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:670 Volume 3: Base IA-32 Instruction Reference


NOP—No Operation
Opcode Instruction Description
90 NOP No operation

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.

Exceptions (All Operating Modes)

None.

Volume 3: Base IA-32 Instruction Reference 3:671


NOT—One's Complement Negation
Opcode Instruction Description
F6 /2 NOT r/m8 Reverse each bit of r/m8
F7 /2 NOT r/m16 Reverse each bit of r/m16
F7 /2 NOT r/m32 Reverse each bit of r/m32

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the destination operand points to a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

3:672 Volume 3: Base IA-32 Instruction Reference


NOT—One's Complement Negation (Continued)

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:673


OR—Logical Inclusive OR
Opcode Instruction Description
0C ib OR AL,imm8 AL OR imm8
0D iw OR AX,imm16 AX OR imm16
0D id OR EAX,imm32 EAXOR imm32
80 /1 ib OR r/m8,imm8 r/m8 OR imm8
81 /1 iw OR r/m16,imm16 r/m16 OR imm16
81 /1 id OR r/m32,imm32 r/m32 OR imm32
83 /1 ib OR r/m16,imm8 r/m16 OR imm8
83 /1 ib OR r/m32,imm8 r/m32 OR imm8
08 /r OR r/m8,r8 r/m8 OR r8
09 /r OR r/m16,r16 r/m16 OR r16
09 /r OR r/m32,r32 r/m32 OR r32
0A /r OR r8,r/m8 r8 OR r/m8
0B /r OR r16,r/m16 r16 OR r/m16
0B /r OR r32,r/m32 r32 OR r/m32

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

3:674 Volume 3: Base IA-32 Instruction Reference


OR—Logical Inclusive OR (Continued)

Protected Mode Exceptions


#GP(0) If the destination operand points to a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:675


OUT—Output to Port
Opcode Instruction Description
E6 ib OUT imm8, AL Output byte AL to imm8 I/O port address
E7 ib OUT imm8, AX Output word AX to imm8 I/O port address
E7 ib OUT imm8, EAX Output doubleword EAX to imm8 I/O port address
EE OUT DX, AL Output byte AL to I/O port address in DX
EF OUT DX, AX Output word AX to I/O port address in DX
EF OUT DX, EAX Output doubleword EAX to I/O port address in DX

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 *)

3:676 Volume 3: Base IA-32 Instruction Reference


OUT—Output to Port (Continued)

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();

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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
IA_32_Exception Debug traps for data breakpoints and single step
IA_32_Exception Alignment faults
#GP(0) Referenced Port is to an unimplemented virtual address or PSR.dt is zero.

Protected Mode Exceptions


#GP(0) If the CPL is greater than (has less privilege) the I/O privilege level (IOPL)
and any of the corresponding I/O permission bits in TSS for the I/O port being
accessed is 1 and when CFLG.io is 1.

Real Address Mode Exceptions

None.

Virtual 8086 Mode Exceptions


#GP(0) If any of the I/O permission bits in the TSS for the I/O port being accessed is
1.

Volume 3: Base IA-32 Instruction Reference 3:677


OUTS/OUTSB/OUTSW/OUTSD—Output String to Port
Opcode Instruction Description
6E OUTS DX, DS:(E)SI Output byte at address DS:(E)SI to I/O port in DX
6F OUTS DX, DS:SI Output word at address DS:SI to I/O port in DX
6F OUTS DX, DS:ESI Output doubleword at address DS:ESI to I/O port in DX
6E OUTSB Output byte at address DS:(E)SI to I/O port in DX
6F OUTSW Output word at address DS:SI to I/O port in DX
6F OUTSD Output doubleword at address DS:ESI to I/O port in DX

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.

3:678 Volume 3: Base IA-32 Instruction Reference


OUTS/OUTSB/OUTSW/OUTSD—Output String to Port (Continued)
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 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.

Volume 3: Base IA-32 Instruction Reference 3:679


OUTS/OUTSB/OUTSW/OUTSD—Output String to Port (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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
IA_32_Exception Debug traps for data breakpoints and single step
IA_32_Exception Alignment faults
#GP(0) Referenced Port is to an unimplemented virtual address or PSR.dt is zero.

Protected Mode Exceptions


#GP(0) If the CPL is greater than (has less privilege) the I/O privilege level (IOPL)
and any of the corresponding I/O permission bits in TSS for the I/O port being
accessed is 1 and when CFLG.io is 1.
If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the limit of the ES segment.
If the ES register contains a null segment selector.
If an illegal memory operand effective address in the ES segments is given.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If any of the I/O permission bits in the TSS for the I/O port being accessed is
1.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:680 Volume 3: Base IA-32 Instruction Reference


POP—Pop a Value from the Stack
Opcode Instruction Description
8F /0 POP m16 Pop top of stack into m16; increment stack pointer
8F /0 POP m32 Pop top of stack into m32; increment stack pointer
58+ rw POP r16 Pop top of stack into r16; increment stack pointer
58+ rd POP r32 Pop top of stack into r32; increment stack pointer
1F POP DS Pop top of stack into DS; increment stack pointer
07 POP ES Pop top of stack into ES; increment stack pointer
17 POP SS Pop top of stack into SS; increment stack pointer
0F A1 POP FS Pop top of stack into FS; increment stack pointer
0F A9 POP GS Pop top of stack into GS; increment stack pointer

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.

Volume 3: Base IA-32 Instruction Reference 3:681


POP—Pop a Value from the Stack (Continued)
This action allows sequential execution of POP SS and MOV ESP, EBP instructions without the
danger of having an invalid stack during an interrupt. However, use of the LSS instruction is the
preferred 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;

3:682 Volume 3: Base IA-32 Instruction Reference


POP—Pop a Value from the Stack (Continued)

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept System Flag Intercept trap for POP SS
Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If attempt is made to load SS register with null segment selector.
If the destination operand is in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#GP(selector) If segment selector index is outside descriptor table limits.
If the SS register is being loaded and the segment selector's RPL and the
segment descriptor’s DPL are not equal to the CPL.
If the SS register is being loaded and the segment pointed to is a nonwritable
data segment.

Volume 3: Base IA-32 Instruction Reference 3:683


POP—Pop a Value from the Stack (Continued)
If the DS, ES, FS, or GS register is being loaded and the segment pointed to
is not a data or readable code segment.
If the DS, ES, FS, or GS register is being loaded and the segment pointed to
is a data or nonconforming code segment, but both the RPL and the CPL are
greater than the DPL.
#SS(0) If the current top of stack is not within the stack segment.
If a memory operand effective address is outside the SS segment limit.
#SS(selector) If the SS register is being loaded and the segment pointed to is marked not
present.
#NP If the DS, ES, FS, or GS register is being loaded and the segment pointed to
is marked not present.
#PF(fault-code) If a page fault occurs.
#AC(0) If an unaligned memory reference is made while the current privilege level is
3 and alignment checking is enabled.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If an unaligned memory reference is made while alignment checking is
enabled.

3:684 Volume 3: Base IA-32 Instruction Reference


POPA/POPAD—Pop All General-Purpose Registers
Opcode Instruction Description
61 POPA Pop DI, SI, BP, BX, DX, CX, and AX
61 POPAD Pop EDI, ESI, EBP, EBX, EDX, ECX, and EAX

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.

Volume 3: Base IA-32 Instruction Reference 3:685


POPA/POPAD—Pop All General-Purpose Registers (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#SS(0) If the starting or ending stack address is not within the stack segment.
#PF(fault-code) If a page fault occurs.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.

3:686 Volume 3: Base IA-32 Instruction Reference


POPF/POPFD—Pop Stack into EFLAGS Register
Opcode Instruction Description
9D POPF Pop top of stack into EFLAGS
9D POPFD Pop top of stack into EFLAGS

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

Volume 3: Base IA-32 Instruction Reference 3:687


POPF/POPFD—Pop Stack into EFLAGS Register (Continued)

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;

3:688 Volume 3: Base IA-32 Instruction Reference


POPF/POPFD—Pop Stack into EFLAGS Register (Continued)

IF(Itanium System Environment AND (AC, TF != OLD_AC, OLD_TF)


THEN IA-32_Intercept(System_Flag,POPF);
IF Itanium System Environment AND CFLG.ii AND IF != OLD_IF
THEN IA-32_Intercept(System_Flag,POPF);

Flags Affected

All flags except the reserved bits.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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
IA-32_Intercept System Flag Intercept Trap if CFLG.ii is 1 and the IF flag changes state or if
the AC, RF or TF changes state.

Protected Mode Exceptions


#SS(0) If the top of stack is not within the stack segment.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the I/O privilege level is less than 3.
If an attempt is made to execute the POPF/POPFD instruction with an
operand-size override prefix.
#SS(0) If a memory operand effective address is outside the SS segment limit.

Volume 3: Base IA-32 Instruction Reference 3:689


PUSH—Push Word or Doubleword Onto the Stack
Opcode Instruction Description
FF /6 PUSH r/m16 Push r/m16
FF /6 PUSH r/m32 Push r/m32
50+rw PUSH r16 Push r16
50+rd PUSH r32 Push r32
6A PUSH imm8 Push imm8
68 PUSH imm16 Push imm16
68 PUSH imm32 Push imm32
0E PUSH CS Push CS
16 PUSH SS Push SS
1E PUSH DS Push DS
06 PUSH ES Push ES
0F A0 PUSH FS Push FS
0F A8 PUSH GS Push GS

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*)

3:690 Volume 3: Base IA-32 Instruction Reference


PUSH—Push Word or Doubleword Onto the Stack (Continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
If the new value of the SP or ESP register is outside the stack segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.

Volume 3: Base IA-32 Instruction Reference 3:691


PUSH—Push Word or Doubleword Onto the Stack (Continued)
#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.

Intel Architecture Compatibility

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).

3:692 Volume 3: Base IA-32 Instruction Reference


PUSHA/PUSHAD—Push All General-Purpose Registers
Opcode Instruction Description
60 PUSHA Push AX, CX, DX, BX, original SP, BP, SI, and DI
60 PUSHAD Push EAX, ECX, EDX, EBX, original ESP, EBP, ESI, and EDI

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.

In the real-address mode, if the ESP or SP register is 1, 3, or 5 when the PUSHA/PUSHAD


instruction is executed, the processor shuts down due to a lack of stack space. No exception is
generated to indicate this condition.

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;

Volume 3: Base IA-32 Instruction Reference 3:693


PUSHA/PUSHAD—Push All General-Purpose Registers (Continued)

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#SS(0) If the starting or ending stack address is outside the stack segment limit.
#PF(fault-code) If a page fault occurs.

Real Address Mode Exceptions


#GP If the ESP or SP register contains 7, 9, 11, 13, or 15.

Virtual 8086 Mode Exceptions


#GP(0) If the ESP or SP register contains 7, 9, 11, 13, or 15.
#PF(fault-code) If a page fault occurs.

3:694 Volume 3: Base IA-32 Instruction Reference


PUSHF/PUSHFD—Push EFLAGS Register onto the Stack
Opcode Instruction Description
9C PUSHF Push EFLAGS
9C PUSHFD Push EFLAGS

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.

In the real-address mode, if the ESP or SP register is 1, 3, or 5 when the PUSHA/PUSHAD


instruction is executed, the processor shuts down due to a lack of stack space. No exception is
generated to indicate this condition.

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 *)

Volume 3: Base IA-32 Instruction Reference 3:695


PUSHF/PUSHFD—Push EFLAGS Register onto the Stack (Continued)

FI;
ELSE (*IOPL < 3*)

IF OperandSize =32 OR CR$.VME=0


THEN #GP(0); (* Trap to virtual-8086 monitor *)
ELSE
TempFlags <- FLAGS OR 3000H; (*Set IOPL bits to 11B or IOPL 3 *)
TempFlags.IF <- EFLAGS.VIF;
push(TempFlags);
FI;
FI;
FI;

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#SS(0) If the new value of the ESP register is outside the stack segment boundary.

Real Address Mode Exceptions

None.

Virtual 8086 Mode Exceptions


#GP(0) If the I/O privilege level is less than 3.

3:696 Volume 3: Base IA-32 Instruction Reference


RCL/RCR/ROL/ROR-—Rotate
Opcode Instruction Description
D0 /2 RCL r/m8,1 Rotate 9 bits (CF,r/m8) left once
D2 /2 RCL r/m8,CL Rotate 9 bits (CF,r/m8) left CL times
C0 /2 ib RCL r/m8,imm8 Rotate 9 bits (CF,r/m8) left imm8 times
D1 /2 RCL r/m16,1 Rotate 17 bits (CF,r/m16) left once
D3 /2 RCL r/m16,CL Rotate 17 bits (CF,r/m16) left CL times
C1 /2 ib RCL r/m16,imm8 Rotate 17 bits (CF,r/m16) left imm8 times
D1 /2 RCL r/m32,1 Rotate 33 bits (CF,r/m32) left once
D3 /2 RCL r/m32,CL Rotate 33 bits (CF,r/m32) left CL times
C1 /2 ib RCL r/m32,imm8 Rotate 33 bits (CF,r/m32) left imm8 times
D0 /3 RCR r/m8,1 Rotate 9 bits (CF,r/m8) right once
D2 /3 RCR r/m8,CL Rotate 9 bits (CF,r/m8) right CL times
C0 /3 ib RCR r/m8,imm8 Rotate 9 bits (CF,r/m8) right imm8 times
D1 /3 RCR r/m16,1 Rotate 17 bits (CF,r/m16) right once
D3 /3 RCR r/m16,CL Rotate 17 bits (CF,r/m16) right CL times
C1 /3 ib RCR r/m16,imm8 Rotate 17 bits (CF,r/m16) right imm8 times
D1 /3 RCR r/m32,1 Rotate 33 bits (CF,r/m32) right once
D3 /3 RCR r/m32,CL Rotate 33 bits (CF,r/m32) right CL times
C1 /3 ib RCR r/m32,imm8 Rotate 33 bits (CF,r/m32) right imm8 times
D0 /0 ROL r/m8,1 Rotate 8 bits r/m8 left once
D2 /0 ROL r/m8,CL Rotate 8 bits r/m8 left CL times
C0 /0 ib ROL r/m8,imm8 Rotate 8 bits r/m8 left imm8 times
D1 /0 ROL r/m16,1 Rotate 16 bits r/m16 left once
D3 /0 ROL r/m16,CL Rotate 16 bits r/m16 left CL times
C1 /0 ib ROL r/m16,imm8 Rotate 16 bits r/m16 left imm8 times
D1 /0 ROL r/m32,1 Rotate 32 bits r/m32 left once
D3 /0 ROL r/m32,CL Rotate 32 bits r/m32 left CL times
C1 /0 ib ROL r/m32,imm8 Rotate 32 bits r/m32 left imm8 times
D0 /1 ROR r/m8,1 Rotate 8 bits r/m8 right once
D2 /1 ROR r/m8,CL Rotate 8 bits r/m8 right CL times
C0 /1 ib ROR r/m8,imm8 Rotate 8 bits r/m16 right imm8 times
D1 /1 ROR r/m16,1 Rotate 16 bits r/m16 right once
D3 /1 ROR r/m16,CL Rotate 16 bits r/m16 right CL times
C1 /1 ib ROR r/m16,imm8 Rotate 16 bits r/m16 right imm8 times
D1 /1 ROR r/m32,1 Rotate 32 bits r/m32 right once
D3 /1 ROR r/m32,CL Rotate 32 bits r/m32 right CL times
C1 /1 ib ROR r/m32,imm8 Rotate 32 bits r/m32 right imm8 times

Volume 3: Base IA-32 Instruction Reference 3:697


RCL/RCR/ROL/ROR-—Rotate (Continued)

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);

3:698 Volume 3: Base IA-32 Instruction Reference


RCL/RCR/ROL/ROR-—Rotate (Continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: Base IA-32 Instruction Reference 3:699


RCL/RCR/ROL/ROR-—Rotate (Continued)

Protected Mode Exceptions


#GP(0) If the source operand is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Intel Architecture Compatibility

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.

3:700 Volume 3: Base IA-32 Instruction Reference


RDMSR—Read from Model Specific Register
Opcode Instruction Description
0F 32 RDMSR Load MSR specified by ECX into EDX:EAX

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept.

Protected Mode Exceptions


#GP(0) If the current privilege level is not 0.
If the value in ECX specifies a reserved or unimplemented MSR address.

Real Address Mode Exceptions


#GP If the current privilege level is not 0
If the value in ECX specifies a reserved or unimplemented MSR address.

Virtual 8086 Mode Exceptions


#GP(0) The RDMSR instruction is not recognized in virtual 8086 mode.

Volume 3: Base IA-32 Instruction Reference 3:701


RDMSR—Read from Model Specific Register (Continued)

Intel Architecture Compatibility

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.

3:702 Volume 3: Base IA-32 Instruction Reference


RDPMC—Read Performance-Monitoring Counters
Opcode Instruction Description
0F 33 RDPMC Read performance-monitoring counter specified by ECX into
EDX:EAX

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;

Volume 3: Base IA-32 Instruction Reference 3:703


RDPMC—Read Performance-Monitoring Counters (Continued)

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
#GP(0) If the current privilege level is not 0 and the selected PMD register’s PM bit
is 1, or if PSR.sp is 1.

Protected Mode Exceptions


#GP(0) If the current privilege level is not 0 and the PCE flag in the CR4 register is
clear
/*In IA-32 System Environment*/.
If the value in the ECX register does not match an implemented performance
counter.

Real Address Mode Exceptions


#GP If the PCE flag in the CR4 register is clear. /*In the IA-32 System
Environment*/
If the value in the ECX register does not match an implemented performance
counter.

Virtual 8086 Mode Exceptions


#GP(0) If the PCE flag in the CR4 register is clear. /*In the IA-32 System
Environment*/
If the value in the ECX register does not match an implemented performance
counter.

3:704 Volume 3: Base IA-32 Instruction Reference


RDTSC—Read Time-Stamp Counter
Opcode Instruction Description
0F 31 RDTSC Read time-stamp counter into EDX:EAX

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.

Volume 3: Base IA-32 Instruction Reference 3:705


RDTSC—Read Time-Stamp Counter (Continued)

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
#GP(0) If PSR.si is 1 or CR4.TSD is 1 and the CPL is greater than 0.

Protected Mode Exceptions


#GP(0) If the TSD flag in register CR4 is set and the CPL is greater than 0.
/*For the IA-32 System Environment only*/

Real Address Mode Exceptions


#GP If the TSD flag in register CR4 is set. /*For the IA-32 System Environment
only*/

Virtual 8086 Mode Exceptions


#GP(0) If the TSD flag in register CR4 is set. /*For the IA-32 System Environment
only*/

3:706 Volume 3: Base IA-32 Instruction Reference


REP/REPE/REPZ/REPNE /REPNZ—Repeat String Operation Prefix
F3 6C REP INS r/m8, DX Input ECX bytes from port DX into ES:[EDI]
F3 6D REP INS r/m16,DX Input ECX words from port DX into ES:[EDI]
F3 6D REP INS r/m32,DX Input ECX doublewords from port DX into ES:[EDI]
F3 A4 REP MOVS m8,m8 Move ECX bytes from DS:[ESI] to ES:[EDI]
F3 A5 REP MOVS m16,m16 Move ECX words from DS:[ESI] to ES:[EDI]
F3 A5 REP MOVS m32,m32 Move ECX doublewords from DS:[ESI] to ES:[EDI]
F3 6E REP OUTS DX,r/m8 Output ECX bytes from DS:[ESI] to port DX
F3 6F REP OUTS DX,r/m16 Output ECX words from DS:[ESI] to port DX
F3 6F REP OUTS DX,r/m32 Output ECX doublewords from DS:[ESI] to port DX
F3 AC REP LODS AL Load ECX bytes from DS:[ESI] to AL
F3 AD REP LODS AX Load ECX words from DS:[ESI] to AX
F3 AD REP LODS EAX Load ECX doublewords from DS:[ESI] to EAX
F3 AA REP STOS m8 Fill ECX bytes at ES:[EDI] with AL
F3 AB REP STOS m16 Fill ECX words at ES:[EDI] with AX
F3 AB REP STOS m32 Fill ECX doublewords at ES:[EDI] with EAX
F3 A6 REPE CMPS m8,m8 Find nonmatching bytes in ES:[EDI] and DS:[ESI]
F3 A7 REPE CMPS m16,m16 Find nonmatching words in ES:[EDI] and DS:[ESI]
F3 A7 REPE CMPS m32,m32 Find nonmatching doublewords in ES:[EDI] and DS:[ESI]
F3 AE REPE SCAS m8 Find non-AL byte starting at ES:[EDI]
F3 AF REPE SCAS m16 Find non-AX word starting at ES:[EDI]
F3 AF REPE SCAS m32 Find non-EAX doubleword starting at ES:[EDI]
F2 A6 REPNE CMPS m8,m8 Find matching bytes in ES:[EDI] and DS:[ESI]
F2 A7 REPNE CMPS m16,m16 Find matching words in ES:[EDI] and DS:[ESI]
F2 A7 REPNE CMPS m32,m32 Find matching doublewords in ES:[EDI] and DS:[ESI]
F2 AE REPNE SCAS m8 Find AL, starting at ES:[EDI]
F2 AF REPNE SCAS m16 Find AX, starting at ES:[EDI]
F2 AF REPNE SCAS m32 Find EAX, starting at ES:[EDI]

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.

Volume 3: Base IA-32 Instruction Reference 3:707


REP/REPE/REPZ/REPNE /REPNZ—Repeat String Operation Prefix
(Continued)
All of these repeat prefixes cause the associated instruction to be repeated until the count in register
ECX is decremented to 0 (see the following table). The REPE, REPNE, REPZ, and REPNZ
prefixes also check the state of the ZF flag after each iteration and terminate the repeat loop if the
ZF flag is not in the specified state. When both termination conditions are tested, the cause of a
repeat termination can be determined either by testing the ECX register with a JECXZ instruction
or by testing the ZF flag with a JZ, JNZ, and JNE instruction.

Table 1-17. Repeat Conditions


Repeat Prefix Termination Condition 1 Termination Condition 2
REP ECX=0 None
REPE/REPZ ECX=0 ZF=0
REPNE/REPNZ ECX=0 ZF=1

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;

3:708 Volume 3: Base IA-32 Instruction Reference


REP/REPE/REPZ/REPNE /REPNZ—Repeat String Operation Prefix
(Continued)

IF (repeat prefix is REPZ or REPE) AND (ZF=0)


OR (repeat prefix is REPNZ or REPNE) AND (ZF=1)

THEN exit WHILE loop


FI;
OD;

Flags Affected

None; however, the CMPS and SCAS instructions do set the status flags in the EFLAGS register.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Exceptions (All Operating Modes)

None; however, exceptions can be generated by the instruction a repeat prefix is associated with.

Volume 3: Base IA-32 Instruction Reference 3:709


RET—Return from Procedure
Opcode Instruction Description
C3 RET Near return to calling procedure
CB RET Far return to calling procedure
C2 iw RET imm16 Near return to calling procedure and pop imm16 bytes from
stack
CA iw RET imm16 Far return to calling procedure and pop imm16 bytes from stack

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.

The inter-privilege-level return type can only be executed in protected mode.

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.

3:710 Volume 3: Base IA-32 Instruction Reference


RET—Return from Procedure (Continued)

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;

(* Real-address mode or virtual-8086 mode *)


IF ((PE = 0) OR (PE = 1 AND VM = 1)) AND instruction = far return
THEN;
IF OperandSize = 32
THEN
IF top 12 bytes of stack not within stack limits THEN #SS(0); FI;
EIP ←Pop();
CS ←Pop(); (* 32-bit pop, high-order 16-bits discarded *)
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;
CS ←Pop(); (* 16-bit pop *)
FI;
IF instruction has immediate operand THEN SP ←SP + (SRC AND FFFFH); FI;
IF Itanium System Environment AND PSR.tb THEN IA_32_Exception(Debug);
FI;

(* Protected mode, not virtual 8086 mode *)


IF (PE = 1 AND VM = 0) AND instruction = far RET
THEN
IF OperandSize = 32
THEN

Volume 3: Base IA-32 Instruction Reference 3:711


RET—Return from Procedure (Continued)
IF second doubleword on stack is not within stack limits THEN #SS(0); FI;
ELSE (* OperandSize = 16 *)
IF second word on stack is not within stack limits THEN #SS(0); FI;
FI;
IF return code segment selector is null THEN GP(0); FI;
IF return code segment selector addrsses descriptor beyond diescriptor table limit
THEN GP(selector; FI;
Obtain descriptor to which return code segment selector points from descriptor table
IF return code segment descriptor is not a code segment THEN #GP(selector); FI;
if return code segment selector RPL < CPL THEN #GP(selector); FI;
IF return code segment descriptor is condorming
AND return code segment DPL > return code segment selector RPL
THEN #GP(selector); FI;
IF return code segment descriptor is not present THEN #NP(selector); FI:
IF return code segment selector RPL > CPL
THEN GOTO RETURN-OUTER-PRIVILEGE-LEVEL;
ELSE GOTO RETURN-TO-SAME-PRIVILEGE-LEVEL
FI;
END;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;

3:712 Volume 3: Base IA-32 Instruction Reference


RET—Return from Procedure (Continued)

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.

Volume 3: Base IA-32 Instruction Reference 3:713


RET—Return from Procedure (Continued)

Additional Itanium System Environment Exceptions


Itanium Mem Faults VHPT 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
IA_32_Exception Taken Branch Debug Exception if PSR.tb is 1

Protected Mode Exceptions


#GP(0) If the return code or stack segment selector null.
If the return instruction pointer is not within the return code segment limit
#GP(selector) If the RPL of the return code segment selector is less then the CPL.
If the return code or stack segment selector index is not within its descriptor
table limits.
If the return code segment descriptor does not indicate a code segment.
If the return code segment is non-conforming and the segment selector’s DPL
is not equal to the RPL of the code segment’s segment selector
If the return code segment is conforming and the segment selector’s DPL
greater than the RPL of the code segment’s segment selector
If the stack segment is not a writable data segment.
If the stack segment selector RPL is not equal to the RPL of the return code
segment selector.
If the stack segment descriptor DPL is not equal to the RPL of the return code
segment selector.
#SS(0) If the top bytes of stack are not within stack limits.
If the return stack segment is not present.
#NP(selector) If the return code segment is not present.
#PF(fault-code) If a page fault occurs.
#AC(0) If an unaligned memory access occurs when the CPL is 3 and alignment
checking is enabled.

Real Address Mode Exceptions


#GP If the return instruction pointer is not within the return code segment limit
#SS If the top bytes of stack are not within stack limits.

Virtual 8086 Mode Exceptions


#GP(0) If the return instruction pointer is not within the return code segment limit
#SS(0) If the top bytes of stack are not within stack limits.
#PF(fault-code) If a page fault occurs.
#AC(0) If an unaligned memory access occurs when alignment checking is enabled.

3:714 Volume 3: Base IA-32 Instruction Reference


ROL/ROR—Rotate
See entry for RCL/RCR/ROL/ROR.

Volume 3: Base IA-32 Instruction Reference 3:715


RSM—Resume from System Management Mode
Opcode Instruction Description
0F AA RSM Resume operation of interrupted program

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept.

Protected Mode Exceptions


#UD If an attempt is made to execute this instruction when the processor is not in
SMM.

Real Address Mode Exceptions


#UD If an attempt is made to execute this instruction when the processor is not in
SMM.

Virtual 8086 Mode Exceptions


#UD If an attempt is made to execute this instruction when the processor is not in
SMM.

3:716 Volume 3: Base IA-32 Instruction Reference


SAHF—Store AH into Flags
Opcode Instruction Clocks Description
9E SAHF 2 Loads SF, ZF, AF, PF, and CF from AH into
EFLAGS register

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

Exceptions (All Operating Modes)

None.

Volume 3: Base IA-32 Instruction Reference 3:717


SAL/SAR/SHL/SHR—Shift Instructions
Opcode Instruction Description
D0 /4 SAL r/m8,1 Multiply r/m8 by 2, once
D2 /4 SAL r/m8,CL Multiply r/m8 by 2, CL times
C0 /4 ib SAL r/m8,imm8 Multiply r/m8 by 2, imm8 times
D1 /4 SAL r/m16,1 Multiply r/m16 by 2, once
D3 /4 SAL r/m16,CL Multiply r/m16 by 2, CL times
C1 /4 ib SAL r/m16,imm8 Multiply r/m16 by 2, imm8 times
D1 /4 SAL r/m32,1 Multiply r/m32 by 2, once
D3 /4 SAL r/m32,CL Multiply r/m32 by 2, CL times
C1 /4 ib SAL r/m32,imm8 Multiply r/m32 by 2, imm8 times
D0 /7 SAR r/m8,1 Signed divide* r/m8 by 2, once
D2 /7 SAR r/m8,CL Signed divide* r/m8 by 2, CL times
C0 /7 ib SAR r/m8,imm8 Signed divide* r/m8 by 2, imm8 times
D1 /7 SAR r/m16,1 Signed divide* r/m16 by 2, once
D3 /7 SAR r/m16,CL Signed divide* r/m16 by 2, CL times
C1 /7 ib SAR r/m16,imm8 Signed divide* r/m16 by 2, imm8 times
D1 /7 SAR r/m32,1 Signed divide* r/m32 by 2, once
D3 /7 SAR r/m32,CL Signed divide* r/m32 by 2, CL times
C1 /7 ib SAR r/m32,imm8 Signed divide* r/m32 by 2, imm8 times
D0 /4 SHL r/m8,1 Multiply r/m8 by 2, once
D2 /4 SHL r/m8,CL Multiply r/m8 by 2, CL times
C0 /4 ib SHL r/m8,imm8 Multiply r/m8 by 2, imm8 times
D1 /4 SHL r/m16,1 Multiply r/m16 by 2, once
D3 /4 SHL r/m16,CL Multiply r/m16 by 2, CL times
C1 /4 ib SHL r/m16,imm8 Multiply r/m16 by 2, imm8 times
D1 /4 SHL r/m32,1 Multiply r/m32 by 2, once
D3 /4 SHL r/m32,CL Multiply r/m32 by 2, CL times
C1 /4 ib SHL r/m32,imm8 Multiply r/m32 by 2, imm8 times
D0 /5 SHR r/m8,1 Unsigned divide r/m8 by 2, once
D2 /5 SHR r/m8,CL Unsigned divide r/m8 by 2, CL times
C0 /5 ib SHR r/m8,imm8 Unsigned divide r/m8 by 2, imm8 times
D1 /5 SHR r/m16,1 Unsigned divide r/m16 by 2, once
D3 /5 SHR r/m16,CL Unsigned divide r/m16 by 2, CL times
C1 /5 ib SHR r/m16,imm8 Unsigned divide r/m16 by 2, imm8 times
D1 /5 SHR r/m32,1 Unsigned divide r/m32 by 2, once
D3 /5 SHR r/m32,CL Unsigned divide r/m32 by 2, CL times
C1 /5 ib SHR r/m32,imm8 Unsigned divide r/m32 by 2, imm8 times

Note:
*Not the same form of division as IDIV; rounding is toward negative infinity.

3:718 Volume 3: Base IA-32 Instruction Reference


SAL/SAR/SHL/SHR—Shift Instructions (Continued)

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);

Volume 3: Base IA-32 Instruction Reference 3:719


SAL/SAR/SHL/SHR—Shift Instructions (Continued)

ELSE (* instruction is SAR or SHR *)


CF ←LSB(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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

3:720 Volume 3: Base IA-32 Instruction Reference


SAL/SAR/SHL/SHR—Shift Instructions (Continued)

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Intel Architecture Compatibility

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.

Volume 3: Base IA-32 Instruction Reference 3:721


SBB—Integer Subtraction with Borrow
Opcode Instruction Description
1C ib SBB AL,imm8 Subtract with borrow imm8 from AL
1D iw SBB AX,imm16 Subtract with borrow imm16 from AX
1D id SBB EAX,imm32 Subtract with borrow imm32 from EAX
80 /3 ib SBB r/m8,imm8 Subtract with borrow imm8 from r/m8
81 /3 iw SBB r/m16,imm16 Subtract with borrow imm16 from r/m16
81 /3 id SBB r/m32,imm32 Subtract with borrow imm32 from r/m32
83 /3 ib SBB r/m16,imm8 Subtract with borrow sign-extended imm8 from r/m16
83 /3 ib SBB r/m32,imm8 Subtract with borrow sign-extended imm8 from r/m32
18 /r SBB r/m8,r8 Subtract with borrow r8 from r/m8
19 /r SBB r/m16,r16 Subtract with borrow r16 from r/m16
19 /r SBB r/m32,r32 Subtract with borrow r32 from r/m32
1A /r SBB r8,r/m8 Subtract with borrow r/m8 from r8
1B /r SBB r16,r/m16 Subtract with borrow r/m16 from r16
1B /r SBB r32,r/m32 Subtract with borrow r/m32 from r32

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.

3:722 Volume 3: Base IA-32 Instruction Reference


SBB—Integer Subtraction with Borrow (Continued)
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:723


SCAS/SCASB/SCASW/SCASD—Scan String Data
Opcode Instruction Description
AE SCAS ES:(E)DI Compare AL with byte at ES:(E)DI and set status flags
AF SCAS ES:DI Compare AX with word at ES:DI and set status flags
AF SCAS ES:EDI Compare EAX with doubleword at ES:EDI and set status flags
AE SCASB Compare AL with byte at ES:(E)DI and set status flags
AF SCASW Compare AX with word at ES:DI and set status flags
AF SCASD Compare EAX with doubleword at ES:EDI and set status flags

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

3:724 Volume 3: Base IA-32 Instruction Reference


SCAS/SCASB/SCASW/SCASD—Scan String Data (Continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the limit of the ES segment.
If the ES register contains a null segment selector.
If an illegal memory operand effective address in the ES segment is given.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:725


SETcc—Set Byte on Condition
Opcode Instruction Description
0F 97 SETA r/m8 Set byte if above (CF=0 and ZF=0)
0F 93 SETAE r/m8 Set byte if above or equal (CF=0)
0F 92 SETB r/m8 Set byte if below (CF=1)
0F 96 SETBE r/m8 Set byte if below or equal (CF=1 or (ZF=1)
0F 92 SETC r/m8 Set if carry (CF=1)
0F 94 SETE r/m8 Set byte if equal (ZF=1)
0F 9F SETG r/m8 Set byte if greater (ZF=0 and SF=OF)
0F 9D SETGE r/m8 Set byte if greater or equal (SF=OF)
0F 9C SETL r/m8 Set byte if less (SF<>OF)
0F 9E SETLE r/m8 Set byte if less or equal (ZF=1 or SF<>OF)
0F 96 SETNA r/m8 Set byte if not above (CF=1 or ZF=1)
0F 92 SETNAE r/m8 Set byte if not above or equal (CF=1)
0F 93 SETNB r/m8 Set byte if not below (CF=0)
0F 97 SETNBE r/m8 Set byte if not below or equal (CF=0 and ZF=0)
0F 93 SETNC r/m8 Set byte if not carry (CF=0)
0F 95 SETNE r/m8 Set byte if not equal (ZF=0)
0F 9E SETNG r/m8 Set byte if not greater (ZF=1 or SF<>OF)
0F 9C SETNGE r/m8 Set if not greater or equal (SF<>OF)
0F 9D SETNL r/m8 Set byte if not less (SF=OF)
0F 9F SETNLE r/m8 Set byte if not less or equal (ZF=0 and SF=OF)
0F 91 SETNO r/m8 Set byte if not overflow (OF=0)
0F 9B SETNP r/m8 Set byte if not parity (PF=0)
0F 99 SETNS r/m8 Set byte if not sign (SF=0)
0F 95 SETNZ r/m8 Set byte if not zero (ZF=0)
0F 90 SETO r/m8 Set byte if overflow (OF=1)
0F 9A SETP r/m8 Set byte if parity (PF=1)
0F 9A SETPE r/m8 Set byte if parity even (PF=1)
0F 9B SETPO r/m8 Set byte if parity odd (PF=0)
0F 98 SETS r/m8 Set byte if sign (SF=1)
0F 94 SETZ r/m8 Set byte if zero (ZF=1)

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.

3:726 Volume 3: Base IA-32 Instruction Reference


SETcc—Set Byte on Condition (Continued)
Many of the SETcc instruction opcodes have alternate mnemonics. For example, the SETG (set
byte if greater) and SETNLE (set if not less or equal) both have the same opcode and test for the
same condition: ZF equals 0 and SF equals OF. These alternate mnemonics are provided to make
code more intelligible.

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Volume 3: Base IA-32 Instruction Reference 3:727


SETcc—Set Byte on Condition (Continued)

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:728 Volume 3: Base IA-32 Instruction Reference


SGDT/SIDT—Store Global/Interrupt Descriptor Table Register
Opcode Instruction Description
0F 01 /0 SGDT m Store GDTR to m
0F 01 /1 SIDT m Store IDTR to m

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept Instruction Intercept for SIDT and SGDT.

Volume 3: Base IA-32 Instruction Reference 3:729


SGDT/SIDT—Store Global/Interrupt Descriptor Table Register (Continued)

Protected Mode Exceptions


#UD If the destination operand is a register.
#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If an unaligned memory access occurs when the CPL is 3 and alignment
checking is enabled.

Real Address Mode Exceptions


#UD If the destination operand is a register.
#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#UD If the destination operand is a register.
#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If an unaligned memory access occurs when alignment checking is enabled.

Intel Architecture Compatibility

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.

3:730 Volume 3: Base IA-32 Instruction Reference


SHL/SHR—Shift Instructions
See entry for SAL/SAR/SHL/SHR.

Volume 3: Base IA-32 Instruction Reference 3:731


SHLD—Double Precision Shift Left
Opcode Instruction Description
0F A4 SHLD r/m16,r16,imm8 Shift r/m16 to left imm8 places while shifting bits from r16 in
from the right
0F A5 SHLD r/m16,r16,CL Shift r/m16 to left CL places while shifting bits from r16 in from
the right
0F A4 SHLD r/m32,r32,imm8 Shift r/m32 to left imm8 places while shifting bits from r32 in
from the right
0F A5 SHLD r/m32,r32,CL Shift r/m32 to left CL places while shifting bits from r32 in from
the right

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.

The SHLD instruction is useful for multi-precision shifts of 64 bits or more.

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

3:732 Volume 3: Base IA-32 Instruction Reference


SHLD—Double Precision Shift Left (Continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:733


SHRD—Double Precision Shift Right
Opcode Instruction Description
0F AC SHRD r/m16,r16,imm8 Shift r/m16 to right imm8 places while shifting bits from r16 in
from the left
0F AD SHRD r/m16,r16,CL Shift r/m16 to right CL places while shifting bits from r16 in from
the left
0F AC SHRD r/m32,r32,imm8 Shift r/m32 to right imm8 places while shifting bits from r32 in
from the left
0F AD SHRD r/m32,r32,CL Shift r/m32 to right CL places while shifting bits from r32 in from
the left

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.

The SHRD instruction is useful for multiprecision shifts of 64 bits or more.

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;

3:734 Volume 3: Base IA-32 Instruction Reference


SHRD—Double Precision Shift Right (Continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:735


SIDT—Store Interrupt Descriptor Table Register
See entry for SGDT/SIDT.

3:736 Volume 3: Base IA-32 Instruction Reference


SLDT—Store Local Descriptor Table Register
Opcode Instruction Description
0F 00 /0 SLDT r/m16 Stores segment selector from LDTR in r/m16
0F 00 /0 SLDT r/m32 Store segment selector from LDTR in low-order 16 bits of r/m32;
high-order 16 bits 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.

Additional Itanium System Environment Exceptions


IA-32_Intercept SLDT results in an IA-32 Intercept

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Volume 3: Base IA-32 Instruction Reference 3:737


SLDT—Store Local Descriptor Table Register (Continued)

Real Address Mode Exceptions


#UD The SLDT instruction is not recognized in real address mode.

Virtual 8086 Mode Exceptions


#UD The SLDT instruction is not recognized in virtual 8086 mode.

3:738 Volume 3: Base IA-32 Instruction Reference


SMSW—Store Machine Status Word
Opcode Instruction Description
0F 01 /4 SMSW r32/m16 Store machine status word in low-order 16 bits of r32/m16;
high-order 16 bits of r32 are undefined

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept.

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a
null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Volume 3: Base IA-32 Instruction Reference 3:739


SMSW—Store Machine Status Word (Continued)

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:740 Volume 3: Base IA-32 Instruction Reference


STC—Set Carry Flag
Opcode Instruction Description
F9 STC Set CF flag

Description

Sets the CF flag in the EFLAGS register.

Operation
CF ←1;

Flags Affected

The CF flag is set. The OF, ZF, SF, AF, and PF flags are unaffected.

Exceptions (All Operating Modes)

None.

Volume 3: Base IA-32 Instruction Reference 3:741


STD—Set Direction Flag
Opcode Instruction Description
FD STD Set DF flag

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;

Exceptions (All Operating Modes)

None.

3:742 Volume 3: Base IA-32 Instruction Reference


STI—Set Interrupt Flag
Opcode Instruction Description
FB STI Set interrupt flag; interrupts enabled at the end of the next
instruction

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 *)

Volume 3: Base IA-32 Instruction Reference 3:743


STI—Set Interrupt Flag (Continued)

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;

IF Itanium System Environment AND CFLG.ii AND IF != OLD_IF


THEN IA-32_Intercept(System_Flag,STI);

Flags Affected

The IF flag is set to 1.

Additional Itanium System Environment Exceptions


IA-32_Intercept System Flag Intercept Trap if CFLG.ii is 1 and the IF flag changes state.

Protected Mode Exceptions


#GP(0) If the CPL is greater (has less privilege) than the IOPL of the current program
or procedure.

3:744 Volume 3: Base IA-32 Instruction Reference


STI—Set Interrupt Flag (Continued)

Real Address Mode Exceptions

None.

Virtual 8086 Mode Exceptions


#GP(0) If the CPL is greater (has less privilege) than the IOPL of the current program
or procedure.

Volume 3: Base IA-32 Instruction Reference 3:745


STOS/STOSB/STOSW/STOSD—Store String Data
Opcode Instruction Description
AA STOS ES:(E)DI Store AL at address ES:(E)DI
AB STOS ES:DI Store AX at address ES:DI
AB STOS ES:EDI Store EAX at address ES:EDI
AA STOSB Store AL at address ES:(E)DI
AB STOSW Store AX at address ES:DI
AB STOSD Store EAX at address ES:EDI

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

3:746 Volume 3: Base IA-32 Instruction Reference


STOS/STOSB/STOSW/STOSD—Store String Data (Continued)

THEN EDI ←4;


ELSE EDI ←-4;

FI;
FI;
FI;

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the limit of the ES segment.
If the ES register contains a null segment selector.
#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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: Base IA-32 Instruction Reference 3:747


STR—Store Task Register
Opcode Instruction Description
0F 00 /1 STR r/m16 Stores segment selector from TR in r/m16

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept.

Protected Mode Exceptions


#GP(0) If the destination is a memory operand that is located in a nonwritable
segment or if the 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.

Real Address Mode Exceptions


#UD The STR instruction is not recognized in real address mode.

Virtual 8086 Mode Exceptions


#UD The STR instruction is not recognized in virtual 8086 mode.

3:748 Volume 3: Base IA-32 Instruction Reference


SUB—Integer Subtraction
Opcode Instruction Description
2C ib SUB AL,imm8 Subtract imm8 from AL
2D iw SUB AX,imm16 Subtract imm16 from AX
2D id SUB EAX,imm32 Subtract imm32 from EAX
80 /5 ib SUB r/m8,imm8 Subtract imm8 from r/m8
81 /5 iw SUB r/m16,imm16 Subtract imm16 from r/m16
81 /5 id SUB r/m32,imm32 Subtract imm32 from r/m32
83 /5 ib SUB r/m16,imm8 Subtract sign-extended imm8 from r/m16
83 /5 ib SUB r/m32,imm8 Subtract sign-extended imm8 from r/m32
28 /r SUB r/m8,r8 Subtract r8 from r/m8
29 /r SUB r/m16,r16 Subtract r16 from r/m16
29 /r SUB r/m32,r32 Subtract r32 from r/m32
2A /r SUB r8,r/m8 Subtract r/m8 from r8
2B /r SUB r16,r/m16 Subtract r/m16 from r16
2B /r SUB r32,r/m32 Subtract r/m32 from r32

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: Base IA-32 Instruction Reference 3:749


SUB—Integer Subtraction (Continued)

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:750 Volume 3: Base IA-32 Instruction Reference


TEST—Logical Compare
Opcode Instruction Description
A8 ib TEST AL,imm8 AND imm8 with AL; set SF, ZF, PF according to result
A9 iw TEST AX,imm16 AND imm16 with AX; set SF, ZF, PF according to result
A9 id TEST EAX,imm32 AND imm32 with EAX; set SF, ZF, PF according to result
F6 /0 ib TEST r/m8,imm8 AND imm8 with r/m8; set SF, ZF, PF according to result
F7 /0 iw TEST r/m16,imm16 AND imm16 with r/m16; set SF, ZF, PF according to result
F7 /0 id TEST r/m32,imm32 AND imm32 with r/m32; set SF, ZF, PF according to result
84 /r TEST r/m8,r8 AND r8 with r/m8; set SF, ZF, PF according to result
85 /r TEST r/m16,r16 AND r16 with r/m16; set SF, ZF, PF according to result
85 /r TEST r/m32,r32 AND r32 with r/m32; set SF, ZF, PF according to 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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: Base IA-32 Instruction Reference 3:751


TEST—Logical Compare (Continued)

Protected Mode Exceptions


#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 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.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:752 Volume 3: Base IA-32 Instruction Reference


UD2—Undefined Instruction
Opcode Instruction Description
0F 0B UD2 Raise invalid opcode exception

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept.

Exceptions (All Operating Modes)


#UD Instruction is guaranteed to raise an invalid opcode exception in all operating
modes).

Volume 3: Base IA-32 Instruction Reference 3:753


VERR, VERW—Verify a Segment for Reading or Writing
Opcode Instruction Description
0F 00 /4 VERR r/m16 Set ZF=1 if segment specified with r/m16 can be read
0F 00 /5 VERW r/m16 Set ZF=1 if segment specified with r/m16 can be written

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.

To set the ZF flag, the following conditions must be met:


• The segment selector is not null.
• The selector must denote a descriptor within the bounds of the descriptor table (GDT or LDT).
• The selector must denote the descriptor of a code or data segment (not that of a system segment
or gate).
• For the VERR instruction, the segment must be readable; the VERW instruction, the segment
must be a writable data segment.
• If the segment is not a conforming code segment, the segment’s DPL must be greater than or
equal to (have less or the same privilege as) both the CPL and the segment selector's RPL.

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;

3:754 Volume 3: Base IA-32 Instruction Reference


VERR, VERW—Verify a Segment for Reading or Writing (Continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions

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.

Real Address Mode Exceptions


#UD The VERR and VERW instructions are not recognized in real address mode.

Virtual 8086 Mode Exceptions


#UD The VERR and VERW instructions are not recognized in virtual 8086 mode.

Volume 3: Base IA-32 Instruction Reference 3:755


WAIT/FWAIT—Wait
Opcode Instruction Description
9B WAIT Check pending unmasked floating-point exceptions.
9B FWAIT Check pending unmasked floating-point exceptions.

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;

FPU Flags Affected

The C0, C1, C2, and C3 flags are undefined.

Floating-point Exceptions

None.

Protected Mode Exceptions


#NM MP and TS in CR0 is set.

Real Address Mode Exceptions


#NM MP and TS in CR0 is set.

Virtual 8086 Mode Exceptions


#NM MP and TS in CR0 is set.

3:756 Volume 3: Base IA-32 Instruction Reference


WBINVD—Write-Back and Invalidate Cache
Opcode Instruction Description
0F 09 WBINVD Write-back and flush Internal caches; initiate writing-back and
flushing of external caches.

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept.

Protected Mode Exceptions


#GP(0) If the current privilege level is not 0.

Real Address Mode Exceptions

None.

Volume 3: Base IA-32 Instruction Reference 3:757


WBINVD—Write-Back and Invalidate Cache (Continued)

Virtual 8086 Mode Exceptions


#GP(0) The WBINVD instruction cannot be executed at the virtual 8086 mode.

Intel Architecture Compatibility

The WDINVD instruction implementation-dependent; its function may be implemented differently


on future Intel architecture processors. The instruction is not supported on Intel architecture
processors earlier than the Intel486 processor.

3:758 Volume 3: Base IA-32 Instruction Reference


WRMSR—Write to Model Specific Register
Opcode Instruction Description
0F 30 WRMSR Write the value in EDX:EAX to MSR specified by ECX

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 WRMSR instruction is a serializing instruction.

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.

Additional Itanium System Environment Exceptions


IA-32_Intercept Mandatory Instruction Intercept.

Protected Mode Exceptions


#GP(0) If the current privilege level is not 0.
If the value in ECX specifies a reserved or unimplemented MSR address.

Real Address Mode Exceptions


#GP If the current privilege level is not 0
If the value in ECX specifies a reserved or unimplemented MSR address.

Volume 3: Base IA-32 Instruction Reference 3:759


WRMSR—Write to Model Specific Register (Continued)

Virtual 8086 Mode Exceptions


#GP(0) The WRMSR instruction is not recognized in virtual 8086 mode.

Intel Architecture Compatibility

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.

3:760 Volume 3: Base IA-32 Instruction Reference


XADD—Exchange and Add
Opcode Instruction Description
0F C0/r XADD r/m8,r8 Exchange r8 and r/m8; load sum into r/m8.
0F C1/r XADD r/m16,r16 Exchange r16 and r/m16; load sum into r/m16.
0F C1/r XADD r/m32,r32 Exchange r32 and r/m32; load sum into r/m32.

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.

This instruction can be used with a LOCK prefix.

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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
IA-32_Intercept Lock Intercept – If an external atomic bus lock is required to complete this
operation and DCR.lc is 1, no atomic transaction occurs, this instruction is
faulted and an IA-32_Intercept(Lock) fault is generated. The software lock
handler is responsible for the emulation of this instruction.

Protected Mode Exceptions


#GP(0) If the destination is located in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Volume 3: Base IA-32 Instruction Reference 3:761


XADD—Exchange and Add (Continued)

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Intel Architecture Compatibility

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.

3:762 Volume 3: Base IA-32 Instruction Reference


XCHG—Exchange Register/Memory with Register
Opcode Instruction Description
90+rw XCHG AX,r16 Exchange r16 with AX
90+rw XCHG r16,AX Exchange r16 with AX
90+rd XCHG EAX,r32 Exchange r32 with EAX
90+rd XCHG r32,EAX Exchange r32 with EAX
86 /r XCHG r/m8,r8 Exchange byte register with EA byte
86 /r XCHG r8,r/m8 Exchange byte register with EA byte
87 /r XCHG r/m16,r16 Exchange r16 with EA word
87 /r XCHG r16,r/m16 Exchange r16 with EA word
87 /r XCHG r/m32,r32 Exchange r32 with EA doubleword
87 /r XCHG r32,r/m32 Exchange r32 with EA doubleword

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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
IA-32_Intercept Lock Intercept – If an external atomic bus lock is required to complete this
operation and DCR.lc is 1, no atomic transaction occurs, this instruction is
faulted and an IA-32_Intercept(Lock) fault is generated. The software lock
handler is responsible for the emulation of this instruction.

Volume 3: Base IA-32 Instruction Reference 3:763


XCHG—Exchange Register/Memory with Register (Continued)

Protected Mode Exceptions


#GP(0) If either operand is in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:764 Volume 3: Base IA-32 Instruction Reference


XLAT/XLATB—Table Look-up Translation
Opcode Instruction Description
D7 XLAT m8 Set AL to memory byte DS:[(E)BX + unsigned AL]
D7 XLATB Set AL to memory byte DS:[(E)BX + unsigned AL]

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#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 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.

Volume 3: Base IA-32 Instruction Reference 3:765


XLAT/XLATB—Table Look-up Translation (Continued)

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:766 Volume 3: Base IA-32 Instruction Reference


XOR—Logical Exclusive OR
Opcode Instruction Description
34 ib XOR AL,imm8 AL XOR imm8
35 iw XOR AX,imm16 AX XOR imm16
35 id XOR EAX,imm32 EAX XOR imm32
80 /6 ib XOR r/m8,imm8 r/m8 XOR imm8
81 /6 iw XOR r/m16,imm16 r/m16 XOR imm16
81 /6 id XOR r/m32,imm32 r/m32 XOR imm32
83 /6 ib XOR r/m16,imm8 r/m16 XOR imm8
83 /6 ib XOR r/m32,imm8 r/m32 XOR imm8
30 /r XOR r/m8,r8 r/m8 XOR r8
31 /r XOR r/m16,r16 r/m16 XOR r16
31 /r XOR r/m32,r32 r/m32 XOR r32
32 /r XOR r8,r/m8 r8 XOR r/m8
33 /r XOR r16,r/m16 r8 XOR r/m8
33 /r XOR r32,r/m32 r8 XOR r/m8

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: Base IA-32 Instruction Reference 3:767


XOR—Logical Exclusive OR (Continued)

Protected Mode Exceptions


#GP(0) If the destination operand points to a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real Address Mode Exceptions


#GP If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS If a memory operand effective address is outside the SS segment limit.

Virtual 8086 Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS, or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:768 Volume 3: Base IA-32 Instruction Reference


IA-32 Intel® MMX™ Technology
3

Instruction Reference 2

This section lists the IA-32 MMX technology instructions designed to increase performance of
multimedia intensive applications.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:769


EMMS—Empty MMX State
Opcode Instruction Description
0F 77 EMMS Set the FP tag word to empty.

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1.

Protected Mode Exceptions


#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Real-Address Mode Exceptions


#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

3:770 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


MOVD—Move 32 Bits
Opcode Instruction Description
0F 6E /r MOVD mm, r/m32 Move doubleword from r/m32 to mm.
0F 7E /r MOVD r/m32, mm Move doubleword from mm to r/m32.

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.

Figure 2-1. Operation of the MOVD Instruction

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);

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:771


MOVD—Move 32 Bits (continued)

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If the destination operand is in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:772 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


MOVQ—Move 64 Bits
Opcode Instruction Description
0F 6F /r MOVQ mm, mm/m64 Move quadword from mm/m64 to mm.
0F 7F /r MOVQ mm/m64, mm Move quadword from mm to mm/m64.

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.

Figure 2-2. Operation of the MOVQ Instruction

MOVQ mm, m64


63 48 47 32 31 1615 0
15 0 b7 b6 b5 b4 b3 b2 b1 b0
b7 b6 W N+3 mm
b5 b4 W N+2
b3 b2 W N+1
b1 b0 W N+0 m64
3006013

Operation
DEST ←SRC;

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:773


MOVQ—Move 64 Bits (continued)

Protected Mode Exceptions


#GP(0) If the destination operand is in a nonwritable segment.
If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:774 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PACKSSWB/PACKSSDW—Pack with Signed Saturation
Opcode Instruction Description
0F 63 /r PACKSSWB mm, Packs and saturate pack 4 signed words from mm and 4
mm/m64 signed words from mm/m64 into 8 signed bytes in mm.
0F 6B /r PACKSSDW mm, Pack and saturate 2 signed doublewords from mm and 2
mm/m64 signed doublewords from mm/m64 into 4 signed words in mm.

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.

Figure 2-3. Operation of the PACKSSDW Instruction

PACKSSDW mm, mm/m64


mm/m64 mm
D C B A

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);

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:775


PACKSSWB/PACKSSDW—Pack with Signed Saturation (continued)

ELSE (* instruction is PACKSSDW *)


DEST(15..0) ←SaturateSignedDoublewordToSignedWord DEST(31..0);
DEST(31..16) ←SaturateSignedDoublewordToSignedWord DEST(63..32);
DEST(47..32) ←SaturateSignedDoublewordToSignedWord SRC(31..0);
DEST(63..48) ←SaturateSignedDoublewordToSignedWord SRC(63..32);
FI;

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

3:776 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PACKSSWB/PACKSSDW—Pack with Signed Saturation (continued)

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:777


PACKUSWB—Pack with Unsigned Saturation
Opcode Instruction Description
0F 67 /r PACKUSWB mm, mm/m64 Pack and saturate 4 signed words from mm and 4 signed
words from mm/m64 into 8 unsigned bytes in mm.

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.

Figure 2-4. Operation of the PACKUSWB Instruction

PACKUSWB mm, mm/m64


mm/m64 mm
H G F E D C B A

H' G' F' E' D' C' B' A'


mm
3006014

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

3:778 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PACKUSWB—Pack with Unsigned Saturation (continued)

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:779


PADDB/PADDW/PADDD—Packed Add
Opcode Instruction Description
0F FC /r PADDB mm, mm/m64 Add packed bytes from mm/m64 to packed bytes in mm.
0F FD /r PADDW mm, mm/m64 Add packed words from mm/m64 to packed words in mm.
0F FE /r PADDD mm, mm/m64 Add packed doublewords from mm/m64 to packed
doublewords in mm.

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.

Figure 2-5. Operation of the PADDW Instruction

PADDW mm, mm/m64


mm 1000000000000000 0111111100111000

+ + + +
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.

3:780 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PADDB/PADDW/PADDD—Packed Add (continued)
Note that like the integer ADD instruction, the PADDB, PADDW, and PADDD instructions can
operate on either unsigned or signed (two's complement notation) packed integers. Unlike the
integer instructions, none of the MMX technology instructions affect the EFLAGS register. With
MMX technology instructions, there are no carry or overflow flags to indicate when overflow has
occurred, so the software must control the range of values or else use the “with saturation” MMX
technology instructions.

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:781


PADDB/PADDW/PADDD—Packed Add (continued)

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:782 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PADDSB/PADDSW—Packed Add with Saturation
Opcode Instruction Description
0F EC /r PADDSB mm, mm/m64 Add signed packed bytes from mm/m64 to signed packed
bytes in mm and saturate.
0F ED /r PADDSW mm, mm/m64 Add signed packed words from mm/m64 to signed packed
words in mm and saturate.

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.

Figure 2-6. Operation of the PADDSW Instruction

PADDSW mm, mm/m64


mm 1000000000000000 0111111100111000

+ + + +
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 *)

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:783


PADDSB/PADDSW—Packed Add with Saturation (continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

3:784 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PADDSB/PADDSW—Packed Add with Saturation (continued)

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:785


PADDUSB/PADDUSW—Packed Add Unsigned with Saturation
Opcode Instruction Description
0F DC /r PADDUSB mm, mm/m64 Add unsigned packed bytes from mm/m64 to unsigned
packed bytes in mm and saturate.
0F DD /r PADDUSW mm, mm/m64 Add unsigned packed words from mm/m64 to unsigned
packed words in mm and saturate.

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.

Figure 2-7. Operation of the PADDUSB Instruction

PADDUSB mm, mm/m64


mm 10000000 01111111 00111000

+ + + + + + + +
mm/m64 11111111 00010111 00000111

mm 11111111 10010110 00111111


3006017

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.

3:786 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PADDUSB/PADDUSW—Packed Add Unsigned with Saturation (continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:787


PADDUSB/PADDUSW—Packed Add Unsigned with Saturation (continued)

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:788 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PAND—Logical AND
Opcode Instruction Description
0F DB /r PAND mm, mm/m64 AND quadword from mm/m64 to quadword in mm.

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

Figure 2-8. Operation of the PAND Instruction

PAND mm, mm/m64


mm 1111111111111000000000000000010110110101100010000111011101110111

&
mm/m64 0001000011011001010100000011000100011110111011110001010110010101

mm 0001000011011000000000000000000100010100100010000001010100010101
3006019

Operation
DEST ←DEST AND SRC;

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:789


PAND—Logical AND (continued)

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:790 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PANDN—Logical AND NOT
Opcode Instruction Description
0F DF /r PANDN mm, mm/m64 AND quadword from mm/m64 to NOT quadword in mm.

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.

Figure 2-9. Operation of the PANDN Instruction

PANDN mm, mm/m64


~
mm 11111111111110000000000000000101101101010011101111000100010001000

&
m/m64 11111111111110000000000000000101101101010011101111000100010001000

mm 11111111111110000000000000000101101101010011101111000100010001000

Operation
DEST ←(NOT DEST) AND SRC;

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:791


PANDN—Logical AND NOT (continued)

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:792 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PCMPEQB/PCMPEQW/PCMPEQD—Packed Compare for Equal
Opcode Instruction Description
0F 74 /r PCMPEQB mm, mm/m64 Compare packed bytes in mm/m64 with packed bytes in mm for
equality.
0F 75 /r PCMPEQW mm, mm/m64 Compare packed words in mm/m64 with packed words in mm for
equality.
0F 76 /r PCMPEQD mm, mm/m64 Compare packed doublewords in mm/m64 with packed
doublewords in mm for equality.

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.

Figure 2-10. Operation of the PCMPEQW Instruction

PCMPEQW mm, mm/m64


mm 0000000000000000 0000000000000001 0000000000000111 0111000111000111

== == == ==
mm/m64 0000000000000000 0000000000000000 0111000111000111 0111000111000111
True False False True

mm 1111111111111111 0000000000000000 0000000000000000 1111111111111111


3006020

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.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:793


PCMPEQB/PCMPEQW/PCMPEQD—Packed Compare for Equal (continued)

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:

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.

3:794 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PCMPEQB/PCMPEQW/PCMPEQD—Packed Compare for Equal (continued)
#AC(0) If alignment checking is enabled and an unaligned memory reference is made
while the current privilege level is 3.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:795


PCMPGTB/PCMPGTW/PCMPGTD—Packed Compare for Greater Than
Opcode Instruction Description
0F 64 /r PCMPGTB mm, mm/m64 Compare packed bytes in mm with packed bytes in mm/m64
for greater value.
0F 65 /r PCMPGTW mm, mm/m64 Compare packed words in mm with packed words in
mm/m64 for greater value.
0F 66 /r PCMPGTD mm, mm/m64 Compare packed doublewords in mm with packed
doublewords in mm/m64 for greater value.

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.

Figure 2-11. Operation of the PCMPGTW Instruction

PCMPGTW mm, mm/m64


mm 0000000000000000 0000000000000001 0000000000000111 0111000111000111

> > > >


mm/m64 0000000000000000 0000000000000000 0111000111000111 0111000111000111
False True False False

mm 0000000000000000 1111111111111111 0000000000000000 0000000000000000


3006021

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.

3:796 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PCMPGTB/PCMPGTW/PCMPGTD—Packed Compare for Greater Than
(continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:797


PCMPGTB/PCMPGTW/PCMPGTD—Packed Compare for Greater Than
(continued)

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:798 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PMADDWD—Packed Multiply and Add
Opcode Instruction Description
0F F5 /r PMADDWD mm, mm/m64 Multiply the packed words in mm by the packed words in
mm/m64. Add the 32-bit pairs of results and store in mm
as doubleword

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.

Figure 2-12. Operation of the PMADDWD Instruction

PMADDWD mm, mm/m64

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:799


PMADDWD—Packed Multiply and Add (continued)

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:800 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PMULHW—Packed Multiply High
Opcode Instruction Description
0F E5 /r PMULHW mm, mm/m64 Multiply the signed packed words in mm by the signed
packed words in mm/m64, then store the high-order word
of each doubleword result in mm.

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.

Figure 2-13. Operation of the PMULHW Instruction

PMULHW mm, mm/m64


mm 0111000111000111 0111000111000111

* * * *
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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:801


PMULHW—Packed Multiply High (continued)

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:802 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PMULLW—Packed Multiply Low
Opcode Instruction Description
0F D5 /r PMULLW mm, Multiply the packed words in mm with the packed words in
mm/m64 mm/m64, then store the low-order word of each doubleword
result in mm.

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.

Figure 2-14. Operation of the PMULLW Instruction

PMULLW mm, mm/m64


mm 0111000111000111 0111000111000111

* * * *
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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:803


PMULLW—Packed Multiply Low (continued)

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:804 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


POR—Bitwise Logical OR
Opcode Instruction Description
0F EB /r POR mm, mm/m64 OR quadword from mm/m64 to quadword in mm.

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.

Figure 2-15. Operation of the POR Instruction.

POR mm, mm/m64


mm 1111111111111000000000000000010110110101100010000111011101110111

mm/m64 0001000011011001010100000011000100011110111011110001010110010101

mm 1111111111111001010100000011010110111111111011110111011111110111
3006024

Operation
DEST ←DEST OR SRC;

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:805


POR—Bitwise Logical OR (continued)

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:806 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PSLLW/PSLLD/PSLLQ—Packed Shift Left Logical
Opcode Instruction Description
0F F1 /r PSLLW mm, mm/m64 Shift words in mm left by amount specified in mm/m64, while
shifting in zeros.
0F 71 /6, ib PSLLW mm, imm8 Shift words in mm left by imm8, while shifting in zeros.
0F F2 /r PSLLD mm, mm/m64 Shift doublewords in mm left by amount specified in mm/m64,
while shifting in zeros.
0F 72 /6 ib PSLLD mm, imm8 Shift doublewords in mm by imm8, while shifting in zeros.
0F F3 /r PSLLQ mm, mm/m64 Shift mm left by amount specified in mm/m64, while shifting in
zeros.
0F 73 /6 ib PSLLQ mm, imm8 Shift mm left by Imm8, while shifting in zeros.

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.

Figure 2-16. Operation of the PSLLW Instruction

PSLLW mm, 2
mm 1111111111111100 0001000111000111

shift left shift left shift left shift left

mm 1111111111110000 0100011100011100
3006026

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:807


PSLLW/PSLLD/PSLLQ—Packed Shift Left Logical (continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

3:808 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PSLLW/PSLLD/PSLLQ—Packed Shift Left Logical (continued)

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:809


PSRAW/PSRAD—Packed Shift Right Arithmetic
Opcode Instruction Description
0F E1 /r PSRAW mm, mm/m64 Shift words in mm right by amount specified in mm/m64 while
shifting in sign bits.
0F 71 /4 ib PSRAW mm, imm8 Shift words in mm right by imm8 while shifting in sign bits
0F E2 /r PSRAD mm, mm/m64 Shift doublewords in mm right by amount specified in mm/m64
while shifting in sign bits.
0F 72 /4 ib PSRAD mm, imm8 Shift doublewords in mm right by imm8 while shifting in sign
bits.

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.

Figure 2-17. Operation of the PSRAW Instruction

PSRAW mm, 2
mm 1111111111111100 1101000111000111

shift right shift right shift right shift right

mm 1111111111111111 1111010001110001
3006048

3:810 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PSRAW/PSRAD—Packed Shift Right Arithmetic (continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:811


PSRAW/PSRAD—Packed Shift Right Arithmetic (continued)

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:812 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PSRLW/PSRLD/PSRLQ—Packed Shift Right Logical
Opcode Instruction Description
0F D1 /r PSRLW mm, mm/m64 Shift words in mm right by amount specified in mm/m64
while shifting in zeros.
0F 71 /2 ib PSRLW mm, imm8 Shift words in mm right by imm8.
0F D2 /r PSRLD mm, mm/m64 Shift doublewords in mm right by amount specified in
mm/m64 while shifting in zeros.
0F 72 /2 ib PSRLD mm, imm8 Shift doublewords in mm right by imm8.
0F D3 /r PSRLQ mm, mm/m64 Shift mm right by amount specified in mm/m64 while
shifting in zeros.
0F 73 /2 ib PSRLQ mm, imm8 Shift mm right by imm8 while shifting in zeros.

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.

Figure 2-18. Operation of the PSRLW Instruction

PSRLW mm, 2
mm 1111111111111100 0001000111000111

shift right shift right shift right shift right

mm 0011111111111111 0000010001110001
3006027

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:813


PSRLW/PSRLD/PSRLQ—Packed Shift Right Logical (continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

3:814 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PSRLW/PSRLD/PSRLQ—Packed Shift Right Logical (continued)

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:815


PSUBB/PSUBW/PSUBD—Packed Subtract
Opcode Instruction Description
0F F8 /r PSUBB mm, mm/m64 Subtract packed bytes in mm/m64 from packed bytes in mm.
0F F9 /r PSUBW mm, mm/m64 Subtract packed words inmm/m64 from packed words in mm.
0F FA /r PSUBD mm, mm/m64 Subtract packed doublewords in mm/m64 from packed
doublewords in mm.

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.

Figure 2-19. Operation of the PSUBW Instruction

PSUBW mm, mm/m64


mm 1000000000000000 0111111100111000

– – – –
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.

3:816 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PSUBB/PSUBW/PSUBD—Packed Subtract (continued)
Note that like the integer SUB instruction, the PSUBB, PSUBW, and PSUBD instructions can
operate on either unsigned or signed (two's complement notation) packed integers. Unlike the
integer instructions, none of the MMX technology instructions affect the EFLAGS register. With
MMX technology instructions, there are no carry or overflow flags to indicate when overflow has
occurred, so the software must control the range of values or else use the “with saturation” MMX
technology instructions.

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:817


PSUBB/PSUBW/PSUBD—Packed Subtract (continued)

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:818 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PSUBSB/PSUBSW—Packed Subtract with Saturation
Opcode Instruction Description
0F E8 /r PSUBSB mm, mm/m64 Subtract signed packed bytes in mm/m64 from signed
packed bytes in mm and saturate.
0F E9 /r PSUBSW mm, mm/m64 Subtract signed packed words in mm/m64 from signed
packed words in mm and saturate.

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.

Figure 2-20. Operation of the PSUBSW Instruction

PSUBSW mm, mm/m64


mm 1000000000000000 0111111100111000

– – – –
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.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:819


PSUBSB/PSUBSW—Packed Subtract with Saturation (continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

3:820 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PSUBSB/PSUBSW—Packed Subtract with Saturation (continued)

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:821


PSUBUSB/PSUBUSW—Packed Subtract Unsigned with Saturation
Opcode Instruction Description
0F D8 /r PSUBUSB mm, mm/m64 Subtract unsigned packed bytes in mm/m64 from
unsigned packed bytes in mm and saturate.
0F D9 /r PSUBUSW mm, Subtract unsigned packed words in mm/m64 from
mm/m64 unsigned packed words in mm and saturate.

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.

Figure 2-21. Operation of the PSUBUSB Instruction

PSUBUSB mm, mm/m64


mm 10000000 01111111 11111000

– – – – – – – –
mm/m64 11111111 00010111 00000111

mm 00000000 01101000 11110001


3006030

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.

3:822 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PSUBUSB/PSUBUSW—Packed Subtract Unsigned with Saturation
(continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:823


PSUBUSB/PSUBUSW—Packed Subtract Unsigned with Saturation
(continued)

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:824 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PUNPCKHBW/PUNPCKHWD/PUNPCKHDQ—Unpack High Packed Data
Opcode Instruction Description
0F 68 /r PUNPCKHBW mm, mm/m64 Interleave high-order bytes from mm and mm/m64 into mm.
0F 69 /r PUNPCKHWD mm, Interleave high-order words from mm and mm/m64 into mm.
mm/m64
0F 6A /r PUNPCKHDQ mm, mm/m64 Interleave high-order doublewords from mm and mm/m64 into
mm.

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

PUNPCKHBW mm, mm/m64


mm/m64 mm
27 2 6 25 24 23 22 21 20 17 16 15 14 13 12 11 10

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).

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:825


PUNPCKHBW/PUNPCKHWD/PUNPCKHDQ—Unpack High Packed Data
(continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

3:826 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PUNPCKHBW/PUNPCKHWD/PUNPCKHDQ—Unpack High Packed Data
(continued)

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:827


PUNPCKLBW/PUNPCKLWD/PUNPCKLDQ—Unpack Low Packed Data
Opcode Instruction Description
0F 60 /r PUNPCKLBW mm, Interleave low-order bytes from mm and mm/m64 into
mm/m32 mm.
0F 61 /r PUNPCKLWD mm, Interleave low-order words from mm and mm/m64 into
mm/m32 mm.
0F 62 /r PUNPCKLDQ mm, mm/m32 Interleave low-order doublewords from mm and mm/m64
into mm.

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

PUNPCKLBW mm, mm/m32


mm/m32 mm
2 3 2 2 21 20 17 16 15 14 13 12 11 10

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).

3:828 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PUNPCKLBW/PUNPCKLWD/PUNPCKLDQ—Unpack Low Packed Data
(continued)

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.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:829


PUNPCKLBW/PUNPCKLWD/PUNPCKLDQ—Unpack Low Packed Data
(continued)

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:830 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


PXOR—Logical Exclusive OR
Opcode Instruction Description
0F EF /r PXOR mm, mm/m64 XOR quadword from mm/m64 to quadword in mm.

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.

Figure 2-24. Operation of the PXOR Instruction

PXOR mm, mm/m64


mm 1111111111111000000000000000010110110101100010000111011101110111

^
mm/m64 0001000011011001010100000011000100011110111011110001010110010101

mm 1110111100100001010100000011010010101011011001110110001011100010
3006033

Operation
DEST ←DEST XOR SRC;

Flags Affected

None.

Additional Itanium System Environment Exceptions


Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1, NaT Register Consumption Abort.
Itanium Mem Faults VHPT 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

Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference 3:831


PXOR—Logical Exclusive OR (continued)

Protected Mode Exceptions


#GP(0) If a memory operand effective address is outside the CS, DS, ES, FS or GS
segment limit.
#SS(0) If a memory operand effective address is outside the SS segment limit.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#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.

Real-Address Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.

Virtual-8086 Mode Exceptions


#GP If any part of the operand lies outside of the effective address space from 0 to
FFFFH.
#UD If EM in CR0 is set.
#NM If TS in CR0 is set.
#MF If there is a pending FPU exception.
#PF(fault-code) If a page fault occurs.
#AC(0) If alignment checking is enabled and an unaligned memory reference is made.

3:832 Volume 3: IA-32 Intel® MMX™ Technology Instruction Reference


3

IA-32 SSE Instruction Reference 3

3.1 IA-32 SSE Instructions


This section lists the IA-32 SSE instructions designed to increase performance of IA-32 3D and
floating-point intensive applications. For details on SSE please refer to the IA-32 Intel®
Architecture Software Developer’s Manual.

3.2 About the Intel® SSE Architecture


The Intel SSE architecture accelerates performance of 3D graphics applications over the current P6
generation of the Pentium Pro, Pentium II and Pentium III processors. The programming model is
similar to the MMX technology model except that instructions now operate on new packed
floating-point data types which contain four single-precision floating-point numbers.

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.

Volume 3: IA-32 SSE Instruction Reference 3:833


3.3 Single Instruction Multiple Data
The Intel SSE architecture uses the Single Instruction Multiple Data (SIMD) technique. This
technique speeds up software performance by processing multiple data elements in parallel, using a
single instruction. The Intel SSE architecture supports operations on packed single-precision
floating-point data types, and the additional SIMD Integer instructions support operations on
packed quadrate data types (byte, word, or double-word). This approach was chosen because most
3D graphics and DSP applications have the following characteristics:
• Inherently parallel
• Wide dynamic range, hence floating-point based
• Regular and re-occurring memory access patterns
• Localized re-occurring operations performed on the data
• Data independent control flow

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.

3.4 New Data Types


The principal data type of the Intel SSE architecture is a packed single-precision floating-point
operand, specifically:
• Four 32-bit single-precision (SP) floating-point numbers (Figure 3-1).

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.

Figure 3-1. Packed Single-FP Data Type

127 96 95 65 63 32 31 0

Packed Single-FP

3:834 Volume 3: IA-32 SSE Instruction Reference


3.5 SSE Registers
The Intel SSE architecture provides eight 128-bit general purpose registers, each of which can be
directly addressed. These registers are new state, and require support from the operating system to
use them.

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.

The contents of SSE registers are cleared upon reset.

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.

Figure 3-2. SSE Register Set

XMM7
XMM6
XMM5
XMM4
XMM3
XMM2
XMM1
XMM0

3.6 Extended Instruction Set


The Intel SSE architecture supplies a rich set of instructions that operate on either all or the least
significant pairs of packed data operands, in parallel. The packed instructions operate on a pair of
operands as shown in Figure 3-3 while scalar instructions always operate on the least significant
pair of the two operands as shown in Figure 3-4; for scalar operations, the three upper components
from the first operand are passed through to the destination. In general, the address of a memory
operand has to be aligned on a 16-byte boundary for all instructions, except for unaligned loads and
stores.

Volume 3: IA-32 SSE Instruction Reference 3:835


Figure 3-3. Packed Operation

X1 (SP) X2 (SP) X3 (SP) X4 (SP)

Y1 (SP) Y2 (SP) Y3 (SP) Y4 (SP)

OP OP OP OP

X1 op Y1 (SP) X2 op Y2 (SP) X3 op Y3 (SP) X4 op Y4 (SP)

Figure 3-4. Scalar Operation

X1 (SP) X2 (SP) X3 (SP) X4 (SP)

Y1 (SP) Y2 (SP) Y3 (SP) Y4 (SP)

OP

X1 (SP) X2 (SP) X3 (SP) X4 op Y4 (SP)

3.6.1 Instruction Group Review

3.6.1.1 Arithmetic Instructions

Packed/Scalar Addition and Subtraction


The ADDPS (Add packed single-precision floating-point) and SUBPS (Subtract packed
single-precision floating-point) instructions add or subtract four pairs of packed single-precision
floating-point operands.

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.

Packed/Scalar Multiplication and Division


The MULPS (Multiply packed single-precision floating-point) instruction multiplies four pairs of
packed single-precision floating-point operands.

3:836 Volume 3: IA-32 SSE Instruction Reference


The MULSS (Multiply scalar single-precision floating-point) instruction multiplies 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.

Packed/Scalar Square Root


The SQRTPS (Square root packed single-precision floating-point) instruction returns the square
root of the packed four single-precision floating-point numbers from the source to a destination
register.

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

3.6.1.2 Logical Instructions

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.

Volume 3: IA-32 SSE Instruction Reference 3:837


3.6.1.3 Compare Instructions

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).

3.6.1.4 Shuffle Instructions

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.

Figure 3-5. Packed Shuffle Operation

X4 X3 X2 X1

Y4 Y3 Y2 Y1

{Y4... Y1} {Y4... Y1} {X4... X1} {X4... X1}

The UNPCKHPS (Unpacked high packed single-precision floating-point) instruction performs an


interleaved unpack of the high-order data elements of first and second packed single-precision
floating-point operands. It ignores the lower half part of the sources (Figure 3-6). When unpacking
from a memory operand, the full 128-bit operand is accessed from memory but only the high order
64 bits are utilized by the instruction.

3:838 Volume 3: IA-32 SSE Instruction Reference


Figure 3-6. Unpack High Operation

X4 X3 X2 X1

Y4 Y3 Y2 Y1

Y4 X4 Y3 X3

The UNPCKLPS (Unpacked low packed single-precision floating-point) instruction performs an


interleaved unpack of the low-order data elements of first and second packed single-precision
floating-point operands. It ignores the higher half part of the sources (Figure 3-7). When unpacking
from a memory operand, the full 128-bit operand is accessed from memory but only the low order
64 bits are utilized by the instruction.

Figure 3-7. Unpack Low Operation

X4 X3 X2 X1

Y4 Y3 Y2 Y1

Y2 X2 Y1 X1

3.6.1.5 Conversion Instructions

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.

Volume 3: IA-32 SSE Instruction Reference 3:839


The CVTPI2PS (Convert packed 32-bit integer to packed single-precision floating-point)
instruction converts two 32-bit signed integers in a MMX technology register to the two least
significant single-precision floating-point numbers; when the conversion is inexact, the rounded
value according to the rounding mode in MXCSR is returned. The upper two significant numbers in
the destination register are retained.

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 CVTPS2PI (Convert packed single-precision floating-point to packed 32-bit integer)


instruction converts the two least significant single-precision floating-point numbers to two 32-bit
signed integers in a MMX technology register; when the conversion is inexact, the rounded value
according to the rounding mode in MXCSR is returned. The CVTTPS2PI (Convert truncate packed
single-precision floating-point to packed 32-bit integer) instruction is similar to CVTPS2PI except
if the conversion is inexact, in which case the truncated result is returned.

The CVTSS2SI (Convert scalar single-precision floating-point to a 32-bit integer) instruction


converts the least significant single-precision floating-point number to a 32-bit signed integer in an
Intel architecture 32-bit integer register; when the conversion is inexact, the rounded value
according to the rounding mode in MXCSR is returned.The CVTTSS2SI (Convert truncate scalar
single-precision floating-point to scalar 32-bit integer) instruction is similar to CVTSS2SI except if
the conversion is inexact, the truncated result is returned.

3.6.1.6 Data Movement Instructions

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 MOVUPS (Move unaligned packed single-precision floating-point) instruction transfers


128-bits of packed data from memory to SSE registers and vice versa, or between SSE registers. No
assumption is made for alignment.

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.

3:840 Volume 3: IA-32 SSE Instruction Reference


3.6.1.7 State Management Instructions

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.

3.6.1.8 Additional SIMD Integer Instructions

Similar to the conversions instructions discussed in Section 3.6.1.5, “Conversion Instructions” on


page 0:839, these SIMD Integer instructions also behave identically to original MMX technology
instructions, in the presence of x87-FP instructions.

The PAVGB/PAVGW (Average unsigned source sub-operands, without incurring a loss in


precision) instructions add the unsigned data elements of the source operand to the unsigned data
elements of the destination register. The results of the add are then each independently right shifted
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 low order bit of each
final shifted result is set to 1 if at least one of the two least significant bits of the intermediate
unshifted shifted sum is 1.

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.

Volume 3: IA-32 SSE Instruction Reference 3:841


3.6.1.9 Cacheability Control Instructions

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 MOVNTPS (Non-temporal store of packed single-precision floating-point) instruction stores


data from a SSE register to memory. The memory address must be aligned to a 16-byte boundary; if
it is not aligned, a general protection exception will occur. 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.

3:842 Volume 3: IA-32 SSE Instruction Reference


• If the programmer specifies a non-temporal store to cacheable memory, two cases may result:
• If the data is present in the cache hierarchy, the instruction will ensure consistency. A
given processor may choose different ways to implement this; some examples include:
updating data in-place in the cache hierarchy while preserving the memory type semantics
assigned to that region, or evicting the data from the caches and writing the new
non-temporal data to memory (with WC semantics).
• If the data is not present in the cache hierarchy, and the destination region is mapped as
WB, WT or WC, the transaction will be weakly ordered, and is subject to all WC memory
semantics. The non-temporal store will not write allocate. Different implementations may
choose to collapse and combine these stores.
• In general, WC semantics require software to ensure coherence, with respect to other
processors and other system agents (such as graphics cards). Appropriate use of
synchronization and a fencing operation (see SFENCE, below) must be performed for
producer-consumer usage models. Fencing ensures that all system agents have global visibility
of the stored data; for instance, failure to fence may result in a written cache line staying within
a processor, and the line would not be visible to other agents. For processors which implement
non-temporal stores by updating data in-place that already resides in the cache hierarchy, the
destination region should also be mapped as WC. Otherwise if mapped as WB or WT, there is
the potential for speculative processor reads to bring the data into the caches; in this case,
non-temporal stores would then update in place, and data would not be flushed from the
processor by a subsequent fencing operation.
• The memory type visible on the bus in the presence of memory type aliasing is implementation
specific. As one possible example, the memory type written to the bus may reflect the memory
type for the first store to this line, as seen in program order; other alternatives are possible. This
behavior should be considered reserved, and dependency on the behavior of any particular
implementation risks future incompatibility.

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.

3.7 IEEE Compliance


SSE floating-point computation is IEEE-754 compliant except when the control word is set to flush
to zero mode. IEEE-754 compliance includes support for single-precision signed infinities, QNaNs,
SNaNs, integer indefinite, signed zeros, denormals, masked and unmasked exceptions.
single-precision floating-point values are represented identically both internally and in memory,
and are of the following form:

Sign Exponent Significand


31 30...23 22...0

Volume 3: IA-32 SSE Instruction Reference 3:843


This is a change from x87 floating-point which internally represents all numbers in 80-bit extended
format. This change implies that x87-FP libraries re-written to use SSE instructions may not
produce results that are identical to the those of the x87-FP implementation.Real Numbers and
Floating-point Formats.

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.

3.7.1 Real Number System


As shown in Figure 3-8, the real-number system comprises the continuum of real numbers from
minus infinity (−∞) to plus infinity (+∞).

Figure 3-8. Binary Real Number System

Binary Real Number System


-100 -10 -1 0 1 10 100
VV VV

Subset of binary real-numbers that can be represented with


IEEE single-precision (32-bit) floating-point format.
-100 -10 -1 0 1 10 100
VV VV

+10

10.0000000000000000000000
1.11111111111111111111111
Precision 24 Binary Digits

Numbers within this range


cannot be represented.

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.

3:844 Volume 3: IA-32 SSE Instruction Reference


3.7.1.1 Floating-point Format

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.

Figure 3-9. Binary Floating-point Format

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.

Table 3-1. Real Number Notation


Notation Value
Ordinary Decimal 178.125
Scientific Decimal 1.78125E102
Scientific Binary 1.0110010001E2111
Scientific Binary 1.0110010001E210000110
(Biased Exponent)
Single Format (Normalized) Sign Biased Exponent Significand
0 10000110 01100100010000000000000
1 (Implied)

3.7.1.2 Normalized Numbers

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.)

Volume 3: IA-32 SSE Instruction Reference 3:845


Representing numbers in normalized form maximizes the number of significant digits that can be
accommodated in a significand of a given width. To summarize, a normalized real number consists
of a normalized significand that represents a real number between 1 and 2 and an exponent that
specifies the number’s binary point.

3.7.1.3 Biased Exponent

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.

3.7.1.4 Real Number and Non-Number Encodings

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

(The term NaN stands for “Not a Number.”)

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.

3.7.1.5 Signed Zeros

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.

3:846 Volume 3: IA-32 SSE Instruction Reference


3.7.1.6 Normalized and Denormalized Finite Numbers

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).

Figure 3-10. Real Numbers and NaNs

NaN NaN
-Denormalized Finite +Denormalized Finite
-∞ -Normalized Finite -0 +0 +Normalized Finite +∞

Real Number and NaN Encodings For 32-bit Floating-point Format


S E F S E F
1 0 0 -0 +0 0 0 0

-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

X1 255 1.0XX2 -SNaN +SNaN X1 255 1.0XX2

X1 255 1.1XX -QNaN +QNaN X1 255 1.1XX

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).

When performing normalized floating-point computations, a processor normally operates on


normalized numbers and produces normalized numbers as results. Denormalized numbers
represent an underflow condition.

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.

Volume 3: IA-32 SSE Instruction Reference 3:847


Table 3-2. Denormalization Process
Operation Sign Exponenta Significand
True Result 0 −129 1.01011100000...00
Denormalize 0 −128 0.10101110000...00
Denormalize 0 −127 0.01010111000...00
Denormalize 0 −126 0.00101011100...00
Denormal Result 0 −126 0.00101011100...00

a. Expressed as an unbiased, decimal number.

In the extreme case, all the significant bits are shifted out to the right by leading zeros, creating a
zero result.

The processor deals with denormal values in the following ways:


• It avoids creating denormals by normalizing numbers whenever possible.
• It provides the floating-point underflow exception to permit programmers to detect cases when
denormals are created.
• It provides the floating-point denormal-operand exception to permit procedures or programs to
detect when denormals are being used as source operands for computations.

3.7.1.7 Signed Infinities

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”.

3:848 Volume 3: IA-32 SSE Instruction Reference


3.7.1.9 Indefinite

In response to a masked invalid-operation floating-point exceptions, the indefinite value QNAN is


produced. The integer indefinite, which can be produced during conversion from single-precision
floating-point to 32-bit integer, is defined to be 80000000H.

3.7.2 Operating on NaNs


As was described in Section 3.7.1.8, “NaNs” on page 0:848, the Intel SSE architecture supports
two types of NaNs: SNaNs and QNaNs. An SNaN is any NaN value with its most-significant
fraction bit set to 0 and at least one other fraction bit set to 1. (If all the fraction bits are set to 0, the
value is an ∞.) A QNaN is any NaN value with the most-significant fraction bit set to 1. The sign bit
of a NaN is not interpreted.

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.

In general Src1 and Src2 relate to an SSE instruction as follows:


ADDPS Src1, Src2/m128

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.

Volume 3: IA-32 SSE Instruction Reference 3:849


Table 3-3. Results of Operations with NAN Operands
NaN Result
Source Operands
(invalid operation exception is masked)
An SNaN and a QNaN. Src1 NaN (converted to QNaN if Src1 is an SNaN).
Two SNaNs. Src1 NaN (converted to QNaN)
Two QNaNs. Src1 QNaN
An SNaN and a real value. The SNaN converted into a QNaN.
A QNaN and a real value. The QNaN source operand.
An SNaN/QNaN value (for instructions The SNaN converted into a QNaN/the source QNaN.
which take only one operand i.e.
RCPPS, RCPSS, RSQRTPS,
RSQRTSS)
Neither source operand is a NaN and a The default QNaN real indefinite.
floating-point invalid-operation
exception is signaled.

3.8 Data Formats

3.8.1 Memory Data Formats


The Intel SSE architecture introduces a new packed 128-bit data type which consists of 4
single-precision floating-point numbers. The 128 bits are numbered 0 through 127. Bit 0 is the least
significant bit (LSB), and bit 127 is the most significant bit (MSB).

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.

Figure 3-11. Four Packed FP Data in Memory (at address 1000H)

Byte 15 Byte 0

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Memory Address 1016d Memory Address 1000d

3.8.2 SSE Register Data Formats


Values in SSE registers have the same format as a 128-bit quantity in memory. They have two data
access modes: 128-bit access mode and 32-bit access mode. The data type corresponds directly to
the single-precision format in the IEEE standard. Table 3-4 gives the precision and range of this
data type. Only the fraction part of the significand is encoded. The integer is assumed to be 1 for all
numbers except 0 and denormalized finite numbers. The exponent of the single-precision data type
is encoded in biased format. The biasing constant is 127 for the single-precision format.

3:850 Volume 3: IA-32 SSE Instruction Reference


Table 3-4. Precision and Range of SSE Datatype

Precision Approximate Normalized Range


Data Type Length
(Bits) Binary Decimal
Single-precision 32 24 2-126 to 2127 1.18 × 10-38 to 3.40 × 1038

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.

Table 3-5. Real Number and NaN Encodings


Significand
Class Sign Biased Exponent
Integer1 Fraction
Positive +∞ 0 11..11 1 00..00
+Normals 0 11..10 1 11..11
. . . .
. . . .
0 00..01 1 00..00
+Denormals 0 00..00 0 11.11
. . . .
. . . .
0 00..00 0 00..01
+Zero 0 00..00 0 00..00
Negative −Zero 1 00..00 0 00..00
−Denormals 1 00..00 0 00..01
. . . .
. . . .
1 00..00 0 11..11
−Normals 1 00..01 1 00..00
. . . .
. . . .
1 11..10 1 11..11
-∞ 1 11..11 1 00..00
NaNs SNaN X 11..11 1 0X..XX2
QNaN X 11..11 1 1X..XX
Real Indefinite 1 11..11 1 10..00
(QNaN)
Single ←⎯ 8 Bits ⎯→ ←⎯23 Bits ⎯→

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.

Volume 3: IA-32 SSE Instruction Reference 3:851


3.9 Instruction Formats
The nature of the Intel SSE architecture allows the use of existing instruction formats. Instructions
use the ModR/M format and are preceded by the 0F prefix byte. In general, operations are not
duplicated to provide two directions (i.e. separate load and store variants).

3.10 Instruction Prefixes


The SSE instructions use prefixes as specified in Table 3-6, Table 3-7, and Table 3-8. The effect of
multiple prefixes (more than one prefix from a group) is unpredictable and may vary from
processor to processor.

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:

ANDPS, ANDNPS, COMISS, FXRSTOR, FXSAVE, ORPS, LDMXCSR, MOVAPS, MOVHPS,


MOVLPS, MOVMSKPS, MOVNTPS, MOVUPS, SHUFPS, STMXCSR, UCOMISS,
UNPCKHPS, UNPCKLPS, XORPS.

Table 3-6. SSE Instruction Behavior with Prefixes


Prefix Type Effect on SSE Instructions
Address Size Prefix (67H) Affects SSE instructions with memory operand
Ignored by SSE instructions without memory operand.
Operand Size (66H) Reserved and may result in unpredictable behavior.
Segment Override Affects SSE instructions with mem.operand
(2EH,36H,3EH,26H,64H,65H) Ignored by SSE instructions without mem operand
Repeat Prefix (F3H) Affects SSE instructions
Repeat NE Prefix(F2H) Reserved and may result in unpredictable behavior.
Lock Prefix (0F0H) Generates invalid opcode exception.

Table 3-7. SIMD Integer Instructions – Behavior with Prefixes


Prefix Type Effect on Intel® MMX™ Technology Instructions
Address Size Prefix (67H) Affects Intel MMX technology instructions with mem. operand
Ignored by Intel MMX technology instructions without mem. operand.
Operand Size (66H) Reserved and may result in unpredictable behavior.
Segment Override Affects Intel MMX technology instructions with mem. operand
(2EH,36H,3EH,26H,64H,65H) Ignored by Intel MMX technology instructions without mem operand
Repeat Prefix (F3H) Reserved and may result in unpredictable behavior.
Repeat NE Prefix(F2H) Reserved and may result in unpredictable behavior.
Lock Prefix (0F0H) Generates invalid opcode exception.

Table 3-8. Cacheability Control Instruction Behavior with Prefixes


Prefix Type Effect on SSE Instructions
Address Size Prefix (67H) Affects cacheability control instruction with a mem. operand
Ignored by cacheability control instruction w/o a mem. operand.
Operand Size (66H) Reserved and may result in unpredictable behavior.

3:852 Volume 3: IA-32 SSE Instruction Reference


Table 3-8. Cacheability Control Instruction Behavior with Prefixes (Continued)
Prefix Type Effect on SSE Instructions
Segment Override Affects cacheability control instructions with mem. operand
(2EH,36H,3EH,26H,64H,65H) Ignored by cacheability control instruction without mem operand
Repeat Prefix(F3H) Reserved and may result in unpredictable behavior.
Repeat NE Prefix(F2H) Reserved and may result in unpredictable behavior.
Lock Prefix (0F0H) Generates an invalid opcode exception for all cacheability
instructions.

3.11 Reserved Behavior and Software Compatibility


In many register and memory layout descriptions, certain bits are marked as reserved. When bits
are marked as reserved, it is essential for compatibility with future processors that software treat
these bits as having a future, though unknown, effect. The behavior of reserved bits should be
regarded as not only reserved, but unpredictable. In general, reserved behavior may also be applied
in other areas. Software should follow these guidelines in dealing with reserved behavior:
• Do not depend on the states of any reserved fields when testing the values of registers which
contain such bits. Mask out the reserved fields before testing.
• Do not depend on the states of any reserved fields when storing to memory or to a register.
• Do not depend on the ability to retain information written into any reserved fields.
• When loading a register, always load the reserved fields with the values indicated in the
documentation, if any, or reload them with values previously read from the same register.
Note: Avoid any software dependency upon the reserved state/behavior. Depending upon
reserved behavior will make the software dependent upon the unspecified manner in
which the processor handles this behavior and risks incompatibility with future proces-
sors.

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.

In addition, the following abbreviations are used:


• r32: Intel architecture 32-bit integer register.
• xmm/m128: Indicates a 128-bit multimedia register or a 128-bit memory location.
• xmm/m64: Indicates a 128-bit multimedia register or a 64-bit memory location.
• xmm/m32: Indicates a 128-bit multimedia register or a 32-bit memory location.
• mm/m64: Indicates a 64-bit multimedia register or a 64-bit memory location.

Volume 3: IA-32 SSE Instruction Reference 3:853


• imm8: Indicates an immediate 8-bit operand.
• ib: Indicates that an immediate byte operand follows the opcode, ModR/M byte or
scaled-indexing byte.

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.

Table 3-9. Key to SSE Naming Convention


Mnemonic Description
PI Packed integer qword (e.g. mm0)
PS Packed single FP (e.g. xmm0)
SI Scalar integer (e.g. eax)
SS Scalar single-FP (e.g. low 32 bits of xmm0)

3:854 Volume 3: IA-32 SSE Instruction Reference


ADDPS: Packed Single-FP Add
Opcode Instruction Description
0F,58,/r ADDPS xmm1, xmm2/m128 Add packed SP FP numbers from XMM2/Mem to XMM1.

Operation: xmm1[31-0] = xmm1[31-0] + xmm2/m128[31-0];

xmm1[63-32] = xmm1[63-32] + xmm2/m128[63-32];

xmm1[95-64] = xmm1[95-64] + xmm2/m128[95-64];

xmm1[127-96] = xmm1[127-96] + xmm2/m128[127-96];

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.

Numeric Exceptions: Overflow, Underflow, Invalid, Precision, Denormal.

Protected Mode 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. #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.

Real Address Mode Exceptions:

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)

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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

Volume 3: IA-32 SSE Instruction Reference 3:855


ADDSS: Scalar Single-FP Add
Opcode Instruction Description
F3,0F,58, /r ADDSS xmm1, xmm2/m32 Add the lower SP FP number from XMM2/Mem to XMM1.

Operation: xmm1[31-0] = 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: 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.

Numeric Exceptions: Overflow, Underflow, Invalid, Precision, Denormal.

Protected Mode 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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

3:856 Volume 3: IA-32 SSE Instruction Reference


ANDNPS: Bit-wise Logical And Not for Single-FP
Opcode Instruction Description
0F,55,/r ANDNPS xmm1, xmm2/m128 Invert the 128 bits in XMM1and then AND the result with 128
bits from XMM2/Mem.

Operation: xmm1[127-0] = ~(xmm1[127-0]) & xmm2/m128[127-0];

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.

Numeric Exceptions: None

Protected Mode 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; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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.

Volume 3: IA-32 SSE Instruction Reference 3:857


ANDPS: Bit-wise Logical And for Single-FP
Opcode Instruction Description
0F,54,/r ANDPS xmm1, xmm2/m128 Logical AND of 128 bits from XMM2/Mem to XMM1 register.

Operation: xmm1[127-0] &= xmm2/m128[127-0];

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.

Numeric Exceptions: None

Protected Mode 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; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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.

3:858 Volume 3: IA-32 SSE Instruction Reference


CMPPS: Packed Single-FP Compare
Opcode Instruction Description
0F,C2,/r,ib CMPPS xmm1, xmm2/m128, Compare packed SP FP numbers from XMM2/Mem to
imm8 packed SP FP numbers in XMM1 register using imm8 as
predicate.

Operation: switch (imm8) {

case eq: op = eq;

case lt: op = lt;

case le: op = le;

case unord: op = unord;

case neq: op = neq;

case nlt: op = nlt;

case nle: op = nle;

case ord: op = ord;

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]);

xmm1[31-0] = (cmp0) ? 0xffffffff : 0x00000000;

xmm1[63-32] = (cmp1) ? 0xffffffff : 0x00000000;

xmm1[95-64] = (cmp2) ? 0xffffffff : 0x00000000;

xmm1[127-96] = (cmp3) ? 0xffffffff : 0x00000000;

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:

Volume 3: IA-32 SSE Instruction Reference 3:859


QNaN
Result if
imm8 Operand
Predicate Descriptiona Relation Emulation NaN
Encoding Signals
Operand
Invalid
eq equal xmm1 == xmm2 000B False No
lt less-than xmm1 < xmm2 001B False Yes
le less-than-or-equal xmm1 <= xmm2 010B False Yes
greater than xmm1 > xmm2 swap, protect, lt False Yes
greater-than-or-equal xmm1 >= xmm2 swap protect, le False Yes
unord unordered xmm1 ? xmm2 011B True No
neq not-equal !(xmm1 == xmm2) 100B True No
nlt not-less-than !(xmm1 < xmm2) 101B True Yes
nle not-less-than-or-equal !(xmm1 <= xmm2) 110B True Yes
not-greater-than !(xmm1 > xmm2) swap, protect, nlt True Yes
not-greater-than-or-equal !(xmm1 >= xmm2) swap, protect, nle True Yes
ord ordered !(xmm1 ? xmm2) 111B False No

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.

Protected Mode 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. #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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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:

3:860 Volume 3: IA-32 SSE Instruction Reference


Pseudo-Op Implementation
CMPEQPS xmm1, xmm2 CMPPS xmm1,xmm2, 0
CMPLTPS xmm1, xmm2 CMPPS xmm1,xmm2, 1
CMPLEPS xmm1, xmm2 CMPPS xmm1,xmm2, 2
CMPUNORDPS xmm1, xmm2 CMPPS xmm1,xmm2, 3
CMPNEQPS xmm1, xmm2 CMPPS xmm1,xmm2, 4
CMPNLTPS xmm1, xmm2 CMPPS xmm1,xmm2, 5
CMPNLEPS xmm1, xmm2 CMPPS xmm1,xmm2, 6
CMPORDPS xmm1, xmm2 CMPPS 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.

Volume 3: IA-32 SSE Instruction Reference 3:861


CMPSS: Scalar Single-FP Compare
Opcode Instruction Description
F3,0F,C2,/r,ib CMPSS xmm1, xmm2/m32, Compare lowest SP FP number from XMM2/Mem to lowest
imm8 SP FP number in XMM1 register using imm8 as predicate.

Operation: switch (imm8) {

case eq: op = eq;

case lt: op = lt;

case le: op = le;

case unord: op = unord;

case neq: op = neq;

case nlt: op = nlt;

case nle: op = nle;

case ord: op = ord;

default: Reserved;

cmp0 = op(xmm1[31-0],xmm2/m32[31-0]);

xmm1[31-0] = (cmp0) ? 0xffffffff : 0x00000000;

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:

3:862 Volume 3: IA-32 SSE Instruction Reference


Result if qNaN
imm8
Predicate Descriptiona Relation Emulation NaN OperandSig
Encoding
Operand nals Invalid
eq equal xmm1 == xmm2 000B False No
lt less-than xmm1 < xmm2 001B False Yes
le less-than-or-equal xmm1 <= xmm2 010B False Yes
greater than xmm1 > xmm2 swap, protect, lt False Yes
greater-than-or-equal xmm1 >= xmm2 swap protect, le False Yes
unord unordered xmm1 ? xmm2 011B True No
neq not-equal !(xmm1 == xmm2) 100B True No
nlt not-less-than !(xmm1 < xmm2) 101B True Yes
nle not-less-than-or- !(xmm1 <= xmm2) 110B True Yes
equal
not-greater-than !(xmm1 > xmm2) swap, protect, nlt True Yes
not-greater-than-or-equal !(xmm1 >= xmm2) swap, protect, nle True Yes
ord ordered !(xmm1 ? xmm2) 111B False No

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.

Protected Mode 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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

Volume 3: IA-32 SSE Instruction Reference 3:863


Comments: Compilers and assemblers should implement the following 2-operand pseudo-ops in addition to the
3-operand CMPSS instruction:

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.

3:864 Volume 3: IA-32 SSE Instruction Reference


COMISS: Scalar Ordered Single-FP Compare and set EFLAGS
Opcode Instruction Description
0F,2F,/r COMISS xmm1, xmm2/m32 Compare lower SP FP number in XMM1 register with lower
SP FP number in XMM2/Mem and set the status flags
accordingly

Operation: switch (xmm1[31-0] <> xmm2/m32[31-0]) {

OF,SF,AF = 000;

case UNORDERED: ZF,PF,CF = 111;

case GREATER_THAN: ZF,PF,CF = 000;

case LESS_THAN: ZF,PF,CF = 001;

case EQUAL: ZF,PF,CF = 100;

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.

Protected Mode 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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Volume 3: IA-32 SSE Instruction Reference 3:865


COMISS: Scalar Ordered Single-FP Compare and set EFLAGS (Continued)
Additional Itanium System Environment Exceptions

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.

3:866 Volume 3: IA-32 SSE Instruction Reference


CVTPI2PS: Packed Signed INT32 to Packed Single-FP Conversion
Opcode Instruction Description
0F,2A,/r CVTPI2PS xmm, mm/m64 Convert two 32-bit signed integers from MM/Mem to two SP
FP.

Operation: xmm[31-0] = (float) (mm/m64[31-0]);

xmm[63-32] = (float) (mm/m64[63-32]);

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.

Numeric Exceptions: Precision.

Protected Mode 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; #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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

Volume 3: IA-32 SSE Instruction Reference 3:867


CVTPI2PS: Packed Signed INT32 to Packed Single-FP Conversion
(Continued)
Comments: This instruction behaves identically to original 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).
• MMX technology instructions write ones (1’s) to the exponent part of the corresponding
x87-FP register.

However, the use of a memory source operand with this instruction will not result in the above
transition from x87-FP to MMX technology.

Prioritization for fault and assist behavior for CVTPI2PS is as follows:

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)

3:868 Volume 3: IA-32 SSE Instruction Reference


CVTPS2PI: Packed Single-FP to Packed INT32 Conversion
Opcode Instruction Description
0F,2D,/r CVTPS2PI mm, xmm/m64 Convert lower 2 SP FP from XMM/Mem to 2 32-bit signed
integers in MM using rounding specified by MXCSR.

Operation: mm[31-0] = (int) (xmm/m64[31-0]);

mm[63-32] = (int) (xmm/m64[63-32]);

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.

Numeric Exceptions: Invalid, Precision.

Protected Mode 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; #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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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:

Volume 3: IA-32 SSE Instruction Reference 3:869


CVTPS2PI: Packed Single-FP to Packed INT32 Conversion (Continued)
• 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.

Prioritization for fault and assist behavior for CVTPS2PI is as follows:

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)

3:870 Volume 3: IA-32 SSE Instruction Reference


CVTSI2SS: Scalar signed INT32 to Single-FP Conversion
Opcode Instruction Description
F3,0F,2A,/r CVTSI2SS xmm, r/m32 Convert one 32-bit signed integer from Integer Reg/Mem to
one SP FP.

Operation: xmm[31-0] = (float) (r/m32);

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.

Numeric Exceptions: Precision.

Protected Mode 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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

Volume 3: IA-32 SSE Instruction Reference 3:871


CVTSS2SI: Scalar Single-FP to Signed INT32 Conversion
Opcode Instruction Description
F3,0F,2D,/r CVTSS2SI r32, xmm/m32 Convert one SP FP from XMM/Mem to one 32 bit signed
integer using rounding mode specified by MXCSR, and move
the result to an integer register.

Operation: r32 = (int) (xmm/m32[31-0]);

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.

Numeric Exceptions: Invalid, Precision.

Protected Mode 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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

3:872 Volume 3: IA-32 SSE Instruction Reference


CVTTPS2PI: Packed Single-FP to Packed INT32 Conversion (truncate)
Opcode Instruction Description
0F,2C,/r CVTTPS2PI mm, xmm/m64 Convert lower 2 SP FP from XMM/Mem to 2 32-bit signed
integers in MM using truncate.

Operation: mm[31-0] = (int) (xmm/m64[31-0]);

mm[63-32] = (int) (xmm/m64[63-32]);

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.

Numeric Exceptions: Invalid, Precision.

Protected Mode 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; #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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

Volume 3: IA-32 SSE Instruction Reference 3:873


CVTTPS2PI: Packed Single-FP to Packed INT32 Conversion (truncate)
(Continued)
Comments: This instruction behaves 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.

Prioritization for fault and assist behavior for CVTTPS2PI is as follows:

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)

3:874 Volume 3: IA-32 SSE Instruction Reference


CVTTSS2SI: Scalar Single-FP to signed INT32 Conversion (truncate)
Opcode Instruction Description
F3,0F,2C,/r CVTTSS2SI r32, xmm/m32 Convert lowest SP FP from XMM/Mem to one 32 bit signed
integer using truncate, and move the result to an integer
register.

Operation: r32 = (int) (xmm/m32[31-0]);

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.

Numeric Exceptions: Invalid, Precision.

Protected Mode 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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

Volume 3: IA-32 SSE Instruction Reference 3:875


DIVPS: Packed Single-FP Divide
Opcode Instruction Description
0F,5E,/r DIVPS xmm1, xmm2/m128 Divide packed SP FP numbers in XMM1 by XMM2/Mem

Operation: xmm1[31-0] = xmm1[31-0] / (xmm2/m128[31-0]);

xmm1[63-32] = xmm1[63-32] / (xmm2/m128[63-32]);

xmm1[95-64] = xmm1[95-64] / (xmm2/m128[95-64]);

xmm1[127-96] = xmm1[127-96] / (xmm2/m128[127-96]);

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.

Numeric Exceptions: Overflow, Underflow, Invalid, Divide by Zero, Precision, Denormal.

Protected Mode 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; #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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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

3:876 Volume 3: IA-32 SSE Instruction Reference


DIVSS: Scalar Single-FP Divide
Opcode Instruction Description
F3,0F,5E,/r DIVSS xmm1, xmm2/m32 Divide lower SP FP numbers in XMM1 by XMM2/Mem

Operation: xmm1[31-0] = 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: The DIVSS instructions divide the lowest SP FP numbers of both operands; the upper 3 fields are
passed through from xmm1.

FP Exceptions: None.

Numeric Exceptions: Overflow, Underflow, Invalid, Divide by Zero, Precision, Denormal.

Protected Mode 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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

Volume 3: IA-32 SSE Instruction Reference 3:877


FXRSTOR: Restore FP and Intel® MMX™ Technology State and SSE State
Opcode Instruction Description
0F,AE,/1 FXRSTOR Load FP/Intel MMX technology and SSE state from m512byte.
m512byte

Operation: FP and MMX technology state and SSE state = m512byte;

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

3:878 Volume 3: IA-32 SSE Instruction Reference


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.

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

Numeric Exceptions: None

Protected Mode 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; #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).

Real Address Mode Exceptions:

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.

Volume 3: IA-32 SSE Instruction Reference 3:879


FXRSTOR: Restore FP and Intel® MMX™ Technology State and SSE State
(Continued)
Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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.

3:880 Volume 3: IA-32 SSE Instruction Reference


FXSAVE: Store FP and Intel® MMX™ Technology State and SSE State
Opcode Instruction Description
0F,AE,/0 FXSAVE Store FP and Intel MMX technology state and SSE state to m512byte.
m512byte

Operation: m512byte = FP and MMX technology state and SSE state;

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

Volume 3: IA-32 SSE Instruction Reference 3:881


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 416
Reserved 432
Reserved 448
Reserved 464
Reserved 480
Reserved 496

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:

Exponent Exponent Fraction J and M


FTW valid bit x87 FTW
all 1’s all 0’s all 0’s bits
0 0 0 0x 1 Special 10
0 0 0 1x 1 Valid 00
0 0 1 00 1 Special 10
0 0 1 10 1 Valid 00
0 1 0 0x 1 Special 10
0 1 0 1x 1 Special 10
0 1 1 00 1 Zero 01
0 1 1 10 1 Special 10

3:882 Volume 3: IA-32 SSE Instruction Reference


Exponent Exponent Fraction J and M
FTW valid bit x87 FTW
all 1’s all 0’s all 0’s bits
1 0 0 1x 1 Special 10
1 0 0 1x 1 Special 10
1 0 1 00 1 Special 10
1 0 1 10 1 Special 10
For all legal combinations above 0 Empty 11

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.

The destination m512byte is assumed to be aligned on a 16-byte boundary. If m512byte is not


aligned on a 16-byte boundary, FXSAVE generates a general protection exception.

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.

Numeric Exceptions: None

Protected Mode 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; #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).

Volume 3: IA-32 SSE Instruction Reference 3:883


FXSAVE: Store FP and Intel® MMX™ Technology State and SSE State
(Continued)
Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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.

3:884 Volume 3: IA-32 SSE Instruction Reference


LDMXCSR: Load SSE Control/Status
Opcode Instruction Description
0F,AE,/2 LDMXCSR m32 Load SSE control/status word from m32.

Operation: MXCSR = m32;

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:

Rounding Mode RC Field Description


Round to nearest (even) 00B Rounded result is the closest to the infinitely
precise result. If two values are equally
close, the result is the even value (that is,
the one with the least-significant bit of zero).
Round down (to minus infinity) 01B Rounded result is close to but no greater
than the infinitely precise result
Round up (toward positive infinity) 10B Rounded result is close to but no less than
the infinitely precise result.
Round toward zero (truncate) 11B Rounded result is close to but no greater in
absolute value than the infinitely precise
result.

The rounding-control is set to round to nearest upon reset.

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.

Volume 3: IA-32 SSE Instruction Reference 3:885


LDMXCSR: Load SSE Control/Status (Continued)
The IEEE mandated masked response to underflow is to deliver the denormalized result (i.e.
gradual underflow); consequently, the flush to zero mode is not compatible with IEEE Std. 754. It
is provided primarily for performance reasons. At the cost of a slight precision loss, faster
execution can be achieved for applications where underflows are common. Unmasking the
underflow exception takes precedence over Flush To Zero mode; this means that an exception
handler will be invoked for a SSE instruction that generates an underflow condition while this
exception is unmasked, regardless of whether flush to zero is enabled.

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.

Numeric Exceptions: None

Protected Mode 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); #UD if
CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault. #AC for unaligned
memory reference.

Additional Itanium System Environment Exceptions

Itanium Reg Faults 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 (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.

3:886 Volume 3: IA-32 SSE Instruction Reference


MAXPS: Packed Single-FP Maximum
Opcode Instruction Description
0F,5F,/r MAXPS xmm1, xmm2/m128 Return the maximum SP FP numbers between XMM2/Mem
and XMM1.

Operation: xmm1[31-0] = (xmm1[31-0] == NAN) ? xmm2[31-0] :

(xmm2[31-0] == NAN) ? xmm2[31-0] :

(xmm1[31-0] > xmm2/m128[31-0]) ? xmm1[31-0] ?


xmm2/m128[31-0];

xmm1[63-32] = (xmm1[63-32] == NAN) ? xmm2[63-32] :

(xmm2[63-32] == NAN) ? xmm2[63-32] :

(xmm1[63-32] > xmm2/m128[63-32]) ? xmm1[63-32] ?


xmm2/m128[63-32];

xmm1[95-64] = (xmm1[95-64] == NAN) ? xmm2[95-64] :

(xmm2[95-64] == NAN) ? xmm2[95-64] :

(xmm1[95-64] > xmm2/m128[95-64]) ? xmm1[95-64] ?


xmm2/m128[95-64];

xmm1[127-96] = (xmm1[127-96] == NAN) ? xmm2[127-96] :

(xmm2[127-96] == NAN) ? xmm2[127-96] :

(xmm1[127-96] > xmm2/m128[127-96]) ? xmm1[127-96] ?


xmm2/m128[127-96];

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.

Numeric Exceptions: Invalid (including qNaN source operand), Denormal.

Protected Mode 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; #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.

Volume 3: IA-32 SSE Instruction Reference 3:887


MAXPS: Packed Single-FP Maximum (Continued)
Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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.

3:888 Volume 3: IA-32 SSE Instruction Reference


MAXSS: Scalar Single-FP Maximum
Opcode Instruction Description
F3,0F,5F,/r MAXSS xmm1, xmm2/m32 Return the maximum SP FP number between the lower SP
FP numbers from XMM2/Mem and XMM1.

Operation: xmm1[31-0] = (xmm1[31-0] == NAN) ? xmm2[31-0] :

(xmm2[31-0] == NAN) ? xmm2[31-0] :

(xmm1[31-0] > xmm2/m32[31-0]) ? 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: 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

Numeric Exceptions: Invalid (including qNaN source operand), Denormal.

Protected Mode 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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Volume 3: IA-32 SSE Instruction Reference 3:889


MAXSS: Scalar Single-FP Maximum (Continued)
Additional Itanium System Environment Exceptions

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.

3:890 Volume 3: IA-32 SSE Instruction Reference


MINPS: Packed Single-FP Minimum
Opcode Instruction Description
0F,5D,/r MINPS xmm1, xmm2/m128 Return the minimum SP numbers between XMM2/Mem and
XMM1.

Operation: xmm1[31-0] = (xmm1[31-0] == NAN) ? xmm2[31-0] :

(xmm2[31-0] == NAN) ? xmm2[31-0] :

(xmm1[31-0] < xmm2/m128[31-0]) : xmm1[31-0] ?


xmm2/m128[31-0];

xmm1[63-32] = (xmm1[63-32] == NAN) ? xmm2[63-32] :

(xmm2[63-32] == NAN) ? xmm2[63-32] :

(xmm1[63-32] < xmm2/m128[63-32]) : xmm1[63-32] ?


xmm2/m128[63-32];

xmm1[95-64] = (xmm1[95-64] == NAN) ? xmm2[95-64] :

(xmm2[95-64] == NAN) ? xmm2[95-64] :

(xmm1[95-64] < xmm2/m128[95-64]) : xmm1[95-64] ?


xmm2/m128[95-64];

xmm1[127-96] = (xmm1[127-96] == NAN) ? xmm2[127-96] :

(xmm2[127-96] == NAN) ? xmm2[127-96] :

(xmm1[127-96] < xmm2/m128[127-96]) : xmm1[127-96] ?


xmm2/m128[127-96];

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.

Numeric Exceptions: Invalid (including qNaN source operand), Denormal.

Protected Mode 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. #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.

Volume 3: IA-32 SSE Instruction Reference 3:891


MINPS: Packed Single-FP Minimum (Continued)
Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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.

3:892 Volume 3: IA-32 SSE Instruction Reference


MINSS: Scalar Single-FP Minimum
Opcode Instruction Description
F3,0F,5D,/r MINSS xmm1, xmm2/m32 Return the minimum SP FP number between the lowest SP
FP numbers from XMM2/Mem and XMM1.

Operation: xmm1[31-0] = (xmm1[31-0] == NAN) ? xmm2[31-0] :

(xmm2[31-0] == NAN) ? xmm2[31-0] :

(xmm1[31-0] < xmm2/m32[31-0]) ? 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: 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

Numeric Exceptions: Invalid (including qNaN source operand), Denormal.

Protected Mode 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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF (fault-code) for a page fault; #AC for unaligned
memory references.

Volume 3: IA-32 SSE Instruction Reference 3:893


MINSS: Scalar Single-FP Minimum (Continued)
Additional Itanium System Environment Exceptions

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.

3:894 Volume 3: IA-32 SSE Instruction Reference


MOVAPS: Move Aligned Four Packed Single-FP
Opcode Instruction Description
0F,28,/r MOVAPS xmm1, xmm2/m128 Move 128 bits representing 4 packed SP data from
XMM2/Mem to XMM1 register.
0F,29,/r MOVAPS xmm2/m128, xmm1 Move 128 bits representing 4 packed SP from XMM1 register
to XMM2/Mem.

Operation: if (destination == xmm1) {

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.

Numeric Exceptions: None

Volume 3: IA-32 SSE Instruction Reference 3:895


MOVAPS: Move Aligned Four Packed Single-FP (Continued)
Protected Mode 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; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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.

3:896 Volume 3: IA-32 SSE Instruction Reference


MOVHLPS: Move High to Low Packed Single-FP
Opcode Instruction Description
0F,12,/r MOVHLPS xmm1, xmm2 Move 64 bits representing higher two SP operands from
XMM2 to lower two fields of XMM1 register.

Operation: // move instruction

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

Numeric Exceptions: None

Protected Mode Exceptions:

#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.

Real Address Mode Exceptions:

#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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode.

Additional Itanium System Environment Exceptions

Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1

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.

Volume 3: IA-32 SSE Instruction Reference 3:897


MOVHPS: Move High Packed Single-FP
Opcode Instruction Description
0F,16,/r MOVHPS xmm, m64 Move 64 bits representing two SP operands from Mem to
upper two fields of XMM register.
0F,17,/r MOVHPS m64, xmm Move 64 bits representing two SP operands from upper two
fields of XMM register to Mem.

Operation: if (destination == xmm) {

// 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

Numeric Exceptions: None

Protected Mode 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); #UD if
CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

3:898 Volume 3: IA-32 SSE Instruction Reference


MOVHPS: Move High Packed Single-FP (Continued)
Additional Itanium System Environment Exceptions

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.

Volume 3: IA-32 SSE Instruction Reference 3:899


MOVLHPS: Move Low to High Packed Single-FP
Opcode Instruction Description
0F,16,/r MOVLHPS xmm1, xmm2 Move 64 bits representing lower two SP operands from XMM2
to upper two fields of XMM1 register.

Operation: // move instruction

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

Numeric Exceptions: None

Protected Mode Exceptions:

#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.

Real Address Mode Exceptions:

#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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode.

Additional Itanium System Environment Exceptions

Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1

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.

3:900 Volume 3: IA-32 SSE Instruction Reference


MOVLPS: Move Low Packed Single-FP
Opcode Instruction Description
0F,12,/r MOVLPS xmm, m64 Move 64 bits representing two SP operands from Mem to
lower two fields of XMM register.
0F,13,/r MOVLPS m64, xmm Move 64 bits representing two SP operands from lower two
fields of XMM register to Mem.

Operation: if (destination == xmm) {

// 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

Numeric Exceptions: None

Protected Mode 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); #UD if
CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Volume 3: IA-32 SSE Instruction Reference 3:901


MOVLPS: Move Low Packed Single-FP (Continued)
Additional Itanium System Environment Exceptions

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.

3:902 Volume 3: IA-32 SSE Instruction Reference


MOVMSKPS: Move Mask to Integer
Opcode Instruction Description
0F,50,/r MOVMSKPS r32, xmm Move the single mask to r32.

Operation: r32[3] = xmm[127]; r32[2] = xmm[95];

r32[1] = xmm[63]; r32[0] = xmm[31];

r32[7-4] = 0x0; r32[15-8] = 0x00;

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

Numeric Exceptions: None.

Protected Mode Exceptions:

#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.

Real Address Mode Exceptions:

#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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode.

Additional Itanium System Environment Exceptions

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.

Volume 3: IA-32 SSE Instruction Reference 3:903


MOVSS: Move Scalar Single-FP
Opcode Instruction Description
F3,0F,10,/r MOVSS xmm1, xmm2/m32 Move 32 bits representing one scalar SP operand from
XMM2/Mem to XMM1 register.
F3,0F,11,/r MOVSS xmm2/m32, xmm1 Move 32 bits representing one scalar SP operand from XMM1
register to XMM2/Mem.

Operation: if (destination == xmm1) {

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];

3:904 Volume 3: IA-32 SSE Instruction Reference


MOVSS: Move Scalar Single-FP (Continued)
xmm2[127-96] = xmm2[127-96];

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

Numeric Exceptions: None

Protected Mode 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); #UD if
CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

Volume 3: IA-32 SSE Instruction Reference 3:905


MOVUPS: Move Unaligned Four Packed Single-FP
Opcode Instruction Description
0F,10,/r MOVUPS xmm1, xmm2/m128 Move 128 bits representing four SP data from XMM2/Mem to
XMM1 register.
0F,11,/r MOVUPS xmm2/m128, xmm1 Move 128 bits representing four SP data from XMM1 register to
XMM2/Mem.

Operation: if (destination == xmm1) {

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

Numeric Exceptions: None

3:906 Volume 3: IA-32 SSE Instruction Reference


MOVUPS: Move Unaligned Four Packed Single-FP (Continued)
Protected Mode 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; #AC for unaligned memory reference if the current privilege level is 3; #NM if TS bit in CR0
is set.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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.

Volume 3: IA-32 SSE Instruction Reference 3:907


MULPS: Packed Single-FP Multiply
Opcode Instruction Description
0F,59,/r MULPS xmm1, xmm2/m128 Multiply packed SP FP numbers in XMM2/Mem to XMM1.

Operation: xmm1[31-0] = xmm1[31-0] * xmm2/m128[31-0];

xmm1[63-32] = xmm1[63-32] * xmm2/m128[63-32];

xmm1[95-64] = xmm1[95-64] * xmm2/m128[95-64];

xmm1[127-96] = xmm1[127-96] * xmm2/m128[127-96];

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.

Numeric Exceptions: Overflow, Underflow, Invalid, Precision, Denormal.

Protected Mode 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; #XM for an unmasked SSE numeric exception
(CR4.OSXMMEXCPT =1); #UD for an unmasked SSE numeric exception (CR4.OSXMMEXCPT
=0).

Real Address Mode Exceptions:

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).

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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

3:908 Volume 3: IA-32 SSE Instruction Reference


MULSS: Scalar Single-FP Multiply
Opcode Instruction Description
F3,0F,59,/r MULSS xmm1 xmm2/m32 Multiply the lowest SP FP number in XMM2/Mem to XMM1.

xmm1[31-0] = 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: 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

Numeric Exceptions: Overflow, Underflow, Invalid, Precision, Denormal.

Protected Mode 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).

Real Address Mode Exceptions:

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).

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

Volume 3: IA-32 SSE Instruction Reference 3:909


ORPS: Bit-wise Logical OR for Single-FP Data
Opcode Instruction Description
0F,56,/r ORPS xmm1, xmm2/m128 OR 128 bits from XMM2/Mem to XMM1 register.

Operation: xmm1[127-0] |= xmm2/m128[127-0];

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.

Numeric Exceptions: None

Protected Mode 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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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.

3:910 Volume 3: IA-32 SSE Instruction Reference


RCPPS: Packed Single-FP Reciprocal
Opcode Instruction Description
0F,53,/r RCPPS xmm1, xmm2/m128 Return a packed approximation of the reciprocal of
XMM2/Mem.

Operation: xmm1[31-0] = approx (1.0/(xmm2/m128[31-0]));

xmm1[63-32] = approx (1.0/(xmm2/m128[63-32]));

xmm1[95-64] = approx (1.0/(xmm2/m128[95-64]));

xmm1[127-96] = approx (1.0/(xmm2/m128[127-96]));

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:

|Error| <= 1.5x2-12

FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.

Numeric Exceptions: None.

Protected Mode 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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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

|x| <= 1.11111111110100000000000B×2125

For input values x which satisfy

Volume 3: IA-32 SSE Instruction Reference 3:911


1.11111111110100000000001B×2125 <= |x| <= 1.00000000000110000000000B×2126

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

|x| <= 1.00000000000110000000001B×2126

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

3:912 Volume 3: IA-32 SSE Instruction Reference


RCPSS: Scalar Single-FP Reciprocal
Opcode Instruction Description
F3,0F,53,/r RCPSS xmm1, xmm2/m32 Return an approximation of the reciprocal of the lower SP FP
number in XMM2/Mem.

Operation: xmm1[31-0] = approx (1.0/(xmm2/m32[31-0]));

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:

|Error| <= 1.5x2-12

Numeric Exceptions: None.

Protected Mode 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; #AC for unaligned memory reference if the current privilege level is 3; #NM if TS bit in CR0
is set.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

|x| <= 1.11111111110100000000000B×2125

For input values x which satisfy

Volume 3: IA-32 SSE Instruction Reference 3:913


1.11111111110100000000001B×2125 <= |x| <= 1.00000000000110000000000B×2126

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

|x| <= 1.00000000000110000000001B×2126

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

3:914 Volume 3: IA-32 SSE Instruction Reference


RSQRTPS: Packed Single-FP Square Root Reciprocal
Opcode Instruction Description
0F,52,/r RSQRTPS xmm1, xmm2/m128 Return a packed approximation of the square root of the
reciprocal of XMM2/Mem.

Operation: xmm1[31-0] = approx (1.0/sqrt(xmm2/m128[31-0]));

xmm1[63-32] = approx (1.0/sqrt(xmm2/m128[63-32]));

xmm1[95-64] = approx (1.0/sqrt(xmm2/m128[95-64]));

xmm1[127-96] = approx (1.0/sqrt(xmm2/m128[127-96]));

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:

|Error| <= 1.5x2-12

FP Exceptions: General protection exception if not aligned on 16-byte boundary, regardless of segment.

Numeric Exceptions: None.

Protected Mode 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; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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).

Volume 3: IA-32 SSE Instruction Reference 3:915


RSQRTSS: Scalar Single-FP Square Root Reciprocal
Opcode Instruction Description
F3,0F,52,/r RSQRTSS xmm1, xmm2/m32 Return an approximation of the square root of the reciprocal of
the lowest SP FP number in XMM2/Mem.

Operation: xmm1[31-0] = approx (1.0/sqrt(xmm2/m32[31-0]));

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:

|Error| <= 1.5x2-12

Numeric Exceptions: None.

Protected Mode 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).

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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).

3:916 Volume 3: IA-32 SSE Instruction Reference


SHUFPS: Shuffle Single-FP
Opcode Instruction Description
0F,C6,/r, ib SHUFPS xmm1, xmm2/m128, imm8 Shuffle Single.

Operation: fp_select = (imm8 >> 0) & 0x3;

xmm1[31-0] = (fp_select == 0) ? xmm1[31-0] :

(fp_select == 1) ? xmm1[63-32] :

(fp_select == 2) ? xmm1[95-64] :

xmm1[127-96];

fp_select = (imm8 >> 2) & 0x3;

xmm1[63-32] = (fp_select == 0) ? xmm1[31-0] :

(fp_select == 1) ? xmm1[63-32] :

(fp_select == 2) ? xmm1[95-64] :

xmm1[127-96];

fp_select = (imm8 >> 4) & 0x3;

xmm1[95-64] = (fp_select == 0) ? xmm2/m128[31-0] :

(fp_select == 1) ? xmm2/m128[63-32] :

(fp_select == 2) ? xmm2/m128[95-64] :

xmm2/m128[127-96];

fp_select = (imm8 >> 6) & 0x3;

xmm1[127-96] = (fp_select == 0) ? xmm2/m128[31-0] :

(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.

Volume 3: IA-32 SSE Instruction Reference 3:917


SHUFPS: Shuffle Single-FP (Continued)
Example:

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.

Numeric Exceptions: None

Protected Mode 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; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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.

3:918 Volume 3: IA-32 SSE Instruction Reference


SQRTPS: Packed Single-FP Square Root
Opcode Instruction Description
0F,51,/r SQRTPS xmm1, xmm2/m128 Square Root of the packed SP FP numbers in XMM2/Mem.

Operation: xmm1[31-0] = sqrt (xmm2/m128[31-0]);

xmm1[63-32] = sqrt (xmm2/m128[63-32]);

xmm1[95-64] = sqrt (xmm2/m128[95-64]);

xmm1[127-96] = sqrt (xmm2/m128[127-96]);

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.

Numeric Exceptions: Invalid, Precision, Denormal.

Protected Mode 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; #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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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

Volume 3: IA-32 SSE Instruction Reference 3:919


SQRTSS: Scalar Single-FP Square Root
Opcode Instruction Description
F3,0F,51,/r SQRTSS xmm1, xmm2/m32 Square Root of the lower SP FP number in XMM2/Mem.

Operation: xmm1[31-0] = sqrt (xmm2/m32[31-0]);

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

Numeric Exceptions: Invalid, Precision, Denormal.

Protected Mode 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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

3:920 Volume 3: IA-32 SSE Instruction Reference


STMXCSR: Store SSE Control/Status
Opcode Instruction Description
0F,AE,/3 STMXCSR m32 Store SSE control/status word to m32.

Operation: m32 = MXCSR;

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.

Numeric Exceptions: None

Protected Mode 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); #UD if
CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit 25) = 0.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault. #AC for unaligned
memory reference.

Additional Itanium System Environment Exceptions

Itanium Reg Faults 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 (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.

Volume 3: IA-32 SSE Instruction Reference 3:921


SUBPS: Packed Single-FP Subtract
Opcode Instruction Description
0F,5C,/r SUBPS xmm1 xmm2/m128 Subtract packed SP FP numbers in XMM2/Mem from XMM1.

Operation: xmm1[31-0] = xmm1[31-0] - xmm2/m128[31-0];

xmm1[63-32] = xmm1[63-32] - xmm2/m128[63-32];

xmm1[95-64] = xmm1[95-64] - xmm2/m128[95-64];

xmm1[127-96] = xmm1[127-96] - xmm2/m128[127-96];

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.

Numeric Exceptions: Overflow, Underflow, Invalid, Precision, Denormal.

Protected Mode 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; #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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault;.

Additional Itanium System Environment Exceptions

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

3:922 Volume 3: IA-32 SSE Instruction Reference


SUBSS: Scalar Single-FP Subtract
Opcode Instruction Description
F3,0F,5C, /r SUBSS xmm1, xmm2/m32 Subtract the lower SP FP numbers in XMM2/Mem from
XMM1.

Operation: xmm1[31-0] = 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: The SUBSS instruction subtracts the lower SP FP numbers of both their operands.

FP Exceptions: None.

Numeric Exceptions: Overflow, Underflow, Invalid, Precision, Denormal.

Protected Mode 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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

Volume 3: IA-32 SSE Instruction Reference 3:923


UCOMISS: Unordered Scalar Single-FP Compare and Set EFLAGS
Opcode Instruction Description
0F,2E,/r UCOMISS xmm1, xmm2/m32 Compare lower SP FP number in XMM1 register with lower
SP FP number in XMM2/Mem and set the status flags
accordingly.

Operation: switch (xmm1[31-0] <> xmm2/m32[31-0]) {

OF,SF,AF = 000;

case UNORDERED: ZF,PF,CF = 111;

case GREATER_THAN: ZF,PF,CF = 000;

case LESS_THAN: ZF,PF,CF = 001;

case EQUAL: ZF,PF,CF = 100;

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.

Protected Mode 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.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

3:924 Volume 3: IA-32 SSE Instruction Reference


UCOMISS: Unordered Scalar Single-FP Compare and Set EFLAGS
(Continued)
Additional Itanium System Environment Exceptions

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.

Volume 3: IA-32 SSE Instruction Reference 3:925


UNPCKHPS: Unpack High Packed Single-FP Data
Opcode Instruction Description
0F,15,/r UNPCKHPS xmm1, xmm2/m128 Interleaves SP FP numbers from the high halves of XMM1
and XMM2/Mem into XMM1 register.

Operation: xmm1[31-0] = xmm1[95-64];

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.

Numeric Exceptions: None

Protected Mode 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; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

3:926 Volume 3: IA-32 SSE Instruction Reference


UNPCKHPS: Unpack High Packed Single-FP Data (Continued)
Additional Itanium System Environment Exceptions

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.

Volume 3: IA-32 SSE Instruction Reference 3:927


UNPCKLPS: Unpack Low Packed Single-FP Data
Opcode Instruction Description
0F,14,/r UNPCKLPS xmm1, xmm2/m128 Interleaves SP FP numbers from the low halves of XMM1
and XMM2/Mem into XMM1 register.

Operation: xmm1[31-0] = xmm1[31-0];

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.

Numeric Exceptions: None.

Protected Mode 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; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

3:928 Volume 3: IA-32 SSE Instruction Reference


UNPCKLPS: Unpack Low Packed Single-FP Data (Continued)
Additional Itanium System Environment Exceptions

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.

Volume 3: IA-32 SSE Instruction Reference 3:929


XORPS: Bit-wise Logical Xor for Single-FP Data
Opcode Instruction Description
0F,57,/r XORPS xmm1, xmm2/m128 XOR 128 bits from XMM2/Mem to XMM1 register.

Operation: xmm[127-0] ^= xmm/m128[127-0];

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.

Numeric Exceptions: None

Protected Mode 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; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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.

3.13 SIMD Integer Instruction Set Extensions


Additional new SIMD Integer instructions have been added to accelerate the performance of 3D
graphics, video decoding and encoding and other applications. These instructions operate on the
MMX technology registers and on 64-bit memory operands.

3:930 Volume 3: IA-32 SSE Instruction Reference


PAVGB/PAVGW: Packed Average
Opcode Instruction Description
0F,E0, /r PAVGB mm1,mm2/m64 Average with rounding packed unsigned bytes from
MM2/Mem to packed bytes in MM1 register.
0F,E3, /r PAVGW mm1, mm2/m64 Average with rounding packed unsigned words from
MM2/Mem to packed words in MM1 register.

Operation: if (instruction == PAVGB) {

x[0] = mm1[7-0] y[0] = mm2/m64[7-0];

x[1] = mm1[15-8] y[1] = mm2/m64[15-8];

x[2] = mm1[23-16] y[2] = mm2/m64[23-16];

x[3] = mm1[31-24] y[3] = mm2/m64[31-24];

x[4] = mm1[39-32] y[4] = mm2/m64[39-32];

x[5] = mm1[47-40] y[5] = mm2/m64[47-40];

x[6] = mm1[55-48] y[6] = mm2/m64[55-48];

x[7] = mm1[63-56] y[7] = mm2/m64[63-56];

for (i = 0; i < 8; i++) {

temp[i] = zero_ext(x[i], 8) + zero_ext(y[i], 8);

res[i] = (temp[i] +1) >> 1;

mm1[7-0] = res[0];

...

mm1[63-56] = res[7];

else if (instruction == PAVGW){

x[0] = mm1[15-0] y[0] = mm2/m64[15-0];

x[1] = mm1[31-16] y[1] = mm2/m64[31-16];

x[2] = mm1[47-32] y[2] = mm2/m64[47-32];

x[3] = mm1[63-48] y[3] = mm2/m64[63-48];

for (i = 0; i < 4; i++) {

Volume 3: IA-32 SSE Instruction Reference 3:931


PAVGB/PAVGW: Packed Average (Continued)
temp[i] = zero_ext(x[i], 16) + zero_ext(y[i], 16);

res[i] = (temp[i] +1) >> 1;

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.

Numeric Exceptions: None.

Protected Mode 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. #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).

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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).

Additional Itanium System Environment Exceptions

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

3:932 Volume 3: IA-32 SSE Instruction Reference


PEXTRW: Extract Word
Opcode Instruction Description
0F,C5, /r, ib PEXTRW r32, mm, imm8 Extract the word pointed to by imm8 from MM and move it to a
32-bit integer register.

Operation: sel = imm8 & 0x3;

mm_temp = (mm >> (sel * 16)) & 0xffff;

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.

Numeric Exceptions: None.

Protected Mode 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. #MF if there is a pending FPU exception.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1

Volume 3: IA-32 SSE Instruction Reference 3:933


PINSRW: Insert Word
Opcode Instruction Description
0F,C4,/r,ib PINSRW mm, r32/m16, imm8 Insert the word from the lower half of r32 or from Mem16 into
the position in MM pointed to by imm8 without touching the
other words.

Operation: sel = imm8 & 0x3;

mask = (sel == 0)? 0x000000000000ffff :

(sel == 1)? 0x00000000ffff0000 :

(sel == 2)? 0x0000ffff00000000 :

0xffff000000000000;

mm = (mm & ~mask) | ((m16/r32[15-0] << (sel * 16)) & mask);

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.

Numeric Exceptions: None.

Protected Mode 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; #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).

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

3:934 Volume 3: IA-32 SSE Instruction Reference


PMAXSW: Packed Signed Integer Word Maximum
Opcode Instruction Description
0F,EE, /r PMAXSW mm1, mm2/m64 Return the maximum words between MM2/Mem and MM1.

Operation: mm1[15-0] = (mm1[15-0] > mm2/m64[15-0]) ? mm1[15-0] : mm2/m64[15-0];

mm1[31-16] = (mm1[31-16] > mm2/m64[31-16]) ? mm1[31-16] : mm2/m64[31-16];

mm1[47-32] = (mm1[47-32] > mm2/m64[47-32]) ? mm1[47-32] : mm2/m64[47-32];

mm1[63-48] = (mm1[63-48] > mm2/m64[63-48]) ? mm1[63-48] : mm2/m64[63-48];

Description: The PMAXSW instruction returns the maximum between the four signed words in MM1 and
MM2/Mem.

Numeric Exceptions: None.

Protected Mode 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; #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).

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

Volume 3: IA-32 SSE Instruction Reference 3:935


PMAXUB: Packed Unsigned Integer Byte Maximum
Opcode Instruction Description
0F,DE, /r PMAXUB mm1, mm2/m64 Return the maximum bytes between MM2/Mem and MM1.

Operation: mm1[7-0] = (mm1[7-0] > mm2/m64[7-0]) ? mm1[7-0] : mm2/m64[7-0];

mm1[15-8] = (mm1[15-8] > mm2/m64[15-8]) ? mm1[15-8] : mm2/m64[15-8];

mm1[23-16] = (mm1[23-16] > mm2/m64[23-16]) ? mm1[23-16] : mm2/m64[23-16];

mm1[31-24] = (mm1[31-24] > mm2/m64[31-24]) ? mm1[31-24] : mm2/m64[31-24];

mm1[39-32] = (mm1[39-32] > mm2/m64[39-32]) ? mm1[39-32] : mm2/m64[39-32];

mm1[47-40] = (mm1[47-40] > mm2/m64[47-40]) ? mm1[47-40] : mm2/m64[47-40];

mm1[55-48] = (mm1[55-48] > mm2/m64[55-48]) ? mm1[55-48] : mm2/m64[55-48];

mm1[63-56] = (mm1[63-56] > mm2/m64[63-56]) ? mm1[63-56] : mm2/m64[63-56];

Description: The PMAXUB instruction returns the maximum between the eight unsigned words in MM1 and
MM2/Mem.

Numeric Exceptions: None.

Protected Mode 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; #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).

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

3:936 Volume 3: IA-32 SSE Instruction Reference


PMINSW: Packed Signed Integer Word Minimum
Opcode Instruction Description
0F,EA, /r PMINSW mm1, mm2/m64 Return the minimum words between MM2/Mem and MM1.

Operation: mm1[15-0] = (mm1[15-0] < mm2/m64[15-0]) ? mm1[15-0] : mm2/m64[15-0];

mm1[31-16] = (mm1[31-16] < mm2/m64[31-16]) ? mm1[31-16] : mm2/m64[31-16];

mm1[47-32] = (mm1[47-32] < mm2/m64[47-32]) ? mm1[47-32] : mm2/m64[47-32];

mm1[63-48] = (mm1[63-48] < mm2/m64[63-48]) ? mm1[63-48] : mm2/m64[63-48];

Description: The PMINSW instruction returns the minimum between the four signed words in MM1 and
MM2/Mem.

Numeric Exceptions: None.

Protected Mode 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; #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).

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

Volume 3: IA-32 SSE Instruction Reference 3:937


PMINUB: Packed Unsigned Integer Byte Minimum
Opcode Instruction Description
0F,DA, /r PMINUB mm1, mm2/m64 Return the minimum bytes between MM2/Mem and MM1.

Operation: mm1[7-0] = (mm1[7-0] < mm2/m64[7-0]) ? mm1[7-0] : mm2/m64[7-0];

mm1[15-8] = (mm1[15-8] < mm2/m64[15-8]) ? mm1[15-8] : mm2/m64[15-8];

mm1[23-16] = (mm1[23-16] < mm2/m64[23-16]) ? mm1[23-16] : mm2/m64[23-16];

mm1[31-24] = (mm1[31-24] < mm2/m64[31-24]) ? mm1[31-24] : mm2/m64[31-24];

mm1[39-32] = (mm1[39-32] < mm2/m64[39-32]) ? mm1[39-32] : mm2/m64[39-32];

mm1[47-40] = (mm1[47-40] < mm2/m64[47-40]) ? mm1[47-40] : mm2/m64[47-40];

mm1[55-48] = (mm1[55-48] < mm2/m64[55-48]) ? mm1[55-48] : mm2/m64[55-48];

mm1[63-56] = (mm1[63-56] < mm2/m64[63-56]) ? mm1[63-56] : mm2/m64[63-56];

Description: The PMINUB instruction returns the minimum between the eight unsigned words in MM1 and
MM2/Mem.

Numeric Exceptions: None.

Protected Mode 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; #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).

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

3:938 Volume 3: IA-32 SSE Instruction Reference


PMOVMSKB: Move Byte Mask To Integer
Opcode Instruction Description
0F,D7,/r PMOVMSKB r32, mm Move the byte mask of MM to r32.

Operation: r32[7] = mm[63]; r32[6] = mm[55];

r32[5] = mm[47]; r32[4] = mm[39];

r32[3] = mm[31]; r32[2] = mm[23];

r32[1] = mm[15]; r32[0] = mm[7];

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.

Numeric Exceptions: None.

Protected Mode 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; #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).

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1

Volume 3: IA-32 SSE Instruction Reference 3:939


PMULHUW: Packed Multiply High Unsigned
Opcode Instruction Description
0F,E4,/r PMULHUW mm1, mm2/m64 Multiply the packed unsigned words in MM1 register
with the packed unsigned words in MM2/Mem, then
store the high-order 16 bits of the results in MM1.

Operation: mm1[15-0] = (mm1[15-0] * mm2/m64[15-0])[31-16];

mm1[31-16] = (mm1[31-16] * mm2/m64[31-16])[31-16];

mm1[47-32] = (mm1[47-32] * mm2/m64[47-32])[31-16];

mm1[63-48] = (mm1[63-48] * mm2/m64[63-48])[31-16];

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.

Numeric Exceptions: None.

Protected Mode 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; #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).

Real Address Mode Exceptions

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.

Virtual 8086 Mode Exceptions

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.

Additional Itanium System Environment Exceptions

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

3:940 Volume 3: IA-32 SSE Instruction Reference


PSADBW: Packed Sum of Absolute Differences
Opcode Instruction Description
0F,F6, /r PSADBW mm1,mm2/m64 Absolute difference of packed unsigned bytes from MM2
/Mem and MM1; these differences are then summed to
produce a word result.

Operation: temp1 = ABS(mm1[7-0] - mm2/m64[7-0]);

temp2 = ABS(mm1[15-8] - mm2/m64[15-8]);

temp3 = ABS(mm1[23-16] - mm2/m64[23-16]);

temp4 = ABS(mm1[31-24] - mm2/m64[31-24]);

temp5 = ABS(mm1[39-32] - mm2/m64[39-32]);

temp6 = ABS(mm1[47-40] - mm2/m64[47-40]);

temp7 = ABS(mm1[55-48] - mm2/m64[55-48]);

temp8 = ABS(mm1[63-56] - mm2/m64[63-56]);

mm1[15:0] = temp1 + temp2 + temp3 + temp4 + temp5 + temp6 + temp7 + temp8;

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.

Numeric Exceptions: None

Protected Mode 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; #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).

Real Address Mode Exceptions

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.

Volume 3: IA-32 SSE Instruction Reference 3:941


PSADBW: Packed Sum of Absolute Differences (Continued)
Virtual 8086 Mode Exceptions

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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

3:942 Volume 3: IA-32 SSE Instruction Reference


PSHUFW: Packed Shuffle Word
Opcode Instruction Description
0F,70,/r,ib PSHUFW mm1, mm2/m64, imm8 Shuffle the words in MM2/Mem based on the
encoding in imm8 and store in MM1.

Operation: mm1[15-0] = (mm2/m64 >> (imm8[1-0] * 16) )[15-0]

mm1[31-16] = (mm2/m64 >> (imm8[3-2] * 16) )[15-0]

mm1[47-32] = (mm2/m64 >> (imm8[5-4] * 16) )[15-0]

mm1[63-48] = (mm2/m64 >> (imm8[7-6] * 16) )[15-0]

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.

Numeric Exceptions: None.

Protected Mode 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; #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).

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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

Volume 3: IA-32 SSE Instruction Reference 3:943


3.14 Cacheability Control Instructions
This section describes the cacheability control instructions which enable an application writer to
minimize data access latency and cache pollution.

3:944 Volume 3: IA-32 SSE Instruction Reference


MASKMOVQ: Byte Mask Write
Opcode Instruction Description
0F,F7,/r MASKMOVQ mm1, mm2 Move 64-bits representing integer data from MM1 register to
memory location specified by the edi register, using the byte
mask in MM2 register.

Operation: if (mm2[7]) m64[edi] = mm1[7-0];

if (mm2[15]) m64[edi+1] = mm1[15-8];

if (mm2[23]) m64[edi+2] = mm1[23-16];

if (mm2[31]) m64[edi+3] = mm1[31-24];

if (mm2[39]) m64[edi+4] = mm1[39-32];

if (mm2[47]) m64[edi+5] = mm1[47-40];

if (mm2[55]) m64[edi+6] = mm1[55-48];

if (mm2[63]) m64[edi+7] = mm1[63-56];

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.

Numeric Exceptions: None

Protected Mode 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; #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).

Volume 3: IA-32 SSE Instruction Reference 3:945


MASKMOVQ: Byte Mask Write (Continued)
Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

Itanium Reg Faults Disabled FP Register Fault if PSR.dfl is 1

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.

As a consequence of the resulting weakly-ordered memory consistency model, a fencing operation


such as SFENCE should be used if multiple processors may use different memory types to
read/write the same memory location specified by edi.

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.

3:946 Volume 3: IA-32 SSE Instruction Reference


MOVNTPS: Move Aligned Four Packed Single-FP Non-temporal
Opcode Instruction Description
0F,2B, /r MOVNTPS m128, xmm Move 128 bits representing four packed SP FP data from XMM
register to Mem, minimizing pollution in the cache hierarchy.

Operation: m128 = xmm;

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.

Numeric Exceptions: None

Protected Mode 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; #UD if CRCR4.OSFXSR(bit 9) = 0; #UD if CPUID.XMM(EDX bit
25) = 0.

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault.

Additional Itanium System Environment Exceptions

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.

Volume 3: IA-32 SSE Instruction Reference 3:947


MOVNTQ: Move 64 Bits Non-temporal
Opcode Instruction Description
0F,E7,/r MOVNTQ m64, mm Move 64 bits representing integer operands (8b, 16b, 32b) from
MM register to memory, minimizing pollution within cache
hierarchy.

Operation: m64 = mm;

Description: The linear address corresponds to the address of the least-significant byte of the referenced memory
data. This store instruction minimizes cache pollution.

Numeric Exceptions: None

Protected Mode 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; #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).

Real Address Mode Exceptions:

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.

Virtual 8086 Mode Exceptions:

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.

Additional Itanium System Environment Exceptions

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.

3:948 Volume 3: IA-32 SSE Instruction Reference


PREFETCH: Prefetch
Opcode Instruction Description
0F,18,/1 PREFETCHT0 m8 Move data specified by address closer to the processor using
the t0 hint.
0F,18,/2 PREFETCHT1 m8 Move data specified by address closer to the processor using
the t1 hint.
0F,18,/3 PREFETCHT2 m8 Move data specified by address closer to the processor using
the t2 hint.
0F,18,/0 PREFETCHNTA m8 Move data specified by address closer to the processor using
the nta hint.

Operation: fetch (m8);

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.

Numeric Exceptions: None

Protected Mode Exceptions: None

Real Address Mode Exceptions: None

Virtual 8086 Mode Exceptions: None

Additional Itanium System Environment Exceptions: None

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.

Volume 3: IA-32 SSE Instruction Reference 3:949


SFENCE: Store Fence
Opcode Instruction Description
0F AE /7 SFENCE Guarantees that every store instruction that precedes in
program order the store fence instruction is globally visible
before any store instruction which follows the fence is globally
visible.

Operation: while (!(preceding_stores_globally_visible)) wait();

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.

SFENCE uses the following ModRM encoding:

Mod (7:6) = 11B

Reg/Opcode (5:3) = 111B

R/M (2:0) = 000B

All other ModRM encodings are defined to be reserved, and use of these encodings risks
incompatibility with future processors.

Numeric Exceptions: None

Protected Mode Exceptions: None

Real Address Mode Exceptions: None

Virtual 8086 Mode Exceptions: None

Additional Itanium System Environment Exceptions: None

Comments: SFENCE ignores the value of CR4.OSFXSR. SFENCE will not generate an invalid exception if
CR4.OSFXSR = 0

3:950 Volume 3: IA-32 SSE Instruction Reference


Index
address translation 2:45, 2:58, 2:514, 2:533, 2:537,
Index

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

Intel® Itanium® Architecture Software Developer’s Manual Index-1


Index
reserved register 1:21, 1:22 branch predict instructions 1:16, 1:17, 1:72, 1:73,
reserved value 1:22 3:337
application regitser branch prediction hints 1:72, 1:172
IA-32 EFLAG register (EFLAG – AR 24) 1:26 modulo-scheduled loop support 1:70
Arctangent, FPU operation 3:519 branching 1:16, 1:24, 1:70, 1:141, 3:480, 3:550
arithmetic instructions 1:47, 3:342, 3:885 break 3:30
ARPL instruction 3:401 brl 2:557, 3:31
atomic operations 2:256 brl.call 1:29, 1:39, 1:44, 1:69, 1:70, 1:71, 2:133, 2:134,
atomicity 2:64, 2:88, 2:257 2:140, 2:141, 2:557, 3:359, 3:360, 3:364,
3:367, 3:368, 3:373, 3:378
brp 3:33
B BSF instruction 3:405
B (default size) flag, segment descriptor 3:681 BSP (bootstrap processor) 2:591
backing store pointer (BSP) 2:129, 2:133, 2:136, 2:139 BSP (Backing Store Pointer (read-only)) application
backing store 1:26, 1:27, 1:28, 1:46, 2:98, 2:99, register 1:26
2:129, 2:130, 2:595 BSPSTORE (Backing Store Pointer for Memory Stores)
backing store pointer application registers 2:136 application register 1:26
backing store switches 2:142 BSR instruction 3:407
BSPSTORE 2:139 bsw 1:50, 2:22, 2:98, 3:35, 3:333, 3:339, 3:364, 3:370,
backing store pointer application registers 2:137 3:378, 3:379
banked general registers 2:39, 2:40, 2:93, 2:232 BSWAP instruction 3:409
barrier synchronization 2:502, 2:503 BT instruction 3:410
BCD integers BTC instruction 3:412, 3:642
packed 3:457, 3:458, 3:473, 3:475 BTR instruction 3:414, 3:642
unpacked 3:391, 3:392, 3:393, 3:394 BTS instruction 3:416, 3:642
be bit 1:33 bundles 1:13, 1:33, 1:35, 1:36, 1:136, 1:137, 3:273
PSR.be 2:98, 3:364, 3:370 byte ordering 1:33
RSC.be 2:135
Biased exponent 3:846
biased exponent 3:845, 3:846, 3:847, 3:848, 3:851 C
bit field and shift instructions 1:48, 1:49 cache synchronization 2:77
boot flow 2:14, 2:591 cache write policy attribute 2:74
firmware boot flow 2:591 cacheability and coherency attribute 2:73
boot sequence 2:13, 2:591 Cacheable 2:71, 2:72, 2:73, 2:74
boot flow 2:14, 2:591 cacheable pages 2:74
bootstrap processor (BSP) 2:591 uncacheable pages 2:74
BOUND instruction 3:403 Caches, invalidating (flushing) 3:598, 3:757
BOUND range exceeded exception (#BR) 3:403 Call gate 3:616
br 3:22 CALL instruction 3:418
br.call 1:29, 1:39, 1:44, 1:69, 1:71, 2:133, 2:134, Causality 2:498
2:140, 2:141, 2:527, 2:529, 3:336, 3:359, obeying causality 2:498
3:360, 3:364, 3:367, 3:368, 3:373, 3:378 CBW instruction 3:427
br.cexit 1:39, 1:40, 1:50, 1:69, 1:70, 1:71, 1:181, CCV (Compare and Exchange Compare Value Register)
3:333, 3:335, 3:374, 3:379 application register 1:26
br.ctop 1:39, 1:40, 1:50, 1:69, 1:70, 1:71, 1:181, 1:182, CDQ instruction 3:455
1:192, 3:333, 3:335, 3:374, 3:379 CF (carry) flag, EFLAGS register 3:395, 3:397, 3:410,
br.ia 1:12, 1:107, 1:109, 2:566 3:412, 3:414, 3:416, 3:429, 3:434, 3:459,
br.ret 1:29, 1:39, 1:44, 1:69, 1:71, 2:54, 2:65, 2:98, 3:577, 3:582, 3:667, 3:698, 3:722, 3:732,
2:104, 2:131, 2:133, 2:134, 2:138, 2:139, 3:734, 3:741, 3:749
2:140, 2:141, 2:142, 2:527, 2:529, 3:334, CFLG 1:26
3:336, 3:359, 3:360, 3:364, 3:365, 3:367, CFLG (IA-32 Combined CR0 and CR4 register)
3:368, 3:370, 3:373, 3:378 application register 1:26
br.wexit 1:39, 1:40, 1:69, 1:70, 1:71, 3:333, 3:335, CFM (current frame marker) 1:21, 1:25, 1:39, 1:44,
3:374, 3:378 2:17, 2:133
br.wtop 1:39, 1:40, 1:69, 1:70, 1:71, 1:185, 1:186, character strings 1:78
3:333, 3:335, 3:374, 3:378 chk 3:36
branch instructions 1:69, 1:72, 1:141, 3:333, 3:334, chk.a 1:37, 1:60, 1:61, 1:62, 1:148, 1:149, 1:150,
3:350 1:152, 2:78, 2:100, 2:553, 3:322, 3:327, 3:373

Index-2 Intel® Itanium® Architecture Software Developer’s Manual


Index
chk.a.clr 1:62, 1:63, 1:64, 3:322, 3:327, 3:359, 3:367, context switching 1:45, 2:157, 2:530, 2:532, 2:587
3:373 address space switching 2:532
chk.a.nc 1:63, 1:64, 3:322, 3:327, 3:373 non-local control transfer 2:530
chk.s 1:37, 1:57, 1:59, 1:60, 1:139, 1:151, 1:152, performance monitor 2:157, 2:158
2:100, 2:553, 3:298, 3:300, 3:322, 3:328, RSE backing store 1:28, 2:142
3:373, 3:378 thread switch within the same address space 2:532
Classify floating-point value, FPU operation 3:563 control flow optimization 1:159
CLC instruction 3:429 control flow optimizations 1:167
CLD instruction 3:430 multiple values for one variable or register 1:169
CLI instruction 3:431 multiway branches 1:169
clr 1:73, 3:305, 3:306, 3:307, 3:308, 3:309, 3:310, parallel compares 1:167, 1:168, 1:169
3:311, 3:312, 3:314, 3:315, 3:316, 3:317, control registers
3:318, 3:322, 3:327, 3:335, 3:373, 3:374 banked general registers 2:20, 2:39, 2:40
clrrrb 1:39, 1:44, 1:50, 1:62, 1:71, 2:530, 3:38, 3:333, Control Register Instructions 2:29
3:339, 3:360, 3:368, 3:379 control registers (CR) 2:20
clrrrb.pr 1:71, 3:333, 3:339 Corrected Machine Check Vector (CMCV – CR74)
CLTS instruction 3:433 2:29
CR (control register) 2:20
CMC (corrected machine check) 2:332
Default Control Register (DCR – CR0) 2:28, 2:30
CMC instruction 3:434 End of External Interrupt (EOI – CR76) 2:29
CMCV (Corrected Machine Check Vector) control External Interrupt Control Registers 2:39
register 2:29 External Interrupt Request Register 0 (read only)
CMOVcc instructions 3:435 (IRR0 – CR68) 2:29
cmp 1:40, 1:50, 1:52, 1:57, 1:139, 1:140, 2:493, External Interrupt Request Register 1 (read only)
2:502, 3:39, 3:283, 3:284, 3:285, 3:286, (IRR1 – CR69) 2:29
3:373, 3:378, 3:439, 3:440 External Interrupt Request Register 2 (read only)
CMP instruction 3:439 (IRR2 – CR70) 2:29
cmp4 1:40, 1:50, 1:52, 1:57, 3:42, 3:283, 3:284, External Interrupt Request Register 3 (read only)
3:285, 3:286, 3:373, 3:378 (IRR3 – CR71) 2:29
CMPS instruction 3:441, 3:707 External Interrupt Vector Register (read only) (IVR –
CMPSB instruction 3:441 CR65) 2:29
CMPSD instruction 3:441 Global Control Registers 2:30
Interruption Control Registers 2:33
CMPSW instruction 3:441
Interruption Faulting Address (IFA – CR20) 2:29,
cmpxchg 1:28, 1:53, 1:55, 1:64, 1:68, 1:69, 2:78, 2:36
2:79, 2:82, 2:193, 2:484, 2:501, 2:502, 3:45, Interruption Function State (IFS – CR23) 2:29, 2:38
3:373, 3:444, 3:445, 3:446, 3:642 Interruption Hash Address (IHA – CR25) 2:29, 2:39
CMPXCHG instruction 3:444, 3:642 Interruption Immediate Register (IIM – CR24) 2:29,
CMPXCHG8B instruction 3:446 2:39
coalescing attribute 2:74 Interruption Instruction Bundle Pointer (IIP – CR19)
coalesced pages 2:75 2:35
coherency 1:129, 2:73, 2:257, 3:598, 3:757 Interruption Instruction Pointer (IIP – CR19) 2:29
compare instructions 1:15, 1:16, 1:24, 1:49, 1:50, Interruption Instruction Previous Address (IIPA –
1:186, 3:283, 3:343 CR22) 2:29, 2:37, 2:38
compare types 1:51, 1:52 Interruption Processor Status Register (IPSR –
normal compare 1:51 CR16) 2:29, 2:34
parallel compare 1:75, 1:168, 3:345 Interruption Status Register (ISR – CR17) 2:29, 2:34
unconditional compare 1:51 interruption status register fields 2:34
Compatibility Interruption TLB Insertion Register (ITIR – CR21)
2:29, 2:36
software 3:853
Interruption Vector Address (IVA – CR2) 2:28, 2:32
computational models 1:204 Interval Time Counter (ITC – AR44) 2:31
Condition code flags, EFLAGS register 3:435 Interval Timer Match Register (ITM – CR1) 2:28, 2:31
Condition code flags, FPU status word Interval Timer Vector (ITV – CR72) 2:29
setting 3:558, 3:560, 3:563 ITIR fields 2:36, 2:37
Conditional jump 3:609 Local Interrupt ID (LID – CR64) 2:29
Conforming code segment 3:616, 3:622 Local Redirection Register 0 (LRR0 – CR80) 2:29
constant register 2:523 Local Redirection Register 1 (LRR1 – CR81) 2:29
Constants (floating point) Page Table Address (PTA – CR8) 2:28, 2:33
loading 3:509 Performance Monitoring Vector (PMV – CR73) 2:29
Task Priority Register (TPR – CR66) 2:29

Intel® Itanium® Architecture Software Developer’s Manual Index-3


Index
control registers (CR) 3:905, 3:907, 3:908, 3:909, 3:910, 3:911,
banked general registers 2:93 3:913, 3:915, 3:916, 3:918, 3:919, 3:920,
external interrupt control registers 2:117, 2:232, 3:921, 3:922, 3:923, 3:925, 3:927, 3:929,
2:577 3:930, 3:932, 3:934, 3:935, 3:936, 3:937,
Control registers, moving values to and from 3:658 3:938, 3:940, 3:942, 3:943, 3:947, 3:948
control speculative 1:14, 2:523, 2:553 data breakpoint register matching 2:265
corrected machine check 2:121, 2:601 DBR.addr 2:265, 2:266
corrected machine check (CMC) 2:332 DBR.mask 2:266
Cosine, FPU operation 3:488, 3:539 trap code B bits 2:266
cover 1:39, 1:44, 1:46, 1:50, 1:71, 2:99, 2:133, 2:134, data breakpoint registers (DBR) 2:145, 2:146
2:137, 2:138, 2:139, 2:141, 3:47, 3:333, data debug 2:64, 2:102, 2:103
3:339, 3:359, 3:360, 3:361, 3:365, 3:367, data dependencies 1:59, 1:144, 1:145, 1:146, 2:17,
3:368, 3:373, 3:378, 3:379 2:486, 2:491
CPI (cycles per instructions) 2:587 data dependency 1:15, 1:16, 1:145, 1:146, 2:17, 2:490,
CPL (Current Privilege Level) 2:17, 3:431, 3:754 2:491, 2:492
CPUID instruction 3:448 data key miss fault 2:140, 2:161, 3:399, 3:401, 3:403,
CPUID registers 1:31, 1:32 3:405, 3:407, 3:411, 3:412, 3:414, 3:416,
3:425, 3:437, 3:439, 3:442, 3:445, 3:446,
CR0 control register 3:640, 3:739
3:459, 3:462, 3:465, 3:471, 3:473, 3:476,
cross-modifying code 2:508 3:483, 3:493, 3:496, 3:499, 3:500, 3:505,
CS register 3:419, 3:587, 3:601, 3:613, 3:654, 3:681 3:507, 3:511, 3:513, 3:517, 3:531, 3:533,
CSD (IA-32 Code Segment Descriptor / Compare and 3:544, 3:546, 3:549, 3:550, 3:554, 3:557,
Store Data register) application register 1:26 3:575, 3:579, 3:581, 3:582, 3:585, 3:607,
current frame marker (CFM) 1:21, 1:25, 1:39, 1:44, 3:617, 3:623, 3:626, 3:630, 3:642, 3:645,
2:17, 2:133 3:650, 3:656, 3:663, 3:664, 3:665, 3:667,
size of frame (sof) 1:44 3:669, 3:672, 3:674, 3:677, 3:680, 3:683,
size of locals (sol) 1:44 3:686, 3:689, 3:691, 3:694, 3:696, 3:699,
Current Privilege Level (CPL) 2:17 3:709, 3:714, 3:720, 3:723, 3:725, 3:727,
CWD instruction 3:455 3:733, 3:735, 3:747, 3:749, 3:751, 3:755,
CWDE instruction 3:427 3:761, 3:763, 3:765, 3:767, 3:772, 3:773,
cycles per instructions (CPI) 2:587 3:776, 3:778, 3:781, 3:784, 3:787, 3:789,
3:791, 3:794, 3:797, 3:799, 3:801, 3:803,
czx 3:48
3:805, 3:808, 3:811, 3:814, 3:817, 3:820,
3:823, 3:826, 3:829, 3:831, 3:855, 3:856,
D 3:857, 3:858, 3:860, 3:863, 3:866, 3:867,
3:869, 3:871, 3:872, 3:873, 3:875, 3:876,
DAA instruction 3:457 3:877, 3:880, 3:884, 3:886, 3:888, 3:890,
DAS instruction 3:458 3:892, 3:894, 3:896, 3:899, 3:902, 3:905,
data access bit 2:64, 2:67, 2:102, 2:103, 3:399, 3:401, 3:907, 3:908, 3:909, 3:910, 3:911, 3:913,
3:403, 3:405, 3:407, 3:411, 3:412, 3:414, 3:915, 3:916, 3:918, 3:919, 3:920, 3:921,
3:416, 3:425, 3:437, 3:439, 3:442, 3:445, 3:922, 3:923, 3:925, 3:927, 3:929, 3:930,
3:446, 3:459, 3:462, 3:465, 3:471, 3:473, 3:932, 3:934, 3:935, 3:936, 3:937, 3:938,
3:476, 3:483, 3:493, 3:496, 3:499, 3:500, 3:940, 3:942, 3:943, 3:947, 3:948
3:505, 3:507, 3:511, 3:513, 3:517, 3:531, data key permission 2:64, 2:67, 2:102, 2:103, 3:399,
3:533, 3:544, 3:546, 3:549, 3:550, 3:554, 3:401, 3:403, 3:405, 3:407, 3:411, 3:412,
3:557, 3:575, 3:579, 3:581, 3:582, 3:585, 3:414, 3:416, 3:425, 3:437, 3:439, 3:442,
3:607, 3:617, 3:623, 3:626, 3:630, 3:642, 3:445, 3:446, 3:459, 3:462, 3:465, 3:471,
3:645, 3:650, 3:656, 3:663, 3:664, 3:665, 3:473, 3:476, 3:483, 3:493, 3:496, 3:499,
3:667, 3:669, 3:672, 3:674, 3:677, 3:680, 3:500, 3:505, 3:507, 3:511, 3:513, 3:517,
3:683, 3:686, 3:689, 3:691, 3:694, 3:696, 3:531, 3:533, 3:544, 3:546, 3:549, 3:550,
3:699, 3:709, 3:714, 3:720, 3:723, 3:725, 3:554, 3:557, 3:575, 3:579, 3:581, 3:582,
3:727, 3:733, 3:735, 3:747, 3:749, 3:751, 3:585, 3:607, 3:617, 3:623, 3:626, 3:630,
3:755, 3:761, 3:763, 3:765, 3:767, 3:772, 3:642, 3:645, 3:650, 3:656, 3:663, 3:664,
3:773, 3:776, 3:778, 3:781, 3:784, 3:787, 3:665, 3:667, 3:669, 3:672, 3:674, 3:677,
3:789, 3:791, 3:794, 3:797, 3:799, 3:801, 3:680, 3:683, 3:686, 3:689, 3:691, 3:694,
3:803, 3:805, 3:808, 3:811, 3:814, 3:817, 3:696, 3:699, 3:709, 3:714, 3:720, 3:723,
3:820, 3:823, 3:826, 3:829, 3:831, 3:855, 3:725, 3:727, 3:733, 3:735, 3:747, 3:749,
3:856, 3:857, 3:858, 3:860, 3:863, 3:866, 3:751, 3:755, 3:761, 3:763, 3:765, 3:767,
3:867, 3:869, 3:871, 3:872, 3:873, 3:875, 3:772, 3:773, 3:776, 3:778, 3:781, 3:784,
3:876, 3:877, 3:880, 3:884, 3:886, 3:888, 3:787, 3:789, 3:791, 3:794, 3:797, 3:799,
3:890, 3:892, 3:894, 3:896, 3:899, 3:902, 3:801, 3:803, 3:805, 3:808, 3:811, 3:814,

Index-4 Intel® Itanium® Architecture Software Developer’s Manual


Index
3:817, 3:820, 3:823, 3:826, 3:829, 3:831, 3:866, 3:867, 3:869, 3:871, 3:872, 3:873,
3:855, 3:856, 3:857, 3:858, 3:860, 3:863, 3:875, 3:876, 3:877, 3:880, 3:884, 3:886,
3:866, 3:867, 3:869, 3:871, 3:872, 3:873, 3:888, 3:890, 3:892, 3:894, 3:896, 3:899,
3:875, 3:876, 3:877, 3:880, 3:884, 3:886, 3:902, 3:905, 3:907, 3:908, 3:909, 3:910,
3:888, 3:890, 3:892, 3:894, 3:896, 3:899, 3:911, 3:913, 3:915, 3:916, 3:918, 3:919,
3:902, 3:905, 3:907, 3:908, 3:909, 3:910, 3:920, 3:921, 3:922, 3:923, 3:925, 3:927,
3:911, 3:913, 3:915, 3:916, 3:918, 3:919, 3:929, 3:930, 3:932, 3:934, 3:935, 3:936,
3:920, 3:921, 3:922, 3:923, 3:925, 3:927, 3:937, 3:938, 3:940, 3:942, 3:943, 3:947,
3:929, 3:930, 3:932, 3:934, 3:935, 3:936, 3:948
3:937, 3:938, 3:940, 3:942, 3:943, 3:947, data prefetch
3:948 load instructions 1:54
data NaT page consumption 2:64, 2:67, 2:81, 2:102, semaphore instructions 1:55, 3:320
2:103, 3:399, 3:401, 3:403, 3:405, 3:407, store instructions 1:55, 3:304, 3:318, 3:320, 3:321,
3:411, 3:412, 3:414, 3:416, 3:425, 3:437, 3:946
3:439, 3:442, 3:445, 3:446, 3:459, 3:462, data serialization 2:18, 2:19, 3:357
3:465, 3:471, 3:473, 3:476, 3:483, 3:493, data speculative 1:15, 1:59, 1:150, 2:523
3:496, 3:499, 3:500, 3:505, 3:507, 3:511, data TLB miss faults 2:65, 2:67
3:513, 3:517, 3:531, 3:533, 3:544, 3:546,
DBR (data breakpoint registers) 2:145, 2:146
3:549, 3:550, 3:554, 3:557, 3:575, 3:579,
3:581, 3:582, 3:585, 3:607, 3:617, 3:623, DCR (Default Control Register) control register 2:28,
3:626, 3:630, 3:642, 3:645, 3:650, 3:656, 2:30
3:663, 3:664, 3:665, 3:667, 3:669, 3:672, Debug 1:61, 2:191, 3:420, 3:421, 3:422, 3:425, 3:581,
3:674, 3:677, 3:680, 3:683, 3:686, 3:689, 3:585, 3:587, 3:611, 3:615, 3:616, 3:617,
3:691, 3:694, 3:696, 3:699, 3:709, 3:714, 3:619, 3:620, 3:647, 3:660, 3:661, 3:677,
3:720, 3:723, 3:725, 3:727, 3:733, 3:735, 3:680, 3:711, 3:712, 3:714
3:747, 3:749, 3:751, 3:755, 3:761, 3:763, break instruction fault 2:145, 2:161, 2:177
3:765, 3:767, 3:772, 3:773, 3:776, 3:778, data debug fault 2:106, 2:140, 2:146, 2:161, 2:191
3:781, 3:784, 3:787, 3:789, 3:791, 3:794, debug breakpoint registers (DBR/IBR) 2:20
3:797, 3:799, 3:801, 3:803, 3:805, 3:808, debug instructions 2:147
3:811, 3:814, 3:817, 3:820, 3:823, 3:826, debug model 2:265
3:829, 3:831, 3:855, 3:856, 3:857, 3:858, debugging 2:145, 2:570, 3:619
3:860, 3:863, 3:866, 3:867, 3:869, 3:871, debugging facilities 2:145
3:872, 3:873, 3:875, 3:876, 3:877, 3:880, instruction breakpoints 2:570
3:884, 3:886, 3:888, 3:890, 3:892, 3:894, instruction debug fault 2:145, 2:161, 2:191, 2:265
3:896, 3:899, 3:902, 3:905, 3:907, 3:908, lower privilege transfer trap 2:145, 2:196, 2:265
3:909, 3:910, 3:911, 3:913, 3:915, 3:916, single step trap 2:96, 2:106, 2:109, 2:145, 2:162,
3:918, 3:919, 3:920, 3:921, 3:922, 3:923, 2:163, 2:199, 2:265, 2:571
3:925, 3:927, 3:929, 3:930, 3:932, 3:934, taken branch trap 2:96, 2:106, 2:109, 2:145, 2:163,
3:935, 3:936, 3:937, 3:938, 3:940, 3:942, 2:198, 2:265, 2:571, 3:620
3:943, 3:947, 3:948 Debug registers, moving value to and from 3:660
data nested TLB faults 2:67, 2:522 DEC instruction 3:459, 3:642
data page not present 2:64, 2:67, 2:101, 2:103, 3:399, Dekker’s algorithm 2:504
3:401, 3:403, 3:405, 3:407, 3:411, 3:412, Denormalization process 3:848
3:414, 3:416, 3:425, 3:437, 3:439, 3:442, Denormalized finite number 3:563, 3:847, 3:850
3:445, 3:446, 3:459, 3:462, 3:465, 3:471, denormalized numbers 3:844, 3:847, 3:848
3:473, 3:476, 3:483, 3:493, 3:496, 3:499, dep 3:50
3:500, 3:505, 3:507, 3:511, 3:513, 3:517, Dependencies 1:37, 1:38, 1:39, 1:40, 1:147, 3:355,
3:531, 3:533, 3:544, 3:546, 3:549, 3:550, 3:356
3:554, 3:557, 3:575, 3:579, 3:581, 3:582,
dependency violation 1:38, 1:40, 1:41, 2:556
3:585, 3:607, 3:617, 3:623, 3:626, 3:630,
instruction execution 3:573, 3:598, 3:703, 3:757
3:642, 3:645, 3:650, 3:656, 3:663, 3:664,
instruction group 1:37, 1:38, 1:39, 1:40, 1:41, 1:69
3:665, 3:667, 3:669, 3:672, 3:674, 3:677,
register dependencies 1:37, 1:39, 1:40, 1:41
3:680, 3:683, 3:686, 3:689, 3:691, 3:694,
WAR dependency 1:40, 3:371
3:696, 3:699, 3:709, 3:714, 3:720, 3:723,
3:725, 3:727, 3:733, 3:735, 3:747, 3:749, DF (direction) flag, EFLAGS register 3:430, 3:441,
3:751, 3:755, 3:761, 3:763, 3:765, 3:767, 3:584, 3:644, 3:662, 3:678, 3:724, 3:742
3:772, 3:773, 3:776, 3:778, 3:781, 3:784, DIV instruction 3:461
3:787, 3:789, 3:791, 3:794, 3:797, 3:799, Divide error exception (#DE) 3:461
3:801, 3:803, 3:805, 3:808, 3:811, 3:814, division operations
3:817, 3:820, 3:823, 3:826, 3:829, 3:831, double precision – divide 1:203
3:855, 3:856, 3:857, 3:858, 3:860, 3:863, double precision – square root 1:203

Intel® Itanium® Architecture Software Developer’s Manual Index-5


Index
DMA 1:19, 2:511 extensible firmware interface (EFI) 2:271
edge sensitive interrupt messages 2:127 External Controller Interrupts (ExtINT) 2:92
Double-extended-precision, IEEE floating-point format external interrupt (INT) 2:104, 2:114
3:850 control register usage examples 2:577
Double-precision, IEEE floating-point format 3:850 external (I/O) devices 2:111
Double-real floating-point format 3:850 external interrupt (INT)
DS register 3:441, 3:625, 3:644, 3:678 external interrupt architecture 2:573
external interrupt delivery 2:93, 2:114, 2:116, 2:117,
2:118, 2:575
E external interrupt masking 2:115, 2:574
EC (Epilog Count Register) application register 1:26 external interrupt sampling 2:116
Edge- and Level-sensitive Interrupts 2:127 external interrupt states 2:113
inactive 2:575
EDI register 3:662, 3:724, 3:742, 3:746
in-service/none pending 2:576
Effective address 3:628 in-service/one pending 2:576
EFI (extensible firmware interface) 2:559, 2:591, 2:592, internal processor interrupts 2:111
2:593, 2:596, 2:598, 2:599 interrupt acknowledge (INTA) cycle 2:127
boot services 2:593, 2:598 interrupt enabling 2:115
EFI boot manager 2:593 interrupt masking 2:115
EFI procedure calls 2:598 interrupt priorities 2:114, 2:573
EFI system partition 2:592, 2:593 interrupt registers 2:20
runtime services 2:598, 2:599 interrupt sources 2:111, 2:117, 2:127, 2:574
EFLAG (IA-32 EFLAG register) application register 1:26 interrupt vectors 2:114, 2:115, 2:117, 2:573, 3:587
EFLAGS register locally connected devices 2:111
condition codes 3:436, 3:480, 3:485 pending 2:94, 2:111, 2:112, 2:115, 2:575, 3:479,
flags affected by instructions 3:388 3:503, 3:511, 3:532, 3:546, 3:548, 3:550,
loading 3:621 3:619, 3:620, 3:708, 3:744, 3:756, 3:770,
popping 3:687 3:772, 3:774, 3:776, 3:777, 3:779, 3:782,
popping on return from interrupt 3:601 3:784, 3:785, 3:787, 3:788, 3:790, 3:792,
pushing 3:695 3:794, 3:795, 3:798, 3:800, 3:802, 3:804,
pushing on interrupts 3:587 3:806, 3:808, 3:809, 3:811, 3:812, 3:814,
saving 3:717 3:815, 3:818, 3:820, 3:821, 3:823, 3:824,
status flags 3:439, 3:610, 3:726, 3:751 3:826, 3:827, 3:829, 3:830, 3:832, 3:867,
EIP register 3:418, 3:587, 3:601, 3:613 3:868, 3:869, 3:870, 3:873, 3:874, 3:879,
ENTER instruction 3:464 3:881, 3:884, 3:903, 3:932, 3:933, 3:934,
EOI (End of External Interrupt) control register 2:29 3:935, 3:936, 3:937, 3:938, 3:939, 3:940,
3:941, 3:943, 3:945, 3:946, 3:948
epc 3:52
external interrupt control registers 2:39, 2:117, 2:232,
ES register 3:441, 3:584, 3:625, 3:678, 3:724, 3:746
2:574, 2:577
ESI register 3:644, 3:662, 3:678, 3:742
Local ID (LID – CR64) 2:117
ESP register 3:418, 3:682, 3:690
external task priority (XTP) 2:123, 2:127
exception deferral 1:58, 2:52, 2:102, 2:103
XTP cycle 2:127
combined hardware/software deferral 2:551, 2:552 XTP register 2:575
exception deferral of control speculative loads 2:551
ExtINT (External Controller Interrupts) 2:92
hardware-only deferral 2:551, 2:552
software-only deferral 2:551, 2:552 extr 3:53
exception indicator 2:81 Extract exponent and significand, FPU operation 3:567
exception qualification 2:101
Exceptions F
BOUND range exceeded (#BR) 3:403 F2XM1 instruction 3:467, 3:567
overflow exception (#OF) 3:587
fabs 3:54
returning from 3:601
FABS instruction 3:469
execution unit type 1:26, 1:34, 1:35, 3:273
fadd 3:55
Exponent
FADD instruction 3:470
extracting from floating-point number 3:567
floating-point number 3:845 FADDP instruction 3:470
extended instructions 1:36, 3:273 famax 3:56
Extended real famin 3:57
floating-point format 3:850 fand 3:58
extensible firmware interface 2:559, 2:591 fandcm 3:59
Far call

Index-6 Intel® Itanium® Architecture Software Developer’s Manual


Index
CALL instruction 3:418 fault suppression 2:100
Far pointer FBLD instruction 3:473
loading 3:625 FBSTP instruction 3:475
Far return fc 3:60
RET instruction 3:710 fchkf 3:61
fault 1:99, 2:30, 2:93, 2:94, 2:97, 2:98, 2:105, 2:106, FCHS instruction 3:478
2:107, 2:108, 2:140, 2:513, 2:557, 3:273, fclass 1:40, 1:50, 1:52, 1:57, 1:96, 1:206, 3:62, 3:343,
3:374, 3:378, 3:399, 3:400, 3:401, 3:402, 3:344, 3:373, 3:378
3:403, 3:404, 3:405, 3:406, 3:407, 3:408, FCLEX/FNCLEX instructions 3:479
3:411, 3:412, 3:413, 3:414, 3:415, 3:416, fclrf 3:64
3:417, 3:425, 3:426, 3:433, 3:437, 3:438, FCMOVcc instructions 3:480
3:439, 3:440, 3:442, 3:443, 3:445, 3:446,
fcmp 1:40, 1:50, 1:52, 1:57, 1:95, 3:65, 3:343, 3:344,
3:447, 3:459, 3:460, 3:462, 3:463, 3:465,
3:359, 3:373, 3:378
3:466, 3:467, 3:469, 3:471, 3:472, 3:473,
3:474, 3:476, 3:477, 3:478, 3:479, 3:480, FCOM instruction 3:482
3:483, 3:484, 3:486, 3:489, 3:490, 3:493, FCOMI instruction 3:485
3:496, 3:497, 3:499, 3:500, 3:501, 3:502, FCOMIP instruction 3:485
3:503, 3:505, 3:506, 3:507, 3:508, 3:509, FCOMP instruction 3:482
3:511, 3:512, 3:513, 3:514, 3:516, 3:517, FCOMPP instruction 3:482
3:518, 3:519, 3:522, 3:525, 3:528, 3:529, FCOS instruction 3:488
3:531, 3:533, 3:534, 3:536, 3:538, 3:540, FCR (IA-32 Floating-point Control Register) application
3:542, 3:544, 3:545, 3:546, 3:547, 3:549, register 1:26
3:550, 3:551, 3:553, 3:554, 3:556, 3:557, fcvt.fx 3:68
3:558, 3:561, 3:563, 3:565, 3:567, 3:570, fcvt.xf 3:70
3:572, 3:575, 3:576, 3:579, 3:581, 3:582,
fcvt.xuf 3:71
3:583, 3:585, 3:586, 3:590, 3:596, 3:597,
3:598, 3:607, 3:608, 3:617, 3:618, 3:619, FDECSTP instruction 3:490
3:620, 3:623, 3:624, 3:626, 3:627, 3:630, FDIV instruction 3:491
3:635, 3:638, 3:640, 3:641, 3:642, 3:645, FDIVP instruction 3:491
3:650, 3:653, 3:656, 3:657, 3:663, 3:664, FDIVR instruction 3:494
3:665, 3:666, 3:667, 3:668, 3:669, 3:670, FDIVRP instruction 3:494
3:672, 3:673, 3:674, 3:675, 3:677, 3:680, FDR (IA-32 Floating-point Data Register) application
3:681, 3:683, 3:684, 3:686, 3:689, 3:691, register 1:26
3:692, 3:694, 3:696, 3:699, 3:700, 3:708, Feature information, processor 3:448
3:709, 3:714, 3:720, 3:721, 3:723, 3:725, Fence 1:68, 2:78, 2:79, 3:452, 3:454, 3:581, 3:585,
3:727, 3:728, 3:730, 3:733, 3:735, 3:737, 3:601, 3:619, 3:677, 3:679, 3:950
3:739, 3:740, 3:747, 3:748, 3:749, 3:750, operations 1:68, 2:78, 2:79, 3:430, 3:441, 3:480,
3:751, 3:752, 3:755, 3:761, 3:762, 3:763, 3:494, 3:555, 3:567, 3:580, 3:584, 3:589,
3:764, 3:765, 3:766, 3:767, 3:768, 3:770, 3:644, 3:662, 3:676, 3:678, 3:708,
3:772, 3:773, 3:774, 3:776, 3:777, 3:778, 3:724, 3:742, 3:746, 3:757, 3:890, 3:894
3:779, 3:781, 3:782, 3:784, 3:785, 3:787, semantics 1:68, 2:78, 2:79, 2:257, 2:258, 3:945
3:788, 3:789, 3:790, 3:791, 3:792, 3:794,
fetchadd 1:53, 1:55, 1:64, 1:68, 1:69, 2:78, 2:79, 2:82,
3:795, 3:797, 3:798, 3:799, 3:800, 3:801,
2:193, 2:484, 2:485, 2:502, 2:503, 3:72,
3:802, 3:803, 3:804, 3:805, 3:806, 3:808,
3:373
3:809, 3:811, 3:812, 3:814, 3:815, 3:817,
3:818, 3:820, 3:821, 3:823, 3:824, 3:826, FFREE instruction 3:497
3:827, 3:829, 3:830, 3:831, 3:832, 3:855, FIADD instruction 3:470
3:856, 3:857, 3:858, 3:859, 3:860, 3:862, FICOM instruction 3:498
3:863, 3:865, 3:866, 3:867, 3:868, 3:869, FICOMP instruction 3:498
3:870, 3:871, 3:872, 3:873, 3:874, 3:875, FIDIV instruction 3:491
3:876, 3:877, 3:879, 3:880, 3:883, 3:884, FIDIVR instruction 3:494
3:886, 3:887, 3:888, 3:889, 3:890, 3:891, FILD instruction 3:500
3:892, 3:893, 3:894, 3:896, 3:897, 3:898, FIMUL instruction 3:515
3:899, 3:900, 3:901, 3:902, 3:903, 3:905, FINCSTP instruction 3:502
3:907, 3:908, 3:909, 3:910, 3:911, 3:913,
FINIT/FNINIT instructions 3:503, 3:532
3:915, 3:916, 3:918, 3:919, 3:920, 3:921,
3:922, 3:923, 3:924, 3:925, 3:926, 3:927, FIR (IA-32 Floating-point Instruction Register)
3:928, 3:929, 3:930, 3:932, 3:933, 3:934, application register 1:26
3:935, 3:936, 3:937, 3:938, 3:939, 3:940, firmware address space 2:276
3:941, 3:942, 3:943, 3:945, 3:946, 3:947, firmware entrypoint 2:332
3:948 firmware entrypoints 2:275

Intel® Itanium® Architecture Software Developer’s Manual Index-7


Index
firmware interface table (FIT) 2:280 floating-point system software
firmware model 2:592 floating-point exception handling 2:559, 2:561
firmware procedure 2:333 Flushing
FIST instruction 3:504 caches 3:598, 3:757
FISTP instruction 3:504 TLB entry 3:600
FISUB instruction 3:552 flushrs 1:39, 1:46, 1:50, 2:65, 2:131, 2:133, 2:134,
FISUBR instruction 3:555 2:137, 2:138, 2:139, 2:140, 2:141, 2:142,
FIT (firmware interface table) 2:280 3:74, 3:323, 3:328, 3:359, 3:360, 3:366,
FLD instruction 3:507 3:367, 3:368, 3:378, 3:379
FLD1 instruction 3:509 fma 3:75
FLDCW instruction 3:511 fmax 3:76
FLDENV instruction 3:513 fmerge 3:77
FLDL2E instruction 3:509 fmin 3:79
FLDL2T instruction 3:509 fmix 3:80
FLDLG2 instruction 3:509 fmpy 3:82
FLDLN2 instruction 3:509 fms 3:83
FLDPI instruction 3:509 FMUL instruction 3:515
FLDZ instruction 3:509 FMULP instruction 3:515
floating-point applications 1:197 fneg 3:84
execution bandwidth 1:198 fnegabs 3:85
execution latency 1:197 fnma 3:86
memory bandwidth 1:199 fnmpy 3:87
memory latency 1:198 FNOP instruction 3:518
performance limiters 1:197 fnorm 3:88
floating-point architecture 1:13, 1:17, 1:81 FNSTENV instruction 3:513
Floating-point format for 3:89
biased exponent 3:846 FP precision 1:201
exponent 3:845 FP subfield handling 1:207
fraction 3:845 fpabs 3:90
real number system 3:844 fpack 3:91
sign 3:845 fpamax 3:92
significand 3:845
fpamin 3:94
floating-point format 3:844, 3:845, 3:846, 3:848
FPATAN instruction 3:519
floating-point instructions 1:29, 1:40, 1:87, 3:339,
fpcmp 3:96
3:341, 3:388, 3:511, 3:513, 3:532, 3:548,
3:565, 3:770 fpcvt.fx 3:98
arithmetic instructions 1:94, 3:342, 3:885 fpma 3:100
integer multiply and add instructions 1:97, 1:98 fpmax 3:102
memory access instructions 1:87 fpmerge 3:103
non-arithmetic instructions 1:96 fpmin 3:105
register to/from general register transfer instructions fpmpy 3:106
1:93 fpms 3:107
floating-point programming model 1:81 fpneg 3:109
data types and formats 1:81 fpnegabs 3:110
floating-point register encodings 1:82, 1:83 fpnma 3:111
floating-point register format 1:81, 1:82 fpnmpy 3:113
floating-point status register 1:26, 1:29, 1:84, 1:85, fprcpa 3:114
1:97
FPREM instruction 3:521
real types 1:81
FPREM1 instruction 3:524
floating-point register (FR)
fprsqrta 3:116
high FP reg fault 3:382
low FP reg fault 3:381 FPSR (Floating-point Status Register) application
register 1:26
floating-point register set 1:199
FPTAN instruction 3:527
floating-point software assistance (FP SWA) 2:559
FPU
SWA faults 2:559, 2:560, 2:562
SWA traps 2:559, 2:560, 2:561 checking for pending FPU exceptions 3:756
constants 3:509
floating-point status register (FPSR) 1:29, 1:40, 1:84,
floating-point format 3:844, 3:845
1:97, 2:559
initialization 3:503

Index-8 Intel® Itanium® Architecture Software Developer’s Manual


Index
FPU control word FXAM instruction 3:563
loading 3:511, 3:513 FXCH instruction 3:565
RC field 3:504, 3:509, 3:543 fxor 3:131
restoring 3:530 FXTRACT instruction 3:535, 3:567
saving 3:532, 3:548 FYL2X instruction 3:569
storing 3:546 FYL2XP1 instruction 3:571
FPU data pointer 3:513, 3:530, 3:532, 3:548
FPU instruction pointer 3:513, 3:530, 3:532, 3:548
FPU last opcode 3:513, 3:530, 3:532, 3:548 G
FPU status word gate interception 2:231
condition code flags 3:482, 3:498, 3:558, 3:560, GDT (global descriptor table) 3:634, 3:637
3:563 GDTR (global descriptor table register) 3:634, 3:729
FPU flags affected by instructions 3:388 general register (GR)
loading 3:513 NaT bit 1:23, 1:138, 1:150, 1:151
restoring 3:530
General-purpose registers
saving 3:532, 3:548, 3:550
TOP field 3:502 moving value to and from 3:654
popping all 3:685
FPU tag word 3:513, 3:530, 3:532, 3:548
pushing all 3:693
FPSR (Floating-point Status Register) 1:26, 1:29
getf 3:132
FR (floating-point register) 3:381, 3:382
global TLB purge operations 2:77, 2:78
Fraction, floating-point number 3:845
GS register 3:625
frcpa 1:40, 1:50, 1:51, 1:52, 1:57, 1:95, 1:202, 1:203,
1:204, 2:562, 3:118, 3:341, 3:344, 3:373,
3:378 H
FRNDINT instruction 3:529 hardware debugger 2:148
frsqrta 1:40, 1:50, 1:51, 1:52, 1:57, 1:95, 1:202, hint 3:134
1:203, 2:562, 3:121, 3:341, 3:345, 3:373,
HLT instruction 3:573
3:378
FRSTOR instruction 3:530
FS register 3:625 I
FSAVE/FNSAVE instructions 3:530, 3:532 i bit
FSCALE instruction 3:535 PSR.i 2:94, 2:114, 2:116, 2:117, 2:118, 2:235,
fselect 3:123 2:515, 2:518, 2:574, 3:365, 3:370, 3:431,
fsetc 3:124 3:743
FSIN instruction 3:537 I/O port space 2:260, 2:261, 2:262, 2:583, 2:584,
FSINCOS instruction 3:539 2:585, 3:580, 3:584, 3:676, 3:679
FSQRT instruction 3:541 I/O port space model 2:260
FSR (IA-32 Floating-point Status Register) application physical I/O port addressing 2:262
register 1:26 virtual I/O port addressing 2:261
FST instruction 3:543 IA-32 application execution model 1:107
FSTCW/FNSTCW instructions 3:546 IA-32 instruction set execution 1:24, 1:25, 1:43,
FSTENV/FNSTENV instructions 3:548 1:61, 1:108, 2:258
FSTP instruction 3:543 IA-32 operating mode transitions 1:110
FSTSW/FNSTSW instructions 3:550 instruction set execution in the Itanium architecture
fsub 3:125 1:108
instruction set modes 1:107
FSUB instruction 3:552
instruction set transitions 1:109, 2:231, 2:259
FSUBP instruction 3:552
IA-32 application register state model 1:111
FSUBR instruction 3:555
IA-32 application EFLAG register 1:120
FSUBRP instruction 3:555 IA-32 floating-point registers 1:122
fswap 3:126 IA-32 general purpose registers 1:111, 1:112, 1:114
fsxt 3:128 IA-32 instruction pointer 1:115
FTST instruction 3:558 IA-32 MMX technology registers 1:126
FUCOM instruction 3:560 IA-32 segment registers 1:115
FUCOMI instruction 3:485 IA-32 streaming SIMD extension registers 1:113,
FUCOMIP instruction 3:485 1:127
FUCOMP instruction 3:560 IA-32 application support 2:269
FUCOMPP instruction 3:560 procedure calls between Itanium and IA-32
fwb 3:130 instruction sets 2:567

Intel® Itanium® Architecture Software Developer’s Manual Index-9


Index
transitioning between Itanium and IA-32 instruction IA-32 virtual memory support 2:231
sets 2:566 ic bit
IA-32 architecture 1:5, 1:19, 2:5, 3:5, 3:381 PSR.ic 2:94, 2:97, 2:98, 2:100, 2:101, 2:102, 2:103,
IA-32 architecture handlers 2:568 2:114, 2:116, 2:138, 2:160, 2:515, 2:538,
IA-32 vectors that need Itanium-based OS support 2:539, 3:365, 3:370
2:569 IDIV instruction 3:574
shared Itanium/IA-32 exception vectors 2:569 IDT (interrupt descriptor table) 3:587, 3:634
unique IA-32 exception vectors 2:569 IDTR (interrupt descriptor table register) 3:634, 3:729
unique Itanium exception vectors 2:569 IEEE considerations 1:98
IA-32 compatible bus transactions 2:270 additions beyond the IEEE standard 1:104
IA-32 current privilege level 2:234 arithmetic operations 1:104, 3:848
IA-32 fault and trap handling 2:231 floating-point interruptions 1:98
IA-32 faults 3:381 inexact 1:101, 1:103, 2:561, 2:564, 3:467, 3:471,
IA-32 floating-point exceptions 2:564 3:476, 3:489, 3:492, 3:495, 3:505, 3:509,
IA-32 GPFault 3:381 3:516, 3:519, 3:521, 3:524, 3:528, 3:529,
IA-32 I/O instructions 2:263 3:536, 3:538, 3:540, 3:541, 3:544, 3:553,
IA-32 instruction behavior 2:231, 2:246 3:556, 3:569, 3:572, 3:867, 3:869, 3:871,
3:872, 3:873, 3:875
IA-32 instruction format 3:382
integer invalid operations 1:104
IA-32 instruction summary 2:246 mandated operations deferred to software 1:104
IA-32 interruption 2:107, 2:267 NaNs 1:83, 1:104, 3:475, 3:519, 3:521, 3:524,
IA-32 interruption priorities and classes 2:107 3:553, 3:556, 3:569, 3:571, 3:844, 3:846,
IA-32 interruption vector 2:205, 2:267 3:847, 3:848, 3:849, 3:851
IA-32 memory ordering 2:257, 2:500 overflow 1:101, 1:102, 2:560, 2:563, 3:436, 3:461,
IA-32 MMX technology instructions 1:127, 3:769 3:467, 3:470, 3:473, 3:488, 3:491, 3:494,
IA-32 numeric exception model 2:269 3:500, 3:507, 3:509, 3:515, 3:528, 3:535,
IA-32 physical memory references 2:254 3:540, 3:541, 3:543, 3:552, 3:555, 3:567,
IA-32 privileged system resources 2:231 3:569, 3:574, 3:587, 3:609, 3:610, 3:720,
3:726, 3:727, 3:770, 3:781, 3:817, 3:848,
IA-32 processes during a context switch 2:244
3:855, 3:856, 3:876, 3:877, 3:908, 3:909,
entering IA-32 processes 2:245 3:922, 3:923
exiting IA-32 processes 2:245 tininess 1:103
IA-32 segmentation 1:128, 2:252 underflow 1:101, 1:103, 2:560, 2:564, 3:467, 3:469,
IA-32 streaming SIMD extension instructions 1:127, 3:470, 3:471, 3:476, 3:478, 3:480, 3:491,
3:833 3:494, 3:515, 3:516, 3:529, 3:535, 3:538,
IA-32 system and control register behavior 2:231 3:540, 3:541, 3:543, 3:552, 3:561, 3:565,
IA-32 system EFLAG register 2:235 3:567, 3:569, 3:570, 3:571, 3:572, 3:847,
IA-32 system environment 1:5, 1:11, 1:12, 1:19, 2:5, 3:848, 3:855, 3:856, 3:876, 3:877, 3:885,
2:13, 3:5, 3:619, 3:620, 3:655, 3:681, 3:703, 3:886, 3:908, 3:909, 3:922, 3:923
3:704, 3:705, 3:706, 3:743 IEEE floating-point exception filter 2:559, 2:562
IA-32 system register mapping 2:232 denormal/unnormal operand exception (fault) 2:563
IA-32 system registers 2:238 divide by zero exception (fault) 2:563
IA-32 control registers 2:238 inexact exception (trap) 2:564
IA-32 debug registers 2:243 invalid operation exception (fault) 2:563
IA-32 machine check registers 2:244 overflow exception (trap) 2:563
IA-32 memory type range registers (MTRRs) 2:244 underflow exception (trap) 2:564
IA-32 model specific and test registers 2:244 IEEE-754 2:559, 2:562, 2:564, 3:843
IA-32 performance monitor registers 2:244 ANSI/IEEE-754 standard compliant 1:197
IA-32 system segment registers 2:233 IF (interrupt enable) flag, EFLAGS register 3:431, 3:743
IA-32 TLB forward progress requirements 2:253 IFA (Interruption Faulting Address) control register 2:29
IA-32 trap code 2:205 if-conversion 1:161
IA-32 usage of Itanium registers 1:130 IFS (Interruption Function State) control register 2:29
ALAT 1:130 IHA (Interruption Hash Address) control register 2:29
NaT/NaTVal response for IA-32 instructions 1:130 IIM (Interruption Immediate register) control register 2:29
register stack engine 1:130, 3:619 IIP (Interruption Instruction Bundle Pointer) control
IA-32 virtual memory references 2:253 register 2:35
protection keys 2:253 IIP (Interruption Instruction Pointer) control register 2:29
region identifiers 2:253 IIPA (Interruption Instruction Previous Address) control
TLB access bit 2:253 register 2:29
TLB dirty bit 2:253 illegal dependency fault 1:41, 2:162, 2:556

Index-10 Intel® Itanium® Architecture Software Developer’s Manual


Index
illegal operation fault 1:21, 1:22, 1:41, 2:162, 3:273 integer (I) 1:137, 3:274
ILP (Instruction Level Parallelism) 1:13 memory (M) 1:137, 3:274
implicit serialization 2:17 instruction/data TLB miss 2:64, 2:65, 2:66
IMUL instruction 3:577 INSW instruction 3:584
IN instruction 3:580 INTA (Interrupt Acknowledge) 2:123
INC instruction 3:582, 3:642 INT3 instruction 3:587
Indefinite integer computation instructions 1:46
description of 3:849 32-bit addresses and integers 1:48
real 3:851 arithmetic instructions 1:47, 3:342, 3:885
Index_Non 2.1 3:381 bit field and shift instructions 1:48, 1:49
Infinity, floating-point format 3:848 large constants 1:49
in-flight resources 2:19 logical instructions 1:47
INIT flows 2:602 Integer, FPU data type
initialization event (INIT) 2:599 storing 3:504
initialization interrupts 2:92, 2:110, 2:514 integer/floating-point conversion 1:207
PALE_INIT 2:92, 2:104 Inter-privilege level call
Initialization FPU 3:503 CALL instruction 3:418
INS instruction 3:584, 3:707 Inter-privilege level return
INSB instruction 3:584 RET instruction 3:710
INSD instruction 3:584 inter-processor interrupt (IPI) 2:110, 2:111, 2:123,
inserting/purging of translations 2:533 2:581
instruction breakpoint register matching 2:266 inter-processor interrupt message 2:124, 2:602
IBR.addr 2:266 data fields 2:124, 2:126
IBR.mask 2:266 Interrupt 2:79, 2:92, 2:93, 2:104, 2:109, 2:110, 2:111,
instruction breakpoint registers (IBR) 2:145, 2:146 2:112, 2:113, 2:114, 2:115, 2:116, 2:117,
2:118, 2:119, 2:513, 2:514, 2:573, 2:574,
instruction classes 3:356, 3:371, 3:373
2:601, 3:431, 3:432, 3:573, 3:587, 3:588,
instruction dependencies 1:144 3:589, 3:590, 3:591, 3:592, 3:593, 3:594,
control dependencies 1:68, 1:144, 2:492 3:595, 3:596, 3:597, 3:601, 3:602, 3:603,
data dependencies 1:59, 1:145, 1:146, 1:147, 2:17 3:604, 3:605, 3:606, 3:607, 3:608, 3:623,
instruction encoding 1:34 3:634, 3:635, 3:639, 3:649, 3:655, 3:681,
bundles 1:13, 1:33, 1:35, 1:36, 1:136, 1:137, 3:273 3:682, 3:687, 3:695, 3:708, 3:716, 3:729,
instruction slots 1:35, 3:273 3:730, 3:736, 3:743, 3:744, 3:745, 3:855,
template 1:35, 1:36, 1:137, 3:273, 3:274 3:856, 3:857, 3:858, 3:860, 3:863, 3:865,
instruction field names 3:275, 3:278 3:867, 3:869, 3:871, 3:872, 3:873, 3:875,
instruction format 1:136, 3:276 3:876, 3:877, 3:879, 3:884, 3:886, 3:888,
instruction interception 2:231 3:889, 3:892, 3:893, 3:896, 3:898, 3:901,
Instruction Level Parallelism (ILP) 1:13 3:905, 3:907, 3:908, 3:909, 3:910, 3:911,
instruction pointer (IP) 1:21, 1:24, 2:516, 2:589 3:913, 3:915, 3:916, 3:918, 3:919, 3:920,
3:921, 3:922, 3:923, 3:924, 3:926, 3:928,
instruction serialization 2:18, 2:19, 2:518, 3:357,
3:930, 3:932, 3:933, 3:934, 3:935, 3:936,
3:452, 3:601
3:937, 3:938, 3:939, 3:940, 3:941, 3:943,
Instruction set 3:946, 3:947, 3:948
string instructions 3:441, 3:584, 3:644, 3:662, Interrupt Acknowledge (INTA) 2:123
3:678, 3:746
Interruption 2:91, 2:92, 2:93, 2:94, 2:95, 2:96, 2:97,
instruction set architecture (ISA) 1:5, 2:5, 3:5 2:98, 2:99, 2:104, 2:107, 2:108, 2:116, 2:141,
instruction set features 1:13 2:513, 2:514, 2:515
instruction set transition model overview 1:12 execution environment 2:515
instruction set transitions 2:38, 2:231, 2:259 heavyweight interruptions 2:519, 2:521
instruction slots 1:35, 3:273 interruption handler 2:98, 2:99, 2:513, 2:514, 2:515,
instruction slot mapping 1:35, 3:274 2:518
instruction stream 1:171, 3:518, 3:532, 3:548, 3:613, interruption handling 2:91, 2:94, 2:97, 2:98, 2:518
3:671 interruption register state 2:516
instruction stream alignment 1:171 lightweight interruptions 2:518, 2:519
instruction stream fetching 1:171 nested interruptions 2:521, 2:522
instruction type 1:34, 3:273, 3:719 resource serialization 2:517, 2:518
ALU (A) 3:274 interruption model 2:94, 2:266
branch (B) 3:274 interruption priorities 2:104, 2:107
floating-point (F) 3:274 interruption registers 2:232, 2:514, 2:516

Intel® Itanium® Architecture Software Developer’s Manual Index-11


Index
interruption vector address (IVA) 2:514 3:686, 3:689, 3:691, 3:694, 3:696, 3:699,
interruption vector table (IVT) 2:91, 2:108, 2:514 3:704, 3:706, 3:709, 3:714, 3:717, 3:720,
interruption vectors 2:97, 2:108, 2:159, 2:164, 2:514 3:722, 3:723, 3:725, 3:727, 3:733, 3:735,
Alternate Data TLB vector (0x1000) 2:170 3:747, 3:749, 3:751, 3:755, 3:761, 3:763,
Alternate Instruction TLB vector (0x0c00) 2:169 3:765, 3:767, 3:770, 3:772, 3:773, 3:776,
Break Instruction vector (0x2c00) 2:177 3:778, 3:781, 3:784, 3:787, 3:789, 3:791,
Data Access Rights vector (0x5300) 2:183 3:794, 3:797, 3:799, 3:801, 3:803, 3:805,
Data Access-Bit vector (0x2800) 2:176 3:808, 3:811, 3:814, 3:817, 3:820, 3:823,
Data Key Miss vector (0x1c00) 2:173 3:826, 3:829, 3:831, 3:855, 3:856, 3:857,
Data Nested TLB vector (0x1400) 2:171 3:858, 3:860, 3:863, 3:866, 3:867, 3:869,
Data TLB vector (0x0800) 2:168 3:871, 3:872, 3:873, 3:875, 3:876, 3:877,
Debug vector (0x5900) 2:191 3:880, 3:884, 3:886, 3:888, 3:890, 3:892,
Dirty-Bit vector (0x2000) 2:174 3:894, 3:896, 3:897, 3:899, 3:900, 3:902,
Disabled FP-Register vector (0x5500) 2:186 3:903, 3:905, 3:907, 3:908, 3:909, 3:910,
External Interrupt vector (0x3000) 2:178 3:911, 3:913, 3:915, 3:916, 3:918, 3:919,
Floating-point Fault vector (0x5c00) 2:194 3:920, 3:921, 3:922, 3:923, 3:925, 3:927,
Floating-point Trap vector (0x5d00) 2:195 3:929, 3:930, 3:932, 3:933, 3:934, 3:935,
General Exception vector (0x5400) 2:184 3:936, 3:937, 3:938, 3:939, 3:940, 3:942,
IA-32 Exception vector (0x6900) 2:201 3:943, 3:945, 3:946, 3:947, 3:948
IA-32 Intercept vector (0x6a00) 2:202 interruption handling during instruction execution 2:94
IA-32 Interrupt vector (0x6b00) 2:203 interruption programming model 2:93
Instruction Access Rights vector (0x5200) 2:182 interrupts 2:91, 2:92, 2:94, 2:97, 2:101, 2:104,
Instruction Access-Bit vector (0x2400) 2:175 2:107, 2:110, 2:111, 2:112, 2:114, 2:115,
Instruction Key Miss vector (0x1800) 2:172 2:116, 2:117, 2:118, 2:119, 2:235, 2:513,
Instruction TLB vector (0x0400) 2:167 2:514, 3:431, 3:550, 3:587, 3:588, 3:655,
interruption vector definition 2:160 3:681, 3:703, 3:708, 3:743
Key Permission vector (0x5100) 2:181 IVA-based interruption 2:97, 2:108, 2:514
Lower-Privilege Transfer Trap vector (0x5e00) 2:196 PAL-based interruption 2:97, 2:513
NaT Consumption vector (0x5600) 2:187 traps 1:101, 2:91, 2:92, 2:96, 2:97, 2:98, 2:104,
Page Not Present vector (0x5000) 2:180 2:106, 2:107, 2:108, 2:513, 3:581, 3:585,
Single Step Trap vector (0x6000) 2:199 3:655, 3:677, 3:680, 3:681
Speculation vector (0x5700) 2:189 Interrupts
Taken Branch Trap vector (0x5f00) 2:198 interrupt vector 4 3:587
Unaligned Reference vector (0x5a00) 2:192 returning from 3:601
Unsupported Data Reference vector (0x5b00) 2:193 software 3:587
VHPT Translation vector (0x0000) 2:165 interval timer 1:114, 2:20, 2:31, 2:32, 2:111, 2:120,
Virtual External Interrupt vector (0x3400) 2:179 2:121, 2:579, 2:580
Virtualization vector (0x6100) 2:200 INTn instruction 3:587
Interruptions 2:91, 2:92, 2:93, 2:94, 2:97, 2:98, 2:99, INTO instruction 3:587
2:104, 2:107, 2:108, 2:139, 2:140, 2:513, invala 1:62, 1:64, 2:141, 2:528, 2:595, 3:135, 3:323,
2:514 3:324, 3:328, 3:373
aborts 2:91, 2:101, 2:104, 2:514 invala.e 1:62, 1:64, 2:523, 2:524, 2:525, 2:528, 3:323,
faults 2:91, 2:92, 2:97, 2:101, 2:104, 2:105, 2:106, 3:324, 3:328, 3:359, 3:373
2:107, 2:108, 2:513, 3:401, 3:403, 3:405, INVD instruction 3:598
3:407, 3:409, 3:411, 3:412, 3:414, 3:416, INVLPG instruction 3:600
3:425, 3:427, 3:436, 3:437, 3:439, 3:442,
IOPL (I/O privilege level) field, EFLAGS register 3:431,
3:445, 3:446, 3:454, 3:455, 3:457, 3:458,
3:695, 3:743
3:459, 3:462, 3:465, 3:467, 3:469, 3:471,
3:473, 3:476, 3:478, 3:479, 3:480, 3:483, IPI (inter-processor interrupt) 2:110, 2:111, 2:123, 2:581
3:486, 3:489, 3:490, 3:493, 3:496, 3:497, IPI ordering 2:126
3:499, 3:500, 3:502, 3:503, 3:505, 3:507, IPSR (Interruption Processor Status Register) control
3:509, 3:511, 3:513, 3:517, 3:518, 3:519, register 2:29, 2:34
3:522, 3:525, 3:528, 3:529, 3:531, 3:533, IRET instruction 3:601
3:536, 3:538, 3:540, 3:542, 3:544, 3:546, IRETD instruction 3:601
3:549, 3:550, 3:554, 3:557, 3:558, 3:561, IRR0 (External Interrupt Request Register 0 (read only))
3:563, 3:565, 3:567, 3:570, 3:572, 3:575, control register 2:29
3:579, 3:581, 3:582, 3:585, 3:593, 3:607, IRR1 (External Interrupt Request Register 1 (read only))
3:617, 3:619, 3:620, 3:621, 3:623, 3:626, control register 2:29
3:629, 3:630, 3:642, 3:645, 3:647, 3:650, IRR2 (External Interrupt Request Register 2 (read only))
3:656, 3:663, 3:664, 3:665, 3:667, 3:669, control register 2:29
3:671, 3:672, 3:674, 3:677, 3:680, 3:683, IRR3 (External Interrupt Request Register 3 (read only))

Index-12 Intel® Itanium® Architecture Software Developer’s Manual


Index
control register 2:29 Itanium-based firmware 1:5, 1:19, 2:5, 3:5
ISR (Interruption Status Register) control register 2:29 itc 1:29, 2:31, 2:32, 2:50, 2:55, 2:57, 2:537, 2:539,
ISR setting 2:159 2:579, 2:580, 3:136, 3:329, 3:330, 3:359,
Itanium architecture 1:1, 1:5, 1:11, 1:13, 1:14, 1:108, 3:360, 3:361, 3:362, 3:365, 3:366, 3:367,
1:110, 1:135, 1:143, 1:150, 2:1, 2:5, 3:1, 3:5, 3:369, 3:373, 3:375, 3:376, 3:378
3:452, 3:580, 3:584, 3:619, 3:620, 3:676, ITC (Interval Time Counter) application register 1:26
3:679 ITC (Interval Time Counter) control register 2:31
Itanium data mem faults 3:382 ITIR (Interruption TLB Insertion Register) control
Itanium instruction 1:111, 3:273, 3:355, 3:452, 3:619, register 2:29, 2:36
3:620 ITM (Interval Timer Match Register) control register
expressing parallelism 1:137 2:28, 2:31
format 3:486, 3:561 ITM (Interval Timer Match register) control register 2:28
Itanium instruction set 1:19, 3:452, 3:619, 3:620 itr 2:46, 2:50, 2:55, 2:57, 2:537, 2:538, 2:595, 2:598,
syntax 1:136, 3:356 2:599, 3:138, 3:329, 3:330, 3:360, 3:361,
Itanium instruction mem faults 3:382 3:362, 3:365, 3:366, 3:369, 3:373, 3:378
Itanium system environment 1:5, 1:11, 1:12, 1:19, 2:5, ITV (Interval Timer Vector) control register 2:29
2:13, 2:14, 2:15, 3:5, 3:381, 3:401, 3:403,
3:405, 3:407, 3:409, 3:411, 3:412, 3:414, IVA (Interruption Vector Address) control register 2:28
3:416, 3:418, 3:419, 3:420, 3:421, 3:422, IVA-based interruptions 2:91, 2:92, 2:93, 2:97, 2:513,
3:424, 3:425, 3:427, 3:431, 3:432, 3:433, 2:514
3:437, 3:439, 3:442, 3:444, 3:445, 3:446, IVR (External Interrupt Vector Register (read only))
3:454, 3:455, 3:457, 3:458, 3:459, 3:462, control register 2:29
3:465, 3:467, 3:469, 3:471, 3:473, 3:476,
IVT (interruption vector table) 2:91, 2:108, 2:514
3:478, 3:479, 3:480, 3:483, 3:486, 3:489,
3:490, 3:493, 3:496, 3:497, 3:499, 3:500,
3:502, 3:503, 3:505, 3:507, 3:509, 3:511,
3:513, 3:517, 3:518, 3:519, 3:522, 3:525,
J
3:528, 3:529, 3:531, 3:533, 3:536, 3:538, J-bit 3:845
3:540, 3:542, 3:544, 3:546, 3:549, 3:550, Jcc instructions 3:609
3:554, 3:557, 3:558, 3:561, 3:563, 3:565, JMP instruction 3:613
3:567, 3:570, 3:572, 3:573, 3:575, 3:579, jmpe 1:12, 1:107, 1:109
3:580, 3:581, 3:582, 3:584, 3:585, 3:589, Jump operation 3:613
3:595, 3:598, 3:600, 3:601, 3:602, 3:607,
3:611, 3:613, 3:614, 3:615, 3:616, 3:617,
3:619, 3:620, 3:621, 3:623, 3:626, 3:629, K
3:630, 3:634, 3:635, 3:637, 3:640, 3:642, KR 0-7 (Kernel Registers 0-7) application register 1:26
3:645, 3:647, 3:650, 3:652, 3:655, 3:656,
3:658, 3:659, 3:660, 3:663, 3:664, 3:665,
3:667, 3:669, 3:672, 3:674, 3:676, 3:677, L
3:679, 3:680, 3:681, 3:683, 3:686, 3:689, LAHF instruction 3:619, 3:621
3:691, 3:694, 3:696, 3:699, 3:701, 3:703, Lamport’s algorithm 2:505, 2:506
3:704, 3:705, 3:706, 3:709, 3:711, 3:712, LAR instruction 3:622
3:714, 3:716, 3:717, 3:720, 3:722, 3:725,
LC (Loop Count Register) application register 1:26
3:727, 3:729, 3:733, 3:735, 3:737, 3:739,
3:743, 3:744, 3:747, 3:748, 3:749, 3:751, ld 3:140
3:753, 3:755, 3:757, 3:759, 3:761, 3:763, ld.a 1:53, 1:59, 1:63, 1:64, 1:148, 1:150, 1:157, 2:76,
3:765, 3:767, 3:770, 3:772, 3:773, 3:776, 2:78, 2:83, 2:484, 2:551, 2:552, 2:553
3:778, 3:781, 3:784, 3:787, 3:789, 3:791, ld.acq 1:53, 1:62, 1:68, 2:78, 2:79, 2:484, 2:489,
3:794, 3:797, 3:799, 3:801, 3:803, 3:805, 2:491, 2:493, 2:495, 2:497, 2:498
3:808, 3:811, 3:814, 3:817, 3:820, 3:823, ld.c 1:59, 1:60, 1:61, 1:62, 1:148, 1:149, 1:150, 1:157,
3:826, 3:829, 3:831, 3:855, 3:856, 3:857, 2:78, 2:552, 2:553
3:858, 3:860, 3:863, 3:866, 3:867, 3:869, ld.c.clr 1:53, 1:62, 1:63, 1:64, 2:82, 2:83
3:871, 3:872, 3:873, 3:875, 3:876, 3:877, ld.c.clr.acq 1:53, 1:62, 1:63, 1:64, 1:68, 2:78, 2:79,
3:880, 3:884, 3:886, 3:888, 3:890, 3:892, 2:82, 2:83
3:894, 3:896, 3:897, 3:899, 3:900, 3:902, ld.c.nc 1:53, 1:63, 1:64, 2:82, 2:83
3:903, 3:905, 3:907, 3:908, 3:909, 3:910, ld.s 1:53, 1:56, 1:59, 1:152, 2:76, 2:78, 2:484, 2:551,
3:911, 3:913, 3:915, 3:916, 3:918, 3:919, 2:552, 2:553
3:920, 3:921, 3:922, 3:923, 3:925, 3:927, ld.sa 1:53, 1:63, 1:64, 1:152, 2:76, 2:78, 2:83, 2:484,
3:929, 3:930, 3:932, 3:933, 3:934, 3:935, 2:524, 2:551, 2:552, 2:553
3:936, 3:937, 3:938, 3:939, 3:940, 3:942,
ld16 3:310
3:943, 3:946, 3:947, 3:948, 3:949, 3:950

Intel® Itanium® Architecture Software Developer’s Manual Index-13


Index
ld8.fill 1:28, 1:39, 1:54, 1:58, 1:59, 1:151, 2:523, 2:524, LODSW instruction 3:644
3:305, 3:306, 3:310, 3:311, 3:312, 3:358, Log (base 2), FPU operation 3:571
3:360, 3:373 Log epsilon, FPU operation 3:569
ldf 3:145 logical instructions 1:47
ldf.a 1:53, 1:59, 1:63, 1:64 long branch handler 2:555
ldf.c 1:59 LOOP instructions 3:646
ldf.c.clr 1:53, 1:63, 1:64, 2:82 loop support 1:70, 1:175, 1:178
ldf.c.nc 1:53, 1:63, 1:64, 2:82 capacity limitations 1:189
ldf.fill 1:53, 1:54, 1:58, 1:59, 1:87, 1:151, 2:78, 2:523, conflicts in the ALAT 1:190
2:525, 3:307, 3:308, 3:314, 3:315, 3:316, counted loop 1:71, 1:72, 1:175, 1:180, 1:181
3:374 counted loop branches 1:180
ldf.s 1:53, 1:56, 1:59, 2:78 epilog 1:70, 1:177, 1:178, 1:183
ldf.sa 1:53, 1:63, 1:64, 2:78 epilog count register (EC) 1:29, 1:30
ldfp 3:149 explicit prolog and epilog 1:194
ldfp.a 1:53, 1:59, 1:61, 1:63, 1:64 implementing reductions 1:193
ldfp.c 1:59 induction variable 1:176
initiation interval (II) 1:177
ldfp.c.clr 1:53, 1:63, 1:64
kernel 1:70, 1:177, 1:178, 1:183
ldfp.c.nc 1:53, 1:63, 1:64 kernel iteration 1:178
ldfp.s 1:53, 1:56, 1:59, 2:78 kernel loop 1:178
ldfp.sa 1:53, 1:63, 1:64, 2:78 loop count application register (LC) 1:71, 1:175
LDS instruction 3:625 loop unrolling 1:141, 1:176, 1:191
LDT (local descriptor table) 3:637 loop unrolling prior to software pipelining 1:191
LDTR (local descriptor table register) 3:637, 3:737 loops with predicated instructions 1:186
LEA instruction 3:628 multiple-exit loops 1:187
LEAVE instruction 3:630 prolog 1:70, 1:177, 1:178, 1:183
LES instruction 3:625 redundant load elimination in loops 1:196
register rotation 1:17, 1:178, 1:179
level sensitive external interrupts 2:127
software pipelining and advanced loads 1:189
lfetch 3:152 software pipelining considerations 1:189
LFS instruction 3:625 software-pipelined loop branches 1:179, 1:180,
LGDT instruction 3:634 1:181
LGS instruction 3:625 source iteration 1:178
LID (Local Interrupt ID) control register 2:29 source loop 1:178
LIDT instruction 3:634 while loop 1:72, 1:182, 1:184, 3:708, 3:709
LINT 2:111, 2:122, 2:123, 2:126, 2:127 LOOPcc instructions 3:646
LINT0 2:122 LRR0 (Local Redirection Register 0) control register 2:29
LINT0 (Local Interrupt 0) 2:122 LRR1 (Local Redirection Register 1) control register 2:29
LINT1 2:122 LSL instruction 3:648
LINT1 (Local Interrupt 1) 2:122 LSS instruction 3:625
LLDT instruction 3:637 LTR instruction 3:652
LMSW instruction 3:640
Load effective address operation 3:628
load instruction 1:163, 2:484, 3:895, 3:898, 3:901,
M
3:904, 3:906 machine check 2:91, 2:104, 2:242, 2:244, 2:514, 2:600,
loadrs 1:27, 1:39, 1:46, 1:50, 2:65, 2:104, 2:131, 2:601, 2:602, 3:701, 3:759
2:133, 2:134, 2:135, 2:137, 2:138, 2:139, machine check abort
2:140, 2:141, 2:142, 2:526, 2:527, 2:595, PALE_CHECK 2:91, 2:104
3:155, 3:323, 3:328, 3:359, 3:360, 3:366, machine check abort flows
3:367, 3:368, 3:373, 3:378, 3:379 machine check abort handling in OS 2:601
loadrs field 1:46, 2:134, 2:137 machine check handling in PAL 2:601
RSC.loadrs 1:46, 2:137, 2:138, 2:139, 2:595 machine check handling in SAL 2:601
Local Interrupt 0 (LINT0) 2:122 machine check aborts 2:591
Local Interrupt 1 (LINT1) 2:122 machine checks 2:288
LOCK prefix 3:444, 3:446, 3:642, 3:761, 3:763 Machine status word, CR0 register 3:640, 3:739
Locking operation 3:642 major opcode 1:36, 3:273, 3:274, 3:275
LODS instruction 3:644, 3:707 master boot record 2:593
LODSB instruction 3:644 mc bit
LODSD instruction 3:644 PSR.mc 2:94, 2:97, 2:98, 2:114, 2:516, 3:365,

Index-14 Intel® Itanium® Architecture Software Developer’s Manual


Index
3:370 3:733, 3:735, 3:737, 3:739, 3:740, 3:747,
MC (machine check) 2:332 3:748, 3:750, 3:752, 3:755, 3:761, 3:762,
MCA 2:591 3:764, 3:765, 3:766, 3:768, 3:772, 3:774,
memory acceptance fence 2:583 3:776, 3:777, 3:779, 3:782, 3:784, 3:785,
memory access control 1:208 3:787, 3:788, 3:790, 3:792, 3:795, 3:798,
3:800, 3:802, 3:804, 3:806, 3:808, 3:809,
allocation control 1:65, 1:209
3:811, 3:812, 3:814, 3:815, 3:818, 3:820,
data prefetch 1:209
3:821, 3:823, 3:824, 3:826, 3:827, 3:829,
load-pair instructions 1:208
3:830, 3:832, 3:856, 3:863, 3:865, 3:867,
memory access instructions 1:53, 1:64, 2:483 3:869, 3:871, 3:872, 3:873, 3:875, 3:877,
memory access ordering 1:68, 2:79 3:879, 3:880, 3:883, 3:884, 3:886, 3:889,
memory ordering instructions 1:68 3:893, 3:898, 3:901, 3:905, 3:907, 3:909,
memory ordering rules 1:68 3:913, 3:916, 3:920, 3:921, 3:923, 3:924,
memory addressing model 1:33, 1:128 3:932, 3:934, 3:935, 3:936, 3:937, 3:938,
memory alignment 2:255 3:939, 3:940, 3:941, 3:943, 3:945, 3:946,
memory attribute 2:52, 2:71, 2:72, 2:82, 2:83, 2:84 3:948
effects of memory attributes on advanced/check memory synchronization 2:500
loads 2:82 mf 1:69, 2:126, 2:486, 3:156
effects of memory attributes on memory reference mf.a 2:78, 2:126, 2:583, 2:584, 2:585, 2:586, 3:323,
instructions 2:81 3:328
memory attribute transition 2:83 Min/Max/AMin/AMax 1:206
physical addressing memory attribute 2:72 mix 3:157
virtual addressing memory attribute 2:71, 2:83 MMX technology 1:17, 1:108, 1:111, 1:113, 1:126,
memory dependency 1:37, 2:77 1:127, 3:381, 3:769, 3:770, 3:771, 3:773,
read-after-write 1:37, 1:40, 1:41, 1:68, 2:77 3:775, 3:778, 3:780, 3:783, 3:786, 3:789,
write-after-read 1:37, 1:40, 1:41, 1:68, 2:77 3:791, 3:793, 3:796, 3:799, 3:801, 3:803,
write-after-write 1:37, 1:40, 1:41, 1:68, 2:77 3:805, 3:807, 3:810, 3:813, 3:816, 3:819,
memory endianess 1:128 3:822, 3:825, 3:828, 3:831, 3:839, 3:840,
memory fence 1:68, 2:500 3:841, 3:842, 3:868, 3:870, 3:874, 3:878,
memory fences 2:126, 2:486 3:881, 3:882, 3:930, 3:932, 3:941, 3:945,
memory hierarchy 1:65 3:946
hierarchy control and hints 1:64 mov 1:31, 1:39, 1:40, 1:49, 1:52, 1:70, 1:76, 1:77,
memory consistency 1:67, 3:946, 3:947, 3:948 1:78, 2:17, 2:22, 2:23, 2:55, 2:57, 2:136,
memory mapped I/O model 2:260, 2:584 2:139, 2:147, 2:153, 2:587, 3:298, 3:299,
memory model 1:127, 2:252 3:301, 3:302, 3:303, 3:324, 3:325, 3:326,
3:328, 3:329, 3:330, 3:331, 3:337, 3:374,
memory ordering 1:68, 2:77, 2:78, 2:142, 2:483,
3:375, 3:376, 3:377, 3:410, 3:640, 3:654,
2:484, 2:486, 2:491, 2:492, 2:493, 2:532,
3:655, 3:656, 3:657, 3:658, 3:659, 3:660,
3:950
3:661, 3:681, 3:682, 3:739
acquire semantics 1:68, 2:79, 2:257, 2:483
mov ar 3:160
memory ordering executions 2:486
memory ordering interactions 1:129 mov cr 3:163
memory ordering model 2:257, 2:486, 2:500 mov fr 3:165
memory ordering semantics 1:68, 2:486 mov gr 3:166
release semantics 1:68, 2:257, 2:258, 2:483 mov imm 3:166
Memory ordering fence 1:69 mov indirect 3:168
memory reference 1:143, 1:144, 2:44, 3:400, 3:402, MOV instruction 3:654
3:404, 3:406, 3:408, 3:411, 3:413, 3:415, MOV instruction (control registers) 3:658
3:417, 3:437, 3:438, 3:440, 3:442, 3:443, MOV instruction (debug registers) 3:660
3:445, 3:447, 3:459, 3:460, 3:462, 3:463, mov ip 3:171
3:472, 3:473, 3:474, 3:476, 3:477, 3:484, mov pr 3:172
3:493, 3:496, 3:499, 3:500, 3:501, 3:505, mov psr 3:173
3:506, 3:508, 3:511, 3:512, 3:514, 3:517,
mov um 3:174
3:531, 3:533, 3:534, 3:544, 3:545, 3:546,
3:547, 3:549, 3:551, 3:554, 3:557, 3:575, movl 3:175
3:576, 3:579, 3:582, 3:583, 3:586, 3:607, MOVS instruction 3:662, 3:707
3:608, 3:618, 3:624, 3:625, 3:627, 3:645, MOVSB instruction 3:662
3:650, 3:655, 3:657, 3:663, 3:664, 3:665, MOVSD instruction 3:662
3:666, 3:668, 3:669, 3:670, 3:672, 3:673, MOVSW instruction 3:662
3:675, 3:680, 3:681, 3:684, 3:691, 3:692, MOVSX instruction 3:664
3:700, 3:721, 3:723, 3:725, 3:727, 3:728, MOVZX instruction 3:665

Intel® Itanium® Architecture Software Developer’s Manual Index-15


Index
MP (multiprocessor) not a thing attribute (NaTPage) 2:81
multiprocessor instruction cache coherency 2:257 NOT instruction 3:642, 3:672
multiprocessor TLB coherency 2:254 Notation
MSRs (model specific registers) reserved bits 3:853
reading 3:701 NT (nested task) flag, EFLAGS register 3:601
writing 3:759
MUL instruction 3:393, 3:667
multimedia instructions 1:13, 1:17, 1:43, 1:74 O
data arrangement 1:76 OF (carry) flag, EFLAGS register 3:577
parallel arithmetic 1:74, 1:75 OF (overflow) flag, EFLAGS register 3:395, 3:397,
parallel shifts 1:75 3:587, 3:667, 3:722, 3:732, 3:734, 3:749
multimedia support 1:17 OLR 2:332
multiple address space (MAS) 1:18, 2:43, 2:533, 2:534 operand screening support 1:206
multiple status fields 1:204 operating environments 1:11, 1:12
multiply-add instruction 1:202 Optimization of Memory References
multiprocessor (MP) Using Post-increment Loads and Stores 1:155
multiprocessor instruction cache coherency 2:257 optimization of memory references 1:152
multiprocessor TLB coherency 2:254 data interference 1:153, 1:154
mux 3:176 loop optimization 1:156
minimizing check code 1:156
optimizing code size 1:154
N or 3:180
NaN OR instruction 3:642, 3:674
description of 3:846, 3:848 orderable instruction 2:484, 2:488
encoding of 3:847, 3:851 ordered cacheable operations 2:497
operating on 3:849 ordering semantics 1:68, 2:78, 2:79, 2:488
SNaNs vs. QNaNs 3:848 acquire 1:68, 2:78, 2:79, 2:257, 2:258, 2:483, 2:488,
testing for 3:558 2:489
NaNs 1:83, 1:104, 1:206, 3:475, 3:519, 3:521, 3:524, fence 1:68, 1:69, 2:78, 2:79, 2:258, 2:483, 2:488,
3:553, 3:556, 3:569, 3:571, 3:844, 3:846, 3:452, 3:454, 3:581, 3:585, 3:601, 3:619,
3:847, 3:848, 3:849, 3:851 3:677, 3:679, 3:950
NaT (not a thing) 1:135 release 1:68, 2:78, 2:79, 2:257, 2:258, 2:483, 2:488,
NaT page consumption fault 2:81 2:489, 3:710
NaTPage attribute 2:81 unordered 1:68, 2:78, 2:79, 2:258, 2:483, 2:488,
NaTVal (not a thing value) 1:24 3:480, 3:482, 3:485, 3:498, 3:558, 3:560,
Near call 3:561, 3:860, 3:863, 3:865, 3:924, 3:925
CALL instruction 3:418 OS boot flow sample code 2:607
Near return OS kernel 2:593, 2:594, 2:595
RET instruction 3:710 OS loader 2:593
NEG instruction 3:642, 3:669 OUT instruction 3:676
NMI (Non-Maskable Interrupts) 2:92 OUTS instruction 3:678, 3:707
non-access instructions 2:99 OUTSB instruction 3:678
non-cacheable memory 2:77 OUTSD instruction 3:678
Nonconforming code segment 3:616 OUTSW instruction 3:678
Non-Maskable Interrupts (NMI) 2:92 overflow 1:16, 1:101, 1:102, 2:560, 2:563, 3:436,
Non-number encodings, FPU 3:846 3:461, 3:467, 3:473, 3:500, 3:507, 3:509,
non-programmer-visible state 2:486 3:535, 3:540, 3:555, 3:567, 3:569, 3:574,
3:587, 3:609, 3:610, 3:720, 3:726, 3:727,
non-speculative 1:56, 1:57, 2:75, 2:76, 2:83, 2:553
3:770, 3:781, 3:817, 3:848, 3:855, 3:856,
non-speculative memory references 1:143, 2:70 3:876, 3:877, 3:908, 3:909, 3:922, 3:923
data prefetch hint 1:144 Overflow exception (#OF) 3:587
loads from memory 1:143
stores to memory 1:143
non-temporal hint 1:209 P
nop 3:179 pack 3:181
NOP instruction 3:671 PACKSSDW instruction 3:775
no-recovery model 2:100, 2:101 PACKSSWB instruction 3:775
Normalized finite number 3:845, 3:847 PACKUSWB instruction 3:778
normalized numbers 1:83, 3:844, 3:845, 3:847

Index-16 Intel® Itanium® Architecture Software Developer’s Manual


Index
padd 3:183 PAL_PROC_SET_FEATURES 2:435
PADDB instruction 3:780 PAL_PTCE_INFO 2:438
PADDD instruction 3:780 PAL_REGISTER_INFO 2:439
padding restrictions 2:255 PAL_RSE_INFO 2:440
PADDSB instruction 3:783 PAL_TEST_INFO 2:445
PADDSW instruction 3:783 PAL_TEST_PROC 2:446
PADDUSB instruction 3:786 PAL_VERSION 2:449
PADDUSW instruction 3:786 PAL_VM_INFO 2:450
PADDW instruction 3:780 PAL_VM_PAGE_SIZE 2:451
Page Table Address (PTA) 2:59 PAL_VM_SUMMARY 2:452
PAL 1:5, 2:5, 2:374, 2:591, 2:593, 2:596, 2:597, PAL_VM_TR_READ 2:454
2:598, 2:599, 2:601, 3:5 PAL-based interrupt states 2:113
entrypoints 2:274 PAL-based interruptions 2:91, 2:92, 2:93, 2:97, 2:108,
procedures 2:274 2:513, 2:514
PAL power on/reset 2:281 PALE_CHECK 2:288
PALE_RESET 2:91 PALE_INIT 2:298
PAL procedure calling conventions 2:339 PALE_RESET 2:281
PAL procedure calls 2:596 PAND instruction 3:789
PAL procedures 2:334, 2:592, 2:596, 2:598, 2:599 PANDN instruction 3:791
stacked PAL call 2:597 pavg 3:186
stacked registers 1:140, 2:596, 2:597 pavgsub 3:189
static PAL call 2:596 pcmp 3:191
PAL self-test control word 2:287 PCMPEQB instruction 3:793
PAL_BUS_GET_FEATURES 2:348 PCMPEQD instruction 3:793
PAL_BUS_SET_FEATURES 2:350 PCMPEQW instruction 3:793
PAL_CACHE_FLUSH 2:351 PCMPGTB instruction 3:796
PAL_CACHE_INFO 2:355 PCMPGTD instruction 3:796
PAL_CACHE_INIT 2:358 PCMPGTW instruction 3:796
PAL_CACHE_LINE_INIT 2:359 PE (protection enable) flag, CR0 register 3:640
PAL_CACHE_PROT_INFO 2:360 performance counters 1:30, 2:149, 2:150, 2:243,
PAL_CACHE_READ 2:362 2:587, 3:703
PAL_CACHE_SHARED_INFO 2:364 Performance Monitor Events 2:155
PAL_CACHE_SUMMARY 2:366 performance monitors 1:30, 1:31, 2:149, 2:152, 2:233,
PAL_CACHE_WRITE 2:367 2:587, 2:588, 2:589
PAL_COPY_INFO 2:370 performance monitor code sequences 2:156
PAL_COPY_PAL 2:371 performance monitor configuration (PMC) 2:149,
PAL_DEBUG_INFO 2:372 2:152
PAL_ENTER_IA_32_ENV 2:373 performance monitor data (PMD) 2:149, 2:587
PAL_FIXED_ADDR 2:380 performance monitor data registers (PMD) 1:21,
PAL_FREQ_BASE 2:381 1:30
performance monitor interrupt service routine 2:156,
PAL_FREQ_RATIOS 2:382
2:157
PAL_HALT 2:387 performance monitor registers 2:149, 2:152, 2:588
PAL_HALT_INFO 2:390 performance monitoring mechanisms 2:587
PAL_HALT_LIGHT 2:392 Performance-monitoring counters
PAL_LOGICAL_TO_PHYSICAL 2:393 reading 3:703
PAL_MC_CLEAR_LOG 2:396 PFS (Previous Function State) application register 1:26
PAL_MC_DRAIN 2:397 physical addressing 2:68, 2:69, 2:72, 2:85, 2:598,
PAL_MC_DYNAMIC_STATE 2:398 2:599, 3:659
PAL_MC_EXPECTED 2:419 Physical Memory Attribute (PMA) 2:69
PAL_MC_RESUME 2:297 Physical Page Number (PPN) 2:44
PAL_MEM_ATTRIB 2:422 Pi
PAL_MEMORY_BUFFER 2:423 loading 3:509
PAL_PERF_MON_INFO 2:425 pk bit 2:536
PAL_PLATFORM_ADDR 2:427 PSR.pk 2:95, 2:98, 2:536, 3:366, 3:371
PAL_PMI_ENTRYPOINT 2:428 PKR (protection key registers) 2:20, 2:56
PAL_PREFETCH_VISIBILITY 2:429 platform management interrupt (PMI) 2:104, 2:302,
PAL_PROC_GET_FEATURES 2:431 2:513, 2:591, 2:599, 2:603

Intel® Itanium® Architecture Software Developer’s Manual Index-17


Index
PMA (Physical Memory Attribute) 2:69 probe 2:54, 2:57, 2:70, 2:99, 3:199, 3:329, 3:330,
PMADDWD instruction 3:799 3:378
pmax 3:193 Procedure 1:43, 1:44, 1:45, 3:401, 3:418, 3:419, 3:420,
PMC (performance monitor configuration) 2:149, 2:152 3:421, 3:422, 3:423, 3:424, 3:425, 3:426,
PMD (performance monitor data) 2:149, 2:587 3:431, 3:432, 3:454, 3:464, 3:465, 3:466,
PMD (performance monitor data registers) 1:21, 1:30 3:532, 3:548, 3:573, 3:587, 3:588, 3:589,
3:590, 3:591, 3:592, 3:593, 3:594, 3:595,
PMI Flows 2:603
3:596, 3:597, 3:598, 3:600, 3:601, 3:604,
pmin 3:194 3:614, 3:630, 3:631, 3:681, 3:685, 3:690,
pmpy 3:195 3:693, 3:695, 3:703, 3:710, 3:711, 3:712,
pmpyshr 3:196 3:713, 3:714, 3:716, 3:743, 3:744, 3:745,
PMULHW instruction 3:801 3:757, 3:882
PMULLW instruction 3:803 procedure calls 1:43, 1:140, 2:523, 2:567, 2:596, 2:598
PMV (Performance Monitoring Vector) control register br.call 1:29, 1:39, 1:44, 1:69, 1:71, 3:336
2:29 br.ret 1:29, 1:39, 1:44, 1:69, 1:71, 2:54, 2:65, 2:98,
POP instruction 3:681 2:104, 3:334, 3:336
POPA instruction 3:685 branch instructions 1:72, 1:141, 3:333, 3:334, 3:350
POPAD instruction 3:685 branches and hints 1:140
popcnt 3:198 loops and software pipelining 1:141
POPF instruction 3:687 register stack engine 1:43, 1:140, 2:98, 2:129, 3:619
rotating registers 1:25, 1:141, 1:142
POPFD instruction 3:687
stacked register 1:44, 2:596, 2:598
population count 1:78, 3:295
Procedure stack
POR instruction 3:805
popping values from 3:681
power management 2:92, 2:305, 2:603 pushing values on 3:690
NORMAL 1:168, 3:563, 3:927, 3:929 Processor 2:271
PPN (Physical Page Number) 2:44 processor abstraction layer 1:5, 1:19, 2:5, 2:591, 3:5
PR (predicate register) processor abstraction layer (PAL) 2:271, 2:274, 2:333
predicate register transfers 1:52 processor caches 2:84, 2:486
predicate register (PR) processor identifiers (CPUID) 1:21
predicate register transfers 1:52 processor identification registers 1:31
Predication 1:13, 1:15, 1:49, 1:50, 1:139, 1:142, 1:159, processor interrupt block 2:123, 2:124, 2:125, 2:581
1:160, 1:161, 1:162, 1:163, 1:164
processor min-state save area 2:294
cache pollution reduction 1:164
processor ordered 2:257
downward code motion 1:163, 1:164
guidelines for removing branches 1:166 Processor Reset (RESET) 2:91
instruction prefetch hints 1:172 processor state 2:340
instruction scheduling 1:144, 1:146, 1:160 system state 2:17, 2:19, 2:20
off-path predication 1:162 processor state parameter 2:291
optimizing program performance using predication processor status register (PSR) 2:17, 2:20, 2:22, 2:152,
1:161 2:516
performance costs of branches 1:159 programmed I/O 2:509, 2:510
predication considerations 1:164 Protected Bootblock 2:279
predication in the itanium architecture 1:160 protected mode 1:12, 1:108, 1:110, 1:117, 1:118,
prediction resources 1:73, 1:159, 1:160 1:119, 2:242, 2:566, 3:389, 3:396, 3:398,
upward code motion 1:163 3:399, 3:402, 3:404, 3:406, 3:408, 3:411,
Prefixes 3:413, 3:415, 3:417, 3:418, 3:419, 3:421,
LOCK 3:642 3:425, 3:431, 3:432, 3:433, 3:437, 3:440,
REP/REPE/REPZ/REPNE/REPNZ 3:707 3:442, 3:445, 3:447, 3:459, 3:462, 3:466,
preservation of floating-point state in the OS 2:527 3:468, 3:469, 3:472, 3:473, 3:476, 3:478,
preserved 2:333 3:479, 3:481, 3:484, 3:487, 3:489, 3:490,
preserved registers 2:523, 2:528 3:493, 3:496, 3:497, 3:499, 3:500, 3:502,
preserving ALAT coherency 2:528 3:503, 3:505, 3:508, 3:509, 3:511, 3:514,
privilege levels 1:24, 2:17, 3:619, 3:620, 3:710 3:517, 3:518, 3:520, 3:523, 3:526, 3:528,
3:529, 3:531, 3:533, 3:536, 3:538, 3:540,
current privilege level (CPL) 2:17, 3:754
3:542, 3:544, 3:546, 3:549, 3:551, 3:554,
privilege level transfer 1:78
3:557, 3:558, 3:561, 3:564, 3:565, 3:568,
processor status register (PSR) 2:17, 2:20, 2:22
3:570, 3:572, 3:573, 3:575, 3:579, 3:580,
processor status register fields 2:23
3:581, 3:582, 3:585, 3:586, 3:587, 3:588,
processor status register instructions 2:22
3:593, 3:594, 3:595, 3:598, 3:600, 3:601,
privileged operation fault 2:162 3:607, 3:611, 3:613, 3:614, 3:615, 3:617,

Index-18 Intel® Itanium® Architecture Software Developer’s Manual


Index
3:622, 3:624, 3:625, 3:626, 3:629, 3:630, 3:378, 3:593
3:634, 3:635, 3:637, 3:640, 3:642, 3:645, PUNPCKHBW instruction 3:825
3:647, 3:650, 3:652, 3:655, 3:656, 3:659, PUNPCKHDQ instruction 3:825
3:660, 3:663, 3:664, 3:665, 3:668, 3:669, PUNPCKHWD instruction 3:825
3:672, 3:675, 3:676, 3:677, 3:679, 3:680, PUNPCKLBW instruction 3:828
3:681, 3:682, 3:683, 3:686, 3:687, 3:689,
PUNPCKLDQ instruction 3:828
3:691, 3:694, 3:696, 3:700, 3:701, 3:704,
3:706, 3:710, 3:711, 3:714, 3:716, 3:721, PUNPCKLWD instruction 3:828
3:723, 3:725, 3:727, 3:730, 3:733, 3:735, PUSH instruction 3:690
3:737, 3:739, 3:743, 3:744, 3:747, 3:748, PUSHA instruction 3:693
3:750, 3:752, 3:755, 3:756, 3:757, 3:759, PUSHAD instruction 3:693
3:761, 3:764, 3:765, 3:768, 3:770, 3:772, PUSHF instruction 3:695
3:774, 3:776, 3:779, 3:782, 3:784, 3:787, PUSHFD instruction 3:695
3:790, 3:792, 3:794, 3:798, 3:800, 3:802, PXOR instruction 3:831
3:804, 3:806, 3:808, 3:811, 3:814, 3:818,
3:820, 3:823, 3:826, 3:829, 3:832, 3:940,
3:941 Q
protection key registers (PKR) 2:20, 2:56 QNaN
protection keys 1:18, 2:20, 2:56, 2:57, 2:533, 2:535, description of 3:848
2:536, 2:537, 2:543 operating on 3:849
psad 3:201 qualified exception deferral 2:103
pseudo-code functions 3:261
pshl 3:202
pshladd 3:203 R
pshr 3:204 RAR (read-after-read) dependency 3:355
pshradd 3:206 RAW (read-after-write) dependency 3:355
PSLLD instruction 3:807 RC (rounding control) field, FPU control word 3:504,
PSLLQ instruction 3:807 3:509, 3:543
PSLLW instruction 3:807 RCL instruction 3:697
PSRAD instruction 3:810 RCR instruction 3:697
PSRAW instruction 3:810 RDMSR instruction 3:701, 3:705
PSR (processor status register) 2:17, 2:20, 2:22, RDPMC instruction 3:703
2:152, 2:516 RDTSC instruction 3:705
PSRLD instruction 3:813 reader of a resource 3:355
PSRLQ instruction 3:813 real mode 1:12, 1:108, 1:110, 1:117, 1:119, 2:566,
PSRLW instruction 3:813 3:513, 3:530, 3:532, 3:548, 3:601, 3:687
psub 3:207 real number 3:469, 3:471, 3:475, 3:478, 3:488, 3:492,
PSUBB instruction 3:816 3:495, 3:504, 3:516, 3:519, 3:521, 3:524,
PSUBD instruction 3:816 3:527, 3:535, 3:537, 3:539, 3:541, 3:553,
3:556, 3:567, 3:569, 3:571, 3:844, 3:845,
PSUBSB instruction 3:819
3:846, 3:847, 3:848, 3:851
PSUBSW instruction 3:819
Real numbers
PSUBUSB instruction 3:822
encoding 3:846, 3:847, 3:851
PSUBUSW instruction 3:822 indefinite 3:851
PSUBW instruction 3:816 notation 3:845
PTA (Page Table Address) 2:59 system 3:844
PTA (Page Table Address) control register 2:28 recovery model 2:100, 2:101
ptc.e 2:47, 2:58, 2:64, 2:534, 2:540, 2:541, 2:542, region identifier (RID) 2:44, 2:55, 2:533
3:210, 3:329, 3:332, 3:362, 3:369, 3:373, region register (RR) 2:55, 2:533
3:378 register dependency 1:37, 1:39
ptc.g 2:47, 2:54, 2:55, 2:57, 2:64, 2:71, 2:77, 2:78, read-after-write (RAW) 1:37
2:541, 2:542, 3:329, 3:331, 3:362, 3:366, write-after-read (WAR) 1:37
3:369, 3:373, 3:378 write-after-write (WAW) 1:37
ptc.g, ptc.ga 3:211 register file transfers 1:76
ptc.ga 1:62, 2:47, 2:54, 2:55, 2:58, 2:64, 2:71, 2:77, register preservation 2:523
2:78, 2:534, 2:541, 2:542, 3:329, 3:331,
preservation at different points in the OS 2:526
3:362, 3:366, 3:369, 3:373, 3:378
preservation of stacked registers in the OS 2:526
ptc.l 3:213 preserving floating-point registers 2:525
ptr 2:46, 2:54, 2:58, 2:64, 2:537, 2:539, 2:595, 3:214, preserving general registers 2:524
3:329, 3:331, 3:362, 3:366, 3:369, 3:373,

Intel® Itanium® Architecture Software Developer’s Manual Index-19


Index
register rotation 1:17, 1:25, 1:178, 1:179 3:371, 3:372, 3:378
initializing rotating predicates 1:52, 1:179 RSE byte order 2:135
register stack 1:16, 1:25, 1:26, 1:43, 1:44, 1:45, 1:46, RSE control instructions 2:137, 2:138
2:99, 2:129, 2:131, 2:132, 2:133, 2:595, RSE initialization 2:144
3:470, 3:475, 3:482, 3:485, 3:491, 3:494, RSE internal state 2:131
3:498, 3:500, 3:503, 3:504, 3:507, 3:509, RSE interruptions 2:139
3:515, 3:519, 3:527, 3:530, 3:532, 3:539, RSE mode 1:27, 2:134
3:543, 3:552, 3:555, 3:560, 3:565, 3:567, RSE operation instructions and state modification
3:569, 3:571, 3:619, 3:770 2:134
clean partition 2:132, 2:139 RSE privilege level 1:27, 2:135
current frame 1:25, 1:44, 2:98, 2:99, 2:129, 2:132, rsm 2:22, 2:23, 2:38, 2:116, 2:117, 2:152, 2:251,
2:595, 3:464 2:518, 2:574, 2:587, 3:219, 3:328, 3:331,
dirty partition 2:132, 2:139 3:378, 3:379, 3:716
invalid partition 2:132, 2:139 RSM instruction 3:716
register stack instructions 1:45 rum 1:77, 2:17, 2:22, 2:152, 2:587, 3:221, 3:328,
register stack operation 1:43 3:331, 3:358, 3:366, 3:379
register stack configuration 1:26, 1:27, 1:46, 2:131,
2:134, 2:135, 2:595
RSC 1:27, 1:46, 2:131, 2:134, 2:135, 2:139, 2:595, S
3:375, 3:376 SAL 1:5, 1:19, 2:5, 2:566, 2:591, 2:592, 2:593, 2:596,
register stack engine 1:27, 1:43, 2:98, 2:129 2:597, 2:598, 2:599, 2:600, 2:601, 2:602, 3:5,
release semantics 1:68, 2:257, 2:258, 2:483 3:718, 3:719, 3:720, 3:721, 3:731
release stores 2:484, 2:486, 2:497, 2:498 SAL procedure calls 2:598
Remainder, FPU operation 3:521, 3:524 SAL instruction 3:718, 3:750
REP/REPE/REPZ/REPNE/REPNZ prefixes 3:441, SALE_ENTRY 2:284
3:584, 3:678, 3:707 SAR instruction 3:718, 3:750
reserved 1:21, 1:22, 2:109, 2:333, 3:273, 3:453, 3:454, SAS (single address space) 1:18, 2:43, 2:533, 2:535,
3:587, 3:621, 3:623, 3:649, 3:658, 3:659, 2:537
3:687, 3:688, 3:689, 3:701, 3:716, 3:717, SBB instruction 3:642, 3:722
3:753, 3:759, 3:853, 3:857, 3:858, 3:859, SC (sequential consistency)
3:861, 3:862, 3:864, 3:866, 3:878, 3:879, SC system 2:500
3:880, 3:881, 3:882, 3:884, 3:885, 3:886, Scale, FPU operation 3:535
3:896, 3:897, 3:899, 3:900, 3:902, 3:903, SCAS instruction 3:707, 3:724
3:907, 3:910, 3:918, 3:921, 3:925, 3:927,
SCASB instruction 3:724
3:929, 3:930, 3:945, 3:947, 3:949, 3:950
SCASD instruction 3:724
Reserved bits 3:853
SCASW instruction 3:724
RESET (Processor Reset) 2:91
scratch 2:333
RET instruction 3:710
scratch registers 2:93, 2:523, 2:528
rfi 1:12, 1:37, 1:39, 1:41, 1:50, 1:71, 1:107, 2:22, 2:23,
2:65, 2:91, 2:93, 2:96, 2:98, 2:99, 2:100, Segment descriptor
2:104, 2:131, 2:133, 2:134, 2:139, 2:140, segment limit 3:648
2:141, 2:142, 2:196, 2:198, 2:199, 2:514, Segment limit 3:648
2:518, 2:528, 2:529, 2:595, 3:216, 3:333, Segment registers
3:339, 3:359, 3:360, 3:361, 3:364, 3:365, moving values to and from 3:654
3:366, 3:367, 3:368, 3:370, 3:371, 3:373, Segment selector
3:378, 3:379 RPL field 3:401
RNAT (RSE NaT Collection Register) application register self test state parameter 2:286
1:26 self-modifying code 2:507
ROL instruction 3:697 Semaphore 3:320
ROR instruction 3:697 semaphore instructions 1:38, 1:55, 2:484, 3:320
Rotate operation 3:697 semaphore operations 1:55, 2:256, 2:486, 2:496
Rounding Semaphores
round to integer, FPU operation 3:529 behavior of uncacheable and misaligned semaphores
RPL field 3:401 2:485
RSC (Register Stack Configuration Register) application sequential consistency (SC)
register 1:26 SC system 2:500
RSE 1:27, 1:28, 1:43, 1:140, 2:98, 2:129, 2:130, 2:131, sequential semantics 2:79
2:133, 2:134, 2:135, 2:137, 2:138, 2:139, inter-processor interrupt messages 2:79, 2:124,
2:140, 2:141, 2:142, 2:143, 2:595, 3:366, 2:125, 2:126

Index-20 Intel® Itanium® Architecture Software Developer’s Manual


Index
sequential pages 2:79 combining data and control speculation 1:152
serialization 2:17, 2:18, 2:19, 2:518, 3:355, 3:356, control speculation 1:14, 1:56, 1:57, 1:58, 1:59,
3:357, 3:452, 3:601, 3:619 1:63, 1:138, 1:147, 1:150, 1:151, 2:553
SETcc instructions 3:726 control speculation example 1:151
setf 3:222 control speculative load 1:14, 1:150, 1:151, 1:152
SF (sign) flag, EFLAGS register 3:395, 3:397 data speculation 1:14, 1:15, 1:59, 1:60, 1:63, 1:64,
1:139, 1:147, 1:148, 2:553
SGDT instruction 3:729
recovery code 1:14, 1:15, 1:60, 1:149, 1:150,
SHAF instruction 3:717 1:151, 1:152, 2:552, 2:553
shl 3:224 recovery code example 1:149
SHL instruction 3:718, 3:750 speculation attributes 2:75
shladd 3:225 speculation check 1:57, 1:60, 1:152, 3:300, 3:322
shladdp4 3:226 speculation considerations 1:153
SHLD instruction 3:732 speculation model in the itanium architecture 1:147,
shr 3:227 1:148
SHR instruction 3:718, 3:750 speculation recovery code 2:553
SHRD instruction 3:734 speculation related exception handlers 2:553
speculative 1:14, 1:15, 1:56, 1:57, 1:59, 2:75, 2:76,
shrp 3:228
2:83, 2:553
SIDT instruction 3:729 speculative load exceptions 2:101
Sign, floating-point number 3:845 unaligned handler 2:553
signed infinities 3:843, 3:846, 3:848 speculative advanced load 1:152
Signed infinity 3:848 spill/fill 1:58, 1:87, 1:93, 2:98, 2:129, 2:130, 2:133
Signed zero 3:846 spin lock 2:501, 2:502
signed zeros 3:843, 3:844, 3:846 square root operations 1:202
Significand Square root, FPU operation 3:541
extracting from floating-point number 3:567 srlz 3:229
of floating-point number 3:845 SS register 3:625, 3:655, 3:682
SIMD (single instruction multiple data) 3:834 SSD (IA-32 Stack Segment Descriptor) application
Sine, FPU operation 3:537, 3:539 register 1:26
single address space (SAS) 1:18, 2:43, 2:533, 2:535, ssm 2:22, 2:23, 2:38, 2:116, 2:152, 2:153, 2:518,
2:537 2:587, 3:230, 3:328, 3:331, 3:361, 3:378,
single instruction multiple data (SIMD) 3:834 3:379, 3:716
single stepping 2:100 st 1:15, 1:53, 1:64, 2:78, 2:488, 2:489, 2:490, 2:491,
Single-precision, IEEE floating-point format 3:850 2:492, 2:493, 2:495, 2:498, 2:499, 3:378,
Single-real floating-point format 3:850 3:467, 3:469, 3:470, 3:473, 3:475, 3:478,
SLDT instruction 3:737 3:480, 3:482, 3:483, 3:485, 3:486, 3:488,
SMSW instruction 3:739 3:491, 3:494, 3:497, 3:498, 3:500, 3:504,
SNaN 3:505, 3:507, 3:509, 3:515, 3:519, 3:520,
description of 3:848 3:521, 3:522, 3:524, 3:525, 3:527, 3:529,
operating on 3:849 3:530, 3:532, 3:535, 3:536, 3:537, 3:539,
typical uses of 3:849 3:541, 3:543, 3:552, 3:555, 3:558, 3:560,
3:561, 3:563, 3:565, 3:567, 3:569, 3:570,
sof field
3:571
CFM.sof 2:96, 2:132, 2:133, 2:134, 2:138, 2:139,
st.rel 1:53, 1:64, 1:68, 2:78, 2:126, 2:484, 2:489,
2:141
2:491, 2:492, 2:493, 2:496, 2:497, 2:498,
software pipelining 1:13, 1:17, 1:141, 1:177, 1:189, 2:499
1:191
st.spill 1:53, 1:64, 2:78
sol field
st1 1:62, 3:305, 3:306, 3:313, 3:378, 3:878, 3:881,
CFM.sol 2:134, 2:139, 2:141 3:882
special instruction notations 3:279 st16 3:313
special use registers 2:523 st8.spill 1:28, 1:39, 1:40, 1:55, 1:58, 1:59, 1:151,
Speculation 1:13, 1:14, 1:138, 1:143, 1:147, 1:153, 2:523, 2:524, 3:305, 3:306, 3:313, 3:358,
2:75, 2:76, 2:551, 2:553 3:360, 3:368, 3:378
advanced load 1:53, 1:59, 1:60, 1:61, 1:63, 1:148, stack frame 1:16, 1:25, 1:27, 1:39, 1:43, 1:44, 1:45,
1:149, 1:150, 1:157, 2:76, 2:82, 2:83 1:46, 2:129, 2:131, 3:464, 3:465, 3:466
advanced load check 1:60, 1:61, 1:150, 3:322 Stack pointer (ESP register) 3:690
advanced load example 1:149
stacked calling convention 2:333
always-defer model 2:100
check load 1:53, 1:59, 1:60, 1:61, 1:62, 1:63, 1:64, stacked registers 1:23, 1:44, 1:140, 2:129, 2:130,
1:149, 1:150, 2:82, 2:83 2:132, 2:523, 2:526, 2:595

Intel® Itanium® Architecture Software Developer’s Manual Index-21


Index
deallocated 2:141 3:544, 3:546, 3:548, 3:550, 3:553, 3:556,
stacked general registers 1:23, 2:129, 2:524 3:558, 3:565, 3:567, 3:569, 3:571, 3:572,
state mappings 3:381 3:575, 3:579, 3:642, 3:658, 3:660, 3:667,
static calling convention 2:333 3:674, 3:698, 3:699, 3:701, 3:707, 3:720,
static general registers 1:23, 2:129, 2:524 3:732, 3:733, 3:734, 3:735, 3:737, 3:739,
Status flags, EFLAGS register 3:436, 3:439, 3:480, 3:751, 3:753, 3:756, 3:759, 3:767
3:485, 3:610, 3:726, 3:751 unmodified 1:112, 1:113, 2:232, 3:604
STC instruction 3:741 system register resources 2:17, 2:19, 2:20
STD instruction 3:742
stf 1:53, 1:64, 2:78, 3:233, 3:307, 3:308, 3:316, 3:317, T
3:378
tak 2:57, 2:58, 2:70, 2:99, 2:536, 3:239, 3:329, 3:332,
stf.spill 1:53, 1:55, 1:58, 1:59, 1:64, 1:87, 1:151, 2:78, 3:373, 3:378
2:523, 2:525, 3:307, 3:308, 3:316, 3:317,
Tangent, FPU operation 3:527
3:378
Task gate 3:617
STI instruction 3:743
Task register
store buffers 2:486, 2:493, 2:495
loading 3:652
store instruction 2:484, 3:895, 3:898, 3:901, 3:904,
storing 3:748
3:906, 3:947, 3:948, 3:950
Task switch
STOS instruction 3:707, 3:746
CALL instruction 3:418
STOSB instruction 3:746
return from nested task, IRET instruction 3:601
STOSD instruction 3:746
tbit 1:40, 1:50, 1:52, 1:57, 1:139, 3:240, 3:297, 3:373,
STOSW instruction 3:746 3:378
STR instruction 3:748 TCs (translation caches) 2:539
streaming SIMD extension technology 1:108, 3:381 template 1:35, 1:36, 1:137, 3:273, 3:274
String operations 3:441, 3:584, 3:644, 3:662, 3:678, temporal hint 1:209, 3:949
3:746
TEST instruction 3:751
sub 3:235
tf 3:304
SUB instruction 3:394, 3:458, 3:642, 3:749
thash 2:58, 2:61, 2:62, 2:64, 2:546, 2:547, 3:244,
subpaging 2:549 3:329, 3:332, 3:361, 3:366, 3:373, 3:378
sum 1:77, 2:17, 2:22, 2:152, 2:153, 2:587, 3:236, Time-stamp counter, reading 3:705
3:328, 3:331, 3:358, 3:366, 3:378, 3:379,
Tiny number 3:847
3:457, 3:470, 3:761, 3:932, 3:941, 3:942
TLB 1:61, 2:21, 2:33, 2:36, 2:37, 2:43, 2:44, 2:45,
supervisor accesses 2:255
2:46, 2:47, 2:48, 2:49, 2:50, 2:51, 2:52, 2:53,
sxt 3:237 2:54, 2:55, 2:57, 2:58, 2:59, 2:60, 2:61, 2:62,
sync 3:238 2:63, 2:64, 2:65, 2:66, 2:67, 2:108, 2:109,
system abstraction layer 1:5, 1:19, 2:5, 2:591, 3:5 2:253, 2:254, 2:595, 3:399, 3:401, 3:403,
system abstraction layer (SAL) 2:271, 2:333 3:405, 3:407, 3:411, 3:412, 3:414, 3:416,
system architecture features 1:18, 2:15 3:425, 3:437, 3:439, 3:442, 3:445, 3:446,
support for multiple address space operating systems 3:459, 3:462, 3:465, 3:471, 3:473, 3:476,
1:18 3:483, 3:493, 3:496, 3:499, 3:500, 3:505,
support for single address space operating systems 3:507, 3:511, 3:513, 3:517, 3:531, 3:533,
1:18 3:544, 3:546, 3:549, 3:550, 3:554, 3:557,
system performance and scalability 1:18 3:575, 3:579, 3:580, 3:581, 3:582, 3:585,
system security and supportability 1:19 3:600, 3:607, 3:617, 3:623, 3:626, 3:630,
system calls 2:528, 2:529, 2:530 3:642, 3:645, 3:650, 3:656, 3:658, 3:663,
system descriptors 2:233 3:664, 3:665, 3:667, 3:669, 3:672, 3:674,
system flag interception 2:231 3:677, 3:680, 3:683, 3:686, 3:689, 3:691,
3:694, 3:696, 3:699, 3:709, 3:714, 3:720,
system memory model 2:252
3:723, 3:725, 3:727, 3:733, 3:735, 3:747,
system register model 2:21, 2:231 3:749, 3:751, 3:755, 3:761, 3:763, 3:765,
IA-32 state 1:112, 2:231, 2:232 3:767, 3:772, 3:773, 3:776, 3:778, 3:781,
shared 1:112, 2:232, 2:233, 3:642 3:784, 3:787, 3:789, 3:791, 3:794, 3:797,
undefined 1:112, 2:232, 3:405, 3:407, 3:409, 3:410, 3:799, 3:801, 3:803, 3:805, 3:808, 3:811,
3:412, 3:414, 3:416, 3:454, 3:457, 3:458, 3:814, 3:817, 3:820, 3:823, 3:826, 3:829,
3:462, 3:467, 3:469, 3:471, 3:473, 3:476, 3:831, 3:855, 3:856, 3:857, 3:858, 3:860,
3:478, 3:479, 3:480, 3:487, 3:489, 3:490, 3:863, 3:866, 3:867, 3:869, 3:871, 3:872,
3:492, 3:495, 3:497, 3:498, 3:500, 3:502, 3:873, 3:875, 3:876, 3:877, 3:880, 3:884,
3:505, 3:507, 3:509, 3:511, 3:516, 3:518, 3:886, 3:888, 3:890, 3:892, 3:894, 3:896,
3:519, 3:529, 3:536, 3:538, 3:540, 3:541, 3:899, 3:902, 3:905, 3:907, 3:908, 3:909,

Index-22 Intel® Itanium® Architecture Software Developer’s Manual


Index
3:910, 3:911, 3:913, 3:915, 3:916, 3:918, 3:469, 3:470, 3:471, 3:472, 3:476, 3:478,
3:919, 3:920, 3:921, 3:922, 3:923, 3:925, 3:480, 3:483, 3:486, 3:487, 3:488, 3:489,
3:927, 3:929, 3:930, 3:932, 3:934, 3:935, 3:491, 3:492, 3:493, 3:494, 3:495, 3:496,
3:936, 3:937, 3:938, 3:940, 3:942, 3:943, 3:498, 3:499, 3:505, 3:515, 3:516, 3:519,
3:947, 3:948 3:520, 3:521, 3:522, 3:523, 3:524, 3:525,
page not present vector 2:109, 2:164, 2:548 3:526, 3:527, 3:528, 3:529, 3:535, 3:536,
TLB miss 2:49, 2:58, 2:59, 2:62, 2:64, 2:65, 2:66, 3:537, 3:538, 3:539, 3:540, 3:541, 3:543,
2:67, 2:545 3:544, 3:552, 3:553, 3:555, 3:556, 3:557,
TLB miss handlers 2:66, 2:545, 2:548 3:558, 3:561, 3:565, 3:567, 3:569, 3:570,
TLB purges 2:46, 2:48 3:571, 3:572, 3:847, 3:848, 3:855, 3:856,
translation insertion format 2:53 3:876, 3:877, 3:885, 3:886, 3:908, 3:909,
VHPT translation vector 2:108, 2:164, 2:546 3:922, 3:923
TLB entry, invalidating (flushing) 3:600 Underflow, numeric 3:847
tnat 1:40, 1:50, 1:52, 1:57, 1:59, 3:245, 3:297, 3:298, unimplemented addresses 2:70
3:373, 3:378 unimplemented physical address bits 2:69
tpa 2:58, 2:70, 2:99, 3:247, 3:329, 3:332, 3:373, unimplemented virtual address bits 2:70
3:378 unnormalized numbers 1:83
TPR (Task Priority Register) control register 2:29 unordered semantics 2:483
TRs (translation registers) 2:537 Unordered values 3:482, 3:485, 3:558, 3:560
translation caches (TCs) 2:539 unpack 3:249
TC insertion 2:539 unsupported data reference handler 2:555, 2:556
TC purge 2:537, 2:540 user mask (UM) 1:21, 1:30
translation lookaside buffer (TLB) 2:21, 2:43, 2:45,
3:600
translation registers (TRs) 2:537 V
TR insertion 2:538 vector numbers 2:92, 2:114, 2:573, 3:389, 3:595
TR purge 2:537, 2:538, 2:539 VERR instruction 3:754
trap 1:101, 1:102, 2:96, 2:97, 2:106, 2:108, 2:513, Version information, processor 3:448
3:432, 3:587, 3:588, 3:589, 3:590, 3:591, VERW instruction 3:754
3:595, 3:596, 3:597, 3:603, 3:607, 3:619, VHPT (virtual hash page table) 2:33, 2:39, 2:43, 2:58
3:620, 3:623, 3:649, 3:655, 3:656, 3:681, VHPT 2:33, 2:39, 2:43, 2:44, 2:45, 2:47, 2:48, 2:54,
3:683, 3:689, 3:696, 3:743, 3:744 2:55, 2:58, 2:59, 2:60, 2:61, 2:62, 2:63, 2:64,
TS (task switched) flag, CR0 register 3:433 2:65, 2:66, 2:67, 2:108, 2:542, 2:543, 2:544,
TSC (IA-32 time stamp counter ) 1:29, 1:114, 2:32, 2:595, 3:399, 3:401, 3:403, 3:405, 3:407,
2:579 3:411, 3:412, 3:414, 3:416, 3:425, 3:437,
TSD flag, CR4 register 3:705 3:439, 3:442, 3:445, 3:446, 3:459, 3:462,
TSS 3:465, 3:471, 3:473, 3:476, 3:483, 3:493,
relationship to task register 3:748 3:496, 3:499, 3:500, 3:505, 3:507, 3:511,
ttag 2:58, 2:61, 2:62, 2:64, 2:546, 3:248, 3:329, 3:513, 3:517, 3:531, 3:533, 3:544, 3:546,
3:332, 3:366, 3:373, 3:378 3:549, 3:550, 3:554, 3:557, 3:575, 3:579,
3:581, 3:582, 3:585, 3:607, 3:617, 3:623,
3:626, 3:630, 3:642, 3:645, 3:650, 3:656,
U 3:663, 3:664, 3:665, 3:667, 3:669, 3:672,
UC memory attribute 2:262 3:674, 3:677, 3:680, 3:683, 3:686, 3:689,
3:691, 3:694, 3:696, 3:699, 3:709, 3:714,
UD2 instruction 3:753
3:720, 3:723, 3:725, 3:727, 3:733, 3:735,
UM (user mask) 1:21, 1:30 3:747, 3:749, 3:751, 3:755, 3:761, 3:763,
unaligned reference handler 2:553, 2:554, 2:555 3:765, 3:767, 3:772, 3:773, 3:776, 3:778,
UNAT (User NaT Collection Register) application 3:781, 3:784, 3:787, 3:789, 3:791, 3:794,
register 1:26 3:797, 3:799, 3:801, 3:803, 3:805, 3:808,
Uncacheable 2:71, 2:72, 2:73, 3:949 3:811, 3:814, 3:817, 3:820, 3:823, 3:826,
uncacheable pages 2:74 3:829, 3:831, 3:855, 3:856, 3:857, 3:858,
unchanged 2:23, 2:171, 2:334, 3:488, 3:503, 3:527, 3:860, 3:863, 3:866, 3:867, 3:869, 3:871,
3:535, 3:537, 3:539, 3:688, 3:710, 3:887, 3:872, 3:873, 3:875, 3:876, 3:877, 3:880,
3:889, 3:891, 3:893, 3:897, 3:898, 3:900, 3:884, 3:886, 3:888, 3:890, 3:892, 3:894,
3:901 3:896, 3:899, 3:902, 3:905, 3:907, 3:908,
Undefined 3:909, 3:910, 3:911, 3:913, 3:915, 3:916,
format opcodes 3:558 3:918, 3:919, 3:920, 3:921, 3:922, 3:923,
undefined behavior 1:41 3:925, 3:927, 3:929, 3:930, 3:932, 3:934,
3:935, 3:936, 3:937, 3:938, 3:940, 3:942,
underflow 1:16, 1:101, 1:103, 2:560, 2:564, 3:467,

Intel® Itanium® Architecture Software Developer’s Manual Index-23


Index
3:943, 3:947, 3:948
TLB and VHPT search faults 2:66
W
TLB/VHPT search 2:65, 2:66 WAIT/FWAIT instructions 3:756
translation searching 2:65 WAR (write-after-read) dependency 3:355
VHPT configuration 2:59 WAW (write-after-write) dependency 3:355
VHPT searching 2:59 WBINVD instruction 3:757
VHPT short format 2:60 Write BSPSTORE 2:143
VHPT short-format index 2:62 Write-back and invalidate caches 3:757
VHPT updates 2:544 writer of a resource 3:355
VHPT walker 2:45, 2:48, 2:55, 2:58, 2:59, 2:60, WRMSR instruction 3:759
2:61, 2:62, 2:63, 2:64, 2:65, 2:66, 2:542,
2:543, 2:544, 2:545
virtual addressing 2:43, 2:44, 2:71, 2:83, 2:595, 2:598, X
2:599 XADD instruction 3:642, 3:761
virtual aliasing 2:68 xchg 1:53, 1:55, 1:64, 1:68, 1:69, 2:78, 2:79, 2:82,
virtual hash page table (VHPT) 2:33, 2:39, 2:43, 2:58 2:193, 2:484, 2:496, 3:253, 3:379, 3:409,
Virtual Page Number (VPN) 2:44 3:642, 3:763, 3:764
virtual region number (VRN) 2:44, 2:70, 2:533 XCHG instruction 3:642, 3:763
virtualized interrupt flag 2:235 XLAT/XLATB instruction 3:765
visible 1:68, 2:78, 2:79, 2:484, 2:490, 3:622, 3:648, xma 3:255
3:950 xmpy 3:257
VM (virtual 8086 mode) flag, EFLAGS register 3:601 xor 3:258
VM86 1:12, 1:108, 1:110, 1:117, 1:118, 2:237, 2:242, XOR instruction 3:642, 3:767
2:566, 3:593, 3:594
VME extensions 2:235, 2:242
vmsw 3:252 Z
VPN (Virtual Page Number) 2:44 Zero, floating-point format 3:846
VRN (virtual region number) 2:44, 2:70, 2:533 ZF (zero) flag, EFLAGS register 3:444, 3:446, 3:622,
3:646, 3:648, 3:707, 3:754
zxt 3:259

Index-24 Intel® Itanium® Architecture Software Developer’s Manual

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy