Can you please tell me the difference between ja
(jump if above) and jnbe
(jump if not below or equal) instructions in x86 assembly? When do I use each of them? do they give me different results?

- 4,086
- 1
- 11
- 33

- 11
- 3
-
1These are equal (have same opcode). – nevilad Apr 18 '21 at 14:15
-
3`ja` / `jnbe` [are synonyms](https://ulukai.org/ecm/doc/ldebug.htm#helpc) for the condition `NOT (Carry Flag OR Zero Flag)` – ecm Apr 18 '21 at 14:17
-
@HansPassant I don't think `JNBE` would be for signed then, because it has "below". The signed equivalents, using that terminology, would be `JNLE` and `JG`. – Thomas Jager Apr 18 '21 at 14:29
-
Why not try it out? – Erik Eidt Apr 18 '21 at 14:46
1 Answers
Assuming you mean the ja
and jnbe
mnemonics in x86 assembly: There's no difference; they are two different mnemonics for the exact same instruction. You can consult the official instruction description and see that they correspond to the exact same machine code (77 cb for an 8-bit "short" offset, 0f 87 cw/cd for a 16- or 32-bit "near" offset).
So it makes no difference to the machine, only to the human programmers who read and maintain your code. It gives you the freedom to write whichever one seems more intuitive for what your code is doing.
Many of the other x86 conditional instructions have multiple mnemonics for similar situations. For example jb
, "jump if below", jumps precisely when the carry flag is set, making it the same instruction as jc
, "jump if carry". But having two mnemonics means you can write things like:
add eax, ebx
jc there_was_a_carry
...
cmp ecx, edx
jb ecx_is_smaller
Combinations like add / jb
and cmp / jc
would be equivalent to the machine, but less clear for the programmer.

- 48,811
- 6
- 54
- 82
-
Yup, different mnemonics for the same opcode let you pick the one that has the desired **semantic meaning** for human readers of your asm source. (The distinction is lost if you're disassembling machine-code; then you have to remember the equivalence.) Pretty sure this question has come up before, maybe for a different pair like JE / JZ; probably should get closed as a duplicate in one direction or the other. – Peter Cordes Apr 18 '21 at 22:56