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 TechnologyCMPCompareCompares the contents of a register or memory location (first oper<strong>and</strong>) with animmediate value or the contents of a register or memory location (second oper<strong>and</strong>),<strong>and</strong> sets or clears the status flags in the rFLAGS register to reflect the results. Toperform the comparison, the instruction subtracts the second oper<strong>and</strong> from the firstoper<strong>and</strong> <strong>and</strong> sets the status flags in the same manner as the SUB instruction, but doesnot alter the first oper<strong>and</strong>. If the second oper<strong>and</strong> is an immediate value, theinstruction sign-extends the value to the length of the first oper<strong>and</strong>.Use the CMP instruction to set the condition codes for a subsequent conditional jump(Jcc), conditional move (CMOVcc), or conditional SETcc instruction. Appendix E,“Instruction Effects on RFLAGS,” shows how instructions affect the rFLAGS statusflags..Mnemonic Opcode DescriptionCMP AL, imm8CMP AX, imm16CMP EAX, imm32CMP RAX, imm32CMP reg/mem8, imm8CMP reg/mem16, imm16CMP reg/mem32, imm32CMP reg/mem64, imm32CMP reg/mem16, imm8CMP reg/mem32, imm83C ib3D iw3D id3D id80 /7 ib81 /7 iw81 /7 id81 /7 id83 /7 ib83 /7 ibCompare an 8-bit immediate value with the contents of the ALregister.Compare a 16-bit immediate value with the contents of the AXregister.Compare a 32-bit immediate value with the contents of the EAXregister.Compare a 32-bit immediate value with the contents of the RAXregister.Compare an 8-bit immediate value with the contents of an 8-bitregister or memory oper<strong>and</strong>.Compare a 16-bit immediate value with the contents of a 16-bitregister or memory oper<strong>and</strong>.Compare a 32-bit immediate value with the contents of a 32-bitregister or memory oper<strong>and</strong>.Compare a 32-bit signed immediate value with the contents of a64-bit register or memory oper<strong>and</strong>.Compare an 8-bit signed immediate value with the contents of a16-bit register or memory oper<strong>and</strong>.Compare an 8-bit signed immediate value with the contents of a32-bit register or memory oper<strong>and</strong>.CMP 107

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

Saved successfully!

Ooh no, something went wrong!