Summary: Although the JMP Directive provides control over transfers, it does not allow any complex judgments to be made. The 80x86 conditional jump instruction provides this kind of judgment. Conditional jump directives are essential elements for creating loops and implementing other conditional execution statements, such as IF...ENDIF. The conditional jump command checks one or more flag bits to determine if they match a particular condition (like the SETCC Directive): If the flag matches successfully, the instruction transfers control to the target location, and if the match fails, the CPU ignores the conditional jump instruction and continues to execute the next instruction
. Some conditional jump instructions simply test the setting of the symbol bit (sign), carry bit (carry), overflow bit (overflow), 0 flag (zero) bit. For example, after executing a SH1 instruction, you need to test the carry flag to determine whether the SH1 is shifted from the high address of the operand to one bit. Similarly, you can test the 0 flag bit after a test instruction to determine whether the specified bit is 1. In most cases, the conditional jump instruction is executed after the CMP directive. The CMP directive sets the flag bit to determine less than, greater than, equal to, and so on.
JCC directive for test flag bits
Instructions |
Description |
Conditions |
Alias |
Opposite instruction |
Jc |
Jump if the carry bit is set |
Carry Flag =1 |
Jb,jnae |
JNC |
JNC |
Jump if the carry bit has no position |
Carry Flag =0 |
Jnb,jae |
Jc |
JZ |
Jump if the 0 flag is set |
0 Mark =1 |
JE |
Jnz |
Jnz |
If the 0 flag does not have a position then jump |
0 Mark =0 |
JNE |
JZ |
(Continuation of table)
Instructions |
Description |
Conditions |
Alias |
Opposite instruction |
Js |
Jump if the symbol bit is set |
Symbol Mark =1 |
|
JNS |
JNS |
Jump if the symbol bit is not set |
Symbol Mark =0 |
|
Js |
JO |
Jump if overflow flag is set |
Overflow flag =1 |
|
Jno |
Jno |
If the overflow flag does not have a position then jump |
Overflow flag =0 |
JO |
|
Jp |
Jump if parity bit is set |
Parity Check Flag =1 |
JPE |
JNP |
JPE |
Jump if parity bit is parity |
Parity Check Flag =1 |
Jp |
JPO |
JNP |
Jump if parity bit is not set |
Parity Check Flag =0 |
JPO |
Jp |
JPO |
Jump if parity bit is odd check |
Parity Check Flag =0 |
JNP |
JPE |
JCC Instruction with unsigned number comparison
Instructions |
Description |
Conditions |
Alias |
Opposite instruction |
JA |
If more than (>) jumps |
Carry flag =0,0 Flag =0 |
Jnbe |
JNA |
Jnbe |
Jump if not below or equal to (not <=) |
Carry flag =0,0 Flag =0 |
JA |
Jbe |
JAE |
If it is greater than or equal to (>=), jump |
Carry Flag =0 |
Jnc,jnb |
Jnae |
JNB |
If not below then jump (not <) |
Carry Flag =0 |
Jnc,jae |
Jb |
Jb |
Jump if below (<) |
Carry Flag =1 |
Jc,jnae |
JNB |
Jnae |
Jump if not more than or equal to (not >=) |
Carry Flag =1 |
Jc,jb |
JAE |
Jbe |
Jump if below or equal to (<=) |
Carry flag =1 or 0 flag =1 |
JNA |
Jnbe |
JNA |
Jump if Not over (>) |
Carry flag =1 or 0 flag =1 |
Jbe |
JA |
JE |
Jump if equal (=) |
0 Mark =1 |
JZ |
JNE |
JNE |
If not equal (<>) then jump |
0 Mark =0 |
Jnz |
JE |
the JCC directive that uses a signed number comparison
Instructions |
Description |
Conditions |
Alias |
Opposite instruction |
Jg |
Jump if greater than (>) |
Symbol flag = Overflow flag or 0 flag =0 |
Jnle |
JNG |
Jnle |
Jump if less than or equal to (<=) |
Symbol flag = Overflow flag or 0 flag =0 |
Jg |
Jle |
Jge |
Jump if greater than or equal to (>=) |
Symbol flag = Overflow flag |
JNL |
Jge |
JNL |
Jump if not less than (<) |
Symbol flag = Overflow flag |
Jge |
JL |
JL |
Jump if less than (<) |
Symbol Flags <> Overflow flags |
Jnge |
JNL |
Jnge |
If greater than or equal to (>=) jump |
Symbol Flags <> Overflow flags |
JL |
Jge |
Jle |
If less than or equal to (<=) jumps |
Symbol sign <> overflow flag or 0 mark =1 |
JNG |
Jnle |
JNG |
If not greater than (not >) then jump |
Symbol sign <> overflow flag or 0 mark =1 |
Jle |
Jg |
JE |
Jump if equals (=) |
0 Mark =1 |
JZ |
JNE |
JNE |
If not equal to (<>) then jump |
0 Mark =0 |
Jnz |
JE |
Loop Jump Command: Note the following three lines of code:
- MOV CX,3
- Next:movsb
- LOOP NEXT
Among them, loop's jump mechanism: through the automatic decrement of CX to achieve jump reference: http://blog.csdn.net/trochiluses/article/details/19355425
Assembly Language Transfer Instruction rule summary