Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What gets compared to what in the cmovl opcode?

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!

like image 949
Ryan Avatar asked Aug 12 '09 18:08

Ryan


People also ask

What does Cmovl do in assembly?

cmovl means "perform move if previous comparison resulted in "less than". For beginners: Note 1: cmovl responds to flags in the flag register. In particular, it performs a move if SF!=

What x86_64 assembly instruction is used to compare the contents of two registers?

You can use the SUB or CMP command.

What flag does the JE instruction rely upon?

Some instructions don't alter flags (mov in particular). So in case 1 the je is using the flags set by cmp . Case 2, jns is using the flags set by test .

What is EAX for?

(Environmental Audio Extensions) Sound card functions that reproduce the reverberation effects heard in different environments. Developed by Creative Labs, EAX provides an extension to the Windows DirectSound and OpenAL programming interfaces.


2 Answers

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
like image 64
Michael Avatar answered Sep 24 '22 03:09

Michael


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 
like image 32
mmx Avatar answered Sep 24 '22 03:09

mmx