JG - Jump if Condition Is Met

本文介绍了EFLAGS寄存器中条件跳转指令Jcc,它检查状态标志,若满足条件则跳转到目标指令。目标指令通过相对偏移指定,编码对特定偏移范围更高效。还提及部分操作码有两个助记符,Jcc不支持远跳转,JECXZ和JCXZ指令检查寄存器内容,所有条件跳转转换为代码提取。
Up ] [ Docs Home ]

JG - Jump if Condition Is Met

Back ] [ Next ]

*

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

?


CodeMnemonicDescription
77 cbJA rel8Jump short if above (CF=0 and ZF=0)
73 cbJAE rel8Jump short if above or equal (CF=0)
72 cbJB rel8Jump short if below (CF=1)
76 cbJBE rel8Jump short if below or equal (CF=1 or ZF=1)
72 cbJC rel8Jump short if carry (CF=1)
E3 cbJCXZ rel8Jump short if CX register is 0
E3 cbJECXZ rel8Jump short if ECX register is 0
74 cbJE rel8Jump short if equal (ZF=1)
7F cbJG rel8Jump short if greater (ZF=0 and SF=OF)
7D cbJGE rel8Jump short if greater or equal (SF=OF)
7C cbJL rel8Jump short if less (SF<>OF)
7E cbJLE rel8Jump short if less or equal (ZF=1 or SF<>OF)
76 cbJNA rel8Jump short if not above (CF=1 or ZF=1)
72 cbJNAE rel8Jump short if not above or equal (CF=1)
73 cbJNB rel8Jump short if not below (CF=0)
77 cbJNBE rel8Jump short if not below or equal (CF=0 and ZF=0)
73 cbJNC rel8Jump short if not carry (CF=0)
75 cbJNE rel8Jump short if not equal (ZF=0)
7E cbJNG rel8Jump short if not greater (ZF=1 or SF<>OF)
7C cbJNGE rel8Jump short if not greater or equal (SF<>OF)
7D cbJNL rel8Jump short if not less (SF=OF)
7F cbJNLE rel8Jump short if not less or equal (ZF=0 and SF=OF)
71 cbJNO rel8Jump short if not overflow (OF=0)
7B cbJNP rel8Jump short if not parity (PF=0)
79 cbJNS rel8Jump short if not sign (SF=0)
75 cbJNZ rel8Jump short if not zero (ZF=0)
70 cbJO rel8Jump short if overflow (OF=1)
7A cbJP rel8Jump short if parity (PF=1)
7A cbJPE rel8Jump short if parity even (PF=1)
7B cbJPO rel8Jump short if parity odd (PF=0)
78 cbJS rel8Jump short if sign (SF=1)
74 cbJZ rel8Jump short if zero (ZF = 1)
0F 87 cw/cdJA rel16/32Jump near if above (CF=0 and ZF=0)
0F 83 cw/cdJAE rel16/32Jump near if above or equal (CF=0)
0F 82 cw/cdJB rel16/32Jump near if below (CF=1)
0F 86 cw/cdJBE rel16/32Jump near if below or equal (CF=1 or ZF=1)
0F 82 cw/cdJC rel16/32Jump near if carry (CF=1)
0F 84 cw/cdJE rel16/32Jump near if equal (ZF=1)
0F 84 cw/cdJZ rel16/32Jump near if 0 (ZF=1)
0F 8F cw/cdJG rel16/32Jump near if greater (ZF=0 and SF=OF)
0F 8D cw/cdJGE rel16/32Jump near if greater or equal (SF=OF)
0F 8C cw/cdJL rel16/32Jump near if less (SF<>OF)
0F 8E cw/cdJLE rel16/32Jump near if less or equal (ZF=1 or SF<>OF)
0F 86 cw/cdJNA rel16/32Jump near if not above (CF=1 or ZF=1)
0F 82 cw/cdJNAE rel16/32Jump near if not above or equal (CF=1)
0F 83 cw/cdJNB rel16/32Jump near if not below (CF=0)
0F 87 cw/cdJNBE rel16/32Jump near if not below or equal (CF=0 and ZF=0)
0F 83 cw/cdJNC rel16/32Jump near if not carry (CF=0)
0F 85 cw/cdJNE rel16/32Jump near if not equal (ZF=0)
0F 8E cw/cdJNG rel16/32Jump near if not greater (ZF=1 or SF<>OF)
0F 8C cw/cdJNGE rel16/32Jump near if not greater or equal (SF<>OF)
0F 8D cw/cdJNL rel16/32Jump near if not less (SF=OF)
0F 8F cw/cdJNLE rel16/32Jump near if not less or equal (ZF=0 and SF=OF)
0F 81 cw/cdJNO rel16/32Jump near if not overflow (OF=0)
0F 8B cw/cdJNP rel16/32Jump near if not parity (PF=0)
0F 89 cw/cdJNS rel16/32Jump near if not sign (SF=0)
0F 85 cw/cdJNZ rel16/32Jump near if not zero (ZF=0)
0F 80 cw/cdJO rel16/32Jump near if overflow (OF=1)
0F 8A cw/cdJP rel16/32Jump near if parity (PF=1)
0F 8A cw/cdJPE rel16/32Jump near if parity even (PF=1)
0F 8B cw/cdJPO rel16/32Jump near if parity odd (PF=0)
0F 88 cw/cdJS rel16/32Jump near if sign (SF=1)
0F 84 cw/cdJZ rel16/32Jump near if 0 (ZF=1)


