phihag
phihag

Reputation: 288190

Why does x86 have the redundant JNGE instruction?

On page 3-431 of the Intel instruction set reference, two different instructions are mentioned:

7C cb  JL rel8   Jump short if less (SF ≠ OF).
7C cb  JNGE rel8 Jump short if not greater or equal (SF ≠ OF).

What is the reasoning behind having two names for the same instruction? Is there any instance where it matters whether I use JL or JNGE?

Upvotes: 1

Views: 383

Answers (1)

Jester
Jester

Reputation: 58792

It's just to make code more readable in case one or the other matches your intention better. As you quoted, the machine code is the same, and ultimately that's what the processor will execute. As such, it won't know whether you used JL or JNGE. All the relations have their negated name too.

There are other duplicates that illustrate the readability point a little better, for example JE and JZ. You'd normally use JE after a comparison, and JZ otherwise. Similarly you have JB and JC.

Upvotes: 6

Related Questions