Difference between revisions of "Assembler:Commands:CMP"
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | [[Category:Assembler]] | ||
'''command''' cmp ''operand1'', ''operand2'' | '''command''' cmp ''operand1'', ''operand2'' | ||
Line 11: | Line 12: | ||
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. | 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. | ||
− | [http://x86 | + | [http://c9x.me/x86/html/file_module_x86_id_35.html c9x.me/x86/html/file_module_x86_id_35.html] |
</div> | </div> | ||
Line 47: | Line 48: | ||
jne @f | jne @f | ||
− | + | {{AssemblerCommandSeeAlso}} | |
− | |||
− | |||
− | |||
− | + | {{Template:AssemblerCommandExternalLinks}} | |
− | |||
− | |||
− | |||
− |
Latest revision as of 15:41, 3 January 2018
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[edit]
Parameter | Description |
---|---|
operand1 | The first operand to compare |
operand2 | The second operand to compare |
Examples[edit]
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