In the assembly opcode cmovl, what gets compared? For example: EAX: 00000002 EBX: 00000001
cmovl eax,ebx
What is the result? Which one needs to be less so they can be moved?
Thank you!
In the assembly opcode cmovl, what gets compared? For example: EAX: 00000002 EBX: 00000001
cmovl eax,ebx
What is the result? Which one needs to be less so they can be moved?
Thank you!
It should be preceded by another instruction that sets flags appropriately, like cmp
.
cmp ebx, ecx ; compare ebx to ecx and set flags.
cmovl ebx, eax ; if (ebx < ecx (comparison based on flags)) ebx = eax
cmov doesn't do a comparison, it uses the result of a previous comparison - if it is true, it will perform the mov. cmovl means "perform move if previous comparison resulted in "less than".
For example:
cmp ecx, 5
cmovl eax, ebx ; eax = ebx if ecx < 5
cmovl
will perform the move if the flags register has the following: SF!=OF
Those flags would be set as the result of some previous operation (typically, but not necessarily, a compare of some sort).
The cmovl
instruction does not perform a compare of its own.