Conditional jump table
Assembly language - conditional jump instructions
Direct transfer instruction | ||||
---|---|---|---|---|
Instruction format | Machine code | Test flag | Condition Description | symbol |
JO OPR | 70 | OF=1 | Results overflow | |
For OPR | 71 | OF=0 | Results There was no overflow | |
JC OPR | 72 | CF=1 | Less than | < |
JNC OPR | 73 | CF=0 | greater than or equal to | >= |
JZ / IS OPR | 74 | ZF=1 | The result is 0 | == |
JNZ / JNE OPR | 75 | ZF=0 | The result is non-zero | != |
JS OPR | 78 | SF=1 | The result is negative | <0 |
JNS CPR | 79 | SF=0 | The result is positive | >0 |
JP/JPE OPR | 7A | PF=1 | 1 results in an even number | |
JNP / JPO OPR | 7B | PF=0 | Results in an odd number |
Indirect branch instruction - unsigned | ||||
---|---|---|---|---|
Instruction format | Machine code | Test flag | Condition Description | symbol |
JBE / JNA OPER | 72 | CF=1 | Less than / equal to not higher than without | < |
Jhnrb / JAE OPR | 73 | CF=0 | Not less than / greater than or equal to | >= |
Jrbe / JNA OPR | 76 | (CF=1)|(ZF=1) | Less than or equal / not higher than | <= |
JNBE / I OPR | 77 | (CF=0)&(ZF=0) | Not less than and not equal to / higher than | > |
Indirect branch instruction - Number Signed | ||||
---|---|---|---|---|
Instruction format | Machine code | Test flag | Condition Description | symbol |
JL / JNGE OPR | 7C | (SF^OF)=1 | Less than / equal to not greater than not | < |
JNL / OPR JGE | 7D | (SF^OF)=0 | Not less than / greater than or equal to | >= |
Jrlae / JNG OPR | 7E | (SF^OF)=1|(ZF=1) | Less than or equal to / greater than not | <= |
JNLE / JG OPR | 7F | (SF^OF)=0&(ZF=0) | It is not less than and not equal to / greater than | > |
理解方法:
N: Not
E: Equal
A: Above
B: Below
L: Less (Little的比较级)
G: Greater (Great的比较级)
Less Than : 小于
Greater Than: 大于
(SF^OF)=1 --> SF=0,OF=1 --> a < b
SF=1,OF=0 --> a < b
(SF^OF)=0 --> SF=1,OF=1 --> a > b
SF=0,OF=0 --> a >= b
条件跳转指令是根据标志寄存器中的相关标志位的值来进行跳转的,因此,条件跳转指令只能与那些能够影响标志寄存器的相关标志位的指令配合使用;
能够直接影响标志寄存器的相关标志位的指令有:
1、算术运算指令 : add、sub、adc、sbb、inc、dec、neg、mul、div、imul、idiv,等等;
2、按位逻辑运算 : and、or、xor、not,等等;
3、比较运算指令 : cmp、test;
4、移位操作指令 : shr、shl、sar、sal、ror、rol、rcr、rcl;
5、BCD数调整指令: aaa、aas、daa、das、aam、aad;
6、标志处理指令 : clc、stc、cmc、cld、std、cli、sti;
能够间接影响标志寄存器的相关标志位的指令序列有:
pushf --> pop eax --> modify eax --> push eax --> popf
即:
pushf
pop eax
modify eax
push eax
popf
jbe OPR
这样的一系列操作之后,条件转移指令"jbe OPR"也可以根据标志寄存器的相关标志位进行转移;