我很难理解js
和jb
指令到底是做什么的。我知道jb
是jump if below。但是,jb
和jle
之间有什么区别呢。类似地,在我看来,js
相当于jb
,因为它的意思是有符号的跳转。如有任何帮助,我们将不胜感激。
有一个方便的表可以很好地解释要使用哪个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
jb
(和ja
(分支基于标志的无符号结果,而不是jg
、jge
、jl
和jle
的signed分支条件。
在无符号比较中,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
鉴于:
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
将仅根据(R|E)FLAGS
寄存器中的符号标志的状态进行分支