Difference between revisions of "Assembler:Commands:CMP"
(→Command Parameters) |
|||
Line 55: | Line 55: | ||
* [https://wikipedia.org/wiki/X86_instruction_listings wikipedia.org/wiki/X86_instruction_listings] | * [https://wikipedia.org/wiki/X86_instruction_listings wikipedia.org/wiki/X86_instruction_listings] | ||
* [https://wikibooks.org/wiki/X86_Assembly/Other_Instructions wikibooks.org/wiki/X86_Assembly/Other_Instructions] | * [https://wikibooks.org/wiki/X86_Assembly/Other_Instructions wikibooks.org/wiki/X86_Assembly/Other_Instructions] | ||
+ | * [http://x86.renejeschke.de/ x86.renejeschke.de] | ||
* [http://www.asmpedia.org/index.php?title=Main_Page asmpedia.org] | * [http://www.asmpedia.org/index.php?title=Main_Page asmpedia.org] |
Revision as of 04:09, 15 March 2017
command cmp operand1, operand2
Compares the first operand with the second operand and sets the status flags in the (E)FLAGS register according to the results.
The CF, OF, SF, ZF, AF, and PF flags are set according to the result.
Compares the first source operand with the second source operand and sets the status flags in the EFLAGS register according to the results. The comparison is performed by subtracting the second operand from the first operand and then setting the status flags in the same manner as the SUB instruction. When an immediate value is used as an operand, it is sign-extended to the length of the first operand.
The CMP instruction is typically used in conjunction with a conditional jump (Jcc), condition move (CMOVcc), or SETcc instruction. The condition codes used by the Jcc, CMOVcc, and SETcc instructions are based on the results of a CMP instruction. Appendix B, EFLAGS Condition Codes, in the IA-32 Intel Architecture Software Developer's Manual, Volume 1, shows the relationship of the status flags and the condition codes.
Command Parameters
Parameter | Description |
---|---|
operand1 | The first operand to compare |
operand2 | The second operand to compare |
Examples
cmp eax,0
cmp eax,ebx
cmp rax,rbx
cmp eax,[00123ABC]
cmp eax,SomeSymbol
cmp eax,[SomeSymbol]
cmp eax,0 jne @f
cmp eax,0 pop eax jne @f