What is compared to what is in cmovl code?

In opcode cmovl assembly, what compares? For example: EAX: 00000002 EBX: 00000001

cmovl eax,ebx

What is the result? Which one should be smaller so that they can be moved?

Thanks!

+5
source share
4 answers

cmov does not perform the comparison, it uses the result of the previous comparison - if it is true, it will execute mov. cmovl means "perform a move if the previous comparison resulted in" less. "

For example:

cmp ecx, 5
cmovl eax, ebx ; eax = ebx if ecx < 5
+13
source

It should be preceded by another command that sets the flags accordingly, for example cmp.

cmp ebx, ecx   ; compare ebx to ecx and set flags.
cmovl ebx, eax ; if (ebx < ecx (comparison based on flags)) ebx = eax 
+4
source

cmovl , : SF!=OF

( , , - ).

cmovl .

+2
source

In the AT&T assembly, the equivalent code would look like this:

cmp   %ebx, %eax
cmovl %ebx, %eax

which would copy the value %ebxin %eaxif the value contained in %eaxwas greater than the value contained in %ebxduring the call cmp.

With your examples, the result will be that the conditional move will not copy the value from %ebxto %eax, since there is 0x02clearly more than 0x01.

0
source

All Articles