Intel x86 Assembly Language & Microarchitecture Test arithmetic relations


Example

Unsigned integers

Greater than

cmp eax, ebx
ja a_label  

Greater than or equal

cmp eax, ebx
jae a_label  

Less than

cmp eax, ebx
jb a_label  

Less than or equal

cmp eax, ebx
jbe a_label 

Equal

cmp eax, ebx
je a_label 

Not equal

cmp eax, ebx
jne a_label     

Signed integers

Greater than

cmp eax, ebx
jg a_label  

Greater than or equal

cmp eax, ebx
jge a_label  

Less than

cmp eax, ebx
jl a_label  

Less than or equal

cmp eax, ebx
jle a_label 

Equal

cmp eax, ebx
je a_label 

Not equal

cmp eax, ebx
jne a_label 

a_label

In examples above the a_label is target destination for CPU when the tested condition is "true". When tested condition is "false", the CPU will continue on the next instruction following the conditional jump.

Synonyms

There are instruction synonyms that can be used to improve the readability of the code.
For example ja and jnbe (Jump non below nor equal) are the same instruction.

Signed unsigned companion codes

OperationUnsignedSigned
>jajg
>=jaejge
<jbjl
<=jbejle
=jeje
≠, !=, <>jnejne