AngoLinux

80386 Programmer's Reference Manual -- Opcode Jcc


Jcc -- Jump if Condition is Met

OpcodeInstructionClocks DescriptionExample
77 cbja rel87+m,3 Jump short if above (CF=0 and ZF=0)ja rel8_0
73 cbjae rel87+m,3 Jump short if above or equal (CF=0)jae rel8_1
72 cbjb rel87+m,3 Jump short if below (CF=1)jb rel8_2
76 cbjbe rel87+m,3 Jump short if below or equal (CF=1 or ZF=1)jbe rel8_3
72 cbjc rel87+m,3 Jump short if carry (CF=1)jc rel8_4
E3 cbjcxz rel89+m,5 Jump short if CX register is 0jcxz rel8_5
E3 cbjecxz rel89+m,5 Jump short if ECX register is 0jecxz rel8_6
74 cbje rel87+m,3 Jump short if equal (ZF=1)je rel8_7
74 cbjz rel87+m,3 Jump short if 0 (ZF=1)jz rel8_8
7F cbjg rel87+m,3 Jump short if greater (ZF=0 and SF=OF)jg rel8_9
7D cbjge rel87+m,3 Jump short if greater or equal (SF=OF)jge rel8_10
7C cbjl rel87+m,3 Jump short if less (SF<jl rel8_11
7E cbjle rel87+m,3 Jump short if less or equal (ZF=1 and SF<jle rel8_12
76 cbjna rel87+m,3 Jump short if not above (CF=1 or ZF=1)jna rel8_13
72 cbjnae rel87+m,3 Jump short if not above or equal (CF=1)jnae rel8_14
73 cbjnb rel87+m,3 Jump short if not below (CF=0)jnb rel8_15
77 cbjnbe rel87+m,3 Jump short if not below or equal (CF=0 and ZF=0)jnbe rel8_16
73 cbjnc rel87+m,3 Jump short if not carry (CF=0)jnc rel8_17
75 cbjne rel87+m,3 Jump short if not equal (ZF=0)jne rel8_18
7E cbjng rel87+m,3 Jump short if not greater (ZF=1 or SF<jng rel8_19
7C cbjnge rel87+m,3 Jump short if not greater or equal (SF<jnge rel8_20
7D cbjnl rel87+m,3 Jump short if not less (SF=OF)jnl rel8_21
7F cbjnle rel87+m,3 Jump short if not less or equal (ZF=0 and SF=OF)jnle rel8_22
71 cbjno rel87+m,3 Jump short if not overflow (OF=0)jno rel8_23
7B cbjnp rel87+m,3 Jump short if not parity (PF=0)jnp rel8_24
79 cbjns rel87+m,3 Jump short if not sign (SF=0)jns rel8_25
75 cbjnz rel87+m,3 Jump short if not zero (ZF=0)jnz rel8_26
70 cbjo rel87+m,3 Jump short if overflow (OF=1)jo rel8_27
7A cbjp rel87+m,3 Jump short if parity (PF=1)jp rel8_28
7A cbjpe rel87+m,3 Jump short if parity even (PF=1)jpe rel8_29
7B cbjpo rel87+m,3 Jump short if parity odd (PF=0)jpo rel8_30
78 cbjs rel87+m,3 Jump short if sign (SF=1)js rel8_31
74 cbjz rel87+m,3 Jump short if zero (ZF = 1)jz rel8_32
0F 87 cw/cdja rel16/327+m,3 Jump near if above (CF=0 and ZF=0)ja rel16
0F 83 cw/cdjae rel16/327+m,3 Jump near if above or equal (CF=0)jae rel16
0F 82 cw/cdjb rel16/327+m,3 Jump near if below (CF=1)jb rel16
0F 86 cw/cdjbe rel16/327+m,3 Jump near if below or equal (CF=1 or ZF=1)jbe rel16
0F 82 cw/cdjc rel16/327+m,3 Jump near if carry (CF=1)jc rel16
0F 84 cw/cdje rel16/327+m,3 Jump near if equal (ZF=1)je rel16
0F 84 cw/cdjz rel16/327+m,3 Jump near if 0 (ZF=1)jz rel16
0F 8F cw/cdjg rel16/327+m,3 Jump near if greater (ZF=0 and SF=OF)jg rel16
0F 8D cw/cdjge rel16/327+m,3 Jump near if greater or equal (SF=OF)jge rel16
0F 8C cw/cdjl rel16/327+m,3 Jump near if less (SF<jl rel16
0F 8E cw/cdjle rel16/327+m,3 Jump near if less or equal (ZF=1 and SF<jle rel16
0F 86 cw/cdjna rel16/327+m,3 Jump near if not above (CF=1 or ZF=1)jna rel16
0F 82 cw/cdjnae rel16/327+m,3 Jump near if not above or equal (CF=1)jnae rel16
0F 83 cw/cdjnb rel16/327+m,3 Jump near if not below (CF=0)jnb rel16
0F 87 cw/cdjnbe rel16/327+m,3 Jump near if not below or equal (CF=0 and ZF=0)jnbe rel16
0F 83 cw/cdjnc rel16/327+m,3 Jump near if not carry (CF=0)jnc rel16
0F 85 cw/cdjne rel16/327+m,3 Jump near if not equal (ZF=0)jne rel16
0F 8E cw/cdjng rel16/327+m,3 Jump near if not greater (ZF=1 or SF<jng rel16
0F 8C cw/cdjnge rel16/327+m,3 Jump near if not greater or equal (SF<jnge rel16
0F 8D cw/cdjnl rel16/327+m,3 Jump near if not less (SF=OF)jnl rel16
0F 8F cw/cdjnle rel16/327+m,3 Jump near if not less or equal (ZF=0 and SF=OF)jnle rel16
0F 81 cw/cdjno rel16/327+m,3 Jump near if not overflow (OF=0)jno rel16
0F 8B cw/cdjnp rel16/327+m,3 Jump near if not parity (PF=0)jnp rel16
0F 89 cw/cdjns rel16/327+m,3 Jump near if not sign (SF=0)jns rel16
0F 85 cw/cdjnz rel16/327+m,3 Jump near if not zero (ZF=0)jnz rel16
0F 80 cw/cdjo rel16/327+m,3 Jump near if overflow (OF=1)jo rel16
0F 8A cw/cdjp rel16/327+m,3 Jump near if parity (PF=1)jp rel16
0F 8A cw/cdjpe rel16/327+m,3 Jump near if parity even (PF=1)jpe rel16
0F 8B cw/cdjpo rel16/327+m,3 Jump near if parity odd (PF=0)jpo rel16
0F 88 cw/cdjs rel16/327+m,3 Jump near if sign (SF=1)js rel16
0F 84 cw/cdjz rel16/327+m,3 Jump near if 0 (ZF=1)jz rel16

Notes

The first clock count is for the true condition (branch taken); the second clock count is for the false condition (branch not taken). rel16/32 indicates that these instructions map to two; one with a 16-bit relative displacement, the other with a 32-bit relative displacement, depending on the operand-size attribute of the instruction.

Operation




IF condition
THEN
   EIP := EIP + SignExtend(rel8/16/32);
   IF OperandSize = 16
   THEN EIP := EIP AND 0000FFFFH;
   FI;
FI;

Description

Conditional jumps (except JCXZ) test the flags which have been set by a previous instruction. The conditions for each mnemonic are given in parentheses after each description above. The terms "less" and "greater" are used for comparisons of signed integers; "above" and "below" are used for unsigned integers.

If the given condition is true, a jump is made to the location provided as the operand. Instruction coding is most efficient when the target for the conditional jump is in the current code segment and within -128 to +127 bytes of the next instruction's first byte. The jump can also target -32768 thru +32767 (segment size attribute 16) or -2^(31) thru +2^(31) -1 (segment size attribute 32) relative to the next instruction's first byte. When the target for the conditional jump is in a different segment, use the opposite case of the jump instruction (i.e., JE and JNE), and then access the target with an unconditional far jump to the other segment. For example, you cannot code--




JZ FARLABEL;
You must instead code--



   JNZ BEYOND;
   JMP FARLABEL;
BEYOND:
Because there can be several ways to interpret a particular state of the flags, ASM386 provides more than one mnemonic for most of the conditional jump opcodes. For example, if you compared two characters in AX and want to jump if they are equal, use JE; or, if you ANDed AX with a bit field mask and only want to jump if the result is 0, use JZ, a synonym for JE.

JCXZ differs from other conditional jumps because it tests the contents of the CX or ECX register for 0, not the flags. JCXZ is useful at the beginning of a conditional loop that terminates with a conditional loop instruction (such as LOOPNE TARGET LABEL). The JCXZ prevents entering the loop with CX or ECX equal to zero, which would cause the loop to execute 64K or 32G times instead of zero times.

Flags Affected

None

Protected Mode Exceptions

#GP(0) if the offset jumped to is beyond the limits of the code segment

Real Address Mode Exceptions

None

Virtual 8086 Mode Exceptions

None


[Home Page dell'ITIS "Fermi"] [80386 Programmer's Reference Manual Index] [Previous] [Next]