繁体   English   中英

汇编中的js和jb指令

[英]`js` and `jb` instructions in assembly

我很难理解jsjb指令的功能。 我知道如果在下面, jb会跳转。 但是, jbjle之间的区别是什么。 同样,在我看来, js等效于jb ,因为它表示如果签名就跳转。 任何帮助,将不胜感激。

jb (和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

鉴于:

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM