[英]`js` and `jb` instructions in assembly
I am having a hard time understanding what exactly js
and jb
instruction do. 我很难理解
js
和jb
指令的功能。 I understand that jb
is jump if below. 我知道如果在下面,
jb
会跳转。 But, what would be the difference between jb
and jle
. 但是,
jb
和jle
之间的区别是什么。 And similarly, js
seems to me that it is equivalent to jb
, as it means jump if signed. 同样,在我看来,
js
等效于jb
,因为它表示如果签名就跳转。 Any help would be appreciated. 任何帮助,将不胜感激。
jb
(and ja
) branch based on the unsigned result of the flags, as opposed to the signed branch condition for jg
, jge
, jl
, and jle
. jb
(和ja
)基于标志的无符号结果分支,而不是jg
, jge
, jl
和jle
的有符号分支条件。
In an unsigned comparison, the MSB is included as part of the number itself and not an indication of its sign. 在无符号比较中,MSB包含在数字本身中,而不表示其符号。 For example:
例如:
; 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
Whereas: 鉴于:
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
will branch based solely on the state of the sign flag in the (R|E)FLAGS
register js
将仅基于(R|E)FLAGS
寄存器中符号标志的状态进行分支
There exists a handy table that does explain very well which Jcc
instruction to use: 有一个方便的表格可以很好地说明要使用的
Jcc
指令:
Jump conditions and flags: 跳转条件和标志:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.