amd64 architecture programmer’s manual, volume 4: … · advanced micro devices amd64 technology...

432
Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication No. Revision Date 26568 3.10 September 2007

Upload: vuongdang

Post on 27-Jun-2018

277 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Advanced Micro Devices

AMD64 Technology

AMD64 ArchitectureProgrammer’s Manual

Volume 4:128-Bit Media Instructions

Publication No. Revision Date

26568 3.10 September 2007

Page 2: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

AMD64 Technology 26568—Rev. 3.10—September 2007

Trademarks

AMD, the AMD arrow logo, AMD Athlon, and AMD Opteron, and combinations thereof, and 3DNow! are trademarks,and AMD-K6 is a registered trademark of Advanced Micro Devices, Inc.

MMX is a trademark and Pentium is a registered trademark of Intel Corporation.

Windows NT is a registered trademark of Microsoft Corporation.

Other product names used in this publication are for identification purposes only and may be trademarks of theirrespective companies.

© 2002 – 2007 Advanced Micro Devices, Inc. All rights reserved.

The contents of this document are provided in connection with Advanced MicroDevices, Inc. (“AMD”) products. AMD makes no representations or warranties withrespect to the accuracy or completeness of the contents of this publication andreserves the right to make changes to specifications and product descriptions atany time without notice. The information contained herein may be of a preliminaryor advance nature and is subject to change without notice. No license, whetherexpress, implied, arising by estoppel or otherwise, to any intellectual property rightsis granted by this publication. Except as set forth in AMD’s Standard Terms andConditions of Sale, AMD assumes no liability whatsoever, and disclaims anyexpress or implied warranty, relating to its products including, but not limited to, theimplied warranty of merchantability, fitness for a particular purpose, or infringementof any intellectual property right.

AMD’s products are not designed, intended, authorized or warranted for use ascomponents in systems intended for surgical implant into the body, or in other appli-cations intended to support or sustain life, or in any other application in which thefailure of AMD’s product could create a situation where personal injury, death, orsevere property or environmental damage may occur. AMD reserves the right todiscontinue or make changes to its products at any time without notice.

Page 3: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Contents i

26568—Rev. 3.10—September 2007 AMD64 Technology

Contents

Revision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi

Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiiiAbout This Book. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiiiAudience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiiiOrganization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiiiDefinitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xivRelated Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiv

1 128-Bit Media Instruction Reference. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1ADDPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3ADDPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5ADDSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8ADDSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10ADDSUBPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12ADDSUBPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14ANDNPD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17ANDNPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19ANDPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21ANDPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23CMPPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25CMPPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29CMPSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32CMPSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35COMISD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38COMISS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41CVTDQ2PD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44CVTDQ2PS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46CVTPD2DQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48CVTPD2PI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50CVTPD2PS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53CVTPI2PD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56CVTPI2PS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58CVTPS2DQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60CVTPS2PD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62CVTPS2PI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64CVTSD2SI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66CVTSD2SS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69CVTSI2SD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71CVTSI2SS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73CVTSS2SD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75CVTSS2SI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77CVTTPD2DQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80CVTTPD2PI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82CVTTPS2DQ. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

Page 4: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

ii Contents

AMD64 Technology 26568—Rev. 3.10—September 2007

CVTTPS2PI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87CVTTSD2SI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89CVTTSS2SI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92DIVPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95DIVPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98DIVSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101DIVSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103EXTRQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105FXRSTOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107FXSAVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109HADDPD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111HADDPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113HSUBPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116HSUBPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118INSERTQ. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121LDDQU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123LDMXCSR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125MASKMOVDQU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127MAXPD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129MAXPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131MAXSD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133MAXSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135MINPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137MINPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139MINSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141MINSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143MOVAPD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145MOVAPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147MOVD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150MOVDDUP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153MOVDQ2Q . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155MOVDQA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157MOVDQU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159MOVHLPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161MOVHPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163MOVHPS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165MOVLHPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167MOVLPD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169MOVLPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171MOVMSKPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173MOVMSKPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175MOVNTDQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177MOVNTPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179MOVNTPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181MOVNTSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183MOVNTSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185MOVQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

Page 5: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Contents iii

26568—Rev. 3.10—September 2007 AMD64 Technology

MOVQ2DQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189MOVSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191MOVSHDUP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194MOVSLDUP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196MOVSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198MOVUPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200MOVUPS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202MULPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205MULPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207MULSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210MULSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212ORPD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214ORPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216PACKSSDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218PACKSSWB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220PACKUSWB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222PADDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224PADDD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226PADDQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228PADDSB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230PADDSW. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232PADDUSB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234PADDUSW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236PADDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238PAND. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240PANDN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242PAVGB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244PAVGW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246PCMPEQB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248PCMPEQD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250PCMPEQW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252PCMPGTB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254PCMPGTD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256PCMPGTW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258PEXTRW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260PINSRW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262PMADDWD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264PMAXSW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266PMAXUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268PMINSW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270PMINUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272PMOVMSKB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274PMULHUW. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276PMULHW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278PMULLW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280PMULUDQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282POR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284

Page 6: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

iv Contents

AMD64 Technology 26568—Rev. 3.10—September 2007

PSADBW. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286PSHUFD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288PSHUFHW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291PSHUFLW. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294PSLLD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297PSLLDQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299PSLLQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301PSLLW. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303PSRAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305PSRAW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307PSRLD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309PSRLDQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311PSRLQ. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313PSRLW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315PSUBB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317PSUBD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319PSUBQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321PSUBSB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323PSUBSW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325PSUBUSB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327PSUBUSW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329PSUBW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331PUNPCKHBW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333PUNPCKHDQ. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335PUNPCKHQDQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337PUNPCKHWD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339PUNPCKLBW. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341PUNPCKLDQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343PUNPCKLQDQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345PUNPCKLWD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347PXOR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349RCPPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351RCPSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353RSQRTPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355RSQRTSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357SHUFPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359SHUFPS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361SQRTPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364SQRTPS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366SQRTSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368SQRTSS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370STMXCSR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372SUBPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373SUBPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375SUBSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378SUBSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380UCOMISD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382

Page 7: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Contents v

26568—Rev. 3.10—September 2007 AMD64 Technology

UCOMISS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385UNPCKHPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388UNPCKHPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390UNPCKLPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392UNPCKLPS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394XORPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396XORPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401

Page 8: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

vi Contents

AMD64 Technology 26568—Rev. 3.10—September 2007

Page 9: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Figures vii

26568—Rev. 3.10—September 2007 AMD64 Technology

Figures

Figure 1-1. Diagram Conventions for 128-Bit Media Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Page 10: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

viii Figures

AMD64 Technology 26568—Rev. 3.10—September 2007

Page 11: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Tables ix

26568—Rev. 3.10—September 2007 AMD64 Technology

Tables

Table 1-1. Immediate Operand Values for Comparison Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

Table 1-2. Immediate-Byte Operand Encoding for 128-Bit PEXTRW . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

Table 1-3. Immediate-Byte Operand Encoding for 128-Bit PINSRW. . . . . . . . . . . . . . . . . . . . . . . . . . . . 262

Table 1-4. Immediate-Byte Operand Encoding for PSHUFD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

Table 1-5. Immediate-Byte Operand Encoding for PSHUFHW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

Table 1-6. Immediate-Byte Operand Encoding for PSHUFLW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295

Table 1-7. Immediate-Byte Operand Encoding for SHUFPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

Table 1-8. Immediate-Byte Operand Encoding for SHUFPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362

Page 12: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

x Tables

AMD64 Technology 26568—Rev. 3.10—September 2007

Page 13: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Revision History xi

26568—Rev. 3.10—September 2007 AMD64 Technology

Revision History

Date Revision Description

September 2007

3.10 Added minor clarifications and corrected typographical and formatting errors.

July 2007 3.09 Added the following instructions: EXTRQ on page 105, INSERTQ on page 121, MOVNTSD on page 183, and MOVNTSS on page 185.Added misaligned exception mask (MXCSR.MM) information.Added imm8 values with corresponding mnemonics to CMPPD on page 25, CMPPS on page 29, CMPSD on page 32, and CMPSS on page 35.Reworded CPUID information in condition tables.Added minor clarifications and corrected typographical and formatting errors.

September 2006

3.08 Made minor corrections.

December 2005

3.07 Made minor editorial and formatting changes.

January 2005 3.06Added documentation on SSE3 instructions. Corrected numerous minor factual errors and typos.

September 2003

3.05 Made numerous small factual corrections.

April 2003 3.04 Made minor corrections.

Page 14: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

xii Revision History

AMD64 Technology 26568—Rev. 3.10—September 2007

Page 15: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Preface xiii

26568—Rev. 3.10—September 2007 AMD64 Technology

Preface

About This Book

This book is part of a multivolume work entitled the AMD64 Architecture Programmer’s Manual. Thistable lists each volume and its order number.

Audience

This volume (Volume 4) is intended for all programmers writing application or system software forprocessors that implement the AMD64 architecture.

Organization

Volumes 3, 4, and 5 describe the AMD64 architecture’s instruction set in detail. Together, they covereach instruction’s mnemonic syntax, opcodes, functions, affected flags, and possible exceptions.

The AMD64 instruction set is divided into five subsets:

• General-purpose instructions

• System instructions

• 128-bit media instructions

• 64-bit media instructions

• x87 floating-point instructions

Several instructions belong to—and are described identically in—multiple instruction subsets.

This volume describes the 128-bit media instructions. The index at the end cross-references topicswithin this volume. For other topics relating to the AMD64 architecture, and for information oninstructions in other subsets, see the tables of contents and indexes of the other volumes.

Title Order No.

Volume 1: Application Programming 24592

Volume 2: System Programming 24593

Volume 3: General-Purpose and System Instructions 24594

Volume 4: 128-Bit Media Instructions 26568

Volume 5: 64-Bit Media and x87 Floating-Point Instructions 26569

Page 16: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

xiv Preface

AMD64 Technology 26568—Rev. 3.10—September 2007

Definitions

Many of the following definitions assume an in-depth knowledge of the legacy x86 architecture. See“Related Documents” on page xxiv for descriptions of the legacy x86 architecture.

Terms and Notation

In addition to the notation described below, “Opcode-Syntax Notation” in Volume 3 describes notationrelating specifically to opcodes.

1011bA binary value—in this example, a 4-bit value.

F0EAhA hexadecimal value—in this example a 2-byte value.

[1,2)A range that includes the left-most value (in this case, 1) but excludes the right-most value (in thiscase, 2).

7–4A bit range, from bit 7 to 4, inclusive. The high-order bit is shown first.

128-bit media instructionsInstructions that use the 128-bit XMM registers. These are a combination of the SSE, SSE2 andSSE3 instruction sets.

64-bit media instructionsInstructions that use the 64-bit MMX registers. These are primarily a combination of MMX™ and3DNow!™ instruction sets, with some additional instructions from the SSE and SSE2 instructionsets.

16-bit modeLegacy mode or compatibility mode in which a 16-bit address size is active. See legacy mode andcompatibility mode.

32-bit modeLegacy mode or compatibility mode in which a 32-bit address size is active. See legacy mode andcompatibility mode.

64-bit modeA submode of long mode. In 64-bit mode, the default address size is 64 bits and new features, suchas register extensions, are supported for system and application software.

#GP(0)Notation indicating a general-protection exception (#GP) with error code of 0.

Page 17: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Preface xv

26568—Rev. 3.10—September 2007 AMD64 Technology

absoluteSaid of a displacement that references the base of a code segment rather than an instruction pointer.Contrast with relative.

ASIDAddress space identifier.

biased exponentThe sum of a floating-point value’s exponent and a constant bias for a particular floating-point datatype. The bias makes the range of the biased exponent always positive, which allows reciprocationwithout overflow.

byteEight bits.

clearTo write a bit value of 0. Compare set.

compatibility modeA submode of long mode. In compatibility mode, the default address size is 32 bits, and legacy 16-bit and 32-bit applications run without modification.

commitTo irreversibly write, in program order, an instruction’s result to software-visible storage, such as aregister (including flags), the data cache, an internal write buffer, or memory.

CPLCurrent privilege level.

CR0–CR4A register range, from register CR0 through CR4, inclusive, with the low-order register first.

CR0.PE = 1Notation indicating that the PE bit of the CR0 register has a value of 1.

directReferencing a memory location whose address is included in the instruction’s syntax as animmediate operand. The address may be an absolute or relative address. Compare indirect.

dirty dataData held in the processor’s caches or internal buffers that is more recent than the copy held inmain memory.

displacementA signed value that is added to the base of a segment (absolute addressing) or an instruction pointer(relative addressing). Same as offset.

Page 18: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

xvi Preface

AMD64 Technology 26568—Rev. 3.10—September 2007

doublewordTwo words, or four bytes, or 32 bits.

double quadwordEight words, or 16 bytes, or 128 bits. Also called octword.

DS:rSIThe contents of a memory location whose segment address is in the DS register and whose offsetrelative to that segment is in the rSI register.

EFER.LME = 0Notation indicating that the LME bit of the EFER register has a value of 0.

effective address sizeThe address size for the current instruction after accounting for the default address size and anyaddress-size override prefix.

effective operand sizeThe operand size for the current instruction after accounting for the default operand size and anyoperand-size override prefix.

elementSee vector.

exceptionAn abnormal condition that occurs as the result of executing an instruction. The processor’sresponse to an exception depends on the type of the exception. For all exceptions except 128-bitmedia SIMD floating-point exceptions and x87 floating-point exceptions, control is transferred tothe handler (or service routine) for that exception, as defined by the exception’s vector. Forfloating-point exceptions defined by the IEEE 754 standard, there are both masked and unmaskedresponses. When unmasked, the exception handler is called, and when masked, a default responseis provided instead of calling the handler.

FF /0Notation indicating that FF is the first byte of an opcode, and a subopcode in the ModR/M byte hasa value of 0.

flushAn often ambiguous term meaning (1) writeback, if modified, and invalidate, as in “flush the cacheline,” or (2) invalidate, as in “flush the pipeline,” or (3) change a value, as in “flush to zero.”

GDTGlobal descriptor table.

Page 19: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Preface xvii

26568—Rev. 3.10—September 2007 AMD64 Technology

GIFGlobal interrupt flag.

IDTInterrupt descriptor table.

IGNIgnore. Field is ignored.

indirectReferencing a memory location whose address is in a register or other memory location. Theaddress may be an absolute or relative address. Compare direct.

IRBThe virtual-8086 mode interrupt-redirection bitmap.

ISTThe long-mode interrupt-stack table.

IVTThe real-address mode interrupt-vector table.

LDTLocal descriptor table.

legacy x86The legacy x86 architecture. See “Related Documents” on page xxiv for descriptions of the legacyx86 architecture.

legacy modeAn operating mode of the AMD64 architecture in which existing 16-bit and 32-bit applications andoperating systems run without modification. A processor implementation of the AMD64architecture can run in either long mode or legacy mode. Legacy mode has three submodes, realmode, protected mode, and virtual-8086 mode.

long modeAn operating mode unique to the AMD64 architecture. A processor implementation of theAMD64 architecture can run in either long mode or legacy mode. Long mode has two submodes,64-bit mode and compatibility mode.

lsbLeast-significant bit.

LSBLeast-significant byte.

Page 20: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

xviii Preface

AMD64 Technology 26568—Rev. 3.10—September 2007

main memoryPhysical memory, such as RAM and ROM (but not cache memory) that is installed in a particularcomputer system.

mask(1) A control bit that prevents the occurrence of a floating-point exception from invoking anexception-handling routine. (2) A field of bits used for a control purpose.

