Difference between revisions of "Assembler:Commands:CMP"

From Cheat Engine
Jump to navigation Jump to search
(Created page with ''''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…')
 
 
(6 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.renejeschke.de/html/file_module_x86_id_35.html x86.renejeschke.de/html/file_module_x86_id_35.html]
+
[http://c9x.me/x86/html/file_module_x86_id_35.html c9x.me/x86/html/file_module_x86_id_35.html]
 
</div>
 
</div>
  
Line 20: Line 21:
 
!style="width: 80%;background-color:white;" align="left"|Description
 
!style="width: 80%;background-color:white;" align="left"|Description
 
|-
 
|-
|destination
+
|operand1
|The destination operand
+
|The first operand to compare
 
|-
 
|-
|source
+
|operand2
|The source operand
+
|The second operand to compare
 
|}
 
|}
 
  
 
== Examples ==
 
== Examples ==
Line 48: Line 48:
 
  jne @f
 
  jne @f
  
== See also ==
+
{{AssemblerCommandSeeAlso}}
* [[Assembler]]
 
* [[Cheat_Engine:Auto Assembler|Auto Assembler]]
 
* [[Assembler:Commands|Assembler Commands]]
 
  
== External links ==
+
{{Template:AssemblerCommandExternalLinks}}
* [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]
 
* [http://www.asmpedia.org/index.php?title=Main_Page asmpedia.org]
 

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.

c9x.me/x86/html/file_module_x86_id_35.html


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

See also[edit]

External links[edit]