汇编中的`js`和`jb`指令

kon*_*ant 4 x86 assembly att

我很难理解指令的具体js作用jb。我知道jb如果低于则跳转。jb但是,和 之间有什么区别jle。同样,js在我看来,它相当于jb,因为它意味着如果签名则跳转。任何帮助,将不胜感激。

zx4*_*485 9

有一个方便的表格可以很好地解释Jcc要使用哪条指令:

跳转条件和标志:

Mnemonic        Condition tested  Description  
jo              OF = 1            overflow 
jno             OF = 0            not overflow 
jc, jb, jnae    CF = 1            carry / below / not above nor equal
jnc, jae, jnb   CF = 0            not carry / above or equal / not below
je, jz          ZF = 1            equal / zero
jne, jnz        ZF = 0            not equal / not zero
jbe, jna        CF or ZF = 1      below or equal / not above
ja, jnbe        CF or ZF = 0      above / not below or equal
js              SF = 1            sign 
jns             SF = 0            not sign 
jp, jpe         PF = 1            parity / parity even 
jnp, jpo        PF = 0            not parity / parity odd 
jl, jnge        SF xor OF = 1     less / not greater nor equal
jge, jnl        SF xor OF = 0     greater or equal / not less
jle, jng    (SF xor OF) or ZF = 1 less or equal / not greater
jg, jnle    (SF xor OF) or ZF = 0 greater / not less nor equal 
Run Code Online (Sandbox Code Playgroud)


Gov*_*mar 5

jb(and ja) 基于标志的无符号结果进行分支,与、、和 的有符号分支条件相反。jgjgejljle

在无符号比较中,MSB 作为数字本身的一部分包含在内,而不是其符号的指示。例如:

 ; Intel                          ; ; AT&T
 mov eax, 08000000h               ; mov $0x8000000, %eax
 mov ecx, 00000001h               ; mov $0x0000001, %ecx
 cmp eax, ecx                     ; cmp %ecx, %eax
 jl mybranch ; branch taken       ; jl mybranch ; branch taken
Run Code Online (Sandbox Code Playgroud)

然而:

 mov eax, 08000000h               ; mov $0x8000000, %eax
 mov ecx, 00000001h               ; mov $0x0000001, %ecx
 cmp eax, ecx                     ; cmp %ecx, %eax
 jb mybranch ; branch not taken   ; jb mybranch ; branch not taken
Run Code Online (Sandbox Code Playgroud)

js(R|E)FLAGS将仅根据寄存器中标志标志的状态进行分支