assembly language--conditional jump instruction

Source: Internet
Author: User

Modified from: http://bdxnote.blog.163.com/blog/static/84442352015327011988/

In this tribute to the original, most of the online posts are copied from a jump condition to write the wrong post, harm I almost want to suspect life,-_-!.

This post is mainly to change the original author's jump condition to the C language logical expression of the wording, so look more comfortable, and will not produce ambiguity

Direct Transfer Instructions
instruction Format Machine code Jump Conditions Condition Description symbols
JO OPR 70 Of==1 The result is overflow.
Jno OPR 71 Of==0 Results No overflow
JC OPR 72 Cf==1 Less than <
JNC OPR 73 Cf==0 Greater than or equal to >=
Jz/je OPR 74 Zf==1 Result is 0 ==
Jnz/jne OPR 75 Zf==0 Results not 0 !=
JS OPR 78 Sf==1 The result is negative <0
JNS OPR 79 Sf==0 The result is positive >0
Jp/jpe OPR 7A Pf==1 The number of 1 in the result is even
Jnp/jpo OPR 7B Pf==0 The number of 1 in the result is odd

Indirect transfer instruction-unsigned number
instruction Format Machine code Test Flags Condition Description symbols
Jb/jnae OPR 72 Cf==1 below/not above and not equal to <
Jnb/jae OPR 73 Cf==0 No less than/above or equal to >=
Jbe/jna OPR 76 (cf==1) | | (zf==1) Less than or equal to/not higher than <=
Jnbe/ja OPR 77 (cf==0) && (zf==0) No less than and not equal to/above >

Indirect transfer instruction-signed number
instruction Format Machine code Test Flags Condition Description symbols
Jl/jnge OPR 7C (sf^of) ==1 Less than/not greater than and not equal to <
Jnl/jge OPR 7D (sf^of) ==0 not less than/greater than or equal to >=
Jle/jng OPR 7E (sf^of) ==1 | | (zf==1) Less than or equal to/not greater than <=
JNLE/JG OPR 7F (sf^of) ==0 && (zf==0) Not less than and not equal to/greater than >


Understanding Method :
N:not
E:equal
A:above
B:below
L:less (Little's comparative level)
G:greater (comparative level of great)

Conditional jump instruction is to jump according to the value of the relevant flag bit in the flag register, therefore, the conditional jump instruction can only be used with the instruction that can affect the flags of the flag register;
Directives that can directly affect the flag register are:
1. Arithmetic operation instruction: Add, Sub, ADC, SBB, Inc, Dec, neg, mul, Div, Imul, idiv, etc.;
2, bitwise logical operation: And, OR, XOR, not, and so on;
3. Comparison operation instruction: CMP, test;
4. Shift Operation instruction: SHR, SHL, SAR, Sal, Ror, Rol, RCR, RCL;
5, BCD number adjustment directive: AAA, AAs, DAA, Das, AAM, AAD;
6, marking processing instructions: CLC, STC, CMC, CLD, STD, CLI, STI;

The following paragraph is not verified, after the completion of the Assembly to test the paragraph

The sequence of instructions that can indirectly affect the relevant flag bits of the flag register are:
PUSHF--pop eax--Modify EAX--push eax--Popf
That
Pushf
Pop eax
Modify EAX
Push EAX
Popf
Jbe OPR
After such a series of operations, the conditional transfer instruction "Jbe OPR" can also be transferred according to the flag register;

assembly language--conditional jump instruction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.