Description
Checks the state of one or more of the status flags in the EFLAGS register (CF, OF, PF, SF, and ZF) and, if the flags are in the specified state (condition), performs a jump to the target instruction specified by the destination operand. A condition code (cc) is associated with each instruction to indicate the condition being tested for. If the condition is not satisfied, the jump is not performed and execution continues with the instruction following the Jcc instruction.

The target instruction is specified with a relative offset (a signed offset relative to the current value of the instruction pointer in the EIP register). A relative offset (rel8, rel16, or rel32) is generally specified as a label in assembly code, but at the machine code level, it is encoded as a signed, 8-bit or 32-bit immediate value, which is added to the instruction pointer. Instruction coding is most efficient for offsets of –128 to +127. If the operand-size attribute is 16, the upper two bytes of the EIP register are cleared to 0s, resulting in a maximum instruction pointer size of 16 bits.

The conditions for each Jcc mnemonic are given in the "Description" column of the table on the preceding page. The terms "less" and "greater" are used for comparisons of signed integers and the terms "above" and "below" are used for unsigned integers.

Because a particular state of the status flags can sometimes be interpreted in two ways, two mnemonics are defined for some opcodes. For example, the JA (jump if above) instruction and the JNBE (jump if not below or equal) instruction are alternate mnemonics for the opcode 77H.

The Jcc instruction does not support far jumps (jumps to other code segments). When the target for the conditional jump is in a different segment, use the opposite condition from the condition being tested for the Jcc instruction, and then access the target with an unconditional far jump (JMP instruction) to the other segment. For example, the following conditional far jump is illegal:
JZ FARLABEL;

To accomplish this far jump, use the following two instructions:
JNZ BEYOND;
JMP FARLABEL;
BEYOND:

The JECXZ and JCXZ instructions differs from the other Jcc instructions because they do not check the status flags. Instead they check the contents of the ECX and CX registers, respectively, for 0. Either the CX or ECX register is chosen according to the address-size attribute. These instructions are useful at the beginning of a conditional loop that terminates with a conditional loop instruction (such as LOOPNE). They prevent entering the loop when the ECX or CX register is equal to 0, which would cause the loop to execute 2 32 or 64K times, respectively, instead of zero times.

All conditional jumps are converted to code fetches of one or two cache lines, regardless of jump address or cacheability.

OperandsBytesClocks
near821PV
near1631PV

cycles apply to jump and no jump

Flags

 

IDunaffectedDFunaffected
VIPunaffectedIFunaffected
VIFunaffectedTFunaffected
ACunaffectedSFunaffected
VMunaffectedZFunaffected
RFunaffectedAFunaffected
NTunaffectedPFunaffected
IOPLunaffectedCFunaffected
OFunaffected

111

转载于:https://www.cnblogs.com/heycomputer/articles/10803373.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值