MBZMust be zero. If software attempts to set an MBZ bit to 1, a general-protection exception (#GP)occurs.

memoryUnless otherwise specified, main memory.

ModRMA byte following an instruction opcode that specifies address calculation based on mode (Mod),register (R), and memory (M) variables.

moffsetA 16, 32, or 64-bit offset that specifies a memory operand directly, without using a ModRM or SIBbyte.

msbMost-significant bit.

MSBMost-significant byte.

multimedia instructionsA combination of 128-bit media instructions and 64-bit media instructions.

octwordSame as double quadword.

offsetSame as displacement.

overflowThe condition in which a floating-point number is larger in magnitude than the largest, finite,positive or negative number that can be represented in the data-type format being used.

packedSee vector.

Page 21: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Preface xix

26568—Rev. 3.10—September 2007 AMD64 Technology

PAEPhysical-address extensions.

physical memoryActual memory, consisting of main memory and cache.

probeA check for an address in a processor’s caches or internal buffers. External probes originateoutside the processor, and internal probes originate within the processor.

protected modeA submode of legacy mode.

quadwordFour words, or eight bytes, or 64 bits.

RAZRead as zero (0), regardless of what is written.

real-address modeSee real mode.

real modeA short name for real-address mode, a submode of legacy mode.

relativeReferencing with a displacement (also called offset) from an instruction pointer rather than thebase of a code segment. Contrast with absolute.

reservedFields marked as reserved may be used at some future time.

To preserve compatibility with future processors, reserved fields require special handling whenread or written by software.

Reserved fields may be further qualified as MBZ, RAZ, SBZ or IGN (see definitions).

Software must not depend on the state of a reserved field, nor upon the ability of such fields toreturn to a previously written state.

If a reserved field is not marked with one of the above qualifiers, software must not change the stateof that field; it must reload that field with the same values returned from a prior read.

REXAn instruction prefix that specifies a 64-bit operand size and provides access to additionalregisters.

RIP-relative addressingAddressing relative to the 64-bit RIP instruction pointer.

Page 22: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

xx Preface

AMD64 Technology 26568—Rev. 3.10—September 2007

setTo write a bit value of 1. Compare clear.

SIBA byte following an instruction opcode that specifies address calculation based on scale (S), index(I), and base (B).

SIMDSingle instruction, multiple data. See vector.

SSEStreaming SIMD extensions instruction set. See 128-bit media instructions and 64-bit mediainstructions.

SSE2Extensions to the SSE instruction set. See 128-bit media instructions and 64-bit mediainstructions.

SSE3Further extensions to the SSE instruction set. See 128-bit media instructions.

sticky bitA bit that is set or cleared by hardware and that remains in that state until explicitly changed bysoftware.

TOPThe x87 top-of-stack pointer.

TSSTask-state segment.

underflowThe condition in which a floating-point number is smaller in magnitude than the smallest nonzero,positive or negative number that can be represented in the data-type format being used.

vector(1) A set of integer or floating-point values, called elements, that are packed into a single operand.Most of the 128-bit and 64-bit media instructions use vectors as operands. Vectors are also calledpacked or SIMD (single-instruction multiple-data) operands.

(2) An index into an interrupt descriptor table (IDT), used to access exception handlers. Compareexception.

virtual-8086 modeA submode of legacy mode.

Page 23: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Preface xxi

26568—Rev. 3.10—September 2007 AMD64 Technology

VMCBVirtual machine control block.

VMMVirtual machine monitor.

wordTwo bytes, or 16 bits.

x86See legacy x86.

Registers

In the following list of registers, the names are used to refer either to a given register or to the contentsof that register:

AH–DHThe high 8-bit AH, BH, CH, and DH registers. Compare AL–DL.

AL–DLThe low 8-bit AL, BL, CL, and DL registers. Compare AH–DH.

AL–r15BThe low 8-bit AL, BL, CL, DL, SIL, DIL, BPL, SPL, and R8B–R15B registers, available in 64-bitmode.

BPBase pointer register.

CRnControl register number n.

CSCode segment register.

eAX–eSPThe 16-bit AX, BX, CX, DX, DI, SI, BP, and SP registers or the 32-bit EAX, EBX, ECX, EDX,EDI, ESI, EBP, and ESP registers. Compare rAX–rSP.

EFERExtended features enable register.

eFLAGS16-bit or 32-bit flags register. Compare rFLAGS.

Page 24: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

xxii Preface

AMD64 Technology 26568—Rev. 3.10—September 2007

EFLAGS32-bit (extended) flags register.

eIP16-bit or 32-bit instruction-pointer register. Compare rIP.

EIP32-bit (extended) instruction-pointer register.

FLAGS16-bit flags register.

GDTRGlobal descriptor table register.

GPRsGeneral-purpose registers. For the 16-bit data size, these are AX, BX, CX, DX, DI, SI, BP, and SP.For the 32-bit data size, these are EAX, EBX, ECX, EDX, EDI, ESI, EBP, and ESP. For the 64-bitdata size, these include RAX, RBX, RCX, RDX, RDI, RSI, RBP, RSP, and R8–R15.

IDTRInterrupt descriptor table register.

IP16-bit instruction-pointer register.

LDTRLocal descriptor table register.

MSRModel-specific register.

r8–r15The 8-bit R8B–R15B registers, or the 16-bit R8W–R15W registers, or the 32-bit R8D–R15Dregisters, or the 64-bit R8–R15 registers.

rAX–rSPThe 16-bit AX, BX, CX, DX, DI, SI, BP, and SP registers, or the 32-bit EAX, EBX, ECX, EDX,EDI, ESI, EBP, and ESP registers, or the 64-bit RAX, RBX, RCX, RDX, RDI, RSI, RBP, and RSPregisters. Replace the placeholder r with nothing for 16-bit size, “E” for 32-bit size, or “R” for 64-bit size.

RAX64-bit version of the EAX register.

Page 25: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Preface xxiii

26568—Rev. 3.10—September 2007 AMD64 Technology

RBP64-bit version of the EBP register.

RBX64-bit version of the EBX register.

RCX64-bit version of the ECX register.

RDI64-bit version of the EDI register.

RDX64-bit version of the EDX register.

rFLAGS16-bit, 32-bit, or 64-bit flags register. Compare RFLAGS.

RFLAGS64-bit flags register. Compare rFLAGS.

rIP16-bit, 32-bit, or 64-bit instruction-pointer register. Compare RIP.

RIP64-bit instruction-pointer register.

RSI64-bit version of the ESI register.

RSP64-bit version of the ESP register.

SPStack pointer register.

SSStack segment register.

TPRTask priority register (CR8), a new register introduced in the AMD64 architecture to speedinterrupt management.

TRTask register.

Page 26: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

xxiv Preface

AMD64 Technology 26568—Rev. 3.10—September 2007

Endian Order

The x86 and AMD64 architectures address memory using little-endian byte-ordering. Multibytevalues are stored with their least-significant byte at the lowest byte address, and they are illustratedwith their least significant byte at the right side. Strings are illustrated in reverse order, because theaddresses of their bytes increase from right to left.

Related Documents• Peter Abel, IBM PC Assembly Language and Programming, Prentice-Hall, Englewood Cliffs, NJ,

1995.

• Rakesh Agarwal, 80x86 Architecture & Programming: Volume II, Prentice-Hall, EnglewoodCliffs, NJ, 1991.

• AMD, AMD-K6™ MMX™ Enhanced Processor Multimedia Technology, Sunnyvale, CA, 2000.

• AMD, 3DNow!™ Technology Manual, Sunnyvale, CA, 2000.

• AMD, AMD Extensions to the 3DNow!™ and MMX™ Instruction Sets, Sunnyvale, CA, 2000.

• Don Anderson and Tom Shanley, Pentium Processor System Architecture, Addison-Wesley, NewYork, 1995.

• Nabajyoti Barkakati and Randall Hyde, Microsoft Macro Assembler Bible, Sams, Carmel, Indiana,1992.

• Barry B. Brey, 8086/8088, 80286, 80386, and 80486 Assembly Language Programming,Macmillan Publishing Co., New York, 1994.

• Barry B. Brey, Programming the 80286, 80386, 80486, and Pentium Based Personal Computer,Prentice-Hall, Englewood Cliffs, NJ, 1995.

• Ralf Brown and Jim Kyle, PC Interrupts, Addison-Wesley, New York, 1994.

• Penn Brumm and Don Brumm, 80386/80486 Assembly Language Programming, WindcrestMcGraw-Hill, 1993.

• Geoff Chappell, DOS Internals, Addison-Wesley, New York, 1994.

• Chips and Technologies, Inc. Super386 DX Programmer’s Reference Manual, Chips andTechnologies, Inc., San Jose, 1992.

• John Crawford and Patrick Gelsinger, Programming the 80386, Sybex, San Francisco, 1987.

• Cyrix Corporation, 5x86 Processor BIOS Writer's Guide, Cyrix Corporation, Richardson, TX,1995.

• Cyrix Corporation, M1 Processor Data Book, Cyrix Corporation, Richardson, TX, 1996.

• Cyrix Corporation, MX Processor MMX Extension Opcode Table, Cyrix Corporation, Richardson,TX, 1996.

• Cyrix Corporation, MX Processor Data Book, Cyrix Corporation, Richardson, TX, 1997.

• Ray Duncan, Extending DOS: A Programmer's Guide to Protected-Mode DOS, Addison Wesley,NY, 1991.

Page 27: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Preface xxv

26568—Rev. 3.10—September 2007 AMD64 Technology

• William B. Giles, Assembly Language Programming for the Intel 80xxx Family, Macmillan, NewYork, 1991.

• Frank van Gilluwe, The Undocumented PC, Addison-Wesley, New York, 1994.

• John L. Hennessy and David A. Patterson, Computer Architecture, Morgan Kaufmann Publishers,San Mateo, CA, 1996.

• Thom Hogan, The Programmer’s PC Sourcebook, Microsoft Press, Redmond, WA, 1991.

• Hal Katircioglu, Inside the 486, Pentium, and Pentium Pro, Peer-to-Peer Communications, MenloPark, CA, 1997.

• IBM Corporation, 486SLC Microprocessor Data Sheet, IBM Corporation, Essex Junction, VT,1993.

• IBM Corporation, 486SLC2 Microprocessor Data Sheet, IBM Corporation, Essex Junction, VT,1993.

• IBM Corporation, 80486DX2 Processor Floating Point Instructions, IBM Corporation, EssexJunction, VT, 1995.

• IBM Corporation, 80486DX2 Processor BIOS Writer's Guide, IBM Corporation, Essex Junction,VT, 1995.

• IBM Corporation, Blue Lightning 486DX2 Data Book, IBM Corporation, Essex Junction, VT,1994.

• Institute of Electrical and Electronics Engineers, IEEE Standard for Binary Floating-PointArithmetic, ANSI/IEEE Std 754-1985.

• Institute of Electrical and Electronics Engineers, IEEE Standard for Radix-Independent Floating-Point Arithmetic, ANSI/IEEE Std 854-1987.

• Muhammad Ali Mazidi and Janice Gillispie Mazidi, 80X86 IBM PC and Compatible Computers,Prentice-Hall, Englewood Cliffs, NJ, 1997.

• Hans-Peter Messmer, The Indispensable Pentium Book, Addison-Wesley, New York, 1995.

• Karen Miller, An Assembly Language Introduction to Computer Architecture: Using the IntelPentium, Oxford University Press, New York, 1999.

• Stephen Morse, Eric Isaacson, and Douglas Albert, The 80386/387 Architecture, John Wiley &Sons, New York, 1987.

• NexGen Inc., Nx586 Processor Data Book, NexGen Inc., Milpitas, CA, 1993.

• NexGen Inc., Nx686 Processor Data Book, NexGen Inc., Milpitas, CA, 1994.

• Bipin Patwardhan, Introduction to the Streaming SIMD Extensions in the Pentium III,www.x86.org/articles/sse_pt1/ simd1.htm, June, 2000.

• Peter Norton, Peter Aitken, and Richard Wilton, PC Programmer’s Bible, Microsoft Press,Redmond, WA, 1993.

• PharLap 386|ASM Reference Manual, Pharlap, Cambridge MA, 1993.

• PharLap TNT DOS-Extender Reference Manual, Pharlap, Cambridge MA, 1995.

Page 28: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

xxvi Preface

AMD64 Technology 26568—Rev. 3.10—September 2007

• Sen-Cuo Ro and Sheau-Chuen Her, i386/i486 Advanced Programming, Van Nostrand Reinhold,New York, 1993.

• Jeffrey P. Royer, Introduction to Protected Mode Programming, course materials for an onsiteclass, 1992.

• Tom Shanley, Protected Mode System Architecture, Addison Wesley, NY, 1996.

• SGS-Thomson Corporation, 80486DX Processor SMM Programming Manual, SGS-ThomsonCorporation, 1995.

• Walter A. Triebel, The 80386DX Microprocessor, Prentice-Hall, Englewood Cliffs, NJ, 1992.

• John Wharton, The Complete x86, MicroDesign Resources, Sebastopol, California, 1994.

• Web sites and newsgroups:

- www.amd.com

- news.comp.arch

- news.comp.lang.asm.x86

- news.intel.microprocessors

- news.microsoft

Page 29: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference 1

26568—Rev. 3.10—September 2007 AMD64 Technology

1 128-Bit Media Instruction Reference

This chapter describes the function, mnemonic syntax, opcodes, affected flags of the 128-bit mediainstructions and the possible exceptions they generate. These instructions load, store, or operate ondata located in 128-bit XMM registers. Most of the instructions operate in parallel on sets of packedelements called vectors, although a few operate on scalars. These instructions define both integer andfloating-point operations. They include the SSE, SSE2 and SSE3 instructions.

Each instruction that performs a vector (packed) operation is illustrated with a diagram. Figure 1-1shows the conventions used in these diagrams. The particular diagram shows the PSLLW (packed shiftleft logical words) instruction.

Figure 1-1. Diagram Conventions for 128-Bit Media Instructions

Gray areas in diagrams indicate unmodified operand bits.

shift left

xmm1 xmm2/mem128

shift left

513-323.eps

. ... .. . ... ..

. ... ..127 63 0649596111112 7980 4748 15163132 127 63 0649596111112 7980 4748 15163132

Ellipses indicate that the operationis repeated for each element of thesource vectors. In this case, there are8 elements in each source vector, sothe operation is performed 8 times,in parallel.

Arrowheads coming from a source operandindicate that the source operand providesa control function. In this case, the secondsource operand specifies the number of bits to shift, and the first source operand specifiesthe data to be shifted.

Arrowheads going to a source operandindicate the writing of the result. In thiscase, the result is written to the first source operand, which is also the destination operand.

First Source Operand(and Destination Operand) Second Source Operand

Operation.In this case,a bitwiseshift-left.

File name ofthis figure (for documentation control)

Page 30: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

2 Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

The 128-bit media instructions are useful in high-performance applications that operate on blocks ofdata. Because each instruction can independently and simultaneously perform a single operation onmultiple elements of a vector, the instructions are classified as single-instruction, multiple-data(SIMD) instructions. A few 128-bit media instructions convert operands in XMM registers to operandsin GPR, MMX™, or x87 registers (or vice versa), or save or restore XMM state.

Hardware support for a specific 128-bit media instruction depends on the presence of at least one ofthe following CPUID functions:

• FXSAVE and FXRSTOR, indicated by EDX bit 24 returned by CPUID function 0000_0001h andfunction 8000_0001h.

• SSE, indicated by EDX bit 25 returned by CPUID function 0000_0001h.

• SSE2, indicated by EDX bit 26 returned by CPUID function 0000_0001h.

• SSE3, indicated by ECX bit 0 returned by CPUID function 0000_0001h.

The 128-bit media instructions can be used in legacy mode or long mode. Their use in long mode isavailable if the following CPUID function is set:

• Long Mode, indicated by EDX bit 29 returned by CPUID function 8000_0001h.

Compilation of 128-bit media programs for execution in 64-bit mode offers four primary advantages:access to the eight extended XMM registers (for a register set consisting of XMM0–XMM15), accessto the eight extended, 64-bit general-purpose registers (for a register set consisting of GPR0–GPR15),access to the 64-bit virtual address space, and access to the RIP-relative addressing mode.

For further information, see:

• “128-Bit Media and Scientific Programming” in Volume 1.

• “Summary of Registers and Data Types” in Volume 3.

• “Notation” in Volume 3.

• “Instruction Prefixes” in Volume 3.

Page 31: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference ADDPD 3

26568—Rev. 3.10—September 2007 AMD64 Technology

Adds each packed double-precision floating-point value in the first source operand to thecorresponding packed double-precision floating-point value in the second source operand and writesthe result of each addition in the corresponding quadword of the destination (first source). The firstsource/destination operand is an XMM register. The second source operand is another XMM registeror 128-bit memory location.

The ADDPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

ADDPS, ADDSD, ADDSS

rFLAGS Affected

None

MXCSR Flags Affected

ADDPD Add Packed Double-Precision Floating-Point

Mnemonic Opcode Description

ADDPD xmm1, xmm2/mem128 66 0F 58 /r

Adds two packed double-precision floating-point values in an XMM register and another XMM register or 128-bit memory location and writes the result in the destination XMM register.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

addpd.eps

127 63 064 127 63 064

xmm1 xmm2/mem128

add

add

Page 32: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

4 ADDPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions below for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X +infinity was added to –infinity.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 33: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference ADDPS 5

26568—Rev. 3.10—September 2007 AMD64 Technology

Adds each packed single-precision floating-point value in the first source operand to thecorresponding packed single-precision floating-point value in the second source operand and writesthe result of each addition in the corresponding quadword of the destination (first source). The firstsource/destination operand is an XMM register. The second source operand is another XMM registeror 128-bit memory location.

The ADDPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

ADDPD, ADDSD, ADDSS

rFLAGS Affected

None

ADDPS Add Packed Single-Precision Floating-Point

Mnemonic Opcode Description

ADDPS xmm1, xmm2/mem128 0F 58 /r

Adds four packed single-precision floating-point values in an XMM register and another XMM register or 128-bit memory location and writes the result in the destination XMM register.

addps.eps

xmm1 xmm2/mem128

add

add

add

add

127 63 0649596 3132127 63 0649596 3132

Page 34: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

6 ADDPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X +infinity was added to –infinity.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 35: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference ADDPS 7

26568—Rev. 3.10—September 2007 AMD64 Technology

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 36: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

8 ADDSD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Adds the double-precision floating-point value in the low-order quadword of the first source operandto the double-precision floating-point value in the low-order quadword of the second source operandand writes the result in the low-order quadword of the destination (first source). The high-orderquadword of the destination is not modified. The first source/destination operand is an XMM register.The second source operand is another XMM register or 64-bit memory location.

The ADDSD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

ADDPD, ADDPS, ADDSS

rFLAGS Affected

None

MXCSR Flags Affected

ADDSD Add Scalar Double-Precision Floating-Point

Mnemonic Opcode Description

ADDSD xmm1, xmm2/mem64 F2 0F 58 /r

Adds low-order double-precision floating-point values in an XMM register and another XMM register or 64-bit memory location and writes the result in the destination XMM register.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

addsd.eps

xmm1 xmm2/mem64

add

127 63 064 127 63 064

Page 37: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference ADDSD 9

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X

A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X +infinity was added to –infinity.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 38: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

10 ADDSS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Adds the single-precision floating-point value in the low-order doubleword of the first source operandto the single-precision floating-point value in the low-order doubleword of the second source operandand writes the result in the low-order doubleword of the destination (first source). The three high-orderdoublewords of the destination are not modified. The first source/destination operand is an XMMregister. The second source operand is another XMM register or 32-bit memory location.

The ADDSS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

ADDPD, ADDPS, ADDSD

rFLAGS Affected

None

MXCSR Flags Affected

ADDSS Add Scalar Single-Precision Floating-Point

Mnemonic Opcode Description

ADDSS xmm1, xmm2/mem32 F3 0F 58 /r

Adds low-order single-precision floating-point values in an XMM register and another XMM register or 32-bit memory location and writes the result in the destination XMM register.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

addss.eps

xmm1 xmm2/mem32

add

127 31 032 127 31 032

Page 39: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference ADDSS 11

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X +infinity was added to –infinity.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 40: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

12 ADDSUBPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Adds the packed double-precision floating-point value in the high 64 bits of the source operand to thedouble-precision floating-point value in the high 64 bits of the destination operand and stores the sumin the high 64 bits of the destination operand; subtracts the packed double-precision floating-pointvalue in the low 64 bits of the source operand from the low 64 bits of the destination operand and storesthe difference in the low 64 bits of the destination operand.

The ADDSUBPD instruction is an SSE3 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

ADDSUBPS

rFLAGS Affected

None

MXCSR Flags Affected

ADDSUBPD Add and Subtract Packed Double-Precision

Mnemonic Opcode Description

ADDSUBPD xmm1, xmm2/mem128 66 0F D0 /r

Adds the value in the upper 64 bits of the source operand to the value in the upper 64 bits of the destination operand and stores the result in the upper 64 bits of the destination operand; subtracts the value in the lower 64 bits of the source operand from the value in the lower 64 bits of the destination operand and stores the result in the lower 64 bits of the destination operand.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

xmm1 xmm2/mem128

addsub

06364127 06364127

Page 41: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference ADDSUBPD 13

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE3 instructions are not supported, as indicated by ECX bit 0 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCP was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions below for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X +infinity was added to –infinity.

X X X +infinity was subtracted from +infinity.

X X X –infinity was subtracted from –infinity.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 42: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

14 ADDSUBPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Subtracts the first and third single-precision floating-point values in the source operand from the firstand third single-precision floating-point values of the destination operand and stores the result in thefirst and third values of the destination operand. Simultaneously, the instruction adds the second andfourth single-precision floating-point values in the source operand to the second and fourth single-precision floating-point values in the destination operand and stores the result in the second and fourthvalues of the destination operand.

The ADDSUBPS instruction is an SSE3 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

ADDSUBPD

rFLAGS Affected

None

ADDSUBPS Add and Subtract Packed Single-Precision

Mnemonic Opcode Description

ADDSUBPS xmm1, xmm2/mem128 F2 0F D0 /r

Subtracts the first and third packed single-precision values in the source XMM register or 128-bit memory operand from the corresponding values in the destination XMM register and stores the resulting values in the corresponding positions in the destination register; simultaneously, adds the second and fourth packed single-precision values in the source XMM register or 128-bit memory operand to the corresponding values in the destination register and stores the result in the corresponding positions in the destination register.

subadd

subadd

xmm1 xmm2/mem128

06364127 319596 32 06364127 319596 32

Page 43: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference ADDSUBPS 15

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE3 instructions are not supported, as indicated by ECX bit 0 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions below for details.

Page 44: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

16 ADDSUBPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X +infinity was added to –infinity.

X X X +infinity was subtracted from +infinity.

X X X –infinity was subtracted from –infinity.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 45: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference ANDNPD 17

26568—Rev. 3.10—September 2007 AMD64 Technology

Performs a bitwise logical AND of the two packed double-precision floating-point values in thesecond source operand and the one’s-complement of the corresponding two packed double-precisionfloating-point values in the first source operand and writes the result in the destination (first source).The first source/destination operand is an XMM register. The second source operand is another XMMregister or 128-bit memory location.

The ADDNPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

ANDNPS, ANDPD, ANDPS, ORPD, ORPS, XORPD, XORPS

rFLAGS Affected

None

MXCSR Flags Affected

None

ANDNPD Logical Bitwise AND NOTPacked Double-Precision Floating-Point

Mnemonic Opcode Description

ANDNPD xmm1, xmm2/mem128 66 0F 55 /r

Performs bitwise logical AND NOT of two packed double-precision floating-point values in an XMM register and another XMM register or 128-bit memory location and writes the result in the destination XMM register.

andnpd.eps

127 63 064 127 63 064

xmm1 xmm2/mem128

AND

AND

invert

AND

AND

invert

Page 46: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

18 ANDNPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 47: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference ANDNPS 19

26568—Rev. 3.10—September 2007 AMD64 Technology

Performs a bitwise logical AND of the four packed single-precision floating-point values in the secondsource operand and the one’s-complement of the corresponding four packed single-precision floating-point values in the first source operand and writes the result in the destination (first source). The firstsource/destination operand is an XMM register. The second source operand is another XMM registeror 128-bit memory location.

The ADDNPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

ANDNPD, ANDPD, ANDPS, ORPD, ORPS, XORPD, XORPS

rFLAGS Affected

None

MXCSR Flags Affected

None

ANDNPS Logical Bitwise AND NOTPacked Single-Precision Floating-Point

Mnemonic Opcode Description

ANDNPS xmm1, xmm2/mem128 0F 55 /r

Performs bitwise logical AND NOT of four packed single-precision floating-point values in an XMM register and in another XMM register or 128-bit memory location and writes the result in the destination XMM register.

andnps.eps

xmm1 xmm2/mem128

AND

AND

AND

AND

127 63 0649596 3132127 63 0649596 3132

invertinvert

invert

invert

Page 48: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

20 ANDNPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 49: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference ANDPD 21

26568—Rev. 3.10—September 2007 AMD64 Technology

Performs a bitwise logical AND of the two packed double-precision floating-point values in the firstsource operand and the corresponding two packed double-precision floating-point values in the secondsource operand and writes the result in the destination (first source). The first source/destinationoperand is an XMM register. The second source operand is another XMM register or 128-bit memorylocation.

The ANDPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

ANDNPD, ANDNPS, ANDPS, ORPD, ORPS, XORPD, XORPS

rFLAGS Affected

None

MXCSR Flags Affected

None

ANDPD Logical Bitwise ANDPacked Double-Precision Floating-Point

Mnemonic Opcode Description

ANDPD xmm1, xmm2/mem128 66 0F 54 /r

Performs bitwise logical AND of two packed double-precision floating-point values in an XMM register and in another XMM register or 128-bit memory location and writes the result in the destination XMM register.

andpd.eps

127 63 064 127 63 064

xmm1 xmm2/mem128

ANDAND

Page 50: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

22 ANDPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 51: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference ANDPS 23

26568—Rev. 3.10—September 2007 AMD64 Technology

Performs a bitwise logical AND of the four packed single-precision floating-point values in the firstsource operand and the corresponding four packed single-precision floating-point values in the secondsource operand and writes the result in the destination (first source). The first source/destinationoperand is an XMM register. The second source operand is another XMM register or 128-bit memorylocation.

The ADDPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

ANDNPD, ANDNPS, ANDPD, ORPD, ORPS, XORPD, XORPS

rFLAGS Affected

None

MXCSR Flags Affected

None

ANDPS Logical Bitwise ANDPacked Single-Precision Floating-Point

Mnemonic Opcode Description

ANDPS xmm1, xmm2/mem128 0F 54 /r

Performs bitwise logical AND of four packed single-precision floating-point values in an XMM register and in another XMM register or 128-bit memory location and writes the result in the destination XMM register.

andps.eps

xmm1 xmm2/mem128

AND

AND

AND

AND

127 63 0649596 3132127 63 0649596 3132

Page 52: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

24 ANDPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 53: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CMPPD 25

26568—Rev. 3.10—September 2007 AMD64 Technology

Compares each of the two packed double-precision floating-point values in the first source operandwith the corresponding packed double-precision floating-point value in the second source operand andwrites the result of each comparison in the corresponding 64 bits of the destination (first source). Thetype of comparison is specified by the three low-order bits of the immediate-byte operand, as shown inTable 1-1 on page 26. The result of each compare is a 64-bit value of all 1s (TRUE) or all 0s (FALSE).The first source/destination operand is an XMM register. The second source operand is another XMMregister or 128-bit memory location.

Signed compares return TRUE only if both operands are valid numbers, and the numbers have therelation specified by the type of compare. "Ordered" compare returns TRUE if both operands are validnumbers, or FALSE if either operand is a NaN. "Unordered" compare returns TRUE only if one orboth operands are NaN, and FALSE otherwise.

QNaN operands generate an Invalid Operation Exception only if the compare type isn't "Equal","Unequal", "Ordered", or "Unordered". SNaN operands always generate an Invalid OperationException (IE).

Some comparison operations that are not directly supported by the immediate-byte encodings can beimplemented by swapping the contents of the source and destination operands and then executing theappropriate compare instruction using the swapped values. These additional comparison operationsare shown, together with the directly supported comparison operations, in Table 1-1 on page 26. Whenswapping operands, the first source XMM register is overwritten by the result.

The CMPPD instruction with appropriate value of imm8 is aliased to the following mnemonics tofacilitate coding with this instruction.

CMPPD Compare Packed Double-Precision Floating-Point

MnemonicImplied Value of

imm8

CMPEQPD 0

CMPLTPD 1

CMPLEPD 2

CMPUNORDPD 3

CMPNEQPD 4

CMPNLTPD 5

CMPNLEPD 6

CMPORDPD 7

Page 54: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

26 CMPPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

The CMPPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Mnemonic Opcode Description

CMPPD xmm1, xmm2/mem128, imm8 66 0F C2 /r ib

Compares two pairs of packed double-precision floating-point values in an XMM register and an XMM register or 128-bit memory location.

Table 1-1. Immediate Operand Values for Comparison Operations

Immediate-Byte Value(bits 2–0) Compare Operation Result If NaN Operand

QNaN Operand Causes Invalid Operation

Exception

000 Equal FALSE No

001Less than FALSE Yes

Greater than (uses swapped operands)

FALSE Yes

010Less than or equal FALSE Yes

Greater than or equal(uses swapped operands)

FALSE Yes

011 Unordered TRUE No

100 Not equal TRUE No

101Not less than TRUE Yes

Not greater than (uses swapped operands)

TRUE Yes

cmppd.eps

127 63 064 127 63 064

xmm1 xmm2/mem128

imm87 0

compare

all 1s or 0s all 1s or 0s

compare

Page 55: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CMPPD 27

26568—Rev. 3.10—September 2007 AMD64 Technology

Related Instructions

CMPPS, CMPSD, CMPSS, COMISD, COMISS, UCOMISD, UCOMISS

rFLAGS Affected

None

MXCSR Flags Affected

Exceptions

110Not less than or equal TRUE Yes

Not greater than or equal(uses swapped operands)

TRUE Yes

111 Ordered FALSE No

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X XThere was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Table 1-1. Immediate Operand Values for Comparison Operations (continued)

Immediate-Byte Value(bits 2–0) Compare Operation Result If NaN Operand

QNaN Operand Causes Invalid Operation

Exception

Page 56: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

28 CMPPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X XA source operand was a QNaN value, and the comparison does not allow QNaN values (refer to Table 1-1 on page 26).

Denormalized-operand exception (DE)

X X X A source operand was a denormal value.

Exception RealVirtual8086 Protected Cause of Exception

Page 57: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CMPPS 29

26568—Rev. 3.10—September 2007 AMD64 Technology

Compares each of the four packed single-precision floating-point values in the first source operandwith the corresponding packed single-precision floating-point value in the second source operand andwrites the result of each comparison in the corresponding 32 bits of the destination (first source). Thetype of comparison is specified by the three low-order bits of the immediate-byte operand, as shown inTable 1-1 on page 26. The result of each compare is a 32-bit value of all 1s (TRUE) or all 0s (FALSE).The first source/destination operand is an XMM register. The second source operand is another XMMregister or 128-bit memory location.

Signed compares return TRUE only if both operands are valid numbers, and the numbers have therelation specified by the type of compare. "Ordered" compare returns TRUE if both operands are validnumbers, or FALSE if either operand is a NaN. "Unordered" compare returns TRUE only if one orboth operands are NaN, and FALSE otherwise.

QNaN operands generate an Invalid Operation Exception only if the compare type isn't "Equal","Unequal", "Ordered", or "Unordered". SNaN operands always generate an Invalid OperationException (IE).

Some comparison operations that are not directly supported by the immediate-byte encodings can beimplemented by swapping the contents of the source and destination operands and then executing theappropriate compare instruction using the swapped values. These additional comparison operationsare shown in Table 1-1 on page 26. When swapping operands, the first source XMM register isoverwritten by the result.

The CMPPS instruction with appropriate value of imm8 is aliased to the following mnemonics tofacilitate coding with this instruction.

CMPPS Compare Packed Single-Precision Floating-Point

MnemonicImplied Value of

imm8

CMPEQPS 0

CMPLTPS 1

CMPLEPS 2

CMPUNORDPS 3

CMPNEQPS 4

CMPNLTPS 5

CMPNLEPS 6

CMPORDPS 7

Page 58: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

30 CMPPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

The CMPPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CMPPD, CMPSD, CMPSS, COMISD, COMISS, UCOMISD, UCOMISS

rFLAGS Affected

None

Mnemonic Opcode Description

CMPPS xmm1, xmm2/mem128, imm8 0F C2 /r ib

Compares four pairs of packed single-precision floating-point values in an XMM register and an XMM register or 64-bit memory location.

cmpps.eps

xmm1 xmm2/mem128

imm87 0

compare

all 1s or 0s all 1s or 0s

compare

127 63 0649596 3132127 63 0649596 3132

..

..

..

Page 59: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CMPPS 31

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X XA source operand was a QNaN value, and the comparison does not allow QNaN values (refer to Table 1-1 on page 26).

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 60: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

32 CMPSD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Compares the double-precision floating-point value in the low-order 64 bits of the first source operandwith the double-precision floating-point value in the low-order 64 bits of the second source operandand writes the result in the low-order 64 bits of the destination (first source). The type of comparison isspecified by the three low-order bits of the immediate-byte operand, as shown in Table 1-1 on page 26.The result of the compare is a 64-bit value of all 1s (TRUE) or all 0s (FALSE). The firstsource/destination operand is an XMM register. The second source operand is another XMM registeror 64-bit memory location. The high-order 64 bits of the destination XMM register are not modified.

Signed compares return TRUE only if both operands are valid numbers, and the numbers have therelation specified by the type of compare. "Ordered" compare returns TRUE if both operands are validnumbers, or FALSE if either operand is a NaN. "Unordered" compare returns TRUE only if one orboth operands are NaN, and FALSE otherwise.

QNaN operands generate an Invalid Operation Exception only if the compare type isn't "Equal","Unequal", "Ordered", or "Unordered". SNaN operands always generate an Invalid OperationException (IE).

Some comparison operations that are not directly supported by the immediate-byte encodings can beimplemented by swapping the contents of the source and destination operands and then executing theappropriate compare instruction using the swapped values. These additional comparison operationsare shown in Table 1-1 on page 26. When swapping operands, the first source XMM register isoverwritten by the result.

The CMPSD instruction with appropriate value of imm8 is aliased to the following mnemonics tofacilitate coding with this instruction.

CMPSD Compare Scalar Double-Precision Floating-Point

MnemonicImplied Value of

imm8

CMPEQSD 0

CMPLTSD 1

CMPLESD 2

CMPUNORDSD 3

CMPNEQSD 4

CMPNLTSD 5

CMPNLESD 6

CMPORDSD 7

Page 61: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CMPSD 33

26568—Rev. 3.10—September 2007 AMD64 Technology

This CMPSD instruction should not be confused with the same-mnemonic CMPSD (compare stringsby doubleword) instruction in the general-purpose instruction set. Assemblers can distinguish theinstructions by the number and type of operands.

The CMPSD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CMPPD, CMPPS, CMPSS, COMISD, COMISS, UCOMISD, UCOMISS

rFLAGS Affected

None

Mnemonic Opcode Description

CMPSD xmm1, xmm2/mem64, imm8 F2 0F C2 /r ibCompares double-precision floating-point values in an XMM register and an XMM register or 64-bit memory location.

cmpsd.eps

xmm1 xmm2/mem64

imm87 0

compare

all 1s or 0s

127 63 064 127 63 064

Page 62: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

34 CMPSD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X XA source operand was a QNaN value, and the comparison does not allow QNaN values (refer to Table 1-1 on page 26).

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 63: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CMPSS 35

26568—Rev. 3.10—September 2007 AMD64 Technology

Compares the single-precision floating-point value in the low-order 32 bits of the first source operandwith the single-precision floating-point value in the low-order 32 bits of the second source operand andwrites the result in the low-order 32 bits of the destination (first source). The type of comparison isspecified by the three low-order bits of the immediate-byte operand, as shown in Table 1-1 on page 26.The result of the compare is a 32-bit value of all 1s (TRUE) or all 0s (FALSE). The firstsource/destination operand is an XMM register. The second source operand is another XMM registeror 32-bit memory location. The three high-order doublewords of the destination XMM register are notmodified.

Signed compares return TRUE only if both operands are valid numbers, and the numbers have therelation specified by the type of compare. "Ordered" compare returns TRUE if both operands are validnumbers, or FALSE if either operand is a NaN. "Unordered" compare returns TRUE only if one orboth operands are NaN, and FALSE otherwise.

QNaN operands generate an Invalid Operation Exception only if the compare type isn't "Equal","Unequal", "Ordered", or "Unordered". SNaN operands always generate an Invalid OperationException (IE).

Some comparison operations that are not directly supported by the immediate-byte encodings can beimplemented by swapping the contents of the source and destination operands and then executing theappropriate compare instruction using the swapped values. These additional comparison operationsare shown in Table 1-1 on page 26. When swapping operands, the first source XMM register isoverwritten by the result.

The CMPSS instruction with appropriate value of imm8 is aliased to the following mnemonics tofacilitate coding with this instruction.

CMPSS Compare Scalar Single-Precision Floating-Point

MnemonicImplied Value of

imm8

CMPEQSS 0

CMPLTSS 1

CMPLESS 2

CMPUNORDSS 3

CMPNEQSS 4

CMPNLTSS 5

CMPNLESS 6

CMPORDSS 7

Page 64: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

36 CMPSS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

The CMPSS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CMPPD, CMPPS, CMPSD, COMISD, COMISS, UCOMISD, UCOMISS

rFLAGS Affected

None

Mnemonic Opcode Description

CMPSS xmm1, xmm2/mem32, imm8 F3 0F C2 /r ib

Compares single-precision floating-point values in an XMM register and an XMM register or 32-bit memory location.

cmpss.eps

xmm1 xmm2/mem32

imm87 0

compare

127 31 032 127 31 032

Page 65: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CMPSS 37

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X XA source operand was a QNaN value, and the comparison does not allow QNaN values (refer to Table 1-1 on page 26).

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 66: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

38 COMISD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Compares the double-precision floating-point value in the low-order 64 bits of an XMM register withthe double-precision floating-point value in the low-order 64 bits of another XMM register or a 64-bitmemory location and sets the ZF, PF, and CF bits in the rFLAGS register to reflect the result of thecomparison. The OF, AF, and SF bits in rFLAGS are set to zero. The result is unordered if one or bothof the operand values is a NaN.

If the instruction causes an unmasked SIMD floating-point exception (#XF), the rFLAGS bits are notupdated.

The COMISD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CMPPD, CMPPS, CMPSD, CMPSS, COMISS, UCOMISD, UCOMISS

COMISD Compare Ordered Scalar Double-PrecisionFloating-Point

Mnemonic Opcode Description

COMISD xmm1, xmm2/mem64 66 0F 2F /r Compares double-precision floating-point values in an XMM register and an XMM register or 64-bit memory location and sets rFLAGS.

Result of Compare ZF PF CF

Unordered 1 1 1

Greater Than 0 0 0

Less Than 0 0 1

Equal 1 0 0

comisd.eps

compare

127 63 064

03163

127 63 064

xmm1

rFLAGS0

xmm2/mem64

Page 67: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference COMISD 39

26568—Rev. 3.10—September 2007 AMD64 Technology

rFLAGS Affected

MXCSR Flags Affected

Exceptions

ID VIP VIF AC VM RF NT IOPL OF DF IF TF SF ZF AF PF CF

0 0 M 0 M M

21 20 19 18 17 16 14 13–12 11 10 9 8 7 6 4 2 0

Note: Bits 31–22, 15, 5, 3, and 1 are reserved. A flag set to 1 or cleared to 0 is M (modified). Unaffected flags are blank. Note: If the instruction causes an unmasked SIMD floating-point exception (#XF), the rFLAGS bits are not updated.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set either to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

Page 68: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

40 COMISD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN or QNaN value.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Exception RealVirtual8086 Protected Cause of Exception

Page 69: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference COMISS 41

26568—Rev. 3.10—September 2007 AMD64 Technology

Performs an ordered comparison of the single-precision floating-point value in the low-order 32 bits ofan XMM register with the single-precision floating-point value in the low-order 32 bits of anotherXMM register or a 32-bit memory location and sets the ZF, PF, and CF bits in the rFLAGS register toreflect the result of the comparison. The OF, AF, and SF bits in rFLAGS are set to zero. The result isunordered if one or both of the operand values is a NaN.

If the instruction causes an unmasked SIMD floating-point exception (#XF), the rFLAGS bits are notupdated.

The COMISS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CMPPD, CMPPS, CMPSD, CMPSS, COMISD, UCOMISD, UCOMISS

COMISS Compare Ordered Scalar Single-PrecisionFloating-Point

Mnemonic Opcode Description

COMISS xmm1, xmm2/mem32 0F 2F /r Compares single-precision floating-point values in an XMM register and an XMM register or 32-bit memory location. Sets rFLAGS.

Result of Compare ZF PF CF

Unordered 1 1 1

Greater Than 0 0 0

Less Than 0 0 1

Equal 1 0 0

comiss.eps

compare

127 031 127 031

xmm1 xmm2/mem32

03163

rFLAGS0

Page 70: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

42 COMISS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

rFLAGS Affected

MXCSR Flags Affected

Exceptions

ID VIP VIF AC VM RF NT IOPL OF DF IF TF SF ZF AF PF CF

0 0 M 0 M M

21 20 19 18 17 16 14 13–12 11 10 9 8 7 6 4 2 0

Note: Bits 31–22, 15, 5, 3, and 1 are reserved. A flag set to 1 or cleared to 0 is M (modified). Unaffected flags are blank. Note: If the instruction causes an unmasked SIMD floating-point exception (#XF), the rFLAGS bits are not updated.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

Page 71: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference COMISS 43

26568—Rev. 3.10—September 2007 AMD64 Technology

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN or QNaN value.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Exception RealVirtual8086 Protected Cause of Exception

Page 72: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

44 CVTDQ2PD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts two packed 32-bit signed integer values in the low-order 64 bits of an XMM register or a 64-bit memory location to two packed double-precision floating-point values and writes the convertedvalues in another XMM register.

The CVTDQ2PD instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTPD2DQ, CVTPD2PI, CVTPI2PD, CVTSD2SI, CVTSI2SD, CVTTPD2DQ, CVTTPD2PI,CVTTSD2SI

rFLAGS Affected

None

MXCSR Flags Affected

None

CVTDQ2PD Convert Packed Doubleword Integers toPacked Double-Precision Floating-Point

Mnemonic Opcode Description

CVTDQ2PD xmm1, xmm2/mem64 F3 0F E6 /r

Converts packed doubleword signed integers in an XMM register or 64-bit memory location to double-precision floating-point values in the destination XMM register.

cvtdq2pd.eps

127 63 064

xmm1 xmm2/mem64

convertconvert

127 63 064 3132

Page 73: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTDQ2PD 45

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 74: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

46 CVTDQ2PS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts four packed 32-bit signed integer values in an XMM register or a 128-bit memory location tofour packed single-precision floating-point values and writes the converted values in another XMMregister. If the result of the conversion is an inexact value, the value is rounded as specified by therounding control bits (RC) in the MXCSR register.

The CVTDQ2PS instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTPI2PS, CVTPS2DQ, CVTPS2PI, CVTSI2SS, CVTSS2SI, CVTTPS2DQ, CVTTPS2PI,CVTTSS2SI

rFLAGS Affected

None

CVTDQ2PS Convert Packed Doubleword Integers toPacked Single-Precision Floating-Point

Mnemonic Opcode Description

CVTDQ2PS xmm1, xmm2/mem128 0F 5B /r

Converts packed doubleword integer values in an XMM register or 128-bit memory location to packed single-precision floating-point values in the destination XMM register.

cvtdq2ps.eps

xmm1 xmm2/mem128

convert

convert

convert

convert

127 63 0649596 3132127 63 0649596 3132

Page 75: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTDQ2PS 47

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 76: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

48 CVTPD2DQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts two packed double-precision floating-point values in an XMM register or a 128-bit memorylocation to two packed 32-bit signed integers and writes the converted values in the low-order 64 bitsof another XMM register. The high-order 64 bits in the destination XMM register are cleared to all 0s.

If the result of the conversion is an inexact value, the value is rounded as specified by the roundingcontrol bits (RC) in the MXCSR register. If the floating-point value is a NaN, infinity, or if the result ofthe conversion is larger than the maximum signed doubleword (–231 to +231 – 1), the instructionreturns the 32-bit indefinite integer value (8000_0000h) when the invalid-operation exception (IE) ismasked.

The CVTPD2DQ instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTDQ2PD, CVTPD2PI, CVTPI2PD, CVTSD2SI, CVTSI2SD, CVTTPD2DQ, CVTTPD2PI,CVTTSD2SI

rFLAGS Affected

None

CVTPD2DQ Convert Packed Double-Precision Floating-Pointto Packed Doubleword Integers

Mnemonic Opcode Description

CVTPD2DQ xmm1, xmm2/mem128 F2 0F E6 /r

Converts packed double-precision floating-point values in an XMM register or 128-bit memory location to packed doubleword integers in the destination XMM register.

cvtpd2dq.eps

xmm1 xmm2/mem128

convertconvert

127 63 064 3132 127 63 064

0

Page 77: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTPD2DQ 49

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value, a QNaN value, or ±infinity.

X X X A source operand was too large to fit in the destination format.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 78: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

50 CVTPD2PI Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts two packed double-precision floating-point values in an XMM register or a 128-bit memorylocation to two packed 32-bit signed integer values and writes the converted values in an MMXregister.

If the result of the conversion is an inexact value, the value is rounded as specified by the roundingcontrol bits (RC) in the MXCSR register. If the floating-point value is a NaN, infinity, or if the result ofthe conversion is larger than the maximum signed doubleword (–231 to +231 – 1), the instructionreturns the 32-bit indefinite integer value (8000_0000h) when the invalid-operation exception (IE) ismasked.

The CVTPD2PI instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTDQ2PD, CVTPD2DQ, CVTPI2PD, CVTSD2SI, CVTSI2SD, CVTTPD2DQ, CVTTPD2PI,CVTTSD2SI

rFLAGS Affected

None

CVTPD2PI Convert Packed Double-Precision Floating-Pointto Packed Doubleword Integers

Mnemonic Opcode Description

CVTPD2PI mmx, xmm/mem128 66 0F 2D /r

Converts packed double-precision floating-point values in an XMM register or 128-bit memory location to packed doubleword integers values in the destination MMX register.

cvtpd2pi.eps

127 63 0643132

xmm/mem128mmx

convertconvert

63 0

Page 79: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTPD2PI 51

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

x87 floating-point exception pending, #MF X X X An exception is pending due to an x87 floating-point

instruction.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

Page 80: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

52 CVTPD2PI Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value, a QNaN value, or ±infinity.

X X X A source operand was too large to fit in the destination format.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 81: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTPD2PS 53

26568—Rev. 3.10—September 2007 AMD64 Technology

Converts two packed double-precision floating-point values in an XMM register or a 128-bit memorylocation to two packed single-precision floating-point values and writes the converted values in thelow-order 64 bits of another XMM register. The high-order 64 bits in the destination XMM register arecleared to all 0s.

If the result of the conversion is an inexact value, the value is rounded as specified by the roundingcontrol bits (RC) in the MXCSR register.

The CVTPD2PS instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTPS2PD, CVTSD2SS, CVTSS2SD

rFLAGS Affected

None

CVTPD2PS Convert Packed Double-Precision Floating-Pointto Packed Single-Precision Floating-Point

Mnemonic Opcode Description

CVTPD2PS xmm1, xmm2/mem128 66 0F 5A /r

Converts packed double-precision floating-point values in an XMM register or 128-bit memory location to packed single-precision floating-point values in the destination XMM register.

cvtpd2ps.eps

127 63 064

xmm1 xmm2/mem128

convertconvert

127 63 0643132

0

Page 82: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

54 CVTPD2PS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN value.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Page 83: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTPD2PS 55

26568—Rev. 3.10—September 2007 AMD64 Technology

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 84: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

56 CVTPI2PD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts two packed 32-bit signed integer values in an MMX register or a 64-bit memory location totwo double-precision floating-point values and writes the converted values in an XMM register.

The CVTPI2PD instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTDQ2PD, CVTPD2DQ, CVTPD2PI, CVTSD2SI, CVTSI2SD, CVTTPD2DQ, CVTTPD2PI,CVTTSD2SI

rFLAGS Affected

None

MXCSR Flags Affected

None

CVTPI2PD Convert Packed Doubleword Integers toPacked Double-Precision Floating-Point

Mnemonic Opcode Description

CVTPI2PD xmm, mmx/mem64 66 0F 2A /r

Converts two packed doubleword integer values in an MMX register or 64-bit memory location to two packed double-precision floating-point values in the destination XMM register.

cvtpi2pd.eps

127 63 064 3132

mmx/mem64xmm

convertconvert

63 0

Page 85: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTPI2PD 57

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

x87 floating-point exception pending, #MF X X X An exception was pending due to an x87 floating-

point instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 86: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

58 CVTPI2PS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts two packed 32-bit signed integer values in an MMX register or a 64-bit memory location totwo single-precision floating-point values and writes the converted values in the low-order 64 bits ofan XMM register. The high-order 64 bits of the XMM register are not modified.

The CVTPI2PS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTDQ2PS, CVTPS2DQ, CVTPS2PI, CVTSI2SS, CVTSS2SI, CVTTPS2DQ, CVTTPS2PI,CVTTSS2SI

rFLAGS Affected

None

CVTPI2PS Convert Packed Doubleword Integers toPacked Single-Precision Floating-Point

Mnemonic Opcode Description

CVTPI2PS xmm, mmx/mem64 0F 2A /r Converts packed doubleword integer values in an MMX register or 64-bit memory location to single-precision floating-point values in the destination XMM register.

cvtpi2ps.eps

3132

mmx/mem64xmm

convertconvert

63 0127 63 064 3132

Page 87: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTPI2PS 59

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

x87 floating-point exception pending, #MF X X X An exception was pending due to an x87 floating-

point instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 88: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

60 CVTPS2DQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts four packed single-precision floating-point values in an XMM register or a 128-bit memorylocation to four packed 32-bit signed integer values and writes the converted values in another XMMregister.

If the result of the conversion is an inexact value, the value is rounded as specified by the roundingcontrol bits (RC) in the MXCSR register. If the floating-point value is a NaN, infinity, or if the result ofthe conversion is larger than the maximum signed doubleword (–231 to +231 – 1), the instructionreturns the 32-bit indefinite integer value (8000_0000h) when the invalid-operation exception (IE) ismasked.

The CVTPS2DQ instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTDQ2PS, CVTPI2PS, CVTPS2PI, CVTSI2SS, CVTSS2SI, CVTTPS2DQ, CVTTPS2PI,CVTTSS2SI

rFLAGS Affected

None

CVTPS2DQ Convert Packed Single-Precision Floating-Pointto Packed Doubleword Integers

Mnemonic Opcode Description

CVTPS2DQ xmm1, xmm2/mem128 66 0F 5B /r

Converts four packed single-precision floating-point values in an XMM register or 128-bit memory location to four packed doubleword integers in the destination XMM register.

cvtps2dq.eps

xmm1 xmm2/mem128

convertconvert

convert

convert

127 63 0649596 3132127 63 0649596 3132

Page 89: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTPS2DQ 61

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value, a QNaN value, or ±infinity.

X X X A source operand was too large to fit in the destination format.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 90: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

62 CVTPS2PD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts two packed single-precision floating-point values in the low-order 64 bits of an XMMregister or a 64-bit memory location to two packed double-precision floating-point values and writesthe converted values in another XMM register.

The CVTPS2PD instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTPD2PS, CVTSD2SS, CVTSS2SD

rFLAGS Affected

None

CVTPS2PD Convert Packed Single-Precision Floating-Pointto Packed Double-Precision Floating-Point

Mnemonic Opcode Description

CVTPS2PD xmm1, xmm2/mem64 0F 5A /r

Converts packed single-precision floating-point values in an XMM register or 64-bit memory location to packed double-precision floating-point values in the destination XMM register.

cvtps2pd.eps

xmm2/mem64xmm1

convertconvert

127 63 064 3132127 63 064

Page 91: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTPS2PD 63

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN value.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 92: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

64 CVTPS2PI Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts two packed single-precision floating-point values in the low-order 64 bits of an XMMregister or a 64-bit memory location to two packed 32-bit signed integers and writes the convertedvalues in an MMX register.

If the result of the conversion is an inexact value, the value is rounded as specified by the roundingcontrol bits (RC) in the MXCSR register. If the floating-point value is a NaN, infinity, or if the result ofthe conversion is larger than the maximum signed doubleword (–231 to +231 – 1), the instructionreturns the 32-bit indefinite integer value (8000_0000h) when the invalid-operation exception (IE) ismasked.

The CVTPS2PI instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTDQ2PS, CVTPI2PS, CVTPS2DQ, CVTSI2SS, CVTSS2SI, CVTTPS2DQ, CVTTPS2PI,CVTTSS2SI

rFLAGS Affected

None

CVTPS2PI Convert Packed Single-Precision Floating-Pointto Packed Doubleword Integers

Mnemonic Opcode Description

CVTPS2PI mmx, xmm/mem64 0F 2D /r

Converts packed single-precision floating-point values in an XMM register or 64-bit memory location to packed doubleword integers in the destination MMX register.

cvtps2pi.eps

xmm/mem64mmx

convertconvert

127 63 064 3132313263 0

Page 93: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTPS2PI 65

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

x87 floating-point exception pending, #MF X X X An exception was pending due to an x87 floating-

point instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value, a QNaN value, or ±infinity.

X X X A source operand was too large to fit in the destination format.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 94: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

66 CVTSD2SI Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts a scalar double-precision floating-point value in the low-order 64 bits of an XMM register ora 64-bit memory location to a 32-bit or 64-bit signed integer and writes the converted value in ageneral-purpose register.

If the result of the conversion is an inexact value, the value is rounded as specified by the roundingcontrol bits (RC) in the MXCSR register. If the floating-point value is a NaN, infinity, or if the result ofthe conversion is larger than the maximum signed doubleword (–231 to +231 – 1) or quadword value(–263 to +263 – 1), the instruction returns the indefinite integer value (8000_0000h for 32-bit integers,8000_0000_0000_0000h for 64-bit integers) when the invalid-operation exception (IE) is masked.

The CVTSD2SI instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

CVTSD2SI Convert Scalar Double-Precision Floating-Pointto Signed Doubleword or Quadword Integer

Mnemonic Opcode Description

CVTSD2SI reg32, xmm/mem64 F2 0F 2D /r Converts a packed double-precision floating-point value in an XMM register or 64-bit memory location to a doubleword integer in a general-purpose register.

CVTSD2SI reg64, xmm/mem64 F2 0F 2D /r Converts a packed double-precision floating-point value in an XMM register or 64-bit memory location to a quadword integer in a general-purpose register.

cvtsd2si.epswith REX prefix

031 127 63 064

reg32 xmm2/mem64

63 0 127 63 064

reg64 xmm2/mem64

convert

convert

Page 95: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTSD2SI 67

26568—Rev. 3.10—September 2007 AMD64 Technology

Related Instructions

CVTDQ2PD, CVTPD2DQ, CVTPD2PI, CVTPI2PD, CVTSI2SD, CVTTPD2DQ, CVTTPD2PI,CVTTSD2SI

rFLAGS Affected

None

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

Page 96: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

68 CVTSD2SI Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value, a QNaN value, or ±infinity.

X X X A source operand was too large to fit in the destination format.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 97: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTSD2SS 69

26568—Rev. 3.10—September 2007 AMD64 Technology

Converts a scalar double-precision floating-point value in the low-order 64 bits of an XMM register ora 64-bit memory location to a single-precision floating-point value and writes the converted value inthe low-order 32 bits of another XMM register. The three high-order doublewords in the destinationXMM register are not modified. If the result of the conversion is an inexact value, the value is roundedas specified by the rounding control bits (RC) in the MXCSR register.

The CVTSD2SS instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTPD2PS, CVTPS2PD, CVTSS2SD

rFLAGS Affected

None

MXCSR Flags Affected

CVTSD2SS Convert Scalar Double-Precision Floating-Pointto Scalar Single-Precision Floating-Point

Mnemonic Opcode Description

CVTSD2SS xmm1, xmm2/mem64 F2 0F 5A /r

Converts a scalar double-precision floating-point value in an XMM register or 64-bit memory location to a scalar single-precision floating-point value in the destination XMM register.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

cvtsd2ss.eps

xmm1 xmm2/mem64

convert

127 63 064127 31 032

Page 98: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

70 CVTSD2SS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN value.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 99: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTSI2SD 71

26568—Rev. 3.10—September 2007 AMD64 Technology

Converts a 32-bit or 64-bit signed integer value in a general-purpose register or memory location to adouble-precision floating-point value and writes the converted value in the low-order 64 bits of anXMM register. The high-order 64 bits in the destination XMM register are not modified.

If the result of the conversion is an inexact value, the value is rounded as specified by the roundingcontrol bits (RC) in the MXCSR register.

The CVTSI2SD instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTDQ2PD, CVTPD2DQ, CVTPD2PI, CVTPI2PD, CVTSD2SI, CVTTPD2DQ, CVTTPD2PI,CVTTSD2SI

CVTSI2SD Convert Signed Doubleword or QuadwordInteger to Scalar Double-Precision Floating-Point

Mnemonic Opcode Description

CVTSI2SD xmm, reg/mem32 F2 0F 2A /r Converts a doubleword integer in a general-purpose register or 32-bit memory location to a double-precision floating-point value in the destination XMM register.

CVTSI2SD xmm, reg/mem64 F2 0F 2A /r Converts a quadword integer in a general-purpose register or 64-bit memory location to a double-precision floating-point value in the destination XMM register.

cvtsi2sd.eps

031

reg/mem32xmm

convert

127 63 064

reg/mem64xmm

convert

127 63 064

with REX prefix

63 0

Page 100: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

72 CVTSI2SD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

rFLAGS Affected

None

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 101: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTSI2SS 73

26568—Rev. 3.10—September 2007 AMD64 Technology

Converts a 32-bit or 64-bit signed integer value in a general-purpose register or memory location to asingle-precision floating-point value and writes the converted value in the low-order 32 bits of anXMM register. The three high-order doublewords in the destination XMM register are not modified.

If the result of the conversion is an inexact value, the value is rounded as specified by the roundingcontrol bits (RC) in the MXCSR register.

The CVTSI2SS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTDQ2PS, CVTPI2PS, CVTPS2DQ, CVTPS2PI, CVTSS2SI, CVTTPS2DQ, CVTTPS2PI,CVTTSS2SI

CVTSI2SS Convert Signed Doubleword or Quadword Integerto Scalar Single-Precision Floating-Point

Mnemonic Opcode Description

CVTSI2SS xmm, reg/mem32 F3 0F 2A /r Converts a doubleword integer in a general-purpose register or 32-bit memory location to a single-precision floating-point value in the destination XMM register.

CVTSI2SS xmm, reg/mem64 F3 0F 2A /r Converts a quadword integer in a general-purpose register or 64-bit memory location to a single-precision floating-point value in the destination XMM register.

cvtsi2ss.eps

031

reg/mem32xmm

convert

127 03132

127 03132

reg/mem64xmm

convert

with REX prefix

63 0

Page 102: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

74 CVTSI2SS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

rFLAGS Affected

None

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 103: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTSS2SD 75

26568—Rev. 3.10—September 2007 AMD64 Technology

Converts a single-precision floating-point value in the low-order 32 bits of an XMM register or a 32-bitmemory location to a double-precision floating-point value and writes the converted value in the low-order 64 bits of another XMM register. The high-order 64 bits in the destination XMM register are notmodified.

The CVTSS2SD instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTPD2PS, CVTPS2PD, CVTSD2SS

rFLAGS Affected

None

CVTSS2SD Convert Scalar Single-Precision Floating-Pointto Scalar Double-Precision Floating-Point

Mnemonic Opcode Description

CVTSS2SD xmm1, xmm2/mem32 F3 0F 5A /r

Converts scalar single-precision floating-point value in an XMM register or 32-bit memory location to double-precision floating-point value in the destination XMM register.

cvtss2sd.eps

xmm1 xmm2/mem32

convert

127 31 032127 63 064

Page 104: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

76 CVTSS2SD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN value.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 105: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTSS2SI 77

26568—Rev. 3.10—September 2007 AMD64 Technology

The CVTSS2SI instruction converts a single-precision floating-point value in the low-order 32 bits ofan XMM register or a 32-bit memory location to a 32-bit or 64-bit signed integer value and writes theconverted value in a general-purpose register.

If the result of the conversion is an inexact value, the value is rounded as specified by the roundingcontrol bits (RC) in the MXCSR register. If the floating-point value is a NaN, infinity, or if the result ofthe conversion is larger than the maximum signed doubleword (–231 to +231 – 1) or quadword value(–263 to +263 – 1), the instruction returns the indefinite integer value (8000_0000h for 32-bit integers,8000_0000_0000_0000h for 64-bit integers) when the invalid-operation exception (IE) is masked.

The CVTSS2SI instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

CVTSS2SI Convert Scalar Single-Precision Floating-Pointto Signed Doubleword or Quadword Integer

Mnemonic Opcode Description

CVTSS2SI reg32, xmm2/mem32 F3 0F 2D /r

Converts a single-precision floating-point value in an XMM register or 32-bit memory location to a doubleword integer value in a general-purpose register.

CVTSS2SI reg64, xmm2/mem32 F3 0F 2D /r

Converts a single-precision floating-point value in an XMM register or 32-bit memory location to a quadword integer value in a general-purpose register.

cvtss2si.epswith REX prefix

63 0

031 127 31 032

reg32 xmm2/mem32

convert

0 127 31 032

reg64 xmm2/mem32

convert

Page 106: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

78 CVTSS2SI Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

CVTDQ2PS, CVTPI2PS, CVTPS2DQ, CVTPS2PI, CVTSI2SS, CVTTPS2DQ, CVTTPS2PI,CVTTSS2SI

rFLAGS Affected

None

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

Page 107: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTSS2SI 79

26568—Rev. 3.10—September 2007 AMD64 Technology

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value, a QNaN value, or ±infinity.

X X X A source operand was too large to fit in the destination format.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 108: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

80 CVTTPD2DQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts two packed double-precision floating-point values in an XMM register or a 128-bit memorylocation to two packed 32-bit signed integer values and writes the converted values in the low-order 64bits of another XMM register. The high-order 64 bits of the destination XMM register are cleared to all0s.

If the result of the conversion is an inexact value, the value is truncated (rounded toward zero). If thefloating-point value is a NaN, infinity, or if the result of the conversion is larger than the maximumsigned doubleword (–231 to +231 – 1), the instruction returns the 32-bit indefinite integer value(8000_0000h) when the invalid-operation exception (IE) is masked.

The CVTTPD2DQ instruction is an SSE2 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTDQ2PD, CVTPD2DQ, CVTPD2PI, CVTPI2PD, CVTSD2SI, CVTSI2SD, CVTTPD2PI,CVTTSD2SI

rFLAGS Affected

None

CVTTPD2DQ Convert Packed Double-Precision Floating-Pointto Packed Doubleword Integers, Truncated

Mnemonic Opcode Description

CVTTPD2DQ xmm1, xmm2/mem128 66 0F E6 /r

Converts packed double-precision floating-point values in an XMM register or 128-bit memory location to packed doubleword integer values in the destination XMM register. Inexact results are truncated.

cvttpd2dq.eps

127 63 064

xmm1 xmm2/mem128

convert

0

convert

127 63 0643132

Page 109: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTTPD2DQ 81

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value, a QNaN value, or ±infinity.

X X X A source operand was too large to fit in the destination format.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 110: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

82 CVTTPD2PI Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts two packed double-precision floating-point values in an XMM register or a 128-bit memorylocation to two packed 32-bit signed integer values and writes the converted values in an MMXregister.

If the result of the conversion is an inexact value, the value is truncated (rounded toward zero). If thefloating-point value is a NaN, infinity, or if the result of the conversion is larger than the maximumsigned doubleword (–231 to +231 – 1), the instruction returns the 32-bit indefinite integer value(8000_0000h) when the invalid-operation exception (IE) is masked.

The CVTTPD2PI instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTDQ2PD, CVTPD2DQ, CVTPD2PI, CVTPI2PD, CVTSD2SI, CVTSI2SD, CVTTPD2DQ,CVTTSD2SI

rFLAGS Affected

None

CVTTPD2PI Convert Packed Double-Precision Floating-Pointto Packed Doubleword Integers, Truncated

Mnemonic Opcode Description

CVTTPD2PI mmx, xmm/mem128 66 0F 2C /r

Converts packed double-precision floating-point values in an XMM register or 128-bit memory location to packed doubleword integer values in the destination MMX register. Inexact results are truncated.

cvttpd2pi.eps

127 63 0643132

xmm/mem128mmx

convertconvert

63 0

Page 111: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTTPD2PI 83

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM1.

x87 floating-point exception pending, #MF X X X An exception is pending due to an x87 floating-point

instruction.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

Page 112: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

84 CVTTPD2PI Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value, a QNaN value, or ±infinity.

X X X A source operand was too large to fit in the destination format.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 113: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTTPS2DQ 85

26568—Rev. 3.10—September 2007 AMD64 Technology

Converts four packed single-precision floating-point values in an XMM register or a 128-bit memorylocation to four packed 32-bit signed integers and writes the converted values in another XMMregister.

If the result of the conversion is an inexact value, the value is truncated (rounded toward zero). If thefloating-point value is a NaN, infinity, or if the result of the conversion is larger than the maximumsigned doubleword (–231 to +231 – 1), the instruction returns the 32-bit indefinite integer value(8000_0000h) when the invalid-operation exception (IE) is masked.

The CVTTPS2DQ instruction is an SSE2 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTDQ2PS, CVTPI2PS, CVTPS2DQ, CVTPS2PI, CVTSI2SS, CVTSS2SI, CVTTPS2PI,CVTTSS2SI

rFLAGS Affected

None

CVTTPS2DQ Convert Packed Single-Precision Floating-Pointto Packed Doubleword Integers, Truncated

Mnemonic Opcode Description

CVTTPS2DQ xmm1, xmm2/mem128 F3 0F 5B /r

Converts packed single-precision floating-point values in an XMM register or 128-bit memory location to packed doubleword integer values in the destination XMM register. Inexact results are truncated.

cvttps2dq.eps

xmm1 xmm2/mem128

convert

convert

convert

convert

127 63 0649596 3132127 63 0649596 3132

Page 114: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

86 CVTTPS2DQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value, a QNaN value, or ±infinity.

X X X A source operand was too large to fit in the destination format.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 115: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTTPS2PI 87

26568—Rev. 3.10—September 2007 AMD64 Technology

Converts two packed single-precision floating-point values in the low-order 64 bits of an XMMregister or a 64-bit memory location to two packed 32-bit signed integer values and writes theconverted values in an MMX register.

If the result of the conversion is an inexact value, the value is truncated (rounded toward zero). If thefloating-point value is a NaN, infinity, or if the result of the conversion is larger than the maximumsigned doubleword (–231 to +231 – 1), the instruction returns the 32-bit indefinite integer value(8000_0000h) when the invalid-operation exception (IE) is masked.

The CVTTPS2PI instruction is an SSE instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CVTDQ2PS, CVTPI2PS, CVTPS2DQ, CVTPS2PI, CVTSI2SS, CVTSS2SI, CVTTPS2DQ,CVTTSS2SI

rFLAGS Affected

None

CVTTPS2PI Convert Packed Single-Precision Floating-Pointto Packed Doubleword Integers, Truncated

Mnemonic Opcode Description

CVTTPS2PI mmx, xmm/mem64 0F 2C /r

Converts packed single-precision floating-point values in an XMM register or 64-bit memory location to doubleword integer values in the destination MMX register. Inexact results are truncated.

cvttps2pi.eps

xmm/mem64mmx

convertconvert

127 63 064 3132313263 0

Page 116: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

88 CVTTPS2PI Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

x87 floating-point exception pending, #MF X X X An exception was pending due to an x87 floating-point

instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value, a QNaN value, or ±infinity.

X X X A source operand was too large to fit in the destination format.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 117: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTTSD2SI 89

26568—Rev. 3.10—September 2007 AMD64 Technology

Converts a double-precision floating-point value in the low-order 64 bits of an XMM register or a 64-bit memory location to a 32-bit or 64-bit signed integer value and writes the converted value in ageneral-purpose register.

If the result of the conversion is an inexact value, the value is truncated (rounded toward zero). If thefloating-point value is a NaN, infinity, or if the result of the conversion is larger than the maximumsigned doubleword (–231 to +231 – 1) or quadword value (–263 to +263 – 1), the instruction returns theindefinite integer value (8000_0000h for 32-bit integers, 8000_0000_0000_0000h for 64-bit integers)when the invalid-operation exception (IE) is masked.

The CVTTSD2SI instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

CVTTSD2SI Convert Scalar Double-Precision Floating-Pointto Signed Doubleword of Quadword Integer,

Truncated

Mnemonic Opcode Description

CVTTSD2SI reg32, xmm/mem64 F2 0F 2C /r

Converts scalar double-precision floating-point value in an XMM register or 64-bit memory location to a doubleword signed integer value in a general-purpose register. Inexact results are truncated.

CVTTSD2SI reg64, xmm/mem64 F2 0F 2C /r

Converts scalar double-precision floating-point value in an XMM register or 64-bit memory location to a quadword signed integer value in a general-purpose register. Inexact results are truncated.

cvttsd2si.epswith REX prefix

031 127 63 064

reg32 xmm2/mem64

63 0 127 63 064

reg64 xmm2/mem64

convert

convert

Page 118: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

90 CVTTSD2SI Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

CVTDQ2PD, CVTPD2DQ, CVTPD2PI, CVTPI2PD, CVTSD2SI, CVTSI2SD, CVTTPD2DQ,CVTTPD2PI

rFLAGS Affected

None

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

Page 119: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTTSD2SI 91

26568—Rev. 3.10—September 2007 AMD64 Technology

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value, a QNaN value, or ±infinity.

X X X A source operand was too large to fit in the destination format.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 120: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

92 CVTTSS2SI Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts a single-precision floating-point value in the low-order 32 bits of an XMM register or a 32-bitmemory location to a 32-bit or 64-bit signed integer value and writes the converted value in a general-purpose register.

If the result of the conversion is an inexact value, the value is truncated (rounded toward zero). If thefloating-point value is a NaN, infinity, or if the result of the conversion is larger than the maximumsigned doubleword (–231 to +231 – 1) or quadword value (–263 to +263 – 1), the instruction returns theindefinite integer value (8000_0000h for 32-bit integers, 8000_0000_0000_0000h for 64-bit integers)when the invalid-operation exception (IE) is masked.

The CVTTSS2SI instruction is an SSE instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

CVTTSS2SI Convert Scalar Single-Precision Floating-Pointto Signed Doubleword or Quadword Integer,

Truncated

Mnemonic Opcode Description

CVTTSS2SI reg32, xmm/mem32 F3 0F 2C /r

Converts scalar single-precision floating-point value in an XMM register or 32-bit memory location to a signed doubleword integer value in a general-purpose register. Inexact results are truncated.

CVTTSS2SI reg64, xmm/mem32 F3 0F 2C /r

Converts scalar single-precision floating-point value in an XMM register or 32-bit memory location to a signed quadword integer value in a general-purpose register. Inexact results are truncated.

cvttss2si.epswith REX prefix

63 0

031 127 31 032

reg32 xmm2/mem64

convert

0 127 31 032

reg64 xmm2/mem64

convert

Page 121: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference CVTTSS2SI 93

26568—Rev. 3.10—September 2007 AMD64 Technology

Related Instructions

CVTDQ2PS, CVTPI2PS, CVTPS2DQ, CVTPS2PI, CVTSI2SS, CVTSS2SI, CVTTPS2DQ,CVTTPS2PI

rFLAGS Affected

None

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

Page 122: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

94 CVTTSS2SI Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value, a QNaN value, or ±infinity.

X X X A source operand was too large to fit in the destination format.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 123: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference DIVPD 95

26568—Rev. 3.10—September 2007 AMD64 Technology

Divides each of the two packed double-precision floating-point values in the first source operand bythe corresponding packed double-precision floating-point value in the second source operand andwrites the result of each division in the corresponding quadword of the destination (first source). Thefirst source/destination operand is an XMM register. The second source operand is another XMMregister or 128-bit memory location.

The DIVPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

DIVPS, DIVSD, DIVSS

rFLAGS Affected

None

DIVPD Divide Packed Double-Precision Floating-Point

Mnemonic Opcode Description

DIVPD xmm1, xmm2/mem128 66 0F 5E /r

Divides packed double-precision floating-point values in an XMM register by the packed double-precision floating-point values in another XMM register or 128-bit memory location.

divpd.eps

127 63 064 127 63 064

xmm1 xmm2/mem128

divide

divide

Page 124: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

96 DIVPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X ±Zero was divided by ±zero.

X X X ±infinity was divided by ±infinity.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Page 125: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference DIVPD 97

26568—Rev. 3.10—September 2007 AMD64 Technology

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Zero-divide exception (ZE) X X X A non-zero number was divided by zero.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 126: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

98 DIVPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Divides each of the four packed single-precision floating-point values in the first source operand by thecorresponding packed single-precision floating-point value in the second source operand and writesthe result of each division in the corresponding quadword of the destination (first source). The firstsource/destination operand is an XMM register. The second source operand is another XMM registeror 128-bit memory location.

The DIVPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

DIVPD, DIVSD, DIVSS

rFLAGS Affected

None

DIVPS Divide Packed Single-Precision Floating-Point

Mnemonic Opcode Description

DIVPS xmm1, xmm/2mem128 0F 5E /r

Divides packed single-precision floating-point values in an XMM register by the packed single-precision floating-point values in another XMM register or 128-bit memory location.

divps.eps

xmm1 xmm2/mem128

divide

divide

divide

divide

127 63 0649596 3132127 63 0649596 3132

Page 127: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference DIVPS 99

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X ±Zero was divided by ±zero.

X X X ±infinity was divided by ±infinity.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Page 128: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

100 DIVPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Zero-divide exception (ZE) X X X A non-zero number was divided by zero.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 129: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference DIVSD 101

26568—Rev. 3.10—September 2007 AMD64 Technology

Divides the double-precision floating-point value in the low-order quadword of the first sourceoperand by the double-precision floating-point value in the low-order quadword of the second sourceoperand and writes the result in the low-order quadword of the destination (first source). The high-order quadword of the destination is not modified. The first source/destination operand is an XMMregister. The second source operand is another XMM register or 128-bit memory location.

The DIVSD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

DIVPD, DIVPS, DIVSS

rFLAGS Affected

None

MXCSR Flags Affected

DIVSD Divide Scalar Double-Precision Floating-Point

Mnemonic Opcode Description

DIVSD xmm1, xmm2/mem64 F2 0F 5E /r

Divides low-order double-precision floating-point value in an XMM register by the low-order double-precision floating-point value in another XMM register or in a 64- or 128-bit memory location.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

divsd.eps

xmm1 xmm2/mem64

divide

127 63 064 127 63 064

Page 130: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

102 DIVSD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X ±Zero was divided by ±zero.

X X X ±infinity was divided by ±infinity.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Zero-divide exception (ZE) X X X A non-zero number was divided by zero.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 131: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference DIVSS 103

26568—Rev. 3.10—September 2007 AMD64 Technology

Divides the single-precision floating-point value in the low-order doubleword of the first sourceoperand by the single-precision floating-point value in the low-order doubleword of the second sourceoperand and writes the result in the low-order doubleword of the destination (first source). The threehigh-order doublewords of the destination are not modified. The first source/destination operand is anXMM register. The second source operand is another XMM register or 128-bit memory location.

The DIVSS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

DIVPD, DIVPS, DIVSD

rFLAGS Affected

None

MXCSR Flags Affected

DIVSS Divide Scalar Single-Precision Floating-Point

Mnemonic Opcode Description

DIVSS xmm1, xmm2/mem32 F3 0F 5E /r

Divides low-order single-precision floating-point value in an XMM register by the low-order single-precision floating-point value in another XMM register or in a 32-bit memory location.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

divss.eps

xmm1 xmm2/mem32

divide

127 31 032 127 31 032

Page 132: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

104 DIVSS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X ±Zero was divided by ±zero.

X X X ±infinity was divided by ±infinity.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Zero-divide exception (ZE) X X X A non-zero number was divided by zero.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 133: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference EXTRQ 105

26568—Rev. 3.10—September 2007 AMD64 Technology

Extracts specified bits from the lower 64 bits of the first operand (the destination XMM register). Theextracted bits are saved in the least-significant bit positions of the destination; the remaining bits in thelower 64 bits of the destination register are cleared to 0. The upper 64 bits of the destination register areundefined.

The portion of the source data being extracted is defined by the bit index and the field length. The bitindex defines the least-significant bit of the source operand being extracted. Bits [bit index + lengthfield – 1]:[bit index] are extracted. If the sum of the bit index + length field is greater than 64, the resultsare undefined.

For example, if the bit index is 32 (20h) and the field length is 16 (10h), then the result in thedestination register will be source [47:32] in bits 15:0, with zeros in bits 63:16.

A value of zero in the field length is defined as a length of 64. If the length field is 0 and the bit index is 0, bits 63:0 of the source are extracted. For any other value of the bit index, the results areundefined.

The bit index and field length can be specified as immediate values (second and first immediateoperands, respectively, in the case of the three argument version of the instruction), or they can both bespecified by fields in an XMM source operand. In the latter case, bits [5:0] of the XMM registerspecify the number of bits to extract (the field length) and bits [13:8] of the XMM register specify theindex of the first bit in the field to extract. The bit index and field length are each six bits in length;other bits of the field are ignored.

Support for the EXTRQ instruction is indicated by ECX bit 6 (SSE4A) as returned by CPUID function8000_0001h. Software must check the CPUID bit once per program or library initialization beforeusing the EXTRQ instruction, or inconsistent behavior may result.

EXTRQ Extract Field From Register

Mnemonic Opcode Description

EXTRQ xmm1, imm8, imm8 66 0F 78 /0 ib ib

Extract field from xmm1, with the least significant bit of the extracted data starting at the bit index specified by [5:0] of the second immediate byte, with the length specified by [5:0] of the first immediate byte.

EXTRQ xmm1, xmm2 66 0F 79 /r

Extract field from xmm1, with the least significant bit of the extracted data starting at the bit index specified by xmm2[13:8], with the length specified by xmm2[5:0].

Page 134: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

106 EXTRQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

INSERTQ, PINSRW, PEXTRW

rFLAGS Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE4A instructions are not supported, as indicated by ECX bit 6 (SSE4A) of CPUID function 8000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

xmm1 xmm2

06364127 127

shift right

mask to field length

xmm1 second imm8

06364127 05

shift right

mask to field length

first imm8

05

13 8 5 0

7 7

Page 135: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference FXRSTOR 107

26568—Rev. 3.10—September 2007 AMD64 Technology

Restores the XMM, MMX, and x87 state. The data loaded from memory is the state informationpreviously saved using the FXSAVE instruction. Restoring data with FXRSTOR that had beenpreviously saved with an FSAVE (rather than FXSAVE) instruction results in an incorrect restoration.

If FXRSTOR results in set exception flags in the loaded x87 status word register, and these exceptionsare unmasked in the x87 control word register, a floating-point exception occurs when the nextfloating-point instruction is executed (except for the no-wait floating-point instructions).

If the restored MXCSR register contains a set bit in an exception status flag, and the correspondingexception mask bit is cleared (indicating an unmasked exception), loading the MXCSR register frommemory does not cause a SIMD floating-point exception (#XF).

FXRSTOR does not restore the x87 error pointers (last instruction pointer, last data pointer, and lastopcode), except when FXRSTOR sets FSW.ES=1 after recomputing it from the error mask bits inFCW and error status bits in FSW.

The architecture supports two 512-bit memory formats for FXRSTOR, a 64-bit format that loadsXMM0-XMM15, and a 32-bit legacy format that loads only XMM0-XMM7. If FXRSTOR is executedin 64-bit mode, the 64-bit format is used, otherwise the 32-bit format is used. When the 64-bit format isused, if the operand-size is 64-bit, FXRSTOR loads the x87 pointer registers as offset64, otherwise itloads them as sel:offset32. For details about the memory format used by FXRSTOR, see "SavingMedia and x87 Processor State" in Volume 2.

If the fast-FXSAVE/FXRSTOR (FFXSR) feature is enabled in EFER, FXRSTOR does not restore theXMM registers (XMM0-XMM15) when executed in 64-bit mode at CPL 0. MXCSR is restoredwhether fast-FXSAVE/FXRSTOR is enabled or not. Software can use CPUID to determine whetherthe fast-FXSAVE/FXRSTOR feature is available. (See “CPUID” in Volume 3.)

If the operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0, the savedimage of XMM0–XMM15 and MXCSR is not loaded into the processor. A general-protectionexception occurs if the FXRSTOR instruction attempts to load non-zero values into reserved MXCSRbits. Software can use MXCSR_MASK to determine which bits of MXCSR are reserved. For detailson the MXCSR_MASK, see “128-Bit, 64-Bit, and x87 Programming” in Volume 2..

Related Instructions

FWAIT, FXSAVE

rFLAGS Affected

None

FXRSTOR Restore XMM, MMX, and x87 State

Mnemonic Opcode Description

FXRSTOR mem512env 0F AE /1 Restores XMM, MMX™, and x87 state from 512-byte memory location.

Page 136: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

108 FXRSTOR Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M M M M M M M M M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UDX X X

The FXSAVE/FXRSTOR instructions are not supported, as indicated by EDX bit 24 of CPUID function 0000_0001h or function 8000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary.

X X X Ones were written to the reserved bits in MXCSR.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Page 137: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference FXSAVE 109

26568—Rev. 3.10—September 2007 AMD64 Technology

Saves the XMM, MMX, and x87 state. A memory location that is not aligned on a 16-byte boundarycauses a general-protection exception.

Unlike FSAVE and FNSAVE, FXSAVE does not alter the x87 tag bits. The contents of the savedMMX/x87 data registers are retained, thus indicating that the registers may be valid (or whatever othervalue the x87 tag bits indicated prior to the save). To invalidate the contents of the MMX/x87 dataregisters after FXSAVE, software must execute an FINIT instruction. Also, FXSAVE (like FNSAVE)does not check for pending unmasked x87 floating-point exceptions. An FWAIT instruction can beused for this purpose.

FXSAVE does not save the x87 pointer registers (last instruction pointer, last data pointer, and lastopcode), except in the relatively rare cases in which the exception-summary (ES) bit in the x87 statusword is set to 1, indicating that an unmasked x87 exception has occurred.

The architecture supports two 512-bit memory formats for FXSAVE, a 64-bit format that savesXMM0-XMM15, and a 32-bit legacy format that saves only XMM0-XMM7. If FXSAVE is executedin 64-bit mode, the 64-bit format is used, otherwise the 32-bit format is used. When the 64-bit format isused, if the operand-size is 64-bit, FXSAVE saves the x87 pointer registers as offset64, otherwise itsaves them as sel:offset32. For more details about the memory format used by FXSAVE, see “SavingMedia and x87 Processor State” in Volume 2.

If the fast-FXSAVE/FXRSTOR (FFXSR) feature is enabled in EFER, FXSAVE does not save theXMM registers (XMM0-XMM15) when executed in 64-bit mode at CPL 0. MXCSR is saved whetherfast-FXSAVE/FXRSTOR is enabled or not. Software can use CPUID to determine whether the fast-FXSAVE/FXRSTOR feature is available. (See “CPUID” in Volume 3.)

If the operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0, FXSAVEdoes not save the image of XMM0–XMM15 or MXCSR. For details about the CR4.OSFXSR bit, see“FXSAVE/FXRSTOR Support (OSFXSR) Bit” in Volume 2.

Related Instructions

FINIT, FNSAVE, FRSTOR, FSAVE, FXRSTOR, LDMXCSR, STMXCSR

rFLAGS Affected

None

MXCSR Flags Affected

None

FXSAVE Save XMM, MMX, and x87 State

Mnemonic Opcode Description

FXSAVE mem512env 0F AE /0 Saves XMM, MMX, and x87 state to 512-byte memory location.

Page 138: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

110 FXSAVE Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UDX X X

The FXSAVE/FXRSTOR instructions are not supported, as indicated by EDX bit 24 of CPUID function 0000_0001h or function 8000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

X X X The memory operand was not aligned on a 16-byte boundary.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Page 139: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference HADDPD 111

26568—Rev. 3.10—September 2007 AMD64 Technology

Adds the double-precision floating-point values in the high and low quadwords of the destinationoperand and stores the result in the low quadword of the destination operand. Simultaneously, theinstruction adds the double-precision floating-point values in the high and low quadwords of thesource operand and stores the result in the high quadword of the destination operand.

The HADDPD instruction is an SSE3 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

HADDPS, HSUBPD, HSUBPS

rFLAGS Affected

None

MXCSR Flags Affected

HADDPD Horizontal Add Packed Double

Mnemonic Opcode Description

HADDPD xmm1, xmm2/mem128 66 0F 7C /r

Adds two packed double-precision values in xmm1 and stores the result in the lower 64 bits of xmm1; adds two packed double-precision values in xmm2 or a 128-bit memory operand and stores the result in the upper 64 bits of xmm1.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

xmm1 xmm2/mem128

addadd

06364127 06364127

Page 140: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

112 HADDPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE3 instructions are not supported, as indicated by ECX bit 0 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions below for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X +infinity was added to –infinity.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 141: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference HADDPS 113

26568—Rev. 3.10—September 2007 AMD64 Technology

Adds pairs of packed single-precision floating-point values simultaneously. The sum of the values inthe first and second doublewords of the destination operand is stored in the first doubleword of thedestination operand; the sum of the values in the third and fourth doubleword of the destinationoperand is stored in the second doubleword of the destination operand; the sum of the values in the firstand second doubleword of the source operand is stored in the third doubleword of the destinationoperand; and the sum of the values in the third and fourth doubleword of the source operand is stored inthe fourth doubleword of the destination operand.

The HADDPS instruction is an SSE3 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

HADDPD, HSUBPD, HSUBPS

rFLAGS Affected

None

HADDPS Horizontal Add Packed Single

Mnemonic Opcode Description

HADDPS xmm1, xmm2/mem128 F2 0F 7C /r

Adds the first and second packed single-precision values in xmm1 and stores the sum in xmm1[0-31]; adds the third and fourth single-precision values in xmm1 and stores the sum in xmm1[32–63]; adds the first and second packed single-precision values in xmm2 or a 128-bit memory operand and stores the sum in the xmm1[64–95]; adds the third and fourth packed single-precision values in xmm2 or a 128-bit memory operand and stores the result in xmm1[96–127].

add

xmm1 xmm2/mem128

addadd

add

06364127 319596 32 06364127 319596 32

Page 142: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

114 HADDPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE3 instructions are not supported, as indicated by ECX bit 0 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

Page 143: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference HADDPS 115

26568—Rev. 3.10—September 2007 AMD64 Technology

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X +infinity was added to –infinity.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 144: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

116 HSUBPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Subtracts the packed double-precision floating-point value in the upper quadword of the destinationXMM register operand from the lower quadword of the destination operand and stores the result in thelower quadword of the destination operand; subtracts the value in the upper quadword of the sourceXMM register or 128-bit memory operand from the value in the lower quadword of the source operandand stores the result in the upper quadword of the destination XMM register.

The HSUBPD instruction is an SSE3 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

HSUBPS, HADDPD, HADDPS

rFLAGS Affected

None

MXCSR Flags Affected

HSUBPD Horizontal Subtract Packed Double

Mnemonic Opcode Description

HSUBPD xmm1, xmm2/mem128 66 0F 7D /r

Subtracts the packed double-precision value in the upper 64 bits of the source register from the value in the lower 64 bits of the source register or 128-bit memory operand and stores the difference in the upper 64 bits of the destination XMM register; Subtracts the upper 64 bits of the destination register from the lower 64 bits of the destination register and stores the result in the lower 64 bits of the destination XMM register.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

xmm1 xmm2/mem128

subsub

06364127 06364127

Page 145: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference HSUBPD 117

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE3 instructions are not supported, as indicated by ECX bit 0 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions below for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X +infinity was subtracted from +infinity.

X X X –infinity was subtracted from –infinity.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 146: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

118 HSUBPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Subtracts the packed single-precision floating-point value in the second doubleword of the destinationXMM register from that in the first doubleword of the destination register and stores the difference inthe first doubleword of the destination register; subtracts the value in the fourth doubleword of thedestination register from that in the third doubleword of the destination register and stores the result inthe second doubleword of the destination register; subtracts the value in the second doubleword of thesource XMM register or 128-bit memory operand from the first doubleword of the source operand andstores the result in the third doubleword of the destination XMM register; subtracts the single-precision floating-point value in the fourth doubleword of the source operand from the thirddoubleword of the source operand and stores the result in the fourth doubleword of the destinationXMM register.

The HSUBPS instruction is an SSE3 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

HSUBPD, HADDPD, HADDPS

HSUBPS Horizontal Subtract Packed Single

Mnemonic Opcode Description

HSUBPS xmm1, xmm2/mem128 F2 0F 7D /r

Subtracts the second 32 bits of the destination operand from the first 32 bits of the destination operand and stores the difference in the first doubleword of the destination operand; subtracts the fourth 32 bits of the destination operand from the third 32-bits of the destination operand and stores the difference in the second doubleword of the destination operand; subtracts the second 32 bits of the source operand from the first 32 bits of the source operand and stores the difference in the third doubleword of the destination operand; subtracts the fourth 32-bits of the source operand from the third 32 bits of the source operand and stores the difference in the fourth doubleword of the destination operand.

sub

xmm1 xmm2/mem128

subsub

sub

06364127 319596 32 06364127 319596 32

Page 147: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference HSUBPS 119

26568—Rev. 3.10—September 2007 AMD64 Technology

rFLAGS Affected

None

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE3 instructions are not supported, as indicated by ECX bit 0 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions below for details.

Page 148: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

120 HSUBPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X +infinity was subtracted from +infinity.

X X X –infinity was subtracted from –infinity.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 149: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference INSERTQ 121

26568—Rev. 3.10—September 2007 AMD64 Technology

Inserts bits from the lower 64 bits of the source operand into the lower 64 bits of the destinationoperand. No other bits in the lower 64 bits of the destination are modified. The upper 64 bits of thedestination are undefined.

The least-significant l bits of the source operand are inserted into the destination, with the least-significant bit of the source operand inserted at bit position n, where l and n are defined as the fieldlength and bit index, respectively.

Bits (field length – 1):0 of the source operand are inserted into bits (bit index + field length – 1):(bitindex) of the destination. If the sum of the bit index + length field is greater than 64, the results areundefined.

For example, if the bit index is 32 (20h) and the field length is 16 (10h), then the result in thedestination register will be source operand[15:0] in bits 47:32. Bits 63:48 and bits 31:0 are notmodified.

A value of zero in the field length is defined as a length of 64. If the length field is 0 and the bit index is0, bits 63:0 of the source operand are inserted. For any other value of the bit index, the results areundefined.

The bits to insert are located in the XMM2 source operand. The bit index and field length can bespecified as immediate values or can be specified in the XMM source operand. In the immediate form,the bit index and the field length are specified by the fourth (second immediate byte) and thirdoperands (first immediate byte), respectively. In the register form, the bit index and field length arespecified in bits [77:72] and bits [69:64] of the source XMM register, respectively. The bit index andfield length are each six bits in length; other bits in the field are ignored.

Support for the INSERTQ instruction is indicated by ECX bit 6 (SSE4A) as returned by CPUIDfunction 8000_0001h. Software must check the CPUID bit once per program or library initializationbefore using the INSERTQ instruction, or inconsistent behavior may result.

INSERTQ Insert Field

Mnemonic Opcode Description

INSERTQ xmm1, xmm2, imm8, imm8 F2 0F 78 /r ib ib

Insert field starting at bit 0 of xmm2 with the length specified by [5:0] of the first immediate byte. This field is inserted into xmm1 starting at the bit position specified by [5:0] of the second immediate byte.

INSERTQ xmm1, xmm2 F2 0F 79 /r

Insert field starting at bit 0 of xmm2 with the length specified by xmm2[69:64]. This field is inserted into xmm1 starting at the bit position specified by xmm2[77:72].

Page 150: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

122 INSERTQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

EXTRQ, PINSRW, PEXTRW

rFLAGS Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE4A instructions are not supported, as indicated by ECX bit 6 (SSE4A) of CPUID function 8000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

7

xmm1 xmm2

06364127 0127

xmm2second

06364127 05

select number of bits to insert

select bit position for insert

first

05

imm8 imm8

06364127

xmm1

69 64 63

select bit position for insert

select number of bits to insert

77 72

7

Page 151: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference LDDQU 123

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves an unaligned 128-bit (double quadword) value from a 128-bit memory location to a destinationXMM register.

Like the MOVUPD instruction, the LDDQU instruction loads a 128-bit operand from an unalignedmemory location. However, to improve performance when the memory operand is actuallymisaligned, LDDQU may read an aligned 16 bytes to get the first part of the operand, and an aligned16 bytes to get the second part of the operand. This behavior is implementation-specific, and LDDQUmay only read the exact 16 bytes needed for the memory operand. If the memory operand is in amemory range where reading extra bytes can cause performance or functional issues, use theMOVUPD instruction instead of LDDQU.

Memory operands that are not aligned on a 16-byte boundary do not cause a general-protectionexception.

The LDDQU instruction is an SSE3 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVDQU

rFLAGS Affected

None

MXCSR Flags Affected

None

LDDQU Load Unaligned Double Quadword

Mnemonic Opcode Description

LDDQU xmm1, mem128 F2 0F F0 /r Moves a 128-bit value from an unaligned 128-bit memory location to the destination XMM register.

copy

0127 0127

xmm1 mem128

Page 152: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

124 LDDQU Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE3 instructions are not supported, as indicated by ECX bit 0 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 153: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference LDMXCSR 125

26568—Rev. 3.10—September 2007 AMD64 Technology

Loads the MXCSR register with a 32-bit value from memory.

A general protection exception occurs if the LDMXCSR instruction attempts to load non-zero valuesinto reserved MXCSR bits. Software can use MXCSR_MASK to determine which bits of MXCSR arereserved. For details on the MXCSR_MASK, see “128-Bit, 64-Bit, and x87 Programming” inVolume 2.

The MXCSR register is described in “Registers” in Volume 1.

The LDMXCSR instruction is an SSE instruction; check the status of EDX bit 25 returned by CPUIDfunction 0000_0001h to verify that the processor supports this function. (See “CPUID” in Volume 3.)

Related Instructions

STMXCSR

rFLAGS Affected

None

MXCSR Flags Affected

Exceptions

LDMXCSR Load MXCSR Control/Status Register

Mnemonic Opcode Description

LDMXCSR mem32 0F AE /2 Loads MXCSR register with 32-bit value in memory.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M M M M M M M M M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

Page 154: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

126 LDMXCSR Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X Ones were written to the reserved bits in MXCSR.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Exception RealVirtual8086 Protected Cause of Exception

Page 155: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MASKMOVDQU 127

26568—Rev. 3.10—September 2007 AMD64 Technology

Stores bytes from the first source operand as selected by the sign bits in the second source operand(sign-bit is 0 = no write and sign-bit is 1 = write) to a memory location specified in the DS:rDIregisters. The first source operand is an XMM register, and the second source operand is anotherXMM register. The store address may be unaligned.

A mask value of all 0s results in the following behavior:

• No data is written to memory.

• Code and data breakpoints are not guaranteed to be signaled in all implementations.

• Exceptions associated with memory addressing and page faults are not guaranteed to be signaled inall implementations.

MASKMOVDQU implicitly uses weakly-ordered, write-combining buffering for the data, asdescribed in “Buffering and Combining Memory Writes” in Volume 2. For data that is shared bymultiple processors, this instruction should be used together with a fence instruction in order to ensuredata coherency (refer to “Cache and TLB Management” in Volume 2).

The MASKMOVDQU instruction is an SSE2 instruction. The presence of this instruction set isindicated by a CPUID feature bit. (See “CPUID” in Volume 3.)

MASKMOVDQU Masked Move Double Quadword Unaligned

Mnemonic Opcode Description

MASKMOVDQU xmm1, xmm2 66 0F F7 /r Store bytes from an XMM register selected by a mask value in another XMM register to DS:rDI.

xmm1

select

maskmovdqu.eps

127 0

select. . . . . . .. . . . . . .

. . . . . . .. . . . . . .

. . . . . . .. . . . . . .

xmm2 127 0

store addressMemory

DS:rDI

Page 156: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

128 MASKMOVDQU Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

MASKMOVQ

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Page 157: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MAXPD 129

26568—Rev. 3.10—September 2007 AMD64 Technology

Compares each of the two packed double-precision floating-point values in the first source operandwith the corresponding packed double-precision floating-point value in the second source operand andwrites the numerically greater of the two values for each comparison in the corresponding quadword ofthe destination (first source). The first source/destination operand is an XMM register. The secondsource operand is another XMM register or 128-bit memory location.

If both source operands are equal to zero, the value in the second source operand is returned. If eitheroperand is a NaN (SNaN or QNaN), and invalid-operation exceptions are masked, the second sourceoperand is written to the destination.

The MAXPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MAXPS, MAXSD, MAXSS, MINPD, MINPS, MINSD, MINSS

rFLAGS Affected

None

MAXPD Maximum Packed Double-Precision Floating-Point

Mnemonic Opcode Description

MAXPD xmm1, xmm2/mem128 66 0F 5F /r

Compares two pairs of packed double-precision values in an XMM register and another XMM register or 128-bit memory location and writes the greater value of each comparison in the destination XMM register.

maxpd.eps

127 63 064 127 63 064

xmm1 xmm2/mem128

maximum

maximum

Page 158: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

130 MAXPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN or QNaN value.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 159: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MAXPS 131

26568—Rev. 3.10—September 2007 AMD64 Technology

Compares each of the four packed single-precision floating-point values in the first source operandwith the corresponding packed single-precision floating-point value in the second source operand andwrites the numerically greater of the two values for each comparison in the corresponding doublewordof the destination (first source). The first source/destination operand is an XMM register. The secondsource operand is another XMM register or 128-bit memory location.

If both source operands are equal to zero, the value in the second source operand is returned. If eitheroperand is a NaN (SNaN or QNaN), and invalid-operation exceptions are masked, the second sourceoperand is written to the destination.

The MAXPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MAXPD, MAXSD, MAXSS, MINPD, MINPS, MINSD, MINSS

rFLAGS Affected

None

MAXPS Maximum Packed Single-Precision Floating-Point

Mnemonic Opcode Description

MAXPS xmm1, xmm2/mem128 0F 5F /r

Compares four pairs of packed single-precision values in an XMM register and another XMM register or 128-bit memory location and writes the maximum value of each comparison in the destination XMM register.

maxps.eps

xmm1 xmm2/mem128

maximum

maximum

maximum

maximum

127 63 0649596 3132127 63 0649596 3132

Page 160: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

132 MAXPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN or QNaN value.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 161: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MAXSD 133

26568—Rev. 3.10—September 2007 AMD64 Technology

Compares the double-precision floating-point value in the low-order 64 bits of the first source operandwith the double-precision floating-point value in the low-order 64 bits of the second source operandand writes the numerically greater of the two values in the low-order quadword of the destination (firstsource). The first source/destination operand is an XMM register. The second source operand isanother XMM register or a 64-bit memory location. The high-order quadword of the destination XMMregister is not modified.

If both source operands are equal to zero, the value in the second source operand is returned. If eitheroperand is a NaN (SNaN or QNaN), and invalid-operation exceptions are masked, the second sourceoperand is written to the destination.

The MAXSD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MAXPD, MAXPS, MAXSS, MINPD, MINPS, MINSD, MINSS

rFLAGS Affected

None

MAXSD Maximum Scalar Double-Precision Floating-Point

Mnemonic Opcode Description

MAXSD xmm1, xmm2/mem64 F2 0F 5F /r

Compares scalar double-precision values in an XMM register and another XMM register or 64-bit memory location and writes the greater of the two values in the destination XMM register.

maxsd.eps

xmm1 xmm2/mem64

maximum

127 63 064 127 63 064

Page 162: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

134 MAXSD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN or QNaN value.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 163: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MAXSS 135

26568—Rev. 3.10—September 2007 AMD64 Technology

Compares the single-precision floating-point value in the low-order 32 bits of the first source operandwith the single-precision floating-point value in the low-order 32 bits of the second source operand andwrites the numerically greater of the two values in the low-order 32 bits of the destination (firstsource). The first source/destination operand is an XMM register. The second source operand isanother XMM register or a 32-bit memory location. The three high-order doublewords of thedestination XMM register are not modified.

If both source operands are equal to zero, the value in the second source operand is returned. If eitheroperand is a NaN (SNaN or QNaN), and invalid-operation exceptions are masked, the second sourceoperand is written to the destination.

The MAXSS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MAXPD, MAXPS, MAXSD, MINPD, MINPS, MINSD, MINSS, PFMAX

rFLAGS Affected

None

MAXSS Maximum Scalar Single-Precision Floating-Point

Mnemonic Opcode Description

MAXSS xmm1, xmm2/mem32 F3 0F 5F /r

Compares scalar single-precision floating-point values in an XMM register and another XMM register or 32-bit memory location and writes the greater of the two values in the destination XMM register.

maxss.eps

xmm1 xmm2/mem32

maximum

127 31 032 127 31 032

Page 164: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

136 MAXSS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN or QNaN value.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 165: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MINPD 137

26568—Rev. 3.10—September 2007 AMD64 Technology

Compares each of the two packed double-precision floating-point values in the first source operandwith the corresponding packed double-precision floating-point value in the second source operand andwrites the numerically lesser of the two values for each comparison in the corresponding quadword ofthe destination (first source). The first source/destination operand is an XMM register. The secondsource operand is another XMM register or a 128-bit memory location.

If both source operands are equal to zero, the value in the second source operand is returned. If eitheroperand is a NaN (SNaN or QNaN), and invalid-operation exceptions are masked, the second sourceoperand is written to the destination.

The MINPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MAXPD, MAXPS, MAXSD, MAXSS, MINPS, MINSD, MINSS

rFLAGS Affected

None

MINPD Minimum Packed Double-Precision Floating-Point

Mnemonic Opcode Description

MINPD xmm1, xmm2/mem128 66 0F 5D /r

Compares two pairs of packed double-precision floating-point values in an XMM register and another XMM register or 128-bit memory location and writes the lesser value of each comparison in the destination XMM register.

minpd.eps

127 63 064 127 63 064

xmm1 xmm2/mem128

minimum

minimum

Page 166: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

138 MINPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN or QNaN value.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 167: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MINPS 139

26568—Rev. 3.10—September 2007 AMD64 Technology

The MINPS instruction compares each of the four packed single-precision floating-point values in thefirst source operand with the corresponding packed single-precision floating-point value in the secondsource operand and writes the numerically lesser of the two values for each comparison in thecorresponding doubleword of the destination (first source). The first source/destination operand is anXMM register. The second source operand is another XMM register or a 128-bit memory location.

If both source operands are equal to zero, the value in the second source operand is returned. If eitheroperand is a NaN (SNaN or QNaN), and invalid-operation exceptions are masked, the second sourceoperand is written to the destination.

The MINPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MAXPD, MAXPS, MAXSD, MAXSS, MINPD, MINSD, MINSS, PFMIN

rFLAGS Affected

None

MINPS Minimum Packed Single-Precision Floating-Point

Mnemonic Opcode Description

MINPS xmm1, xmm2/mem128 0F 5D /r

Compares four pairs of packed single-precision values in an XMM register and another XMM register or 128-bit memory location and writes the numerically lesser value of each comparison in the destination XMM register.

minps.eps

xmm1 xmm2/mem128

minimum

minimum

minimum

minimum

127 63 0649596 3132127 63 0649596 3132

Page 168: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

140 MINPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN or QNaN value.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 169: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MINSD 141

26568—Rev. 3.10—September 2007 AMD64 Technology

Compares the double-precision floating-point value in the low-order 64 bits of the first source operandwith the double-precision floating-point value in the low-order 64 bits of the second source operandand writes the numerically lesser of the two values in the low-order 64 bits of the destination (firstsource). The first source/destination operand is an XMM register. The second source operand isanother XMM register or a 64-bit memory location. The high-order quadword of the destination XMMregister is not modified.

If both source operands are equal to zero, the value in the second source operand is returned. If eitheroperand is a NaN (SNaN or QNaN), and invalid-operation exceptions are masked, the second sourceoperand is written to the destination.

The MINSD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MAXPD, MAXPS, MAXSD, MAXSS, MINPD, MINPS, MINSS

rFLAGS Affected

None

MINSD Minimum Scalar Double-Precision Floating-Point

Mnemonic Opcode Description

MINSD xmm1, xmm2/mem64 F2 0F 5D /r

Compares scalar double-precision floating-point values in an XMM register and another XMM register or 64-bit memory location and writes the lesser of the two values in the destination XMM register.

minsd.eps

xmm1 xmm2/mem64

minimum

127 63 064 127 63 064

Page 170: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

142 MINSD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN or QNaN value.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 171: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MINSS 143

26568—Rev. 3.10—September 2007 AMD64 Technology

Compares the single-precision floating-point value in the low-order 32 bits of the first source operandwith the single-precision floating-point value in the low-order 32 bits of the second source operand andwrites the numerically lesser of the two values in the low-order 32 bits of the destination (first source).The first source/destination operand is an XMM register. The second source operand is another XMMregister or a 32-bit memory location. The three high-order doublewords of the destination XMMregister are not modified.

If both source operands are equal to zero, the value in the second source operand is returned. If eitheroperand is a NaN (SNaN or QNaN), and invalid-operation exceptions are masked, the second sourceoperand is written to the destination.

The MINSS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MAXPD, MAXPS, MAXSD, MAXSS, MINPD, MINPS, MINSD

rFLAGS Affected

None

MINSS Minimum Scalar Single-Precision Floating-Point

Mnemonic Opcode Description

MINSS xmm1, xmm2/mem32 F3 0F 5D /r

Compares scalar single-precision floating-point values in an XMM register and another XMM register or 32-bit memory location and writes the lesser of the two values in the destination XMM register.

minss.eps

xmm1 xmm2/mem32

minimum

127 31 032 127 31 032

Page 172: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

144 MINSS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN or QNaN value.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 173: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVAPD 145

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves two packed double-precision floating-point values:

• from an XMM register or 128-bit memory location to another XMM register, or

• from an XMM register to another XMM register or 128-bit memory location.

A memory operand that is not aligned on a 16-byte boundary causes a general-protection exception.

The MOVAPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVHPD, MOVLPD, MOVMSKPD, MOVSD, MOVUPD

MOVAPD Move Aligned Packed Double-PrecisionFloating-Point

Mnemonic Opcode Description

MOVAPD xmm1, xmm2/mem128 66 0F 28 /rMoves packed double-precision floating-point value from an XMM register or 128-bit memory location to an XMM register.

MOVAPD xmm1/mem128, xmm2 66 0F 29 /rMoves packed double-precision floating-point value from an XMM register to an XMM register or 128-bit memory location.

movapd.eps

127 63 064

xmm1 xmm2/mem128

copycopy

127 63 064

127 63 064

xmm1/mem128 xmm2

copycopy

127 63 064

Page 174: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

146 MOVAPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

X X X The memory operand was not aligned on a 16-byte boundary.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Page 175: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVAPS 147

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves four packed single-precision floating-point values:

• from an XMM register or 128-bit memory location to another XMM register, or

• from an XMM register to another XMM register or 128-bit memory location.

The MOVAPS instruction is an SSE instruction; check the status of EDX bit 25 returned by CPUIDfunction 0000_0001h to verify that the processor supports this function. (See “CPUID” in Volume 3.)

A memory operand that is not aligned on a 16-byte boundary causes a general-protection exception.

MOVAPS Move Aligned Packed Single-PrecisionFloating-Point

Mnemonic Opcode Description

MOVAPS xmm1, xmm2/mem128 0F 28 /rMoves aligned packed single-precision floating-point value from an XMM register or 128-bit memory location to the destination XMM register.

MOVAPS xmm1/mem128, xmm2 0F 29 /rMoves aligned packed single-precision floating-point value from an XMM register to the destination XMM register or 128-bit memory location.

Page 176: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

148 MOVAPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

MOVHLPS, MOVHPS, MOVLHPS, MOVLPS, MOVMSKPS, MOVSS, MOVUPS

rFLAGS Affected

None

MXCSR Flags Affected

None

movaps.eps

xmm1 xmm2/mem128

copy

copy

copy

copy

127 63 0649596 3132127 63 0649596 3132

xmm1/mem128 xmm2

copy

copy

copy

copy

127 63 0649596 3132127 63 0649596 3132

Page 177: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVAPS 149

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

X X X The memory operand was not aligned on a 16-byte boundary.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Page 178: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

150 MOVD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Moves a 32-bit or 64-bit value in one of the following ways:

• from a 32-bit or 64-bit general-purpose register or memory location to the low-order 32 or 64 bitsof an XMM register, with zero-extension to 128 bits

• from the low-order 32 or 64 bits of an XMM to a 32-bit or 64-bit general-purpose register ormemory location

• from a 32-bit or 64-bit general-purpose register or memory location to the low-order 32 bits (withzero-extension to 64 bits) or the full 64 bits of an MMX register

• from the low-order 32 or the full 64 bits of an MMX register to a 32-bit or 64-bit general-purposeregister or memory location

The MOVD instruction is an MMX instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

MOVD Move Doubleword or Quadword

Mnemonic Opcode Description

MOVD xmm, reg/mem32 66 0F 6E /r Move 32-bit value from a general-purpose register or 32-bit memory location to an XMM register.

MOVD xmm, reg/mem64 66 0F 6E /r Move 64-bit value from a general-purpose register or 64-bit memory location to an XMM register.

MOVD reg/mem32, xmm 66 0F 7E /r Move 32-bit value from an XMM register to a 32-bit general-purpose register or memory location.

MOVD reg/mem64, xmm 66 0F 7E /r Move 64-bit value from an XMM register to a 64-bit general-purpose register or memory location.

Page 179: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVD 151

26568—Rev. 3.10—September 2007 AMD64 Technology

movd.eps

with REX prefix

All operationsare "copy"

with REX prefix

reg/mem64xmm

63 0

63 0

127 63 064

127 63 064

reg/mem64 xmm

0

031

reg/mem32xmm

reg/mem32 xmm

127 0313231 0

127 31 032

0

0

reg/mem64mmx

reg/mem64 mmx

0

with REX prefix

with REX prefix

63 063 0

63 063 0

0310

reg/mem32mmx

reg/mem32 mmx

31 0

313263 0

313263 0

0

Page 180: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

152 MOVD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

MOVDQA, MOVDQU, MOVDQ2Q, MOVQ, MOVQ2DQ

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Description

Invalid opcode, #UD

X X XThe MMX™ instructions are not supported, as indicated by EDX bit 23 of CPUID function 0000_0001h.

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The instruction used XMM registers while CR4.OSFXSR=0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

x87 floating-point exception pending, #MF

X X X An x87 floating-point exception was pending and the instruction referenced an MMX register.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 181: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVDDUP 153

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves a quadword value with its duplicate from the source operand to each quadword half of theXMM destination operand. The source operand may be an XMM register or the address of the least-significant byte of 64 bits of data in memory. When an XMM register is specified as the sourceoperand, the lower 64-bits are duplicated and copied. When a memory address is specified, the 8 bytesof data at mem64 are duplicated and loaded.

The MOVDDUP instruction is an SSE3 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVSHDUP, MOVSLDUP

rFLAGS Affected

None

MXCSR Flags Affected

None

MOVDDUP Move Double-Precision and Duplicate

Mnemonic Opcode Description

MOVDDUP xmm1, xmm2/mem64 F2 0F 12 /r

Moves two copies of the lower 64 bits of the source XMM or 128-bit memory operand to the lower and upper quadwords of the destination XMM register.

xmm1 xmm2/mem64

06306364127 64128

Page 182: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

154 MOVDDUP Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE3 instructions are not supported, as indicated by ECX bit 0 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 183: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVDQ2Q 155

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves the low-order 64-bit value in an XMM register to a 64-bit MMX register.

The MOVDQ2Q instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVD, MOVDQA, MOVDQU, MOVQ, MOVQ2DQ

rFLAGS Affected

None

MXCSR Flags Affected

None

MOVDQ2Q Move Quadword to Quadword

Mnemonic Opcode Description

MOVDQ2Q mmx, xmm F2 0F D6 /r Moves low-order 64-bit value from an XMM register to the destination MMX register.

movdq2q.eps

mmx xmm

copy

63 0 127 63 064

Page 184: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

156 MOVDQ2Q Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

General protection X The destination operand was in a non-writable segment.

x87 floating-point exception pending, #MF

X X X An exception was pending due to an x87 floating-point instruction.

Page 185: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVDQA 157

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves an aligned 128-bit (double quadword) value:

• from an XMM register or 128-bit memory location to another XMM register, or

• from an XMM register to a 128-bit memory location or another XMM register.

A memory operand that is not aligned on a 16-byte boundary causes a general-protection exception.

The MOVDQA instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVD, MOVDQU, MOVDQ2Q, MOVQ, MOVQ2DQ

rFLAGS Affected

None

MOVDQA Move Aligned Double Quadword

Mnemonic Opcode Description

MOVDQA xmm1, xmm2/mem128 66 0F 6F /r Moves 128-bit value from an XMM register or 128-bit memory location to the destination XMM register.

MOVDQA xmm1/mem128, xmm2 66 0F 7F /r Moves 128-bit value from an XMM register to the destination XMM register or 128-bit memory location.

movdqa.eps

xmm1 xmm2/mem128

copy

127 0127 0

xmm1/mem128 xmm2

copy

127 0127 0

Page 186: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

158 MOVDQA Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

X X X The memory operand was not aligned on a 16-byte boundary.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Page 187: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVDQU 159

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves an unaligned 128-bit (double quadword) value:

• from an XMM register or 128-bit memory location to another XMM register, or

• from an XMM register to another XMM register or 128-bit memory location.

Memory operands that are not aligned on a 16-byte boundary do not cause a general-protectionexception.

The MOVDQU instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVD, MOVDQA, MOVDQ2Q, MOVQ, MOVQ2DQ

rFLAGS Affected

None

MOVDQU Move Unaligned Double Quadword

Mnemonic Opcode Description

MOVDQU xmm1, xmm2/mem128 F3 0F 6F /rMoves 128-bit value from an XMM register or unaligned 128-bit memory location to the destination XMM register.

MOVDQU xmm1/mem128, xmm2 F3 0F 7F /rMoves 128-bit value from an XMM register to the destination XMM register or unaligned 128-bit memory location.

movdqu.eps

xmm1 xmm2/mem128

copy

127 0127 0

xmm1/mem128 xmm2

copy

127 0127 0

Page 188: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

160 MOVDQU Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 189: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVHLPS 161

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves two packed single-precision floating-point values from the high-order 64 bits of an XMMregister to the low-order 64 bits of another XMM register. The high-order 64 bits of the destinationXMM register are not modified.

The MOVHLPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVAPS, MOVHPS, MOVLHPS, MOVLPS, MOVMSKPS, MOVSS, MOVUPS

rFLAGS Affected

None

MXCSR Flags Affected

None

MOVHLPS Move Packed Single-Precision Floating-PointHigh to Low

Mnemonic Opcode Description

MOVHLPS xmm1, xmm2 0F 12 /r Moves two packed single-precision floating-point values from an XMM register to the destination XMM register.

127 63 0649596

xmm1 xmm2

copy copy

movhlps.eps

127 63 064 3132

Page 190: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

162 MOVHLPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Page 191: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVHPD 163

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves a double-precision floating-point value:

• from a 64-bit memory location to the high-order 64 bits of an XMM register, or

• from the high-order 64 bits of an XMM register to a 64-bit memory location.

The low-order 64 bits of the destination XMM register are not modified.

The MOVHPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVAPD, MOVLPD, MOVMSKPD, MOVSD, MOVUPD

rFLAGS Affected

None

MOVHPD Move High Packed Double-PrecisionFloating-Point

Mnemonic Opcode Description

MOVHPD xmm, mem64 66 0F 16 /r Moves double-precision floating-point value from a 64-bit memory location to an XMM register.

MOVHPD mem64, xmm 66 0F 17 /r Moves double-precision floating-point value from an XMM register to a 64-bit memory location.

127 63 064

xmm mem64

copy

63 0

movhpd.eps

127 31 032

xmmmem64

copy

63 0

Page 192: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

164 MOVHPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 193: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVHPS 165

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves two packed single-precision floating-point values:

• from a 64-bit memory location to the high-order 64 bits of an XMM register, or

• from the high-order 64 bits of an XMM register to a 64-bit memory location.

The low-order 64 bits of the destination XMM register are not modified.

The MOVHPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVAPS, MOVHLPS, MOVLHPS, MOVLPS, MOVMSKPS, MOVSS, MOVUPS

rFLAGS Affected

None

MOVHPS Move High Packed Single-Precision Floating-Point

Mnemonic Opcode Description

MOVHPS xmm, mem64 0F 16 /r Moves two packed single-precision floating-point values from a 64-bit memory location to an XMM register.

MOVHPS mem64, xmm 0F 17 /r Moves two packed single-precision floating-point values from an XMM register to a 64-bit memory location.

127 63 0649596

xmm mem64

copy copy

63 03132

movhps.eps

xmmmem64

copy copy

63 03132 127 63 0649596

Page 194: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

166 MOVHPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 195: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVLHPS 167

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves two packed single-precision floating-point values from the low-order 64 bits of an XMMregister to the high-order 64 bits of another XMM register. The low-order 64 bits of the destinationXMM register are not modified.

The MOVLHPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVAPS, MOVHLPS, MOVHPS, MOVLPS, MOVMSKPS, MOVSS, MOVUPS

rFLAGS Affected

None

MXCSR Flags Affected

None

MOVLHPS Move Packed Single-Precision Floating-PointLow to High

Mnemonic Opcode Description

MOVLHPS xmm1, xmm2 0F 16 /r Moves two packed single-precision floating-point values from an XMM register to another XMM register.

127 63 0649596

xmm1 xmm2

copy copy

movlhps.eps

127 63 064 3132

Page 196: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

168 MOVLHPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Page 197: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVLPD 169

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves a double-precision floating-point value:

• from a 64-bit memory location to the low-order 64 bits of an XMM register, or

• from the low-order 64 bits of an XMM register to a 64-bit memory location.

The high-order 64 bits of the destination XMM register are not modified.

The MOVLPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVAPD, MOVHPD, MOVMSKPD, MOVSD, MOVUPD

rFLAGS Affected

None

MOVLPD Move Low Packed Double-PrecisionFloating-Point

Mnemonic Opcode Description

MOVLPD xmm, mem64 66 0F 12 /r Moves double-precision floating-point value from a 64-bit memory location to an XMM register.

MOVLPD mem64, xmm 66 0F 13 /r Moves double-precision floating-point value from an XMM register to a 64-bit memory location.

127 63 064

xmm mem64

copy

63 0

movlpd.eps

xmmmem64

copy

63 0 127 63 064

Page 198: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

170 MOVLPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 199: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVLPS 171

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves two packed single-precision floating-point values:

• from a 64-bit memory location to the low-order 64 bits of an XMM register, or

• from the low-order 64 bits of an XMM register to a 64-bit memory location

The high-order 64 bits of the destination XMM register are not modified.

The MOVLPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVAPS, MOVHLPS, MOVHPS, MOVLHPS, MOVMSKPS, MOVSS, MOVUPS

MOVLPS Move Low Packed Single-PrecisionFloating-Point

Mnemonic Opcode Description

MOVLPS xmm, mem64 0F 12 /r Moves two packed single-precision floating-point values from a 64-bit memory location to an XMM register.

MOVLPS mem64, xmm 0F 13 /r Moves two packed single-precision floating-point values from an XMM register to a 64-bit memory location.

127 63 064 3132

xmm mem64

copy copy

63 03132

movlps.eps

xmmmem64

copy copy

63 03132 127 63 064 3132

Page 200: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

172 MOVLPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X XThe operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of the control register (CR4) was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 201: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVMSKPD 173

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves the sign bits of two packed double-precision floating-point values in an XMM register to thetwo low-order bits of a 32-bit general-purpose register, with zero-extension.

The MOVMSKPD instruction is an SSE2 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVMSKPS, PMOVMSKB

rFLAGS Affected

None

MXCSR Flags Affected

None

MOVMSKPD Extract Packed Double-Precision Floating-PointSign Mask

Mnemonic Opcode Description

MOVMSKPD reg32, xmm 66 0F 50 /r Move sign bits in an XMM register to a 32-bit general-purpose register.

movmskpd.eps

reg32 xmm

copy signcopy sign

127 63 00

0

131

Page 202: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

174 MOVMSKPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception (vector) RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Page 203: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVMSKPS 175

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves the sign bits of four packed single-precision floating-point values in an XMM register to thefour low-order bits of a 32-bit general-purpose register, with zero-extension.

The MOVMSKPS instruction is an SSE instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVMSKPD, PMOVMSKB

rFLAGS Affected

None

MXCSR Flags Affected

None

MOVMSKPS Extract Packed Single-Precision Floating-PointSign Mask

Mnemonic Opcode Description

MOVMSKPS reg32, xmm 0F 50 /r Move sign bits in an XMM register to a 32-bit general-purpose register.

movmskps.eps

03 127 63 095 31

reg32 xmm

copy signcopy signcopy signcopy sign

0

31

Page 204: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

176 MOVMSKPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Page 205: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVNTDQ 177

26568—Rev. 3.10—September 2007 AMD64 Technology

Stores a 128-bit (double quadword) XMM register value into a 128-bit memory location. Thisinstruction indicates to the processor that the data is non-temporal, and is unlikely to be used againsoon. The processor treats the store as a write-combining (WC) memory write, which minimizes cachepollution. The exact method by which cache pollution is minimized depends on the hardwareimplementation of the instruction. For further information, see “Memory Optimization” in Volume 1.

MOVNTDQ is weakly-ordered with respect to other instructions that operate on memory. Softwareshould use an SFENCE instruction to force strong memory ordering of MOVNTDQ with respect toother stores.

The MOVNTDQ instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVNTI, MOVNTPD, MOVNTPS, MOVNTQ

rFLAGS Affected

None

MXCSR Flags Affected

None

MOVNTDQ Move Non-Temporal Double Quadword

Mnemonic Opcode Description

MOVNTDQ mem128, xmm 66 0F E7 /r Stores a 128-bit XMM register value into a 128-bit memory location, minimizing cache pollution.

movntdq.eps

mem128 xmm

copy

127 0127 0

Page 206: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

178 MOVNTDQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (CR0.EM) was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (CR4.OSFXSR) was cleared to 0.

Device not available, #NM X X X The task-switch bit (CR0.TS) was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

X X X The memory operand was not aligned on a 16-byte boundary.

Page fault, #PF X X A page fault resulted from executing the instruction.

Page 207: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVNTPD 179

26568—Rev. 3.10—September 2007 AMD64 Technology

Stores two double-precision floating-point XMM register values into a 128-bit memory location. Thisinstruction indicates to the processor that the data is non-temporal, and is unlikely to be used againsoon. The processor treats the store as a write-combining (WC) memory write, which minimizes cachepollution. The exact method by which cache pollution is minimized depends on the hardwareimplementation of the instruction. For further information, see “Memory Optimization” in Volume 1.

The MOVNTPD instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

MOVNTPD is weakly-ordered with respect to other instructions that operate on memory. Softwareshould use an SFENCE instruction to force strong memory ordering of MOVNTPD with respect toother stores.

Related Instructions

MOVNTDQ, MOVNTI, MOVNTPS, MOVNTQ

rFLAGS Affected

None

MXCSR Flags Affected

None

MOVNTPD Move Non-Temporal Packed Double-PrecisionFloating-Point

Mnemonic Opcode Description

MOVNTPD mem128, xmm 66 0F 2B /rStores two packed double-precision floating-point XMM register values into a 128-bit memory location, minimizing cache pollution.

movntpd.eps

mem128 xmm

copy copy

127 63 064 127 63 064

Page 208: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

180 MOVNTPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (CR0.EM) was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (CR4.OSFXSR) was cleared to 0.

Device not available, #NM X X X The task-switch bit (CR0.TS) was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

X X X The memory operand was not aligned on a 16-byte boundary.

Page fault, #PF X X A page fault resulted from executing the instruction.

Page 209: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVNTPS 181

26568—Rev. 3.10—September 2007 AMD64 Technology

Stores four single-precision floating-point XMM register values into a 128-bit memory location. Thisinstruction indicates to the processor that the data is non-temporal, and is unlikely to be used againsoon. The processor treats the store as a write-combining (WC) memory write, which minimizes cachepollution. The exact method by which cache pollution is minimized depends on the hardwareimplementation of the instruction. For further information, see “Memory Optimization” in Volume 1.

The MOVNTPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

MOVNTPD is weakly-ordered with respect to other instructions that operate on memory. Softwareshould use an SFENCE instruction to force strong memory ordering of MOVNTPD with respect toother stores.

Related Instructions

MOVNTDQ, MOVNTI, MOVNTPD, MOVNTQ

rFLAGS Affected

None

MXCSR Flags Affected

None

MOVNTPS Move Non-Temporal PackedSingle-Precision Floating-Point

Mnemonic Opcode Description

MOVNTPS mem128, xmm 0F 2B /rStores four packed single-precision floating-point XMM register values into a 128-bit memory location, minimizing cache pollution.

movntps.eps

mem128 xmm

copycopy

copycopy

127 63 0649596 3132127 63 0649596 3132

Page 210: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

182 MOVNTPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (CR0.EM) was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (CR4.OSFXSR) was cleared to 0.

Device not available, #NM X X X The task-switch bit (CR0.TS) was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

X X X The memory operand was not aligned on a 16-byte boundary.

Page fault, #PF X X A page fault resulted from executing the instruction.

Page 211: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVNTSD 183

26568—Rev. 3.10—September 2007 AMD64 Technology

Stores one double-precision floating-point XMM register value into a 64-bit memory location. Thisinstruction indicates to the processor that the data is non-temporal, and is unlikely to be used againsoon. The processor treats the store as a write-combining memory write, which minimizes cachepollution.

Support for the MOVNTSD instruction is indicated by ECX bit 6 (SSE4A) as returned by CPUIDfunction 8000_0001h. Software must check the CPUID bit once per program or library initializationbefore using the MOVNTSD instruction or inconsistent behavior may result.

Related Instructions

MOVNTDQ, MOVNTI, MOVNTPD, MOVNTPS, MOVNTQ, MOVNTSS

rFLAGS Affected

None

MOVNTSD Move Non-Temporal ScalarDouble-Precision Floating-Point

Mnemonic Opcode Description

MOVNTSD mem64, xmm F2 0F 2B /rStores one double-precision floating-point XMM register value into a 64 bit memory location. Treat as a non-temporal store.

mem64 xmm

copy

063 06364127

Page 212: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

184 MOVNTSD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE4A instructions are not supported, as indicated by ECX bit 6 (SSE4A) of CPUID function 8000_0001h.

X X X The emulate bit (CR0.EM) was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (CR4.OSFXSR) was cleared to 0.

Device not available, #NM X X X The task-switch bit (CR0.TS) was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

Page fault, #PF X X A page fault resulted from executing the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 213: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVNTSS 185

26568—Rev. 3.10—September 2007 AMD64 Technology

Stores one single-precision floating-point XMM register value into a 32-bit memory location. Thisinstruction indicates to the processor that the data is non-temporal, and is unlikely to be used againsoon. The processor treats the store as a write-combining memory write, which minimizes cachepollution.

Support for the MOVNTSS instruction is indicated by ECX bit 6 (SSE4A) as returned by CPUIDfunction 8000_0001h. Software must check the CPUID bit once per program or library initializationbefore using the MOVNTSS instruction, or inconsistent behavior may result.

Related Instructions

MOVNTDQ, MOVNTI, MOVNTOPD, MOVNTPS, MOVNTQ, MOVNTSD

rFLAGS Affected

None

MOVNTSS Move Non-Temporal ScalarSingle-Precision Floating-Point

Mnemonic Opcode Description

MOVNTSS mem32, xmm F3 0F 2B /rStores one single-precision floating-point XMM register value into a 32-bit memory location. Treat as a non-temporal store.

mem32 xmm

copy

0 03112731

Page 214: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

186 MOVNTSS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE4A instructions are not supported, as indicated by ECX bit 6 (SSE4A) of CPUID function 8000_0001h.

X X X The emulate bit (CR0.EM) was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (CR4.OSFXSR) was cleared to 0.

Device not available, #NM X X X The task-switch bit (CR0.TS) was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

Page fault, #PF X X A page fault resulted from executing the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 215: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVQ 187

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves a 64-bit value in one of the following ways:

• from the low-order 64 bits of an XMM register or a 64-bit memory location to the low-order 64 bitsof another XMM register, with zero-extension to 128 bits

• from the low-order 64 bits of an XMM register to the low-order 64 bits of another XMM register,with zero-extension to 128 bits or to a 64-bit memory location

The MOVQ instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVD, MOVDQA, MOVDQU, MOVDQ2Q, MOVQ2DQ

rFLAGS Affected

None

MOVQ Move Quadword

Mnemonic Opcode Description

MOVQ xmm1, xmm2/mem64 F3 0F 7E /r Moves 64-bit value from an XMM register or memory location to an XMM register.

MOVQ xmm1/mem64, xmm2 66 0F D6 /r Moves 64-bit value from an XMM register to an XMM register or memory location.

xmm1 xmm2/mem64

copy

movq-128.eps

xmm2xmm1/mem64

copy

127 63 064127

0

63 064

127 63 064127

0

63 064

Page 216: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

188 MOVQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 217: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVQ2DQ 189

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves a 64-bit value from an MMX register to the low-order 64 bits of an XMM register, with zero-extension to 128 bits.

The MOVQ2DQ instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVD, MOVDQA, MOVDQU, MOVDQ2Q, MOVQ

rFLAGS Affected

None

MXCSR Flags Affected

None

MOVQ2DQ Move Quadword to Quadword

Mnemonic Opcode Description

MOVQ2DQ xmm, mmx F3 0F D6 /r Moves 64-bit value from an MMX™ register to an XMM register.

127 63 064

xmm mmx

copy

63 0

movq2dq.eps

0

Page 218: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

190 MOVQ2DQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

x87 floating-point exception pending, #MF

X X X An exception was pending due to an x87 floating-point instruction.

Page 219: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVSD 191

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves a scalar double-precision floating-point value:

• from the low-order 64 bits of an XMM register or a 64-bit memory location to the low-order 64 bitsof another XMM register, or

• from the low-order 64 bits of an XMM register to the low-order 64 bits of another XMM register ora 64-bit memory location.

If the source operand is an XMM register, the high-order 64 bits of the destination XMM register arenot modified. If the source operand is a memory location, the high-order 64 bits of the destinationXMM register are cleared to all 0s.

This MOVSD instruction should not be confused with the MOVSD (move string doubleword)instruction with the same mnemonic in the general-purpose instruction set. Assemblers can distinguishthe instructions by the number and type of operands.

The MOVSD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

MOVSD Move Scalar Double-Precision Floating-Point

Mnemonic Opcode Description

MOVSD xmm1, xmm2/mem64 F2 0F 10 /rMoves double-precision floating-point value from an XMM register or 64-bit memory location to an XMM register.

MOVSD xmm1/mem64, xmm2 F2 0F 11 /rMoves double-precision floating-point value from an XMM register to an XMM register or 64-bit memory location.

Page 220: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

192 MOVSD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

MOVAPD, MOVHPD, MOVLPD, MOVMSKPD, MOVUPD

rFLAGS Affected

None

MXCSR Flags Affected

None

xmm1 xmm2

copy

mem64xmm1

copy

63 0127

0

63 064

movsd.eps

xmm2mem64

copy

127 63 06463 0

127 63 064127 63 064

Page 221: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVSD 193

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 222: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

194 MOVSHDUP Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Moves two copies of the second doubleword of data in the source XMM register or 128-bit memoryoperand to bits 31–0 and bits 63–32 of the destination XMM register; moves two copies of the fourthdoubleword of data in the source operand to bits 95–64 and bits 127–96 of the destination XMMregister.

The MOVSHDUP instruction is an SSE3 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVDDUP, MOVSLDUP

rFLAGS Affected

None

MXCSR Flags Affected

None

MOVSHDUP Move Single-Precision High and Duplicate

Mnemonic Opcode Description

MOVSHDUP xmm1, xmm2/mem128 F3 0F 16 /r

Copies the second 32-bits from the source operand to the first and second 32-bit segments of the destination XMM register; copies the fourth 32-bits from the source operand to the third and fourth 32-bit segments of the destination XMM register.

xmm1 xmm2/mem128

03132636495961270313263649596127

Page 223: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVSHDUP 195

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE3 instructions are not supported, as indicated by ECX bit 0 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 224: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

196 MOVSLDUP Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Moves two copies of the first doubleword of data in the source XMM register or 128-bit memoryoperand to bits 31–0 and bits 32–63 of the destination XMM register and moves two copies of the thirddoubleword of data in the source operand to bits 95–64 and bits 127–96 of the destination XMMregister.

The MOVSLDUP instruction is an SSE3 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVDDUP, MOVSHDUP

rFLAGS Affected

None

MXCSR Flags Affected

None

MOVSLDUP Move Single-Precision Low and Duplicate

Mnemonic Opcode Description

MOVSLDUP xmm1, xmm2/mem128 F3 0F 12 /r

Copies the first 32-bits from the source operand to the first and second 32-bit segments of the destination XMM register; copies the third 32-bits from the source operand to the third and fourth 32-bit segments of the destination XMM register.

xmm1 xmm2/mem128

03132636495961270313263649596127

Page 225: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVSLDUP 197

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE3 instructions are not supported, as indicated by ECX bit 0 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 226: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

198 MOVSS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Moves a scalar single-precision floating-point value:

• from the low-order 32 bits of an XMM register or a 32-bit memory location to the low-order 32 bitsof another XMM register, or

• from a 32-bit memory location to the low-order 32 bits of an XMM register, with zero-extension to128 bits.

If the source operand is an XMM register, the high-order 96 bits of the destination XMM register arenot modified. If the source operand is a memory location, the high-order 96 bits of the destinationXMM register are cleared to all 0s.

The MOVSS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

MOVSS Move Scalar Single-Precision Floating-Point

Mnemonic Opcode Description

MOVSS xmm1, xmm2/mem32 F3 0F 10 /r Moves single-precision floating-point value from an XMM register or 32-bit memory location to an XMM register.

MOVSS xmm1/mem32, xmm2 F3 0F 11 /r Moves single-precision floating-point value from an XMM register to an XMM register or 32-bit memory location.

127 31 032

xmm1 xmm2

copy

mem32xmm1

copy

0

0

movss.eps

xmm2mem32

copy

127 31 032

31 0127 31 032

31 0 127 31 032

Page 227: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVSS 199

26568—Rev. 3.10—September 2007 AMD64 Technology

Related Instructions

MOVAPS, MOVHLPS, MOVHPS, MOVLHPS, MOVLPS, MOVMSKPS, MOVUPS

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 228: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

200 MOVUPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Moves two packed double-precision floating-point values:

• from an XMM register or 128-bit memory location to another XMM register, or

• from an XMM register to another XMM register or 128-bit memory location.

Memory operands that are not aligned on a 16-byte boundary do not cause a general-protectionexception.

The MOVUPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

MOVUPD Move Unaligned Packed Double-PrecisionFloating-Point

Mnemonic Opcode Description

MOVUPD xmm1, xmm2/mem128 66 0F 10 /rMoves two packed double-precision floating-point values from an XMM register or unaligned 128-bit memory location to an XMM register.

MOVUPD xmm1/mem128, xmm2 66 0F 11 /rMoves two packed double-precision floating-point values from an XMM register to an XMM register or unaligned 128-bit memory location.

127 63 064

xmm1 xmm2/mem28

copycopy

127 63 064

movupd.eps

127 63 064

xmm1/mem28 xmm2

copycopy

127 6364

Page 229: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVUPD 201

26568—Rev. 3.10—September 2007 AMD64 Technology

Related Instructions

MOVAPD, MOVHPD, MOVLPD, MOVMSKPD, MOVSD

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 230: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

202 MOVUPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Moves four packed single-precision floating-point values:

• from an XMM register or 128-bit memory location to another XMM register, or

• from an XMM register to another XMM register or 128-bit memory location.

Memory operands that are not aligned on a 16-byte boundary do not cause a general-protectionexception.

The MOVUPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

MOVUPS Move Unaligned Packed Single-PrecisionFloating-Point

Mnemonic Opcode Description

MOVUPS xmm1, xmm2/mem128 0F 10 /rMoves four packed single-precision floating-point values from an XMM register or unaligned 128-bit memory location to an XMM register.

MOVUPS xmm1/mem128, xmm2 0F 11 /rMoves four packed single-precision floating-point values from an XMM register to an XMM register or unaligned 128-bit memory location.

Page 231: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MOVUPS 203

26568—Rev. 3.10—September 2007 AMD64 Technology

Related Instructions

MOVAPS, MOVHLPS, MOVHPS, MOVLHPS, MOVLPS, MOVMSKPS, MOVSS

rFLAGS Affected

None

MXCSR Flags Affected

None

movups.eps

xmm1 xmm2/mem128

copy

copy

copy

copy

127 63 0649596 3132127 63 0649596 3132

xmm1/mem128 xmm2

copy

copy

copy

copy

127 63 0649596 3132127 63 0649596 3132

Page 232: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

204 MOVUPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 233: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MULPD 205

26568—Rev. 3.10—September 2007 AMD64 Technology

Multiplies each of the two packed double-precision floating-point values in the first source operand bythe corresponding packed double-precision floating-point value in the second source operand andwrites the result of each multiplication operation in the corresponding quadword of the destination(first source). The first source/destination operand is an XMM register. The second source operand isanother XMM register or 128-bit memory location.

The MULPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MULPS, MULSD, MULSS, PFMUL

rFLAGS Affected

None

MXCSR Flags Affected

MULPD Multiply Packed Double-Precision Floating-Point

Mnemonic Opcode Description

MULPD xmm1, xmm2/mem128 66 0F 59 /r

Multiplies packed double-precision floating-point values in an XMM register and another XMM register or 128-bit memory location and writes the results in the destination XMM register.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

mulpd.eps

127 63 064 127 63 064

xmm1 xmm2/mem128

multiply

multiply

Page 234: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

206 MULPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X ±Zero was multiplied by ±infinity.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 235: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MULPS 207

26568—Rev. 3.10—September 2007 AMD64 Technology

Multiplies each of the four packed single-precision floating-point values in first source operand by thecorresponding packed single-precision floating-point value in the second source operand and writesthe result of each multiplication operation in the corresponding doubleword of the destination (firstsource). The first source/destination operand is an XMM register. The second source operand isanother XMM register or 128-bit memory location.

The MULPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MULPD, MULSD, MULSS, PFMUL

rFLAGS Affected

None

MULPS Multiply Packed Single-Precision Floating-Point

Mnemonic Opcode Description

MULPS xmm1, xmm2/mem128 0F 59 /r

Multiplies packed single-precision floating-point values in an XMM register and another XMM register or 128-bit memory location and writes the results in the destination XMM register.

mulps.eps

xmm1 xmm2/mem128

multiply

multiply

multiply

multiply

127 63 0649596 3132127 63 0649596 3132

Page 236: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

208 MULPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X ±Zero was multiplied by ±infinity.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Page 237: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MULPS 209

26568—Rev. 3.10—September 2007 AMD64 Technology

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 238: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

210 MULSD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Multiplies the double-precision floating-point value in the low-order quadword of first source operandby the double-precision floating-point value in the low-order quadword of the second source operandand writes the result in the low-order quadword of the destination (first source). The high-orderquadword of the destination is not modified. The first source/destination operand is an XMM register.The second source operand is another XMM register or 64-bit memory location.

The MULSD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MULPD, MULPS, MULSS, PFMUL

rFLAGS Affected

None

MXCSR Flags Affected

MULSD Multiply Scalar Double-Precision Floating-Point

Mnemonic Opcode Description

MULSD xmm1, xmm2/mem64 F2 0F 59 /r

Multiplies low-order double-precision floating-point values in an XMM register and another XMM register or 64-bit memory location and writes the result in the low-order quadword of the destination XMM register.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

mulsd.eps

xmm1 xmm2/mem64

multiply

127 63 064 127 63 064

Page 239: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MULSD 211

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X ±Zero was multiplied by ±infinity.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 240: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

212 MULSS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Multiplies the single-precision floating-point value in the low-order doubleword of first sourceoperand by the single-precision floating-point value in the low-order doubleword of the second sourceoperand and writes the result in the low-order doubleword of the destination (first source). The threehigh-order doublewords of the destination are not modified. The first source/destination operand is anXMM register. The second source operand is another XMM register or 32-bit memory location.

The MULSS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MULPD, MULPS, MULSD, PFMUL

rFLAGS Affected

None

MXCSR Flags Affected

MULSS Multiply Scalar Single-Precision Floating-Point

Mnemonic Opcode Description

MULSS xmm1, xmm2/mem32 F3 0F 59 /r

Multiplies low-order single-precision floating-point values in an XMM register and another XMM register or 32-bit memory location and writes the result in the low-order doubleword of the destination XMM register.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

mulss.eps

xmm1 xmm2/mem32

multiply

127 31 032 127 31 032

Page 241: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference MULSS 213

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X ±Zero was multiplied by ±infinity.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 242: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

214 ORPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Performs a bitwise logical OR of the two packed double-precision floating-point values in the firstsource operand and the corresponding two packed double-precision floating-point values in the secondsource operand and writes the result in the destination (first source). The first source/destinationoperand is an XMM register. The second source operand is another XMM register or 128-bit memorylocation.

The ORPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

ANDNPD, ANDNPS, ANDPD, ANDPS, ORPS, XORPD, XORPS

rFLAGS Affected

None

MXCSR Flags Affected

None

ORPD Logical Bitwise ORPacked Double-Precision Floating-Point

Mnemonic Opcode Description

ORPD xmm1, xmm2/mem128 66 0F 56 /r

Performs bitwise logical OR of two packed double-precision floating-point values in an XMM register and in another XMM register or 128-bit memory location and writes the result in the destination XMM register.

orpd.eps

127 63 064 127 63 064

xmm1 xmm2/mem128

OR

OR

Page 243: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference ORPD 215

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 244: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

216 ORPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Performs a bitwise logical OR of the four packed single-precision floating-point values in the firstsource operand and the corresponding four packed single-precision floating-point values in the secondsource operand and writes the result in the destination (first source). The first source/destinationoperand is an XMM register. The second source operand is another XMM register or 128-bit memorylocation.

The ORPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

ANDNPD, ANDNPS, ANDPD, ANDPS, ORPD, XORPD, XORPS

rFLAGS Affected

None

MXCSR Flags Affected

None

ORPS Logical Bitwise ORPacked Single-Precision Floating-Point

Mnemonic Opcode Description

ORPS xmm1, xmm2/mem128 0F 56 /r

Performs bitwise logical OR of four packed single-precision floating-point values in an XMM register and in another XMM register or 128-bit memory location and writes the result in the destination XMM register.

orps.eps

xmm1 xmm2/mem128

OR

OR

OR

OR

127 63 0649596 3132127 63 0649596 3132

Page 245: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference ORPS 217

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 246: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

218 PACKSSDW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts each 32-bit signed integer in the first and second source operands to a 16-bit signed integerand packs the converted values into words in the destination (first source). The first source/destinationoperand is an XMM register and the second source operand is another XMM register or 128-bitmemory location.

Converted values from the first source operand are packed into the low-order words of the destination,and the converted values from the second source operand are packed into the high-order words of thedestination.

The PACKSSDW instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

For each packed value in the destination, if the value is larger than the largest signed 16-bit integer, it issaturated to 7FFFh, and if the value is smaller than the smallest signed 16-bit integer, it is saturated to8000h.

Related Instructions

PACKSSWB, PACKUSWB

rFLAGS Affected

None

PACKSSDW Pack with Saturation Signed Doubleword to Word

Mnemonic Opcode Description

PACKSSDW xmm1, xmm2/mem128 66 0F 6B /r

Packs 32-bit signed integers in an XMM register and another XMM register or 128-bit memory location into 16-bit signed integers in an XMM register.

127 63 0649596111112 7980 4748 15163132

xmm1 xmm2/mem128

packssdw-128.eps

convert convert convertconvert

127 63 0649596 3132127 63 0649596 3132

. . .

....

.

Page 247: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PACKSSDW 219

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 248: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

220 PACKSSWB Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts each 16-bit signed integer in the first and second source operands to an 8-bit signed integerand packs the converted values into bytes in the destination (first source). The first source/destinationoperand is an XMM register and the second source operand is another XMM register or 128-bitmemory location.

Converted values from the first source operand are packed into the low-order bytes of the destination,and the converted values from the second source operand are packed into the high-order bytes of thedestination.

The PACKSSWB instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

For each packed value in the destination, if the value is larger than the largest signed 8-bit integer, it issaturated to 7Fh, and if the value is smaller than the smallest signed 8-bit integer, it is saturated to 80h.

Related Instructions

PACKSSDW, PACKUSWB

rFLAGS Affected

None

PACKSSWB Pack with Saturation Signed Word to Byte

Mnemonic Opcode Description

PACKSSWB xmm1, xmm2/mem128 66 0F 63 /r

Packs 16-bit signed integers in an XMM register and another XMM register or 128-bit memory location into 8-bit signed integers in an XMM register.

packsswb-128.eps

......

... ... ... ...

. .. ...

xmm1 xmm2/mem128

convertconvert

127 064 63

127 63 0649596111112 7980 4748 15163132127 63 0649596111112 7980 4748 15163132

Page 249: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PACKSSWB 221

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 250: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

222 PACKUSWB Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Converts each 16-bit signed integer in the first and second source operands to an 8-bit unsigned integerand packs the converted values into bytes in the destination (first source). The first source/destinationoperand is an XMM register and the second source operand is another XMM register or 128-bitmemory location.

Converted values from the first source operand are packed into the low-order bytes of the destination,and the converted values from the second source operand are packed into the high-order bytes of thedestination.

The PACKUSWB instruction is an SSE2 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

For each packed value in the destination, if the value is larger than the largest unsigned 8-bit integer, itis saturated to FFh, and if the value is smaller than the smallest unsigned 8-bit integer, it is saturated to00h.

Related Instructions

PACKSSDW, PACKSSWB

PACKUSWB Pack with Saturation Signed Word toUnsigned Byte

Mnemonic Opcode Description

PACKUSWB xmm1, xmm2/mem128 66 0F 67 /r

Packs 16-bit signed integers in an XMM register and another XMM register or 128-bit memory location into 8-bit unsigned integers in an XMM register.

......

... ... ... ...

. .. ...

xmm1 xmm2/mem128

convertconvert

127 064 63 packuswb-128.eps

127 63 0649596111112 7980 4748 15163132127 63 0649596111112 7980 4748 15163132

Page 251: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PACKUSWB 223

26568—Rev. 3.10—September 2007 AMD64 Technology

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 252: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

224 PADDB Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Adds each packed 8-bit integer value in the first source operand to the corresponding packed 8-bitinteger in the second source operand and writes the integer result of each addition in the correspondingbyte of the destination (first source). The first source/destination operand is an XMM register and thesecond source operand is another XMM register or 128-bit memory location.

The PADDB instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

This instruction operates on both signed and unsigned integers. If the result overflows, the carry isignored (neither the overflow nor carry bit in rFLAGS is set), and only the low-order 8 bits of eachresult are written in the destination.

Related Instructions

PADDD, PADDQ, PADDSB, PADDSW, PADDUSB, PADDUSW, PADDW

rFLAGS Affected

None

MXCSR Flags Affected

None

PADDB Packed Add Bytes

Mnemonic Opcode Description

PADDB xmm1, xmm2/mem128 66 0F FC /r Adds packed byte integer values in an XMM register and another XMM register or 128-bit memory location and writes the result in the destination XMM register.

add

127 0 127 0

xmm1 xmm2/mem128

add

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

paddb-128.eps

Page 253: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PADDB 225

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 254: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

226 PADDD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Adds each packed 32-bit integer value in the first source operand to the corresponding packed 32-bitinteger in the second source operand and writes the integer result of each addition in the correspondingdoubleword of the destination (first source). The first source/destination operand is an XMM registerand the second source operand is another XMM register or 128-bit memory location.

The PADDD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

This instruction operates on both signed and unsigned integers. If the result overflows, the carry isignored (neither the overflow nor carry bit in rFLAGS is set), and only the low-order 32 bits of eachresult are written in the destination.

Related Instructions

PADDB, PADDQ, PADDSB, PADDSW, PADDUSB, PADDUSW, PADDW

rFLAGS Affected

None

MXCSR Flags Affected

None

PADDD Packed Add Doublewords

Mnemonic Opcode Description

PADDD xmm1, xmm2/mem128 66 0F FE /rAdds packed 32-bit integer values in an XMM register and another XMM register or 128-bit memory location and writes the result in the destination XMM register.

add

xmm1 xmm2/mem128

add

. .

paddd-128.eps

127 63 0649596 3132

. .

. .127 63 0649596 3132

Page 255: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PADDD 227

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 256: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

228 PADDQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Adds each packed 64-bit integer value in the first source operand to the corresponding packed 64-bitinteger in the second source operand and writes the integer result of each addition in the correspondingquadword of the destination (first source). The first source/destination operand is an XMM registerand the second source operand is another XMM register or 128-bit memory location.

The PADDQ instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

This instruction operates on both signed and unsigned integers. If the result overflows, the carry isignored (neither the overflow nor carry bit in rFLAGS is set), and only the low-order 64 bits of eachresult are written in the destination.

Related Instructions

PADDB, PADDD, PADDSB, PADDSW, PADDUSB, PADDUSW, PADDW

rFLAGS Affected

None

MXCSR Flags Affected

None

PADDQ Packed Add Quadwords

Mnemonic Opcode Description

PADDQ xmm1, xmm2/mem128 66 0F D4 /rAdds packed 64-bit integer values in an XMM register and another XMM register or 128-bit memory location and writes the result in the destination XMM register.

add

xmm1 xmm2/mem128

add

paddq-128.eps

127 63 064127 63 064

Page 257: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PADDQ 229

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 258: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

230 PADDSB Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Adds each packed 8-bit signed integer value in the first source operand to the corresponding packed 8-bit signed integer in the second source operand and writes the signed integer result of each addition inthe corresponding byte of the destination (first source). The first source/destination operand is anXMM register and the second source operand is another XMM register or 128-bit memory location.

The PADDSB instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

For each packed value in the destination, if the value is larger than the largest representable signed 8-bit integer, it is saturated to 7Fh, and if the value is smaller than the smallest signed 8-bit integer, it issaturated to 80h.

Related Instructions

PADDB, PADDD, PADDQ, PADDSW, PADDUSB, PADDUSW, PADDW

rFLAGS Affected

None

MXCSR Flags Affected

None

PADDSB Packed Add Signed with Saturation Bytes

Mnemonic Opcode Description

PADDSB xmm1, xmm2/mem128 66 0F EC /r

Adds packed byte signed integer values in an XMM register and another XMM register or 128-bit memory location and writes the result in the destination XMM register.

add

127 0 127 0

xmm1 xmm2/mem128

add

saturatesaturate

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

paddsb-128.eps

Page 259: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PADDSB 231

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 260: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

232 PADDSW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Adds each packed 16-bit signed integer value in the first source operand to the corresponding packed16-bit signed integer in the second source operand and writes the signed integer result of each additionin the corresponding word of the destination (first source). The first source/destination operand is anXMM register and the second source operand is another XMM register or 128-bit memory location.

The PADDSW instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

For each packed value in the destination, if the value is larger than the largest representable signed 16-bit integer, it is saturated to 7FFFh, and if the value is smaller than the smallest signed 16-bit integer, itis saturated to 8000h.

Related Instructions

PADDB, PADDD, PADDQ, PADDSB, PADDUSB, PADDUSW, PADDW

rFLAGS Affected

None

MXCSR Flags Affected

None

PADDSW Packed Add Signed with Saturation Words

Mnemonic Opcode Description

PADDSW xmm1, xmm2/mem128 66 0F ED /r

Adds packed 16-bit signed integer values in an XMM register and another XMM register or 128-bit memory location and writes the result in the destination XMM register.

add

xmm1 xmm2/mem128

add

saturatesaturate

paddsw-128.eps

. .. .... .. ...

. .. ...127 63 0649596111112 7980 4748 15163132127 63 0649596111112 7980 4748 15163132

Page 261: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PADDSW 233

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 262: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

234 PADDUSB Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Adds each packed 8-bit unsigned integer value in the first source operand to the corresponding packed8-bit unsigned integer in the second source operand and writes the unsigned integer result of eachaddition in the corresponding byte of the destination (first source). The first source/destination operandis an XMM register and the second source operand is another XMM register or 128-bit memorylocation.

The PADDUSB instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

For each packed value in the destination, if the value is larger than the largest unsigned 8-bit integer, itis saturated to FFh, and if the value is smaller than the smallest unsigned 8-bit integer, it is saturated to00h.

Related Instructions

PADDB, PADDD, PADDQ, PADDSB, PADDSW, PADDUSW, PADDW

rFLAGS Affected

None

MXCSR Flags Affected

None

PADDUSB Packed Add Unsigned with Saturation Bytes

Mnemonic Opcode Description

PADDUSB xmm1, xmm2/mem128 66 0F DC /r

Adds packed byte unsigned integer values in an XMM register and another XMM register or 128-bit memory location and writes the result in the destination XMM register.

add

127 0 127 0

xmm1 xmm2/mem128

add

saturatesaturate

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

paddusb-128.eps

Page 263: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PADDUSB 235

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 264: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

236 PADDUSW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Adds each packed 16-bit unsigned integer value in the first source operand to the correspondingpacked 16-bit unsigned integer in the second source operand and writes the unsigned integer result ofeach addition in the corresponding word of the destination (first source). The first source/destinationoperand is an XMM register and the second source operand is another XMM register or 128-bitmemory location.

The PADDUSW instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

For each packed value in the destination, if the value is larger than the largest unsigned 16-bit integer,it is saturated to FFFFh, and if the value is smaller than the smallest unsigned 16-bit integer, it issaturated to 0000h.

Related Instructions

PADDB, PADDD, PADDQ, PADDSB, PADDSW, PADDUSB, PADDW

rFLAGS Affected

None

MXCSR Flags Affected

None

PADDUSW Packed Add Unsigned with Saturation Words

Mnemonic Opcode Description

PADDUSW xmm1, xmm2/mem128 66 0F DD /r

Adds packed 16-bit unsigned integer values in an XMM register and another XMM register or 128-bit memory location and writes result in the destination XMM register.

add

xmm1 xmm2/mem128

add

saturatesaturate

paddusw-128.eps

. .. .... .. ...

. .. ...127 63 0649596111112 7980 4748 15163132127 63 0649596111112 7980 4748 15163132

Page 265: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PADDUSW 237

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled and MXCSR.MM was set to 1.

Page 266: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

238 PADDW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Adds each packed 16-bit integer value in the first source operand to the corresponding packed 16-bitinteger in the second source operand and writes the integer result of each addition in the correspondingword of the destination (first source). The first source/destination operand is an XMM register and thesecond source operand is another XMM register or 128-bit memory location.

The PADDW instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

This instruction operates on both signed and unsigned integers. If the result overflows, the carry isignored (neither the overflow nor carry bit in rFLAGS is set), and only the low-order 16 bits of theresult are written in the destination.

Related Instructions

PADDB, PADDD, PADDQ, PADDSB, PADDSW, PADDUSB, PADDUSW

rFLAGS Affected

None

MXCSR Flags Affected

None

PADDW Packed Add Words

Mnemonic Opcode Description

PADDW xmm1, xmm2/mem128 66 0F FD /r Adds packed 16-bit integer values in an XMM register and another XMM register or 128-bit memory location and writes the result in the destination XMM register.

add

xmm1 xmm2/mem128

add

paddw-128.eps

. .. .... .. ...

. .. ...127 63 0649596111112 7980 4748 15163132127 63 0649596111112 7980 4748 15163132

Page 267: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PADDW 239

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 268: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

240 PAND Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Performs a bitwise logical AND of the values in the first and second source operands and writes theresult in the destination (first source). The first source/destination operand is an XMM register and thesecond source operand is another XMM register or 128-bit memory location.

The PAND instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PANDN, POR, PXOR

rFLAGS Affected

None

MXCSR Flags Affected

None

PAND Packed Logical Bitwise AND

Mnemonic Opcode Description

PAND xmm1, xmm2/mem128 66 0F DB /r

Performs bitwise logical AND of values in an XMM register and in another XMM register or 128-bit memory location and writes the result in the destination XMM register.

pand-128.eps

AND

xmm1 xmm2/mem128

127 0127 0

Page 269: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PAND 241

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 270: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

242 PANDN Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Performs a bitwise logical AND of the value in the second source operand and the one’s complementof the value in the first source operand and writes the result in the destination (first source). The firstsource/destination operand is an XMM register and the second source operand is another XMMregister or 128-bit memory location.

The PANDN instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PAND, POR, PXOR

rFLAGS Affected

None

MXCSR Flags Affected

None

PANDN Packed Logical Bitwise AND NOT

Mnemonic Opcode Description

PANDN xmm1, xmm2/mem128 66 0F DF /r

Performs bitwise logical AND NOT of values in an XMM register and in another XMM register or 128-bit memory location and writes the result in the destination XMM register.

pandn-128.eps

AND

xmm1 xmm2/mem128

127 0127 0

invert

Page 271: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PANDN 243

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 272: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

244 PAVGB Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Computes the rounded average of each packed unsigned 8-bit integer value in the first source operandand the corresponding packed 8-bit unsigned integer in the second source operand and writes eachaverage in the corresponding byte of the destination (first source). The average is computed by addingeach pair of operands, adding 1 to the 9-bit temporary sum, and then right-shifting the temporary sumby one bit position. The destination and source operands are an XMM register and another XMMregister or 128-bit memory location.

The PAVGB instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PAVGW

rFLAGS Affected

None

MXCSR Flags Affected

None

PAVGB Packed Average Unsigned Bytes

Mnemonic Opcode Description

PAVGB xmm1, xmm2/mem128 66 0F E0 /r

Averages packed 8-bit unsigned integer values in an XMM register and another XMM register or 128-bit memory location and writes the result in the destination XMM register.

average

127 0 127 0

xmm1 xmm2/mem128

average

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

pavgb-128.eps

Page 273: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PAVGB 245

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 in CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 274: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

246 PAVGW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Computes the rounded average of each packed unsigned 16-bit integer value in the first source operandand the corresponding packed 16-bit unsigned integer in the second source operand and writes eachaverage in the corresponding word of the destination (first source). The average is computed by addingeach pair of operands, adding 1 to the 17-bit temporary sum, and then right-shifting the temporary sumby one bit position. The first source/destination operand is an XMM register and the second sourceoperand is another XMM register or 128-bit memory location.

The PAVGW instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PAVGB

rFLAGS Affected

None

MXCSR Flags Affected

None

PAVGW Packed Average Unsigned Words

Mnemonic Opcode Description

PAVGW xmm1, xmm2/mem128 66 0F E3 /r

Averages packed 16-bit unsigned integer values in an XMM register and another XMM register or 128-bit memory location and writes the result in the destination XMM register.

average

xmm1 xmm2/mem128

average

pavgw-128.eps

. .. .... .. ...

. .. ...127 63 0649596111112 7980 4748 15163132127 63 0649596111112 7980 4748 15163132

Page 275: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PAVGW 247

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by bit 25 in CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 276: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

248 PCMPEQB Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Compares corresponding packed bytes in the first and second source operands and writes the result ofeach comparison in the corresponding byte of the destination (first source). For each pair of bytes, ifthe values are equal, the result is all 1s. If the values are not equal, the result is all 0s. The firstsource/destination operand is an XMM register and the second source operand is another XMMregister or 128-bit memory location.

The PCMPEQB instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PCMPEQD, PCMPEQW, PCMPGTB, PCMPGTD, PCMPGTW

rFLAGS Affected

None

MXCSR Flags Affected

None

PCMPEQB Packed Compare Equal Bytes

Mnemonic Opcode Description

PCMPEQB xmm1, xmm2/mem128 66 0F 74 /r Compares packed bytes in an XMM register and an XMM register or 128-bit memory location.

compare

127 0 127 0

xmm1 xmm2/mem128

compare. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

all 1s or 0s

all 1s or 0s

pcmpeqb-128.eps

Page 277: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PCMPEQB 249

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 278: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

250 PCMPEQD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Compares corresponding packed 32-bit values in the first and second source operands and writes theresult of each comparison in the corresponding 32 bits of the destination (first source). For each pair ofdoublewords, if the values are equal, the result is all 1s. If the values are not equal, the result is all 0s.The first source/destination operand is an XMM register and the second source operand is anotherXMM register or 128-bit memory location.

The PCMPEQD instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PCMPEQB, PCMPEQW, PCMPGTB, PCMPGTD, PCMPGTW

rFLAGS Affected

None

MXCSR Flags Affected

None

PCMPEQD Packed Compare Equal Doublewords

Mnemonic Opcode Description

PCMPEQD xmm1, xmm2/mem128 66 0F 76 /r Compares packed doublewords in an XMM register

and an XMM register or 128-bit memory location.

compare

all 1s or 0s

xmm1 xmm2/mem128

compare

all 1s or 0s

. .

pcmpeqd-128.eps

127 63 0649596 3132

. .

. .127 63 0649596 3132

Page 279: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PCMPEQD 251

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 280: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

252 PCMPEQW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Compares corresponding packed 16-bit values in the first and second source operands and writes theresult of each comparison in the corresponding 16 bits of the destination (first source). For each pair ofwords, if the values are equal, the result is all 1s. If the values are not equal, the result is all 0s. The firstsource/destination operand is an XMM register and the second source operand is another XMMregister or 128-bit memory location.

The PCMPEQW instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PCMPEQB, PCMPEQD, PCMPGTB, PCMPGTD, PCMPGTW

rFLAGS Affected

None

MXCSR Flags Affected

None

PCMPEQW Packed Compare Equal Words

Mnemonic Opcode Description

PCMPEQW xmm1, xmm2/mem128 66 0F 75 /r Compares packed 16-bit values in an XMM register and an XMM register or 128-bit memory location.

compare

xmm1 xmm2/mem128

compare

all 1s or 0s

all 1s or 0s

pcmpeqw-128.eps

. .. .... .. ...

. .. ...127 63 0649596111112 7980 4748 15163132127 63 0649596111112 7980 4748 15163132

Page 281: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PCMPEQW 253

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 282: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

254 PCMPGTB Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Compares corresponding packed signed bytes in the first and second source operands and writes theresult of each comparison in the corresponding byte of the destination (first source). For each pair ofbytes, if the value in the first source operand is greater than the value in the second source operand, theresult is all 1s. If the value in the first source operand is less than or equal to the value in the secondsource operand, the result is all 0s. The first source/destination operand is an XMM register and thesecond source operand is another XMM register or 128-bit memory location.

The PCMPGTB instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PCMPEQB, PCMPEQD, PCMPEQW, PCMPGTD, PCMPGTW

rFLAGS Affected

None

MXCSR Flags Affected

None

PCMPGTB Packed Compare Greater Than Signed Bytes

Mnemonic Opcode Description

PCMPGTB xmm1, xmm2/mem128 66 0F 64 /r Compares packed signed bytes in an XMM register and an XMM register or 128-bit memory location.

compare

127 0 127 0

xmm1 xmm2/mem128

compare. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

all 1s or 0sall 1s or 0s

pcmpgtb-128.eps

Page 283: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PCMPGTB 255

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 284: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

256 PCMPGTD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Compares corresponding packed signed 32-bit values in the first and second source operands andwrites the result of each comparison in the corresponding 32 bits of the destination (first source). Foreach pair of doublewords, if the value in the first source operand is greater than the value in the secondsource operand, the result is all 1s. If the value in the first source operand is less than or equal to thevalue in the second source operand, the result is all 0s. The first source/destination operand is an XMMregister and the second source operand is another XMM register or 128-bit memory location.

The PCMPGTD instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PCMPEQB, PCMPEQD, PCMPEQW, PCMPGTB, PCMPGTW

rFLAGS Affected

None

MXCSR Flags Affected

None

PCMPGTD Packed Compare Greater Than SignedDoublewords

Mnemonic Opcode Description

PCMPGTD xmm1, xmm2/mem128 66 0F 66 /rCompares packed signed 32-bit values in an XMM register and an XMM register or 128-bit memory location.

compare

all 1s or 0s

xmm1 xmm2/mem128

compare

all 1s or 0s

. .

pcmpgtd-128.eps

127 63 0649596 3132

. .

. .127 63 0649596 3132

Page 285: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PCMPGTD 257

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 286: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

258 PCMPGTW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Compares corresponding packed signed 16-bit values in the first and second source operands andwrites the result of each comparison in the corresponding 16 bits of the destination (first source). Foreach pair of words, if the value in the first source operand is greater than the value in the second sourceoperand, the result is all 1s. If the value in the first source operand is less than or equal to the value inthe second source operand, the result is all 0s. The first source/destination operand is an XMM registerand the second source operand is another XMM register or 128-bit memory location.

The PCMPGTW instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PCMPEQB, PCMPEQD, PCMPEQW, PCMPGTB, PCMPGTD

rFLAGS Affected

None

MXCSR Flags Affected

None

PCMPGTW Packed Compare Greater Than Signed Words

Mnemonic Opcode Description

PCMPGTW xmm1, xmm2/mem128 66 0F 65 /rCompares packed signed 16-bit values in an XMM register and an XMM register or 128-bit memory location.

127 63 0649596111112 7980 4748 15163132127 63 0649596111112 7980 4748 15163132

compare

xmm1 xmm2/mem128

compare

all 1s or 0sall 1s or 0s

pcmpgtw-128.eps

. .. .... .. ...

. .. ...

Page 287: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PCMPGTW 259

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 288: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

260 PEXTRW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Extracts a 16-bit value from an XMM register, as selected by the immediate byte operand (as shown inTable 1-2) and writes it to the low-order word of a 32-bit general-purpose register, with zero-extensionto 32 bits.

The PEXTRW instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PINSRW

PEXTRW Extract Packed Word

Mnemonic Opcode Description

PEXTRW reg32, xmm, imm8 66 0F C5 /r ibExtracts a 16-bit value from an XMM register and writes it to low-order 16 bits of a general-purpose register.

Table 1-2. Immediate-Byte Operand Encoding for 128-Bit PEXTRW

Immediate-ByteBit Field Value of Bit Field Source Bits Extracted

2–0

0 15–0

1 31–16

2 47–32

3 63–48

4 79–64

5 95–80

6 111–96

7 127–112

reg32 xmm

imm87 0

mux

015

0

pextrw-128.eps

127 63 0649596111112 7980 4748 1516313232

Page 289: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PEXTRW 261

26568—Rev. 3.10—September 2007 AMD64 Technology

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 in CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Page 290: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

262 PINSRW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Inserts a 16-bit value from the low-order word of a 32-bit general purpose register or a 16-bit memorylocation into an XMM register. The location in the destination register is selected by the immediatebyte operand, as shown in Table 1-3 on page 262. The other words in the destination register operandare not modified.

The PINSRW instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

PINSRW Packed Insert Word

Mnemonic Opcode Description

PINSRW xmm, reg32/mem16, imm8 66 0F C4 /r ib

Inserts a 16-bit value from a general-purpose register or memory location into an XMM register.

Table 1-3. Immediate-Byte Operand Encoding for 128-Bit PINSRW

Immediate-ByteBit Field Value of Bit Field Destination Bits Filled

2–0

0 15–0

1 31–16

2 47–32

3 63–48

4 79–64

5 95–80

6 111–96

7 127–112

reg32/mem16xmm

imm87 0

select word position for insert

015

pinsrw-128.eps

127 63 0649596111112 7980 4748 15163132 32

Page 291: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PINSRW 263

26568—Rev. 3.10—September 2007 AMD64 Technology

Related Instructions

PEXTRW

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 in CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 292: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

264 PMADDWD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Multiplies each packed 16-bit signed value in the first source operand by the corresponding packed 16-bit signed value in the second source operand, adds the adjacent intermediate 32-bit results of eachmultiplication (for example, the multiplication results for the adjacent bit fields 63–48 and 47–32, and31–16 and 15–0), and writes the 32-bit result of each addition in the corresponding doubleword of thedestination (first source). The first source/destination operand is an XMM register and the secondsource operand is another XMM register or 128-bit memory location.

The PMADDWD instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

There is only one case in which the result of the multiplication and addition will not fit in a signed 32-bit destination. If all four of the 16-bit source operands used to produce a 32-bit multiply-add resulthave the value 8000h, the 32-bit result is 8000_0000h, which is incorrect.

Related Instructions

PMULHUW, PMULHW, PMULLW, PMULUDQ

PMADDWD Packed Multiply Words and Add Doublewords

Mnemonic Opcode Description

PMADDWD xmm1, xmm2/mem128 66 0F F5 /r

Multiplies eight packed 16-bit signed values in an XMM register and another XMM register or 128-bit memory location, adds intermediate results, and writes the result in the destination XMM register.

xmm1 xmm2/mem128

multiply

multiply

addmultiply

multiply

add

pmaddwd-128.eps

.. .... ..

..127 63 0649596 3132

127 63 0649596111112 7980 4748 15163132127 63 0649596111112 7980 4748 15163132

Page 293: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PMADDWD 265

26568—Rev. 3.10—September 2007 AMD64 Technology

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 294: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

266 PMAXSW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Compares each of the packed 16-bit signed integer values in the first source operand with thecorresponding packed 16-bit signed integer value in the second source operand and writes thenumerically greater of the two values for each comparison in the corresponding word of the destination(first source). The first source/destination and second source operands are an XMM register and anXMM register or 128-bit memory location.

The PMAXSW instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PMAXUB, PMINSW, PMINUB

rFLAGS Affected

None

MXCSR Flags Affected

None

PMAXSW Packed Maximum Signed Words

Mnemonic Opcode Description

PMAXSW xmm1, xmm2/mem128 66 0F EE /r

Compares packed signed 16-bit integer values in an XMM register and another XMM register or 128-bit memory location and writes the greater value of each comparison in destination XMM register.

maximum

xmm1 xmm2/mem128

maximum

pmaxsw-128.eps

. .. .... .. ...

. .. ...127 63 0649596111112 7980 4748 15163132127 63 0649596111112 7980 4748 15163132

Page 295: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PMAXSW 267

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 in CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 296: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

268 PMAXUB Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Compares each of the packed 8-bit unsigned integer values in the first source operand with thecorresponding packed 8-bit unsigned integer value in the second source operand and writes thenumerically greater of the two values for each comparison in the corresponding byte of the destination(first source). The first source/destination and second source operands are an XMM register and anXMM register or 128-bit memory location.

The PMAXUB instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PMAXSW, PMINSW, PMINUB

rFLAGS Affected

None

MXCSR Flags Affected

None

PMAXUB Packed Maximum Unsigned Bytes

Mnemonic Opcode Description

PMAXUB xmm1, xmm2/mem128 66 0F DE /r

Compares packed unsigned 8-bit integer values in an XMM register and another XMM register or 128-bit memory location and writes the greater value of each compare in the destination XMM register.

maximum

127 0 127 0

xmm1 xmm2/mem128

maximum

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

pmaxub-128.eps

Page 297: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PMAXUB 269

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 in CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 298: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

270 PMINSW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Compares each of the packed 16-bit signed integer values in the first source operand with thecorresponding packed 16-bit signed integer value in the second source operand and writes thenumerically lesser of the two values for each comparison in the corresponding word of the destination(first source). The first source/destination and second source operands are an XMM register and anXMM register or 128-bit memory location.

The PMINSW instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PMAXSW, PMAXUB, PMINUB

rFLAGS Affected

None

MXCSR Flags Affected

None

PMINSW Packed Minimum Signed Words

Mnemonic Opcode Description

PMINSW xmm1, xmm2/mem128 66 0F EA /r

Compares packed signed 16-bit integer values in an XMM register and another XMM register or 128-bit memory location and writes the lesser value of each compare in the destination XMM register.

minimum

xmm1 xmm2/mem128

minimum

pminsw-128.eps

. .. .... .. ...

. .. ...127 63 0649596111112 7980 4748 15163132127 63 0649596111112 7980 4748 15163132

Page 299: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PMINSW 271

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 in CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 300: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

272 PMINUB Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Compares each of the packed 8-bit unsigned integer values in the first source operand with thecorresponding packed 8-bit unsigned integer value in the second source operand and writes thenumerically lesser of the two values for each comparison in the corresponding byte of the destination(first source). The first source/destination operand is an XMM register and the second source operandis another XMM register or 128-bit memory location.

The PMINUB instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PMAXSW, PMAXUB, PMINSW

rFLAGS Affected

None

MXCSR Flags Affected

None

PMINUB Packed Minimum Unsigned Bytes

Mnemonic Opcode Description

PMINUB xmm1, xmm2/mem128 66 0F DA /r

Compares packed unsigned 8-bit integer values in an XMM register and another XMM register or 128-bit memory location and writes the lesser value of each comparison in the destination XMM register.

minimum

127 0 127 0

xmm1 xmm2/mem128

minimum

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

pminub-128.eps

Page 301: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PMINUB 273

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 in CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 302: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

274 PMOVMSKB Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Moves the most-significant bit of each byte in the source operand to the destination, with zero-extension to 32 bits. The destination and source operands are a 32-bit general-purpose register and anXMM register. The result is written to the low-order word of the general-purpose register.

The PMOVMSKB instruction is an SSE2 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

MOVMSKPD, MOVMSKPS

rFLAGS Affected

None

MXCSR Flags Affected

None

PMOVMSKB Packed Move Mask Byte

Mnemonic Opcode Description

PMOVMSKB reg32, xmm 66 0F D7 /r Moves most-significant bit of each byte in an XMM register to low-order word of a 32-bit general-purpose register.

reg32 xmm

copycopy

pmovmskb-128.eps

.. . . ... ..... . .

127 01523313947556371798795103111119 7015

0

. . .... . ...... . .... . .....32

Page 303: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PMOVMSKB 275

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Page 304: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

276 PMULHUW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Multiplies each packed unsigned 16-bit values in the first source operand by the corresponding packedunsigned word in the second source operand and writes the high-order 16 bits of each intermediate 32-bit result in the corresponding word of the destination (first source). The first source/destinationoperand is an XMM register and the second source operand is another XMM register or 128-bitmemory location.

The PMULHUW instruction is an SSE instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PMADDWD, PMULHW, PMULLW, PMULUDQ

rFLAGS Affected

None

MXCSR Flags Affected

None

PMULHUW Packed Multiply High Unsigned Word

Mnemonic Opcode Description

PMULHUW xmm1, xmm2/mem128 66 0F E4 /r

Multiplies packed 16-bit values in an XMM register by the packed 16-bit values in another XMM register or 128-bit memory location and writes the high-order 16 bits of each result in the destination XMM register.

multiply

xmm1 xmm2/mem128

multiply

. . .. . .

pmulhuw-128.eps

127 63 0649596111112 7980 4748 15163132

. . .. . .

. . .. . .127 63 0649596111112 7980 4748 15163132

Page 305: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PMULHUW 277

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by bit 25 in CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 306: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

278 PMULHW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Multiplies each packed 16-bit signed integer value in the first source operand by the correspondingpacked 16-bit signed integer in the second source operand and writes the high-order 16 bits of theintermediate 32-bit result of each multiplication in the corresponding word of the destination (firstsource). The first source/destination operand is an XMM register and the second source operand isanother XMM register or 128-bit memory location.

The PMULHW instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PMADDWD, PMULHUW, PMULLW, PMULUDQ

rFLAGS Affected

None

MXCSR Flags Affected

None

PMULHW Packed Multiply High Signed Word

Mnemonic Opcode Description

PMULHW xmm1, xmm2/mem128 66 0F E5 /r

Multiplies packed 16-bit signed integer values in an XMM register and another XMM register or 128-bit memory location and writes the high-order 16 bits of each result in the destination XMM register.

multiply

xmm1 xmm2/mem128

multiply

. . .. . .

pmulhw-128.eps

127 63 0649596111112 7980 4748 15163132

. . .. . .

. . .. . .127 63 0649596111112 7980 4748 15163132

Page 307: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PMULHW 279

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 308: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

280 PMULLW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Multiplies each packed 16-bit signed integer value in the first source operand by the correspondingpacked 16-bit signed integer in the second source operand and writes the low-order 16 bits of theintermediate 32-bit result of each multiplication in the corresponding word of the destination (firstsource). The first source/destination operand is an XMM register and the second source operand isanother XMM register or 128-bit memory location.

The PMULLW instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PMADDWD, PMULHUW, PMULHW, PMULUDQ

rFLAGS Affected

None

MXCSR Flags Affected

None

PMULLW Packed Multiply Low Signed Word

Mnemonic Opcode Description

PMULLW xmm1, xmm2/mem128 66 0F D5 /r

Multiplies packed 16-bit signed integer values in an XMM register and another XMM register or 128-bit memory location and writes the low-order 16 bits of each result in the destination XMM register.

multiply

xmm1 xmm2/mem128

multiply

. . .. . .

pmullw-128.eps

127 63 0649596111112 7980 4748 15163132

. . .. . .

. . .. . .127 63 0649596111112 7980 4748 15163132

Page 309: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PMULLW 281

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 310: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

282 PMULUDQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Multiplies two pairs of 32-bit unsigned integer values in the first and second source operands andwrites the two 64-bit results in the destination (first source). The first source/destination operand is anXMM register and the second source operand is another XMM register or 128-bit memory location.The source operands are in the first (low-order) and third doublewords of the source operands, and theresult of each multiply is stored in the first and second quadwords of the destination XMM register.

The PMULUDQ instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PMADDWD, PMULHUW, PMULHW, PMULLW

rFLAGS Affected

None

MXCSR Flags Affected

None

PMULUDQ Packed Multiply Unsigned Doubleword andStore Quadword

Mnemonic Opcode Description

PMULUDQ xmm1, xmm2/mem128 66 0F F4 /r

Multiplies two pairs of 32-bit unsigned integer values in an XMM register and another XMM register or 128-bit memory location and writes the two 64-bit results in the destination XMM register.

multiply

xmm1 xmm2/mem128

multiply

pmuludq-128.eps

127 63 0649596 3132127 63 0649596 3132

Page 311: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PMULUDQ 283

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 312: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

284 POR Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Performs a bitwise logical OR of the values in the first and second source operands and writes theresult in the destination (first source). The first source/destination operand is an XMM register and thesecond source operand is another XMM register or 128-bit memory location.

The POR instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PAND, PANDN, PXOR

rFLAGS Affected

None

MXCSR Flags Affected

None

POR Packed Logical Bitwise OR

Mnemonic Opcode Description

POR xmm1, xmm2/mem128 66 0F EB /r

Performs bitwise logical OR of values in an XMM register and in another XMM register or 128-bit memory location and writes the result in the destination XMM register.

por-128.eps

OR

xmm1 xmm2/mem128

127 0 127 0

Page 313: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference POR 285

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 314: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

286 PSADBW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Computes the absolute differences of eight corresponding packed 8-bit unsigned integers in the firstand second source operands and writes the unsigned 16-bit integer result of the sum of the eightdifferences in a word in the destination (first source). The first source/destination operand is an XMMregister and the second source operand is another XMM register or 128-bit memory location.

The sum of the differences of the eight bytes in the high-order quadwords of the source operands arewritten in the least-significant word of the high-order quadword in the destination XMM register, withthe remaining bytes cleared to all 0s. The sum of the differences of the eight bytes in the low-orderquadwords of the source operands are written in the least-significant word of the low-order quadwordin the destination XMM register, with the remaining bytes cleared to all 0s.

The PSADBW instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

PSADBW Packed Sum of Absolute Differences of Bytes Intoa Word

Mnemonic Opcode Description

PSADBW xmm1, xmm2/mem128 66 0F F6 /r

Compute the sum of the absolute differences of two sets of packed 8-bit unsigned integer values in an XMM register and another XMM register or 128-bit memory location and writes the 16-bit unsigned integer result in the destination XMM register.

psadbw-128.eps

. . . . . ... . . . . . . . . . . . . . . . .

xmm1 xmm2/mem128

127 0127 0

absolutedifference

absolutedifference

0

absolutedifference

add 8pairs

add 8pairs

absolutedifference

6364 6364

63 015127 6479

0

Page 315: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSADBW 287

26568—Rev. 3.10—September 2007 AMD64 Technology

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 in CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 316: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

288 PSHUFD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Moves any one of the four packed doublewords in an XMM register or 128-bit memory location toeach doubleword in another XMM register. In each case, the value of the destination doubleword isdetermined by a two-bit field in the immediate-byte operand, with bits 0 and 1 selecting the contents ofthe low-order doubleword, bits 2 and 3 selecting the second doubleword, bits 4 and 5 selecting the thirddoubleword, and bits 6 and 7 selecting the high-order doubleword. Refer to Table 1-4 on page 289. Adoubleword in the source operand may be copied to more than one doubleword in the destination.

The PSHUFD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

PSHUFD Packed Shuffle Doublewords

Mnemonic Opcode Description

PSHUFD xmm1, xmm2/mem128, imm8 66 0F 70 /r ib

Moves packed 32-bit values in an XMM register or 128-bit memory location to doubleword locations in another XMM register, as selected by the immediate-byte operand.

pshufd.eps

xmm1 xmm2/mem128

imm87 0

muxmux

muxmux

127 63 0649596 3132127 63 0649596 3132

Page 317: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSHUFD 289

26568—Rev. 3.10—September 2007 AMD64 Technology

Related Instructions

PSHUFHW, PSHUFLW, PSHUFW

rFLAGS Affected

None

MXCSR Flags Affected

None

Table 1-4. Immediate-Byte Operand Encoding for PSHUFD

Destination Bits FilledImmediate-Byte

Bit Field Value of Bit Field Source Bits Moved

31–0 1–0

0 31–0

1 63–32

2 95–64

3 127–96

63–32 3–2

0 31–0

1 63–32

2 95–64

3 127–96

95–64 5–4

0 31–0

1 63–32

2 95–64

3 127–96

127–96 7–6

0 31–0

1 63–32

2 95–64

3 127–96

Page 318: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

290 PSHUFD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 319: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSHUFHW 291

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves any one of the four packed words in the high-order quadword of an XMM register or 128-bitmemory location to each word in the high-order quadword of another XMM register. In each case, thevalue of the destination word is determined by a two-bit field in the immediate-byte operand, with bits0 and 1 selecting the contents of the low-order word, bits 2 and 3 selecting the second word, bits 4 and5 selecting the third word, and bits 6 and 7 selecting the high-order word. Refer to Table 1-5 onpage 292. A word in the source operand may be copied to more than one word in the destination. Thelow-order quadword of the source operand is copied to the low-order quadword of the destinationregister.

The PSHUFHW instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

PSHUFHW Packed Shuffle High Words

Mnemonic Opcode Description

PSHUFHW xmm1, xmm2/mem128, imm8 F3 0F 70 /r ib

Shuffles packed 16-bit values in high-order quadword of an XMM register or 128-bit memory location and puts the result in high-order quadword of another XMM register.

pshufhw.eps

xmm1 xmm2/mem128

imm87 0

127 63 0649596111112 7980127 63 0649596111112 7980

muxmux

muxmux

Page 320: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

292 PSHUFHW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

PSHUFD, PSHUFLW, PSHUFW

rFLAGS Affected

None

MXCSR Flags Affected

None

Table 1-5. Immediate-Byte Operand Encoding for PSHUFHW

Destination Bits FilledImmediate-Byte

Bit Field Value of Bit Field Source Bits Moved

79–64 1–0

0 79–64

1 95–80

2 111–96

3 127–112

95–80 3–2

0 79–64

1 95–80

2 111–96

3 127–112

111–96 5–4

0 79–64

1 95–80

2 111–96

3 127–112

127–112 7–6

0 79–64

1 95–80

2 111–96

3 127–112

Page 321: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSHUFHW 293

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 322: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

294 PSHUFLW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Moves any one of the four packed words in the low-order quadword of an XMM register or 128-bitmemory location to each word in the low-order quadword of another XMM register. In each case, theselection of the value of the destination word is determined by a two-bit field in the immediate-byteoperand, with bits 0 and 1 selecting the contents of the low-order word, bits 2 and 3 selecting thesecond word, bits 4 and 5 selecting the third word, and bits 6 and 7 selecting the high-order word.Refer to Table 1-6 on page 295. A word in the source operand may be copied to more than one word inthe destination. The high-order quadword of the source operand is copied to the high-order quadwordof the destination register.

The PSHUFLW instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

PSHUFLW Packed Shuffle Low Words

Mnemonic Opcode Description

PSHUFLW xmm1, xmm2/mem128, imm8 F2 0F 70 /r ib

Shuffles packed 16-bit values in low-order quadword of an XMM register or 128-bit memory location and puts the result in low-order quadword of another XMM register.

pshuflw.eps

xmm1 xmm2/mem128

imm87 0

muxmux

muxmux

127 064 63 4748 15163132127 064 63 4748 15163132

Page 323: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSHUFLW 295

26568—Rev. 3.10—September 2007 AMD64 Technology

Related Instructions

PSHUFD, PSHUFHW, PSHUFW

rFLAGS Affected

None

MXCSR Flags Affected

None

Table 1-6. Immediate-Byte Operand Encoding for PSHUFLW

Destination Bits FilledImmediate-Byte

Bit Field Value of Bit Field Source Bits Moved

15–0 1–0

0 15–0

1 31–16

2 47–32

3 63–48

31–16 3–2

0 15–0

1 31–16

2 47–32

3 63–48

47–32 5–4

0 15–0

1 31–16

2 47–32

3 63–48

63–48 7–6

0 15–0

1 31–16

2 47–32

3 63–48

Page 324: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

296 PSHUFLW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 325: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSLLD 297

26568—Rev. 3.10—September 2007 AMD64 Technology

Left-shifts each of the packed 32-bit values in the first source operand by the number of bits specifiedin the second source operand and writes each shifted value in the corresponding doubleword of thedestination (first source). The first source/destination and second source operands are:

• an XMM register and another XMM register or 128-bit memory location, or

• an XMM register and an immediate byte value.

The low-order bits that are emptied by the shift operation are cleared to 0. If the shift value is greaterthan 31, the destination is cleared to all 0s.

The PSLLD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PSLLDQ, PSLLQ, PSLLW, PSRAD, PSRAW, PSRLD, PSRLDQ, PSRLQ, PSRLW

PSLLD Packed Shift Left Logical Doublewords

Mnemonic Opcode Description

PSLLD xmm1, xmm2/mem128 66 0F F2 /r

Left-shifts packed doublewords in an XMM register by the amount specified in the low 64 bits of an XMM register or 128-bit memory location.

PSLLD xmm, imm8 66 0F 72 /6 ib Left-shifts packed doublewords in an XMM register by the amount specified in an immediate byte value.

shift left

xmm1 xmm2/mem128

shift left

pslld-128.eps

xmm imm8

127 63 064127 63 0649596 3132

..

..

shift left

shift left

127 63 0649596 3132

..

..7 0

Page 326: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

298 PSLLD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 327: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSLLDQ 299

26568—Rev. 3.10—September 2007 AMD64 Technology

Left-shifts the 128-bit (double quadword) value in an XMM register by the number of bytes specifiedin an immediate byte value. The low-order bytes that are emptied by the shift operation are cleared to0. If the shift value is greater than 15, the destination XMM register is cleared to all 0s.

The PSLLDQ instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PSLLD, PSLLQ, PSLLW, PSRAD, PSRAW, PSRLD, PSRLDQ, PSRLQ, PSRLW

rFLAGS Affected

None

MXCSR Flags Affected

None

PSLLDQ Packed Shift Left Logical Double Quadword

Mnemonic Opcode Description

PSLLDQ xmm, imm8 66 0F 73 /7 ib Left-shifts double quadword value in an XMM register by the amount specified in an immediate byte value.

pslldq.eps

127 0

xmm imm8

shift left

7 0

Page 328: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

300 PSLLDQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Page 329: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSLLQ 301

26568—Rev. 3.10—September 2007 AMD64 Technology

Left-shifts each 64-bit value in the first source operand by the number of bits specified in the secondsource operand and writes each shifted value in the corresponding quadword of the destination (firstsource). The first source/destination and second source operands are:

• an XMM register and another XMM register or 128-bit memory location, or

• an XMM register and an immediate byte value.

The low-order bits that are emptied by the shift operation are cleared to 0. If the shift value is greaterthan 63, the destination is cleared to all 0s.

The PSLLQ instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PSLLD, PSLLDQ, PSLLW, PSRAD, PSRAW, PSRLD, PSRLDQ, PSRLQ, PSRLW

PSLLQ Packed Shift Left Logical Quadwords

Mnemonic Opcode Description

PSLLQ xmm1, xmm2/mem128 66 0F F3 /r Left-shifts packed quadwords in XMM register by the amount specified in the low 64 bits of an XMM register or 128-bit memory location.

PSLLQ xmm, imm8 66 0F 73 /6 ib Left-shifts packed quadwords in an XMM register by the amount specified in an immediate byte value.

shift left

xmm1 xmm2/mem128

shift left

psllq-128.eps

xmm imm8

127 63 064

shift leftshift left

127 63 064 7 0

127 63 064

Page 330: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

302 PSLLQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 331: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSLLW 303

26568—Rev. 3.10—September 2007 AMD64 Technology

Left-shifts each of the packed 16-bit values in the first source operand by the number of bits specifiedin the second source operand and writes each shifted value in the corresponding word of thedestination (first source). The first source/destination and second source operands are:

• an XMM register and another XMM register or 128-bit memory location, or

• an XMM register and an immediate byte value

The low-order bits that are emptied by the shift operation are cleared to 0. If the shift value is greaterthan 15, the destination is cleared to all 0s.

The PSLLW instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

PSLLW Packed Shift Left Logical Words

Mnemonic Opcode Description

PSLLW xmm1, xmm2/mem128 66 0F F1 /r

Left-shifts packed words in an XMM register by the amount specified in the low 64 bits of an XMM register or 128-bit memory location.

PSLLW xmm, imm8 66 0F 71 /6 ib Left-shifts packed words in an XMM register by the amount specified in an immediate byte value.

shift left

xmm1 xmm2/mem128

shift left

psllw-128.eps

xmm imm8

shift leftshift left

. ... ..

. ... ..7 0127 63 0649596111112 7980 4748 15163132

. ... ..

. ... ..127 63 0649596111112 7980 4748 15163132 127 63 064

Page 332: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

304 PSLLW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

PSLLD, PSLLDQ, PSLLQ, PSRAD, PSRAW, PSRLD, PSRLDQ, PSRLQ, PSRLW

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 333: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSRAD 305

26568—Rev. 3.10—September 2007 AMD64 Technology

Right-shifts each of the packed 32-bit values in the first source operand by the number of bits specifiedin the second source operand and writes each shifted value in the corresponding doubleword of thedestination (first source). The first source/destination and second source operands are:

• an XMM register and another XMM register or 128-bit memory location, or

• an XMM register and an immediate byte value.

The high-order bits that are emptied by the shift operation are filled with the sign bit of thedoubleword’s initial value. If the shift value is greater than 31, each doubleword in the destination isfilled with the sign bit of the doubleword’s initial value.

The PSRAD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

PSRAD Packed Shift Right Arithmetic Doublewords

Mnemonic Opcode Description

PSRAD xmm1, xmm2/mem128 66 0F E2 /r

Right-shifts packed doublewords in an XMM register by the amount specified in the low 64 bits of an XMM register or 128-bit memory location.

PSRAD xmm, imm8 66 0F 72 /4 ib Right-shifts packed doublewords in an XMM register by the amount specified in an immediate byte value.

shift right

xmm1 xmm2/mem128

shift right

psrad-128.eps

xmm imm8

127 63 0649596 3132

..

..

..

shift right

shift right

127 63 0649596 3132

..

7 0

127 63 064

Page 334: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

306 PSRAD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

PSLLD, PSLLDQ, PSLLQ, PSLLW, PSRAW, PSRLD, PSRLDQ, PSRLQ, PSRLW

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 335: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSRAW 307

26568—Rev. 3.10—September 2007 AMD64 Technology

Right-shifts each of the packed 16-bit values in the first source operand by the number of bits specifiedin the second source operand and writes each shifted value in the corresponding word of thedestination (first source). The first source/destination and second source operands are:

• an XMM register and another XMM register or 128-bit memory location, or

• an XMM register and an immediate byte value.

The high-order bits that are emptied by the shift operation are filled with the sign bit of the word’sinitial value. If the shift value is greater than 15, each word in the destination is filled with the sign bitof the word’s initial value.

The PSRAW instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

PSRAW Packed Shift Right Arithmetic Words

Mnemonic Opcode Description

PSRAW xmm1, xmm2/mem128 66 0F E1 /r Right-shifts packed words in an XMM register by the amount specified in the low 64 bits of an XMM register or 128-bit memory location.

PSRAW xmm, imm8 66 0F 71 /4 ib Right-shifts packed words in an XMM register by the amount specified in an immediate byte value.

shift rightarithmetic

xmm1 xmm2/mem128

shift rightarithmetic

psraw-128.eps

xmm imm8

shift rightarithmetic

shift rightarithmetic

. ... ..

. ... ..

. ... ..

7 0127 63 0649596111112 7980 4748 15163132

. ... ..

127 63 0649596111112 7980 4748 15163132 127 63 064

Page 336: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

308 PSRAW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

PSLLD, PSLLDQ, PSLLQ, PSLLW, PSRAD, PSRLD, PSRLDQ, PSRLQ, PSRLW

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 337: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSRLD 309

26568—Rev. 3.10—September 2007 AMD64 Technology

Right-shifts each of the packed 32-bit values in the first source operand by the number of bits specifiedin the second source operand and writes each shifted value in the corresponding doubleword of thedestination (first source). The first source/destination and second source operands are:

• an XMM register and another XMM register or 128-bit memory location, or

• an XMM register and an immediate byte value.

The high-order bits that are emptied by the shift operation are cleared to 0. If the shift value is greaterthan 31, the destination is cleared to 0.

The PSRLD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

PSRLD Packed Shift Right Logical Doublewords

Mnemonic Opcode Description

PSRLD xmm1, xmm2/mem128 66 0F D2 /r

Right-shifts packed doublewords in an XMM register by the amount specified in the low 64 bits of an XMM register or 128-bit memory location.

PSRLD xmm, imm8 66 0F 72 /2 ib Right-shifts packed doublewords in an XMM register by the amount specified in an immediate byte value.

psrld-128.eps

shift right

xmm1 xmm2/mem128

shift right

xmm imm8

127 63 0649596 3132

..

..

..

shift right

shift right

127 63 0649596 3132

..

7 0

127 63 064

Page 338: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

310 PSRLD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

PSLLD, PSLLDQ, PSLLQ, PSLLW, PSRAD, PSRAW, PSRLDQ, PSRLQ, PSRLW

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 339: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSRLDQ 311

26568—Rev. 3.10—September 2007 AMD64 Technology

Right-shifts the 128-bit (double quadword) value in an XMM register by the number of bytes specifiedin an immediate byte value. The high-order bytes that are emptied by the shift operation are cleared to0. If the shift value is greater than 15, the destination XMM register is cleared to all 0s.

The PSRLDQ instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PSLLD, PSLLDQ, PSLLQ, PSLLW, PSRAD, PSRAW, PSRLD, PSRLQ, PSRLW

rFLAGS Affected

None

MXCSR Flags Affected

None

PSRLDQ Packed Shift Right Logical Double Quadword

Mnemonic Opcode Description

PSRLDQ xmm, imm8 66 0F 73 /3 ib Right-shifts double quadword value in an XMM register by the amount specified in an immediate byte value.

psrldq.eps

127 0

xmm imm8

shift right

7 0

Page 340: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

312 PSRLDQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Page 341: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSRLQ 313

26568—Rev. 3.10—September 2007 AMD64 Technology

Right-shifts each 64-bit value in the first source operand by the number of bits specified in the secondsource operand and writes each shifted value in the corresponding quadword of the destination (firstsource). The first source/destination and second source operands are:

• an XMM register and another XMM register or 128-bit memory location, or

• an XMM register and an immediate byte value.

The high-order bits that are emptied by the shift operation are cleared to 0. If the shift value is greaterthan 63, the destination is cleared to 0.

The PSRLQ instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

PSRLQ Packed Shift Right Logical Quadwords

Mnemonic Opcode Description

PSRLQ xmm1, xmm2/mem128 66 0F D3 /r

Right-shifts packed quadwords in an XMM register by the amount specified in the low 64 bits of an XMM register or 128-bit memory location.

PSRLQ xmm, imm8 66 0F 73 /2 ib Right-shifts packed quadwords in an XMM register by the amount specified in an immediate byte value.

shift right

xmm1 xmm2/mem128

shift right

psrlq-128.eps

xmm imm8

127 63 064

shift right

shift right

127 63 064 7 0

127 63 064

Page 342: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

314 PSRLQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

PSLLD, PSLLDQ, PSLLQ, PSLLW, PSRAD, PSRAW, PSRLD, PSRLDQ, PSRLW

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 343: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSRLW 315

26568—Rev. 3.10—September 2007 AMD64 Technology

Right-shifts each of the packed 16-bit values in the first source operand by the number of bits specifiedin the second operand and writes each shifted value in the corresponding word of the destination (firstsource). The first source/destination and second source operands are:

• an XMM register and another XMM register or 128-bit memory location, or

• an XMM register and an immediate byte value.

The high-order bits that are emptied by the shift operation are cleared to 0. If the shift value is greaterthan 15, the destination is cleared to 0.

The PSRLW instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

PSRLW Packed Shift Right Logical Words

Mnemonic Opcode Description

PSRLW xmm1, xmm2/mem128 66 0F D1 /r Right-shifts packed words in an XMM register by the amount specified in the low 64 bits of an XMM register or 128-bit memory location.

PSRLW xmm, imm8 66 0F 71 /2 ib Right-shifts packed words in an XMM register by the amount specified in an immediate byte value.

shift right

xmm1 xmm2/mem128

shift right

psrlw-128.eps

xmm imm8

shift right

shift right

. ... ..

. ... ..

. ... ..

7 0127 63 0649596111112 7980 4748 15163132

. ... ..

127 63 0649596111112 7980 4748 15163132 127 63 064

Page 344: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

316 PSRLW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

PSLLD, PSLLDQ, PSLLQ, PSLLW, PSRAD, PSRAW, PSRLD, PSRLDQ, PSRLQ

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X X X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 345: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSUBB 317

26568—Rev. 3.10—September 2007 AMD64 Technology

Subtracts each packed 8-bit integer value in the second source operand from the corresponding packed8-bit integer in the first source operand and writes the integer result of each subtraction in thecorresponding byte of the destination (first source). The first source/destination operand is an XMMregister and the second source operand is another XMM register or 128-bit memory location.

This instruction operates on both signed and unsigned integers. If the result overflows, the carry isignored (neither the overflow nor carry bit in rFLAGS is set), and only the low-order 8 bits of eachresult are written in the destination.

The PSUBB instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PSUBD, PSUBQ, PSUBSB, PSUBSW, PSUBUSB, PSUBUSW, PSUBW

rFLAGS Affected

None

MXCSR Flags Affected

None

PSUBB Packed Subtract Bytes

Mnemonic Opcode Description

PSUBB xmm1, xmm2/mem128 66 0F F8 /r

Subtracts packed byte integer values in an XMM register or 128-bit memory location from packed byte integer values in another XMM register and writes the result in the destination XMM register.

subtract

127 0 127 0

xmm1 xmm2/mem128

subtract

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

psubb-128.eps

Page 346: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

318 PSUBB Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 347: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSUBD 319

26568—Rev. 3.10—September 2007 AMD64 Technology

Subtracts each packed 32-bit integer value in the second source operand from the correspondingpacked 32-bit integer in the first source operand and writes the integer result of each subtraction in thecorresponding doubleword of the destination (first source). The first source/destination operand is anXMM register and the second source operand is another XMM register or 128-bit memory location.

The PSUBD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

This instruction operates on both signed and unsigned integers. If the result overflows, the carry isignored (neither the overflow nor carry bit in rFLAGS is set), and only the low-order 32 bits of eachresult are written in the destination.

Related Instructions

PSUBB, PSUBQ, PSUBSB, PSUBSW, PSUBUSB, PSUBUSW, PSUBW

rFLAGS Affected

None

MXCSR Flags Affected

None

PSUBD Packed Subtract Doublewords

Mnemonic Opcode Description

PSUBD xmm1, xmm2/mem128 66 0F FA /r

Subtracts packed 32-bit integer values in an XMM register or 128-bit memory location from packed 32-bit integer values in another XMM register and writes the result in the destination XMM register.

subtract

xmm1 xmm2/mem128

subtract

. .

psubd-128.eps

127 63 0649596 3132

. .

. .127 63 0649596 3132

Page 348: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

320 PSUBD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 349: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSUBQ 321

26568—Rev. 3.10—September 2007 AMD64 Technology

Subtracts each packed 64-bit integer value in the second source operand from the correspondingpacked 64-bit integer in the first source operand and writes the integer result of each subtraction in thecorresponding quadword of the destination (first source). The first source/destination and sourceoperands are an XMM register and another XMM register or 128-bit memory location.

The PSUBQ instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

This instruction operates on both signed and unsigned integers. If the result overflows, the carry isignored (neither the overflow nor carry bit in rFLAGS is set), and only the low-order 64 bits of eachresult are written in the destination.

Related Instructions

PSUBB, PSUBD, PSUBSB, PSUBSW, PSUBUSB, PSUBUSW, PSUBW

rFLAGS Affected

None

MXCSR Flags Affected

None

PSUBQ Packed Subtract Quadword

Mnemonic Opcode Description

PSUBQ xmm1, xmm2/mem128 66 0F FB /r

Subtracts packed 64-bit integer values in an XMM register or 128-bit memory location from packed 64-bit integer values in another XMM register and writes the result in the destination XMM register.

subtract

xmm1 xmm2/mem128

subtract

psubq-128.eps

127 63 064127 63 064

Page 350: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

322 PSUBQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 351: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSUBSB 323

26568—Rev. 3.10—September 2007 AMD64 Technology

Subtracts each packed 8-bit signed integer value in the second source operand from the correspondingpacked 8-bit signed integer in the first source operand and writes the signed integer result of eachsubtraction in the corresponding byte of the destination (first source). The first source/destinationoperand is an XMM register and the second source operand is another XMM register or 128-bitmemory location.

The PSUBSB instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

For each packed value in the destination, if the value is larger than the largest signed 8-bit integer, it issaturated to 7Fh, and if the value is smaller than the smallest signed 8-bit integer, it is saturated to 80h.

Related Instructions

PSUBB, PSUBD, PSUBQ, PSUBSW, PSUBUSB, PSUBUSW, PSUBW

rFLAGS Affected

None

MXCSR Flags Affected

None

PSUBSB Packed Subtract Signed With Saturation Bytes

Mnemonic Opcode Description

PSUBSB xmm1, xmm2/mem128 66 0F E8 /r

Subtracts packed byte signed integer values in an XMM register or 128-bit memory location from packed byte integer values in another XMM register and writes the result in the destination XMM register.

subtract

127 0 127 0

xmm1 xmm2/mem128

subtract

saturate

saturate

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

psubsb-128.eps

Page 352: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

324 PSUBSB Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 353: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSUBSW 325

26568—Rev. 3.10—September 2007 AMD64 Technology

Subtracts each packed 16-bit signed integer value in the second source operand from thecorresponding packed 16-bit signed integer in the first source operand and writes the signed integerresult of each subtraction in the corresponding word of the destination (first source). The firstsource/destination and source operands are an XMM register and another XMM register or 128-bitmemory location.

For each packed value in the destination, if the value is larger than the largest signed 16-bit integer, it issaturated to 7FFFh, and if the value is smaller than the smallest signed 16-bit integer, it is saturated to8000h.

The PSUBSW instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PSUBB, PSUBD, PSUBQ, PSUBSB, PSUBUSB, PSUBUSW, PSUBW

rFLAGS Affected

None

MXCSR Flags Affected

None

PSUBSW Packed Subtract Signed With Saturation Words

Mnemonic Opcode Description

PSUBSW xmm1, xmm2/mem128 66 0F E9 /r

Subtracts packed 16-bit signed integer values in an XMM register or 128-bit memory location from packed 16-bit integer values in another XMM register and writes the result in the destination XMM register.

subtract

xmm1 xmm2/mem128

subtract

saturatesaturate

psubsw-128.eps

. .. .... .. ...

. .. ...127 63 0649596111112 7980 4748 15163132127 63 0649596111112 7980 4748 15163132

Page 354: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

326 PSUBSW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 355: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSUBUSB 327

26568—Rev. 3.10—September 2007 AMD64 Technology

Subtracts each packed 8-bit unsigned integer value in the second source operand from thecorresponding packed 8-bit unsigned integer in the first source operand and writes the unsigned integerresult of each subtraction in the corresponding byte of the destination (first source). The firstsource/destination operand is an XMM register and the second source operand is another XMMregister or 128-bit memory location.

For each packed value in the destination, if the value is larger than the largest unsigned 8-bit integer, itis saturated to FFh, and if the value is smaller than the smallest unsigned 8-bit integer, it is saturated to00h.

The PSUBUSB instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PSUBB, PSUBD, PSUBQ, PSUBSB, PSUBSW, PSUBUSW, PSUBW

rFLAGS Affected

None

MXCSR Flags Affected

None

PSUBUSB Packed Subtract Unsigned and Saturate Bytes

Mnemonic Opcode Description

PSUBUSB xmm1, xmm2/mem128 66 0F D8 /r

Subtracts packed byte unsigned integer values in an XMM register or 128-bit memory location from packed byte integer values in another XMM register and writes the result in the destination XMM register.

subtract

127 0 127 0

xmm1 xmm2/mem128

subtract

saturate

saturate

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

psubusb-128.eps

Page 356: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

328 PSUBUSB Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Page 357: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSUBUSW 329

26568—Rev. 3.10—September 2007 AMD64 Technology

Subtracts each packed 16-bit unsigned integer value in the second source operand from thecorresponding packed 16-bit unsigned integer in the first source operand and writes the unsignedinteger result of each subtraction in the corresponding word of the destination (first source). The firstsource/destination operand is an XMM register and the second source operand is another XMMregister or 128-bit memory location.

For each packed value in the destination, if the value is larger than the largest unsigned 16-bit integer,it is saturated to FFFFh, and if the value is smaller than the smallest unsigned 16-bit integer, it issaturated to 0000h.

The PSUBUSW instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PSUBB, PSUBD, PSUBQ, PSUBSB, PSUBSW, PSUBUSB, PSUBW

rFLAGS Affected

None

MXCSR Flags Affected

None

PSUBUSW Packed Subtract Unsigned and Saturate Words

Mnemonic Opcode Description

PSUBUSW xmm1, xmm2/mem128 66 0F D9 /r

Subtracts packed 16-bit unsigned integer values in an XMM register or 128-bit memory location from packed 16-bit integer values in another XMM register and writes the result in the destination XMM register.

subtract

xmm1 xmm2/mem128

subtract

saturate

saturate

psubusw-128.eps

. .. .... .. ...

. .. ...127 63 0649596111112 7980 4748 15163132127 63 0649596111112 7980 4748 15163132

Page 358: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

330 PSUBUSW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 359: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PSUBW 331

26568—Rev. 3.10—September 2007 AMD64 Technology

Subtracts each packed 16-bit integer value in the second source operand from the correspondingpacked 16-bit integer in the first source operand and writes the integer result of each subtraction in thecorresponding word of the destination (first source). The first source/destination operand is an XMMregister and the second source operand is another XMM register or 128-bit memory location.

For each packed value in the destination, if the value is larger than the largest unsigned 16-bit integer,it is saturated to FFFFh, and if the value is smaller than the smallest unsigned 16-bit integer, it issaturated to 0000h.

This instruction operates on both signed and unsigned integers. If the result overflows, the carry isignored (neither the overflow nor carry bit in rFLAGS is set), and only the low-order 16 bits of theresult are written in the destination.

The PSUBW instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PSUBB, PSUBD, PSUBQ, PSUBSB, PSUBSW, PSUBUSB, PSUBUSW

rFLAGS Affected

None

PSUBW Packed Subtract Words

Mnemonic Opcode Description

PSUBW xmm1, xmm2/mem128 66 0F F9 /r

Subtracts packed 16-bit integer values in an XMM register or 128-bit memory location from packed 16-bit integer values in another XMM register and writes the result in the destination XMM register.

subtract

xmm1 xmm2/mem128

subtract

psubw-128.eps

. .. .... .. ...

. .. ...127 63 0649596111112 7980 4748 15163132127 63 0649596111112 7980 4748 15163132

Page 360: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

332 PSUBW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 361: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PUNPCKHBW 333

26568—Rev. 3.10—September 2007 AMD64 Technology

Unpacks the high-order bytes from the first and second source operands and packs them intointerleaved bytes in the destination (first source). The low-order bytes of the source operands areignored. The first source/destination operand is an XMM register and the second source operand isanother XMM register or 128-bit memory location.

If the second source operand is all 0s, the destination contains the bytes from the first source operandzero-extended to 16 bits. This operation is useful for expanding unsigned 8-bit values to unsigned 16-bit operands for subsequent processing that requires higher precision.

The PUNPCKHBW instruction is an SSE2 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PUNPCKHDQ, PUNP CKHQDQ, PUNPCKH WD, PUNPCKLBW, PUNPCKLDQ,PUNPCKLQDQ, PUNPCKLWD

rFLAGS Affected

None

PUNPCKHBW Unpack and Interleave High Bytes

Mnemonic Opcode Description

PUNPCKHBW xmm1, xmm2/mem128 66 0F 68 /r

Unpacks the eight high-order bytes in an XMM register and another XMM register or 128-bit memory location and packs them into interleaved bytes in the destination XMM register.

punpckhbw-128.eps

.. ...... ....

127 63 064127 63 064

... ... ... ...

xmm1 xmm2/mem128

copy copy

127 064 63

copy copy

Page 362: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

334 PUNPCKHBW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 363: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PUNPCKHDQ 335

26568—Rev. 3.10—September 2007 AMD64 Technology

Unpacks the high-order doublewords from the first and second source operands and packs them intointerleaved doublewords in the destination (first source). The low-order doublewords of the sourceoperands are ignored. The first source/destination operand is an XMM register and the second sourceoperand is another XMM register or 128-bit memory location.

If the second source operand is all 0s, the destination contains the doubleword(s) from the first sourceoperand zero-extended to 64 bits. This operation is useful for expanding unsigned 32-bit values tounsigned 64-bit operands for subsequent processing that requires higher precision.

The PUNPCKHDQ instruction is an SSE2 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PUNPCKHBW, PUNPCKHQDQ, PUNPCKHWD, PUNPCKL BW, PUNPCKLDQ,PUNPCKLQDQ, PUNPCKLWD

rFLAGS Affected

None

PUNPCKHDQ Unpack and Interleave High Doublewords

Mnemonic Opcode Description

PUNPCKHDQ xmm1, xmm2/mem128 66 0F 6A /r

Unpacks two high-order doublewords in an XMM register and another XMM register or 128-bit memory location and packs them into interleaved doublewords in the destination XMM register.

punpckhdq-128.eps127 63 0649596 3132

127 63 0649596127 63 0649596

xmm1 xmm2/mem128

copy copycopy copy

Page 364: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

336 PUNPCKHDQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 365: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PUNPCKHQDQ 337

26568—Rev. 3.10—September 2007 AMD64 Technology

Unpacks the high-order quadwords from the first and second source operands and packs them intointerleaved quadwords in the destination (first source). The first source/destination is an XMMregister, and the second source operand is another XMM register or 128-bit memory location. The low-order quadwords of the source operands are ignored.

If the second source operand is all 0s, the destination contains the quadword from the first sourceoperand zero-extended to 128 bits. This operation is useful for expanding unsigned 64-bit values tounsigned 128-bit operands for subsequent processing that requires higher precision.

The PUNPCKHQDQ instruction is an SSE2 instruction. The presence of this instruction set isindicated by a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PUNPCKHBW, PUNPCKHDQ, PUNPCKHWD, PUNPCKLBW, PUNPCKLDQ, PUNPCKLQDQ,PUNPCKLWD

rFLAGS Affected

None

PUNPCKHQDQ Unpack and Interleave High Quadwords

Mnemonic Opcode Description

PUNPCKHQDQ xmm1, xmm2/mem128 66 0F 6D /r

Unpacks high-order quadwords in an XMM register and another XMM register or 128-bit memory location and packs them into interleaved quadwords in the destination XMM register.

punpckhqdq.eps

127 63 064127 63 064

63 064127

xmm1 xmm2/mem128

copy copy

Page 366: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

338 PUNPCKHQDQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 367: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PUNPCKHWD 339

26568—Rev. 3.10—September 2007 AMD64 Technology

Unpacks the high-order words from the first and second source operands and packs them intointerleaved words in the destination (first source). The low-order words of the source operands areignored. The first source/destination operand is an XMM register and the second source operand isanother XMM register or 128-bit memory location.

If the second source operand is all 0s, the destination contains the words from the first source operandzero-extended to 32 bits. This operation is useful for expanding unsigned 16-bit values to unsigned 32-bit operands for subsequent processing that requires higher precision.

The PUNPCKHWD instruction is an SSE2 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PUNPCKHBW, PUNPCKHDQ, PUNPCKHQDQ, PUNPCKLBW, PUNPCKLDQ, PUNPCKLQDQ,PUNPCKLWD

rFLAGS Affected

None

PUNPCKHWD Unpack and Interleave High Words

Mnemonic Opcode Description

PUNPCKHWD xmm1, xmm2/mem128 66 0F 69 /r

Unpacks four high-order words in an XMM register and another XMM register or 128-bit memory location and packs them into interleaved words in the destination XMM register.

punpckhwd-128.eps

127 63 0649596111112 7980127 63 0649596111112 7980

. .

. . . .

. .

127 63 0649596111112 7980 4748 15163132... ... ... ...

xmm1 xmm2/mem128

copy copycopy copy

Page 368: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

340 PUNPCKHWD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 369: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PUNPCKLBW 341

26568—Rev. 3.10—September 2007 AMD64 Technology

Unpacks the low-order bytes from the first and second source operands and packs them intointerleaved bytes in the destination (first source). The high-order bytes of the source operands areignored. The first source/destination operand is an XMM register and the second source operand isanother XMM register or 128-bit memory location.

If the second source operand is all 0s, the destination contains the bytes from the first source operandzero-extended to 16 bits. This operation is useful for expanding unsigned 8-bit values to unsigned 16-bit operands for subsequent processing that requires higher precision.

The PUNPCKLBW instruction is an SSE2 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PUNPCKHBW, PUNPCKHDQ, P UNPCKHQ DQ, PUNPCKHWD, PUNPCKLDQ,PUNPCKLQDQ, PUNPCKLWD

rFLAGS Affected

None

PUNPCKLBW Unpack and Interleave Low Bytes

Mnemonic Opcode Description

PUNPCKLBW xmm1, xmm2/mem128 66 0F 60 /r

Unpacks the eight low-order bytes in an XMM register and another XMM register or 128-bit memory location and packs them into interleaved bytes in the destination XMM register.

punpcklbw-128.eps

.. ...... ....

127 63 064127 63 064

... ... ... ...

xmm1 xmm2/mem128

copy copy

127 064 63

copy copy

Page 370: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

342 PUNPCKLBW Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 371: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PUNPCKLDQ 343

26568—Rev. 3.10—September 2007 AMD64 Technology

Unpacks the low-order doublewords from the first and second source operands and packs them intointerleaved doublewords in the destination (first source). The high-order doublewords of the sourceoperands are ignored. The first source/destination operand is an XMM register and the second sourceoperand is another XMM register or 128-bit memory location.

If the second source operand is all 0s, the destination contains the doubleword(s) from the first sourceoperand zero-extended to 64 bits. This operation is useful for expanding unsigned 32-bit values tounsigned 64-bit operands for subsequent processing that requires higher precision.

The PUNPCKLDQ instruction is an SSE2 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PUNPCKHBW, PUNPCKHDQ, PUNPCKH QDQ, PUNPCKHWD , PUNPCKLBW,PUNPCKLQDQ, PUNPCKLWD

rFLAGS Affected

None

PUNPCKLDQ Unpack and Interleave Low Doublewords

Mnemonic Opcode Description

PUNPCKLDQ xmm1, xmm2/mem128 66 0F 62 /r

Unpacks two low-order doublewords in an XMM register and another XMM register or 128-bit memory location and packs them into interleaved doublewords in the destination XMM register.

punpckldq-128.eps

127 63 064 3132127 63 064 3132

127 63 0649596 3132

xmm1 xmm2/mem128

copycopy copycopy

Page 372: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

344 PUNPCKLDQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 373: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PUNPCKLQDQ 345

26568—Rev. 3.10—September 2007 AMD64 Technology

Unpacks the low-order quadwords from the first and second source operands and packs them intointerleaved quadwords in the destination (first source). The first source/destination is an XMMregister, and the second source operand is another XMM register or 128-bit memory location. Thehigh-order quadwords of the source operands are ignored.

If the second source operand is all 0s, the destination contains the quadword from the first sourceoperand zero-extended to 128 bits. This operation is useful for expanding unsigned 64-bit values tounsigned 128-bit operands for subsequent processing that requires higher precision.

The PUNPCKLQDQ instruction is an SSE2 instruction. The presence of this instruction set isindicated by a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PUNPCKHBW, PUNPCKHDQ, PUNPCKHQDQ, PUNPCKHWD, PUNPCKLBW, PUNPCKLDQ,PUNPCKLWD

rFLAGS Affected

None

PUNPCKLQDQ Unpack and Interleave Low Quadwords

Mnemonic Opcode Description

PUNPCKLQDQ xmm1, xmm2/mem128 66 0F 6C /r

Unpacks low-order quadwords in an XMM register and another XMM register or 128-bit memory location and packs them into interleaved quadwords in the destination XMM register.

punpcklqdq.eps

127 63 064127 63 064

63 064127

xmm1 xmm2/mem128

copy copy

Page 374: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

346 PUNPCKLQDQ Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 375: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PUNPCKLWD 347

26568—Rev. 3.10—September 2007 AMD64 Technology

Unpacks the low-order words from the first and second source operands and packs them intointerleaved words in the destination (first source). The high-order words of the source operands areignored. The first source/destination operand is an XMM register and the second source operand isanother XMM register or 128-bit memory location.

If the second source operand is all 0s, the destination contains the words from the first source operandzero-extended to 32 bits. This operation is useful for expanding unsigned 16-bit values to unsigned 32-bit operands for subsequent processing that requires higher precision.

The PUNPCKLWD instruction is an SSE2 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PUNPCKHBW, PUNPCKHDQ, PUNPCKHQDQ, PUNPCKHWD, PUNPCKLBW, PUNPCKLDQ,PUNPCKLQDQ

rFLAGS Affected

None

PUNPCKLWD Unpack and Interleave Low Words

Mnemonic Opcode Description

PUNPCKLWD xmm1, xmm2/mem128 66 0F 61 /r

Unpacks the four low-order words in an XMM register and another XMM register or 128-bit memory location and packs them into interleaved words in the destination XMM register.

punpcklwd-128.eps

127 63 064 4748 15163132127 63 064 4748 15163132

. .. .

. .. .

127 63 0649596111112 7980 4748 15163132... ... ... ...

xmm1 xmm2/mem128

copy copycopy copy

Page 376: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

348 PUNPCKLWD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 377: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference PXOR 349

26568—Rev. 3.10—September 2007 AMD64 Technology

Performs a bitwise exclusive OR of the values in the first and second source operands and writes theresult in the destination (first source). The first source/destination operand is an XMM register and thesecond source operand is another XMM register or 128-bit memory location.

The PXOR instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

PAND, PANDN, POR

rFLAGS Affected

None

MXCSR Flags Affected

None

PXOR Packed Logical Bitwise Exclusive OR

Mnemonic Opcode Description

PXOR xmm1, xmm2/mem128 66 0F EF /r

Performs bitwise logical XOR of values in an XMM register and in another XMM register or 128-bit memory location and writes the result in the destination XMM register.

pxor-128.eps

XOR

xmm1 xmm2/mem128

127 0127 0

Page 378: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

350 PXOR Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 379: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference RCPPS 351

26568—Rev. 3.10—September 2007 AMD64 Technology

Computes the approximate reciprocal of each of the four packed single-precision floating-point valuesin an XMM register or 128-bit memory location and writes the result in the corresponding doublewordof another XMM register. The rounding control bits (RC) in the MXCSR register have no effect on theresult.

The maximum error is less than or equal to 1.5 * 2–12 times the true reciprocal. A source value that is±zero or denormal returns an infinity of the source value’s sign. Results that underflow are changed tosigned zero. For both SNaN and QNaN source operands, a QNaN is returned.

The RCPPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

RCPSS, RSQRTPS, RSQRTSS

rFLAGS Affected

None

MXCSR Flags Affected

None

RCPPS Reciprocal Packed Single-PrecisionFloating-Point

Mnemonic Opcode Description

RCPPS xmm1, xmm2/mem128 0F 53 /r

Computes reciprocals of packed single-precision floating-point values in an XMM register or 128-bit memory location and writes result in the destination XMM register.

rcpps.eps

xmm1 xmm2/mem128

reciprocal

reciprocal

reciprocal

reciprocal

127 63 0649596 3132127 63 0649596 3132

Page 380: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

352 RCPPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 381: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference RCPSS 353

26568—Rev. 3.10—September 2007 AMD64 Technology

Computes the approximate reciprocal of the low-order single-precision floating-point value in anXMM register or in a 32-bit memory location and writes the result in the low-order doubleword ofanother XMM register. The three high-order doublewords in the destination XMM register are notmodified. The rounding control bits (RC) in the MXCSR register have no effect on the result.

The maximum error is less than or equal to 1.5 * 2–12 times the true reciprocal. A source value that is±zero or denormal returns an infinity of the source value’s sign. Results that underflow are changed tosigned zero. For both SNaN and QNaN source operands, a QNaN is returned.

The RCPSS instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

RCPPS, RSQRTPS, RSQRTSS

rFLAGS Affected

None

MXCSR Flags Affected

None

RCPSS Reciprocal Scalar Single-PrecisionFloating-Point

Mnemonic Opcode Description

RCPSS xmm1, xmm2/mem32 F3 0F 53 /r

Computes reciprocal of scalar single-precision floating-point value in an XMM register or 32-bit memory location and writes the result in the destination XMM register.

rcpss.eps

xmm1 xmm2/mem32

reciprocal

127 31 032 127 31 032

Page 382: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

354 RCPSS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 383: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference RSQRTPS 355

26568—Rev. 3.10—September 2007 AMD64 Technology

Computes the approximate reciprocal of the square root of each of the four packed single-precisionfloating-point values in an XMM register or 128-bit memory location and writes the result in thecorresponding doubleword of another XMM register. The rounding control bits (RC) in the MXCSRregister have no effect on the result.

The maximum error is less than or equal to 1.5 * 2–12 times the true reciprocal square root. A sourcevalue that is ±zero or denormal returns an infinity of the source value’s sign. Negative source valuesother than –zero and –denormal return a QNaN floating-point indefinite value (“Indefinite Values” inVolume 1). For both SNaN and QNaN source operands, a QNaN is returned.

The RSQRTPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

RSQRTSS, SQRTPD, SQRTPS, SQRTSD, SQRTSS

rFLAGS Affected

None

RSQRTPS Reciprocal Square Root Packed Single-PrecisionFloating-Point

Mnemonic Opcode Description

RSQRTPS xmm1, xmm2/mem128 0F 52 /r

Computes reciprocals of square roots of packed single-precision floating-point values in an XMM register or 128-bit memory location and writes the result in the destination XMM register.

rsqrtps.eps

xmm1 xmm2/mem128

reciprocalsquare root reciprocal

square rootreciprocal

square rootreciprocal

square root

127 63 0649596 3132127 63 0649596 3132

Page 384: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

356 RSQRTPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 385: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference RSQRTSS 357

26568—Rev. 3.10—September 2007 AMD64 Technology

Computes the approximate reciprocal of the square root of the low-order single-precision floating-point value in an XMM register or in a 32-bit memory location and writes the result in the low-orderdoubleword of another XMM register. The three high-order doublewords in the destination XMMregister are not modified. The rounding control bits (RC) in the MXCSR register have no effect on theresult.

The maximum error is less than or equal to 1.5 * 2–12 times the true reciprocal square root. A sourcevalue that is ±zero or denormal returns an infinity of the source value’s sign. Negative source valuesother than –zero and –denormal return a QNaN floating-point indefinite value (“Indefinite Values” inVolume 1). For both SNaN and QNaN source operands, a QNaN is returned.

The RSQRTSS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

RSQRTPS, SQRTPD, SQRTPS, SQRTSD, SQRTSS

rFLAGS Affected

None

MXCSR Flags Affected

None

RSQRTSS Reciprocal Square Root Scalar Single-PrecisionFloating-Point

Mnemonic Opcode Description

RSQRTSS xmm1, xmm2/mem32 F3 0F 52 /r

Computes reciprocal of square root of single-precision floating-point value in an XMM register or 32-bit memory location and writes the result in the destination XMM register.

rsqrtss.eps

xmm1 xmm2/mem32

reciprocalsquare root

127 31 032 127 31 032

Page 386: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

358 RSQRTSS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 387: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference SHUFPD 359

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves either of the two packed double-precision floating-point values in the first source operand to thelow-order quadword of the destination (first source) and moves either of the two packed double-precision floating-point values in the second source operand to the high-order quadword of thedestination. In each case, the value of the destination quadword is determined by the least-significanttwo bits in the immediate-byte operand, as shown in Table 1-7 on page 359. The firstsource/destination operand is an XMM register. The second source operand is another XMM registeror 128-bit memory location.

The SHUFPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

SHUFPD Shuffle Packed Double-Precision Floating-Point

Mnemonic Opcode Description

SHUFPD xmm1, xmm2/mem128, imm8 66 0F C6 /r ib

Shuffles packed double-precision floating-point values in an XMM register and another XMM register or 128-bit memory location and puts the result in the destination XMM register.

Table 1-7. Immediate-Byte Operand Encoding for SHUFPD

Destination Bits Filled

Immediate-ByteBit Field

Value of Bit Field

Source 1Bits Moved

Source 2Bits Moved

63–0 00 63–0 —

1 127–64 —

127–64 10 — 63–0

1 — 127–64

shufpd.eps

xmm1 xmm2/mem128

imm87 0

mux mux

127 63 064127 63 064

Page 388: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

360 SHUFPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

SHUFPS

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 389: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference SHUFPS 361

26568—Rev. 3.10—September 2007 AMD64 Technology

Moves two of the four packed single-precision floating-point values in the first source operand to thelow-order quadword of the destination (first source) and moves two of the four packed single-precisionfloating-point values in the second source operand to the high-order quadword of the destination. Ineach case, the value of the destination doubleword is determined by a two-bit field in the immediate-byte operand, as shown in Table 1-8 on page 362. The first source/destination operand is an XMMregister. The second source operand is another XMM register or 128-bit memory location.

The SHUFPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

SHUFPS Shuffle Packed Single-Precision Floating-Point

Mnemonic Opcode Description

SHUFPS xmm1, xmm2/mem128, imm8 0F C6 /r ib

Shuffles packed single-precision floating-point values in an XMM register and another XMM register or 128-bit memory location and puts the result in the destination XMM register.

shufps.eps

xmm1 xmm2/mem128

imm87 0

muxmux

127 63 0649596 3132127 63 064

Page 390: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

362 SHUFPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Related Instructions

SHUFPD

rFLAGS Affected

None

MXCSR Flags Affected

None

Table 1-8. Immediate-Byte Operand Encoding for SHUFPS

Destination Bits Filled

Immediate-ByteBit Field

Value of Bit Field

Source 1 Bits Moved

Source 2 Bits Moved

31–0 1–0

0 31–0 —

1 63–32 —

2 95–64 —

3 127–96 —

63–32 3–2

0 31–0 —

1 63–32 —

2 95–64 —

3 127–96 —

95–64 5–4

0 — 31–0

1 — 63–32

2 — 95–64

3 — 127–96

127–96 7–6

0 — 31–0

1 — 63–32

2 — 95–64

3 — 127–96

Page 391: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference SHUFPS 363

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 392: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

364 SQRTPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Computes the square root of each of the two packed double-precision floating-point values in an XMMregister or 128-bit memory location and writes the result in the corresponding quadword of anotherXMM register. Taking the square root of +infinity returns +infinity.

The SQRTPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

RSQRTPS, RSQRTSS, SQRTPS, SQRTSD, SQRTSS

rFLAGS Affected

None

SQRTPD Square Root Packed Double-PrecisionFloating-Point

Mnemonic Opcode Description

SQRTPD xmm1, xmm2/mem128 66 0F 51 /r

Computes square roots of packed double-precision floating-point values in an XMM register or 128-bit memory location and writes the result in the destination XMM register.

sqrtpd.eps

127 63 064

xmm1 xmm2/mem128

square rootsquare root

127 63 064

Page 393: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference SQRTPD 365

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X A source operand was negative (not including –0).

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 394: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

366 SQRTPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Computes the square root of each of the four packed single-precision floating-point values in an XMMregister or 128-bit memory location and writes the result in the corresponding doubleword of anotherXMM register. Taking the square root of +infinity returns +infinity.

The SQRTPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

RSQRTPS, RSQRTSS, SQRTPD, SQRTSD, SQRTSS

rFLAGS Affected

None

SQRTPS Square Root Packed Single-PrecisionFloating-Point

Mnemonic Opcode Description

SQRTPS xmm1, xmm2/mem128 0F 51 /r

Computes square roots of packed single-precision floating-point values in an XMM register or 128-bit memory location and writes the result in the destination XMM register.

sqrtps.eps

xmm1 xmm2/mem128

square root

square root

square root

square root

127 63 0649596 3132127 63 0649596 3132

Page 395: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference SQRTPS 367

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X A source operand was negative (not including –0).

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 396: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

368 SQRTSD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Computes the square root of the low-order double-precision floating-point value in an XMM registeror in a 64-bit memory location and writes the result in the low-order quadword of another XMMregister. The high-order quadword of the destination XMM register is not modified. Taking the squareroot of +infinity returns +infinity.

The SQRTSD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

RSQRTPS, RSQRTSS, SQRTPD, SQRTPS, SQRTSS

rFLAGS Affected

None

SQRTSD Square Root Scalar Double-PrecisionFloating-Point

Mnemonic Opcode Description

SQRTSD xmm1, xmm2/mem64 F2 0F 51 /rComputes square root of double-precision floating-point value in an XMM register or 64-bit memory location and writes the result in the destination XMM register.

sqrtsd.eps

xmm1 xmm2/mem64

127 63 064 127 63 064

square root

Page 397: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference SQRTSD 369

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X A source operand was negative (not including –0).

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 398: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

370 SQRTSS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Computes the square root of the low-order single-precision floating-point value in an XMM register or32-bit memory location and writes the result in the low-order doubleword of another XMM register.The three high-order doublewords of the destination XMM register are not modified. Taking thesquare root of +infinity returns +infinity.

The SQRTSS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

RSQRTPS, RSQRTSS, SQRTPD, SQRTPS, SQRTSD

rFLAGS Affected

None

SQRTSS Square Root Scalar Single-PrecisionFloating-Point

Mnemonic Opcode Description

SQRTSS xmm1, xmm2/mem32 F3 0F 51 /rComputes square root of single-precision floating-point value in an XMM register or 32-bit memory location and writes the result in the destination XMM register.

sqrtss.eps

xmm1 xmm2/mem32

127 31 032 127 31 032

square root

Page 399: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference SQRTSS 371

26568—Rev. 3.10—September 2007 AMD64 Technology

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X A source operand was negative (not including –0).

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 400: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

372 STMXCSR Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Saves the contents of the MXCSR register in a 32-bit location in memory. The MXCSR register isdescribed in “Registers” in Volume 1.

The STMXCSR instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

LDMXCSR

rFLAGS Affected

None

MXCSR Flags Affected

None

Exceptions

STMXCSR Store MXCSR Control/Status Register

Mnemonic Opcode Description

STMXCSR mem32 0F AE /3 Stores contents of MXCSR in 32-bit memory location.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X The destination operand was in a non-writable segment.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

Page 401: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference SUBPD 373

26568—Rev. 3.10—September 2007 AMD64 Technology

Subtracts each packed double-precision floating-point value in the second source operand from thecorresponding packed double-precision floating-point value in the first source operand and writes theresult of each subtraction in the corresponding quadword of the destination (first source). The firstsource/destination operand is an XMM register. The second source operand is another XMM registeror 128-bit memory location.

The SUBPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

SUBPS, SUBSD, SUBSS

rFLAGS Affected

None

MXCSR Flags Affected

SUBPD Subtract Packed Double-Precision Floating-Point

Mnemonic Opcode Description

SUBPD xmm1, xmm2/mem128 66 0F 5C /r

Subtracts packed double-precision floating-point values in an XMM register or 128-bit memory location from packed double-precision floating-point values in another XMM register and writes the result in the destination XMM register.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

subpd.eps

127 63 064 127 63 064

xmm1 xmm2/mem128

subtract

subtract

Page 402: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

374 SUBPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X +infinity was subtracted from +infinity.

X X X –infinity was subtracted from –infinity.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 403: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference SUBPS 375

26568—Rev. 3.10—September 2007 AMD64 Technology

Subtracts each packed single-precision floating-point value in the second source operand from thecorresponding packed single-precision floating-point value in the first source operand and writes theresult of each subtraction in the corresponding doubleword of the destination (first source). The firstsource/destination operand is an XMM register. The second source operand is another XMM registeror 128-bit memory location.

The SUBPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

SUBPD, SUBSD, SUBSS

rFLAGS Affected

None

SUBPS Subtract Packed Single-Precision Floating-Point

Mnemonic Opcode Description

SUBPS xmm1, xmm2/mem128 0F 5C /r

Subtracts packed single-precision floating-point values in an XMM register or 128-bit memory location from packed single-precision floating-point values in another XMM register and writes the result in the destination XMM register.

subps.eps

xmm1 xmm2/mem128

subtract

subtract

subtract

subtract

127 63 0649596 3132127 63 0649596 3132

Page 404: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

376 SUBPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

MXCSR Flags Affected

Exceptions

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X +infinity was subtracted from +infinity.

X X X –infinity was subtracted from –infinity.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Page 405: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference SUBPS 377

26568—Rev. 3.10—September 2007 AMD64 Technology

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Exception RealVirtual8086 Protected Cause of Exception

Page 406: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

378 SUBSD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Subtracts the double-precision floating-point value in the low-order quadword of the second sourceoperand from the double-precision floating-point value in the low-order quadword of the first sourceoperand and writes the result in the low-order quadword of the destination (first source). The high-order quadword of the destination is not modified. The first source/destination operand is an XMMregister. The second source operand is another XMM register or 64-bit memory location.

The SUBSD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

SUBPD, SUBPS, SUBSS

rFLAGS Affected

None

MXCSR Flags Affected

SUBSD Subtract Scalar Double-Precision Floating-Point

Mnemonic Opcode Description

SUBSD xmm1, xmm2/mem64 F2 0F 5C /r

Subtracts low-order double-precision floating-point value in an XMM register or in a 64-bit memory location from low-order double-precision floating-point value in another XMM register and writes the result in the destination XMM register.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

subsd.eps

xmm1 xmm2/mem64

subtract

127 63 064 127 63 064

Page 407: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference SUBSD 379

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X +infinity was subtracted from +infinity.

X X X –infinity was subtracted from –infinity.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 408: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

380 SUBSS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Subtracts the single-precision floating-point value in the low-order doubleword of the second sourceoperand from the single-precision floating-point value in the low-order doubleword of the first sourceoperand and writes the result in the low-order doubleword of the destination (first source). The threehigh-order doublewords of the destination are not modified. The first source/destination operand is anXMM register. The second source operand is another XMM register or 32-bit memory location.

The SUBSS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

SUBPD, SUBPS, SUBSD

rFLAGS Affected

None

MXCSR Flags Affected

SUBSS Subtract Scalar Single-Precision Floating-Point

Mnemonic Opcode Description

SUBSS xmm1, xmm2/mem32 F3 0F 5C /r

Subtracts low-order single-precision floating-point value in an XMM register or in a 32-bit memory location from low-order single-precision floating-point value in another XMM register and writes the result in the destination XMM register.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M M M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

subss.eps

xmm1 xmm2/mem32

subtract

127 31 032 127 31 032

Page 409: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference SUBSS 381

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

SIMD Floating-Point Exceptions

Invalid-operation exception (IE)

X X X A source operand was an SNaN value.

X X X +infinity was subtracted from +infinity.

X X X –infinity was subtracted from –infinity.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Overflow exception (OE) X X X A rounded result was too large to fit into the format of the destination operand.

Underflow exception (UE) X X X A rounded result was too small to fit into the format of

the destination operand.

Precision exception (PE) X X X A result could not be represented exactly in the

destination format.

Page 410: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

382 UCOMISD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Performs an unordered compare of the double-precision floating-point value in the low-order 64 bits ofan XMM register with the double-precision floating-point value in the low-order 64 bits of anotherXMM register or a 64-bit memory location and sets the ZF, PF, and CF bits in the rFLAGS register toreflect the result of the compare. The OF, AF, and SF bits in rFLAGS are set to zero. The result isunordered if one or both of the operand values is a NaN.

If the instruction causes an unmasked SIMD floating-point exception (#XF), the rFLAGS bits are notupdated.

The UCOMISD instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CMPPD, CMPPS, CMPSD, CMPSS, COMISD, COMISS, UCOMISS

UCOMISD Unordered Compare ScalarDouble-Precision Floating-Point

Mnemonic Opcode Description

UCOMISD xmm1, xmm2/mem64 66 0F 2E /r Compares scalar double-precision floating-point values in an XMM register and an XMM register or 64-bit memory location. Sets rFLAGS.

Result of Compare ZF PF CF

Unordered 1 1 1

Greater Than 0 0 0

Less Than 0 0 1

Equal 1 0 0

ucomisd.eps

compare

127 63 064

03163

127 63 064

xmm1

rFLAGS0

xmm2/mem64

Page 411: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference UCOMISD 383

26568—Rev. 3.10—September 2007 AMD64 Technology

rFLAGS Affected

MXCSR Flags Affected

Exceptions

ID VIP VIF AC VM RF NT IOPL OF DF IF TF SF ZF AF PF CF

0 0 M 0 M M

21 20 19 18 17 16 14 13–12 11 10 9 8 7 6 4 2 0

Note: Bits 31–22, 15, 5, 3, and 1 are reserved. A flag set to 1 or cleared to 0 is M (modified). Unaffected flags are blank. Note: If the instruction causes an unmasked SIMD floating-point exception (#XF), the rFLAGS bits are not updated.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP X X X A memory address exceeded a data segment limit or

was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

Page 412: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

384 UCOMISD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN value.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Exception RealVirtual8086 Protected Cause of Exception

Page 413: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference UCOMISS 385

26568—Rev. 3.10—September 2007 AMD64 Technology

Performs an unordered compare of the single-precision floating-point value in the low-order 32 bits ofan XMM register with the single-precision floating-point value in the low-order 32 bits of anotherXMM register or a 32-bit memory location and sets the ZF, PF, and CF bits in the rFLAGS register toreflect the result. The OF, AF, and SF bits in rFLAGS are set to zero. The result is unordered if one orboth of the operand values is a NaN.

If the instruction causes an unmasked SIMD floating-point exception (#XF), the rFLAGS bits are notupdated.

The UCOMISS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

CMPPD, CMPPS, CMPSD, CMPSS, COMISD, COMISS, UCOMISD

UCOMISS Unordered Compare ScalarSingle-Precision Floating-Point

Mnemonic Opcode Description

UCOMISS xmm1, xmm2/mem32 0F 2E /rCompares scalar single-precision floating-point values in an XMM register and an XMM register or 32-bit memory location. Sets rFLAGS.

Result of Compare ZF PF CF

Unordered 1 1 1

Greater Than 0 0 0

Less Than 0 0 1

Equal 1 0 0

ucomiss.eps

compare

127 031 127 031xmm1 xmm2/mem32

03163

rFLAGS0

Page 414: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

386 UCOMISS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

rFLAGS Affected

MXCSR Flags Affected

Exceptions

ID VIP VIF AC VM RF NT IOPL OF DF IF TF SF ZF AF PF CF

0 0 M 0 M M

21 20 19 18 17 16 14 13–12 11 10 9 8 7 6 4 2 0

Note: Bits 31–22, 15, 5, 3, and 1 are reserved. A flag set to 1 or cleared to 0 is M (modified). Unaffected flags are blank. Note: If the instruction causes an unmasked SIMD floating-point exception (#XF), the rFLAGS bits are not updated.

MM FZ RC PM UM OM ZM DM IM DAZ PE UE OE ZE DE IE

M M

17 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Note: A flag that may be set to one or cleared to zero is M (modified). Unaffected flags are blank.

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was cleared to 0.See SIMD Floating-Point Exceptions, below, for details.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X X An unaligned memory reference was performed while alignment checking was enabled.

SIMD Floating-Point Exception, #XF X X X

There was an unmasked SIMD floating-point exception while CR4.OSXMMEXCPT was set to 1.See SIMD Floating-Point Exceptions, below, for details.

Page 415: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference UCOMISS 387

26568—Rev. 3.10—September 2007 AMD64 Technology

SIMD Floating-Point Exceptions

Invalid-operation exception (IE) X X X A source operand was an SNaN value.

Denormalized-operand exception (DE) X X X A source operand was a denormal value.

Exception RealVirtual8086 Protected Cause of Exception

Page 416: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

388 UNPCKHPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Unpacks the high-order double-precision floating-point values in the first and second source operandsand packs them into quadwords in the destination (first source). The value from the first sourceoperand is packed into the low-order quadword of the destination, and the value from the secondsource operand is packed into the high-order quadword of the destination. The low-order quadwords ofthe source operands are ignored. The first source/destination operand is an XMM register. The secondsource operand is another XMM register or 128-bit memory location.

The UNPCKHPD instruction is an SSE2 instruction. The presence of this instruction set is indicatedby a CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

UNPCKHPS, UNPCKLPD, UNPCKLPS

rFLAGS Affected

None

MXCSR Flags Affected

None

UNPCKHPD Unpack High Double-Precision Floating-Point

Mnemonic Opcode Description

UNPCKHPD xmm1, xmm2/mem128 66 0F 15 /r

Unpacks high-order double-precision floating-point values in an XMM register and another XMM register or 128-bit memory location and packs them into the destination XMM register.

unpckhpd.eps

127 63 064127 63 064

63 064127

xmm1 xmm2/mem128

copy copy

Page 417: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference UNPCKHPD 389

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDXX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 418: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

390 UNPCKHPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Unpacks the high-order single-precision floating-point values in the first and second source operandsand packs them into interleaved doublewords in the destination (first source). The low-orderquadwords of the source operands are ignored. The first source/destination operand is an XMMregister. The second source operand is another XMM register or 128-bit memory location.

The UNPCKHPS instruction is an SSE instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

UNPCKHPD, UNPCKLPD, UNPCKLPS

rFLAGS Affected

None

MXCSR Flags Affected

None

UNPCKHPS Unpack High Single-Precision Floating-Point

Mnemonic Opcode Description

UNPCKHPS xmm1, xmm2/mem128 0F 15 /r

Unpacks high-order single-precision floating-point values in an XMM register and another XMM register or 128-bit memory location and packs them into the destination XMM register.

unpckhps.eps127 63 0649596 3132

127 63 0649596127 63 0649596

xmm1 xmm2/mem128

copy copycopy copy

Page 419: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference UNPCKHPS 391

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 420: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

392 UNPCKLPD Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Unpacks the low-order double-precision floating-point values in the first and second source operandsand packs them into the destination (first source). The value from the first source operand is packedinto the low-order quadword of the destination, and the value from the second source operand ispacked into the high-order quadword of the destination. The high-order quadwords of the sourceoperands are ignored. The first source/destination operand is an XMM register. The second sourceoperand is another XMM register or 128-bit memory location.

The UNPCKLPD instruction is an SSE2 instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

UNPCKHPD, UNPCKHPS, UNPCKLPS

rFLAGS Affected

None

MXCSR Flags Affected

None

UNPCKLPD Unpack Low Double-Precision Floating-Point

Mnemonic Opcode Description

UNPCKLPD xmm1, xmm2/mem128 66 0F 14 /r

Unpacks low-order double-precision floating-point values in an XMM register and another XMM register or 128-bit memory location and packs them into the destination XMM register.

unpcklpd.eps

127 63 064127 63 064

63 064127

xmm1 xmm2/mem128

copy copy

Page 421: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Instruction Reference UNPCKLPD 393

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X XThe SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 422: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

394 UNPCKLPS Instruction Reference

AMD64 Technology 26568—Rev. 3.10—September 2007

Unpacks the low-order single-precision floating-point values in the first and second source operandsand packs them into interleaved doublewords in the destination (first source). The high-orderquadwords of the source operands are ignored. The first source/destination operand is an XMMregister. The second source operand is another XMM register or 128-bit memory location.

The UNPCKLPS instruction is an SSE instruction. The presence of this instruction set is indicated bya CPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

UNPCKHPD, UNPCKHPS, UNPCKLPD

rFLAGS Affected

None

MXCSR Flags Affected

None

UNPCKLPS Unpack Low Single-Precision Floating-Point

Mnemonic Opcode Description

UNPCKLPS xmm1, xmm2/mem128 0F 14 /r

Unpacks low-order single-precision floating-point values in an XMM register and another XMM register or 128-bit memory location and packs them into the destination XMM register.

unpcklps.eps127 63 0649596 3132

127 63 064 3132127 63 064 3132

xmm1 xmm2/mem128

copycopy copycopy

Page 423: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

395

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 424: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

396

AMD64 Technology 26568—Rev. 3.10—September 2007

Performs a bitwise logical Exclusive OR of the two packed double-precision floating-point values inthe first source operand and the corresponding two packed double-precision floating-point values inthe second source operand and writes the result in the destination (first source). The firstsource/destination operand is an XMM register. The second source operand is another XMM registeror 128-bit memory location.

The XORPD instruction is an SSE2 instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

ANDNPD, ANDNPS, ANDPD, ANDPS, ORPD, ORPS, XORPS

rFLAGS Affected

None

MXCSR Flags Affected

None

XORPD Logical Bitwise Exclusive ORPacked Double-Precision Floating-Point

Mnemonic Opcode Description

XORPD xmm1, xmm2/mem128 66 0F 57 /r

Performs bitwise logical XOR of two packed double-precision floating-point values in an XMM register and in another XMM register or 128-bit memory location and writes the result in the destination XMM register.

xorpd.eps

127 63 064 127 63 064

xmm1 xmm2/mem128

XOR

XOR

Page 425: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

397

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE2 instructions are not supported, as indicated by EDX bit 26 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 is cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded a data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 426: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

398

AMD64 Technology 26568—Rev. 3.10—September 2007

Performs a bitwise Exclusive OR of the four packed single-precision floating-point values in the firstsource operand and the corresponding four packed single-precision floating-point values in the secondsource operand and writes the result in the destination (first source). The first source/destinationoperand is an XMM register. The second source operand is another XMM register or 128-bit memorylocation.

The XORPS instruction is an SSE instruction. The presence of this instruction set is indicated by aCPUID feature bit. (See “CPUID” in Volume 3.)

Related Instructions

ANDNPD, ANDNPS, ANDPD, ANDPS, ORPD, ORPS, XORPD

rFLAGS Affected

None

MXCSR Flags Affected

None

XORPS Logical Bitwise Exclusive ORPacked Single-Precision Floating-Point

Mnemonic Opcode Description

XORPS xmm1, xmm2/mem128 0F 57 /r

Performs bitwise logical XOR of four packed single-precision floating-point values in an XMM register and in another XMM register or 128-bit memory location and writes the result in the destination XMM register.

xorps.eps

xmm1 xmm2/mem128

XOR

XOR

XOR

XOR

127 63 0649596 3132127 63 0649596 3132

Page 427: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

399

26568—Rev. 3.10—September 2007 AMD64 Technology

Exceptions

Exception RealVirtual8086 Protected Cause of Exception

Invalid opcode, #UD

X X X The SSE instructions are not supported, as indicated by EDX bit 25 of CPUID function 0000_0001h.

X X X The emulate bit (EM) of CR0 was set to 1.

X X X The operating-system FXSAVE/FXRSTOR support bit (OSFXSR) of CR4 was cleared to 0.

Device not available, #NM X X X The task-switch bit (TS) of CR0 was set to 1.

Stack, #SS X X X A memory address exceeded the stack segment limit or was non-canonical.

General protection, #GP

X X X A memory address exceeded the data segment limit or was non-canonical.

X A null data segment was used to reference memory.

X X X The memory operand was not aligned on a 16-byte boundary while MXCSR.MM was cleared to 0.

Page fault, #PF X X A page fault resulted from the execution of the instruction.

Alignment check, #AC X XAn unaligned memory reference was performed while alignment checking was enabled with MXCSR.MM set to 1.

Page 428: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

400

AMD64 Technology 26568—Rev. 3.10—September 2007

Page 429: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Index 401

26568—Rev. 3.10—September 2007 AMD64 Technology

Numerics

16-bit mode............................................................ xiv32-bit mode............................................................ xiv64-bit mode............................................................ xiv

A

ADDPD .................................................................... 3ADDPS..................................................................... 5addressing

RIP-relative......................................................... xixADDSD .................................................................... 8ADDSS................................................................... 10ADDSUBPD........................................................... 12ADDSUBPS............................................................ 14ANDNPD ............................................................... 17ANDNPS ................................................................ 19ANDPD .................................................................. 21ANDPS................................................................... 23

B

biased exponent ....................................................... xv

C

CMPPD .................................................................. 25CMPPS................................................................... 29CMPSD .................................................................. 32CMPSS................................................................... 35COMISD ................................................................ 38COMISS ................................................................. 41commit ................................................................... xvcompatibility mode .................................................. xvCVTDQ2PD............................................................ 44CVTDQ2PS ............................................................ 46CVTPD2DQ............................................................ 48CVTPD2PI.............................................................. 50CVTPD2PS............................................................. 53CVTPI2PD.............................................................. 56CVTPI2PS .............................................................. 58CVTPS2DQ ............................................................ 60CVTPS2PD............................................................. 62CVTPS2PI .............................................................. 64CVTSD2SI.............................................................. 66CVTSD2SS............................................................. 69CVTSI2SD.............................................................. 71CVTSI2SS .............................................................. 73CVTSS2SD............................................................. 75CVTSS2SI .............................................................. 77

CVTTPD2DQ.......................................................... 80CVTTPD2PI............................................................ 82CVTTPS2DQ .......................................................... 85CVTTPS2PI ............................................................ 87CVTTSD2SI............................................................ 89CVTTSS2SI ............................................................ 92

D

direct referencing ..................................................... xvdisplacements .......................................................... xvDIVPD.................................................................... 95DIVPS .................................................................... 98DIVSD.................................................................. 101DIVSS .................................................................. 103double quadword .................................................... xvidoubleword............................................................. xvi

E

eAX–eSP register.................................................... xxieffective address size ............................................... xvieffective operand size .............................................. xvieFLAGS register ..................................................... xxieIP register ............................................................ xxiielement .................................................................. xviendian order.......................................................... xxivexceptions .............................................................. xviexponent.................................................................. xvEXTRQ................................................................. 105

F

flush....................................................................... xviFXRSTOR ............................................................ 107FXSAVE ............................................................... 109

H

HADDPD.............................................................. 111HADDPS .............................................................. 113HSUBPD .............................................................. 116HSUBPS ............................................................... 118

I

IGN ...................................................................... xviiindirect.................................................................. xviiINSERTQ.............................................................. 121instructions

128-bit media ......................................................... 1SSE ....................................................................... 1SSE-2 .................................................................... 1

Index

Page 430: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

402 Index

AMD64 Technology 26568—Rev. 3.10—September 2007

L

LDDQU................................................................ 123LDMXCSR ........................................................... 125legacy mode .......................................................... xviilegacy x86............................................................. xviilong mode ............................................................. xviiLSB...................................................................... xviilsb ........................................................................ xvii

M

mask.................................................................... xviiiMASKMOVDQU.................................................. 127MAXPD ............................................................... 129MAXPS ................................................................ 131MAXSD ............................................................... 133MAXSS ................................................................ 135MBZ.................................................................... xviiiMINPD................................................................. 137MINPS ................................................................. 139MINSD................................................................. 141MINSS ................................................................. 143modes

16-bit.................................................................. xiv32-bit.................................................................. xiv64-bit.................................................................. xivcompatibility ........................................................ xvlegacy ................................................................ xviilong................................................................... xviiprotected............................................................. xixreal ..................................................................... xixvirtual-8086 ......................................................... xx

moffset................................................................. xviiiMOVAPD ............................................................. 145MOVAPS .............................................................. 147MOVD.................................................................. 150MOVDDUP .......................................................... 153MOVDQ2Q........................................................... 155MOVDQA ............................................................ 157MOVDQU ............................................................ 159MOVHLPS ........................................................... 161MOVHPD ............................................................. 163MOVHPS.............................................................. 165MOVLHPS ........................................................... 167MOVLPD ............................................................. 169MOVLPS .............................................................. 171MOVMSKPD........................................................ 173MOVMSKPS ........................................................ 175MOVNTDQ .......................................................... 177MOVNTPD........................................................... 179MOVNTPS ........................................................... 181MOVNTSD........................................................... 183MOVNTSS ........................................................... 185

MOVQ.................................................................. 187MOVQ2DQ........................................................... 189MOVSD................................................................ 191MOVSHDUP......................................................... 194MOVSLDUP ......................................................... 196MOVSS ................................................................ 198MOVUPD ............................................................. 200MOVUPS.............................................................. 202MSB .................................................................... xviiimsb...................................................................... xviiiMSR ..................................................................... xxiiMULPD ................................................................ 205MULPS................................................................. 207MULSD ................................................................ 210MULSS................................................................. 212

O

octword ................................................................ xviiioffset.................................................................... xviiiORPD ................................................................... 214ORPS.................................................................... 216overflow............................................................... xviii

P

packed.................................................................. xviiiPACKSSDW.......................................................... 218PACKSSWB.......................................................... 220PACKUSWB ......................................................... 222PADDB................................................................. 224PADDD................................................................. 226PADDQ................................................................. 228PADDSB............................................................... 230PADDSW.............................................................. 232PADDUSB ............................................................ 234PADDUSW ........................................................... 236PADDW................................................................ 238PAND ................................................................... 240PANDN................................................................. 242PAVGB ................................................................. 244PAVGW ................................................................ 246PCMPEQB............................................................ 248PCMPEQD............................................................ 250PCMPEQW........................................................... 252PCMPGTB............................................................ 254PCMPGTD............................................................ 256PCMPGTW........................................................... 258PEXTRW .............................................................. 260PINSRW ............................................................... 262PMADDWD.......................................................... 264PMAXSW............................................................. 266PMAXUB ............................................................. 268

Page 431: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

Index 403

26568—Rev. 3.10—September 2007 AMD64 Technology

PMINSW .............................................................. 270PMINUB .............................................................. 272PMOVMSKB........................................................ 274PMULHUW.......................................................... 276PMULHW ............................................................ 278PMULLW ............................................................. 280PMULUDQ........................................................... 282POR ..................................................................... 284protected mode ....................................................... xixPSADBW ............................................................. 286PSHUFD............................................................... 288PSHUFHW ........................................................... 291PSHUFLW............................................................ 294PSLLD ................................................................. 297PSLLDQ............................................................... 299PSLLQ ................................................................. 301PSLLW................................................................. 303PSRAD................................................................. 305PSRAW ................................................................ 307PSRLD ................................................................. 309PSRLDQ............................................................... 311PSRLQ ................................................................. 313PSRLW................................................................. 315PSUBB ................................................................. 317PSUBD................................................................. 319PSUBQ................................................................. 321PSUBSB ............................................................... 323PSUBSW .............................................................. 325PSUBUSB ............................................................ 327PSUBUSW ........................................................... 329PSUBW ................................................................ 331PUNPCKHBW...................................................... 333PUNPCKHDQ ...................................................... 335PUNPCKHQDQ.................................................... 337PUNPCKHWD...................................................... 339PUNPCKLBW ...................................................... 341PUNPCKLDQ....................................................... 343PUNPCKLQDQ .................................................... 345PUNPCKLWD ...................................................... 347PXOR................................................................... 349

Q

quadword ............................................................... xix

R

r8–r15................................................................... xxiirAX–rSP ............................................................... xxiiRAZ ...................................................................... xixRCPPS.................................................................. 351RCPSS.................................................................. 353real address mode. See real mode

real mode ............................................................... xixregisters

eAX–eSP ............................................................ xxieFLAGS.............................................................. xxieIP..................................................................... xxiir8–r15................................................................ xxiirAX–rSP ............................................................ xxiirFLAGS............................................................ xxiiirIP .................................................................... xxiii

relative ................................................................... xixreserved.................................................................. xixrevision history ......................................................... xirFLAGS register ................................................... xxiiirIP register............................................................ xxiiiRIP-relative addressing............................................ xixRSQRTPS ............................................................. 355RSQRTSS ............................................................. 357

S

set........................................................................... xxSHUFPD............................................................... 359SHUFPS ............................................................... 361SQRTPD ............................................................... 364SQRTPS................................................................ 366SQRTSD ............................................................... 368SQRTSS................................................................ 370SSE......................................................................... xxSSE2....................................................................... xxSSE3....................................................................... xxsticky bits ................................................................ xxSTMXCSR............................................................ 372SUBPD ................................................................. 373SUBPS.................................................................. 375SUBSD ................................................................. 378SUBSS.................................................................. 380

T

TSS......................................................................... xx

U

UCOMISD ............................................................ 382UCOMISS............................................................. 385underflow ................................................................ xxUNPCKHPD ......................................................... 388UNPCKHPS.......................................................... 390UNPCKLPD.......................................................... 392UNPCKLPS .......................................................... 394

V

vector...................................................................... xxvirtual-8086 mode.................................................... xx

Page 432: AMD64 Architecture Programmer’s Manual, Volume 4: … · Advanced Micro Devices AMD64 Technology AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit Media Instructions Publication

404 Index

AMD64 Technology 26568—Rev. 3.10—September 2007

X

XORPD ................................................................ 396XORPS................................................................. 398