我很难理解js
和jb
指令的作用。我了解jb
在下面时会跳转。但是,jb
和jle
之间会有什么区别。同样,在我看来js
等效于jb
,因为如果签名,则意味着跳转。任何帮助将不胜感激。
答案 0 :(得分:0)
jb
(和ja
)分支基于标志的 unsigned 结果,与{{的 signed 分支条件相反1}},jg
,jge
和jl
。
在无符号比较中,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