[英]`js` and `jb` instructions in assembly
我很難理解js
和jb
指令的功能。 我知道如果在下面, jb
會跳轉。 但是, jb
和jle
之間的區別是什么。 同樣,在我看來, js
等效於jb
,因為它表示如果簽名就跳轉。 任何幫助,將不勝感激。
jb
(和ja
)基於標志的無符號結果分支,而不是jg
, jge
, jl
和jle
的有符號分支條件。
在無符號比較中,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.