13.07.2015 Views

Volume 3: General-Purpose and System Instructions - Stanford ...

Volume 3: General-Purpose and System Instructions - Stanford ...

Volume 3: General-Purpose and System Instructions - Stanford ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

24594 Rev. 3.10 February 2005 AMD64 TechnologyXCHGExchangeExchanges the contents of the two oper<strong>and</strong>s. The oper<strong>and</strong>s can be two generalpurposeregisters or a register <strong>and</strong> a memory location. If either oper<strong>and</strong> referencesmemory, the processor locks automatically, whether or not the LOCK prefix is used<strong>and</strong> independently of the value of IOPL. For details about the LOCK prefix, see “LockPrefix” on page 10.The x86 architecture commonly uses the XCHG EAX, EAX instruction (opcode 90h) asa one-byte NOP. In 64-bit mode, the processor treats opcode 90h as a true NOP only ifit would exchange rAX with itself. Without this special h<strong>and</strong>ling, the instructionwould zero-extend the upper 32 bits of RAX, <strong>and</strong> thus it would not be a true nooperation.Opcode 90h can still be used to exchange rAX <strong>and</strong> r8 if the appropriateREX prefix is used.This special h<strong>and</strong>ling does not apply to the two-byte ModRM form of the XCHGinstruction.Mnemonic Opcode DescriptionXCHG AX, reg1690 +rwXCHG reg16, AX90 +rwXCHG EAX, reg3290 +rdXCHG reg32, EAX90 +rdXCHG RAX, reg6490 +rqXCHG reg64, RAX90 +rqXCHG reg/mem8, reg8 86 /rXCHG reg8, reg/mem8 86 /rXCHG reg/mem16, reg16 87 /rExchange the contents of the AX register with the contents of a16-bit register.Exchange the contents of a 16-bit register with the contents of theAX register.Exchange the contents of the EAX register with the contents of a32-bit register.Exchange the contents of a 32-bit register with the contents of theEAX register.Exchange the contents of the RAX register with the contents of a64-bit register.Exchange the contents of a 64-bit register with the contents ofthe RAX register.Exchange the contents of an 8-bit register with the contents of an8-bit register or memory oper<strong>and</strong>.Exchange the contents of an 8-bit register or memory oper<strong>and</strong>with the contents of an 8-bit register.Exchange the contents of a 16-bit register with the contents of a16-bit register or memory oper<strong>and</strong>.XCHG 289

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!