汇编中的js和jb指令

时间:2018-11-23 18:55:15

标签: assembly x86 att

我很难理解jsjb指令的作用。我了解jb在下面时会跳转。但是,jbjle之间会有什么区别。同样,在我看来js等效于jb,因为如果签名,则意味着跳转。任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:0)

jb(和ja)分支基于标志的 unsigned 结果,与{{的 signed 分支条件相反1}},jgjgejl

在无符号比较中,MSB包含在数字本身中,而不表示其符号。例如:

jle

位置:

 ; 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

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 将仅基于js寄存器中符号标志的状态进行分支

答案 1 :(得分:0)

有一个方便的表格,很好地说明了要使用的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