JCC Instruction Set
Table of Contents
JCC Instruction Set
JE / JZ
(jump if equal / jump if zero)
Basic function
Jump when the most recent comparison/arithmetic result is “equal” or the result is 0.
Jump condition (logic)
ZF == 1RFLAGS (full diagram)
+-------------------------------+| CF | ZF | SF | OF | PF | AF ||carry|zero |sign |overflow|parity|aux|+-------------------------------+| ? | [1] | ? | ? | ? | ? |+-------------------------------+Equivalent expression
if (ZF == 1) jump;Common uses
Branching after string or numeric equality checks (commonly used after cmp).
JNE / JNZ
(jump if not equal / jump if not zero)
Basic function
Jump when the most recent comparison/arithmetic result is not equal or the result is non-zero.
Jump condition
ZF == 0RFLAGS (full diagram)
+-------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------+| ? | [0] | ? | ? | ? | ? |+-------------------------------+Equivalent expression
if (ZF == 0) jump;Common uses
Continue loops, continue after failed searches, etc.
JA / JNBE
(jump if above / jump if not below or equal) (unsigned a > b)
Basic function
Used for unsigned comparison, indicating strictly greater than (a > b, unsigned).
Jump condition
(CF == 0) && (ZF == 0)RFLAGS (full diagram)
+-------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------+| [0] | [0] | ? | ? | ? | ? |+-------------------------------+Equivalent expression
if (!CF && !ZF) jump; // unsigned a > bCommon uses
Memory length, unsigned index comparisons, etc.
JAE / JNB / JNC
(jump if above or equal / jump if not below / jump if not carry) (unsigned a >= b)
Basic function
Unsigned comparison >=: no borrow (carry).
Jump condition
CF == 0RFLAGS (full diagram)
+-------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------+| [0] | ? | ? | ? | ? | ? |+-------------------------------+Equivalent expression
if (!CF) jump; // unsigned a >= bCommon uses
Boundary checks (unsigned).
Note
JAE = JNB = JNC (common aliases).
JB / JNAE / JC
(jump if below / jump if not above or equal / jump if carry) (unsigned a < b)
Basic function
Unsigned less than (with borrow).
Jump condition
CF == 1RFLAGS (full diagram)
+-------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------+| [1] | ? | ? | ? | ? | ? |+-------------------------------+Equivalent expression
if (CF == 1) jump; // unsigned a < bCommon uses
Error/boundary checks.
Note: JC (jump if carry) is an alias of JB.
JBE / JNA
(jump if below or equal / jump if not above) (unsigned a <= b)
Basic function
Unsigned less than or equal.
Jump condition
(CF == 1) || (ZF == 1)RFLAGS (full diagram)
+-------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------+| [1] | ? | ? | ? | ? | ? || OR | [1] | | | | |+-------------------------------+Equivalent expression
if (CF || ZF) jump; // unsigned a <= bCommon uses
Array/buffer boundary checks (unsigned).
JG / JNLE
(jump if greater / jump if not less or equal) (signed a > b)
Basic function
Used for signed integer comparison, indicating strictly greater than (a > b, signed).
Jump condition
(ZF == 0) && (SF == OF)RFLAGS (full diagram)
+-------------------------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------------------------+| ? | [0] | [SF]| [OF]| ? | ? || | | SF==OF (must be true) |+-------------------------------------------------+Equivalent expression
if ((ZF == 0) && (SF == OF)) jump; // signed a > bTypical uses
Signed comparison branches (such as signed integer sorting or conditional checks).
JGE / JNL
(jump if greater or equal / jump if not less) (signed a >= b)
Basic function
Signed >=.
Jump condition
SF == OFRFLAGS (full diagram)
+-------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------+| ? | ? | [SF] | [OF] | ? | ? || (require SF == OF) |+-------------------------------+Equivalent expression
if (SF == OF) jump; // signed a >= bTypical uses
Signed boundary checks.
JL / JNGE
(jump if less / jump if not greater or equal) (signed a < b)
Basic function
Signed less than.
Jump condition
SF != OFRFLAGS (full diagram)
+-------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------+| ? | ? | [SF] | [OF] | ? | ? || (require SF != OF) |+-------------------------------+Equivalent expression
if (SF != OF) jump; // signed a < bTypical uses
Signed comparison branches (negative-number-related checks).
JLE / JNG
(jump if less or equal / jump if not greater) (signed a <= b)
Basic function
Signed less than or equal.
Jump condition
(ZF == 1) || (SF != OF)RFLAGS (full diagram)
+------------------------------------------------+| CF | ZF | SF | OF | PF | AF |+------------------------------------------------+| ? | [1] | [SF]| [OF]| ? | ? || OR (or SF != OF) |+------------------------------------------------+Equivalent expression
if (ZF || (SF != OF)) jump; // signed a <= bTypical uses
Signed range checks (<=).
JO
(jump if overflow)
Basic function
Jump when the previous arithmetic operation caused overflow (signed overflow).
Jump condition
OF == 1RFLAGS (full diagram)
+-------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------+| ? | ? | ? | [1] | ? | ? |+-------------------------------+Equivalent expression
if (OF == 1) jump;Common uses
Detect signed overflow (for example, when an addition/subtraction result cannot be represented in the target bit width).
JNO
(jump if not overflow)
Basic function
Jump when there is no overflow.
Jump condition
OF == 0RFLAGS (full diagram)
+-------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------+| ? | ? | ? | [0] | ? | ? |+-------------------------------+Equivalent expression
if (OF == 0) jump;JS
(jump if sign)
Basic function
Jump when the result is negative (highest bit is 1), checking the sign bit.
Jump condition
SF == 1RFLAGS (full diagram)
+-------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------+| ? | ? | [1] | ? | ? | ? |+-------------------------------+Equivalent expression
if (SF == 1) jump; // result negative (signed)Common uses
Detect negative numbers or branch on negative results in signed arithmetic.
JNS
(jump if not sign)
Basic function
Jump when the result is non-negative (highest bit is 0).
Jump condition
SF == 0RFLAGS (full diagram)
+-------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------+| ? | ? | [0] | ? | ? | ? |+-------------------------------+Equivalent expression
if (SF == 0) jump;JP / JPE
(jump if parity / jump if parity even)
Basic function
Jump when the parity of the most recent arithmetic or logical result is even (that is, PF == 1). PF indicates that the number of 1 bits in the low 8 bits of the result is even.
Jump condition
PF == 1RFLAGS (full diagram)
+-------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------+| ? | ? | ? | ? | [1] | ? |+-------------------------------+Equivalent expression
if (PF == 1) jump;Common uses
Used in some parity-check logic in legacy code/protocols.
JNP / JPO
(jump if not parity / jump if parity odd)
Basic function
Jump when PF == 0 (odd parity).
Jump condition
PF == 0RFLAGS (full diagram)
+-------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------+| ? | ? | ? | ? | [0] | ? |+-------------------------------+Equivalent expression
if (PF == 0) jump;JCXZ / JECXZ / JRCXZ
(jump if CX/ECX/RCX == 0)
Basic function
Check whether register CX/ECX/RCX is 0 (bitwise compare against immediate 0); if it is 0, jump. Commonly used for fast branching when the loop counter is 0 (short jump).
Jump condition
(CX == 0) 或 (ECX == 0) 或 (RCX == 0)RFLAGS (full diagram)
(These instructions do not directly depend on RFLAGS such as CF/ZF, but logically they are equivalent to comparing whether the register is 0, so they can be understood as depending on the register value rather than FLAGS; for consistency, FLAGS are still illustrated)
+-------------------------------+| CF | ZF | SF | OF | PF | AF |+-------------------------------+| ? | ? | ? | ? | ? | ? |+-------------------------------+Equivalent expression
if (RCX == 0) jump;Common uses
Short loops, special-case branches in string/block processing.