轉自:http://www.cnblogs.com/del/archive/2010/04/16/1713886.htmlhtml
http://pan.baidu.com/s/1gVTSiwindows
跳轉指令分三類:測試
1、無條件跳轉:spa
JMP ;無條件跳轉
JCXZ ;CX 爲 0 則跳轉 JECXZ;ECX 爲 0 則跳轉
JE ;等於則跳轉 同JZ JNE ;不等於則跳轉 同JNZ
JA ;無符號大於則跳轉 JNA ;無符號不大於則跳轉 JAE ;無符號大於等於則跳轉 同JNB JNAE ;無符號不大於等於則跳轉 同JB
JB ;無符號小於則跳轉 JNB ;無符號不小於則跳轉 JBE ;無符號小於等於則跳轉 同JNA JNBE ;無符號不小於等於則跳轉 同JA
JG ;有符號大於則跳轉 JNG ;有符號不大於則跳轉 JGE ;有符號大於等於則跳轉 同JNL JNGE ;有符號不大於等於則跳轉 同JL
JL ;有符號小於則跳轉 JNL ;有符號不小於則跳轉 JLE ;有符號小於等於則跳轉 同JNG JNLE ;有符號不小於等於則跳轉 同JG
JZ ;爲零則跳轉 JNZ ;不爲零則跳轉 JS ;爲負則跳轉 JNS ;不爲負則跳轉 JC ;進位則跳轉 JNC ;不進位則跳轉 JO ;溢出則跳轉 JNO ;不溢出則跳轉
JP
;爲偶則跳轉
JNP ;不爲偶則跳轉
JPE ;奇偶位置位則跳轉 同JP
JPO ;奇偶位復位則跳轉 同JNP
11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|---|---|---|
OF | DF | IF | TF | SF | ZF | AF | PF | CF | |||
溢 出 |
方 向 |
中 斷 |
陷 阱 |
符 號 |
零 | 未 用 |
輔 助 |
未 用 |
奇 偶 |
未 用 |
進 位 |
影響標誌位的彙編指令:debug
加法指令:ADD、ADC、INC、XADD 除了INC不影響CF標誌位外,都影響條件標誌位。 CF、ZF、SF、OF CF最高位是否有進位 DF若兩個操做數符號相同而結果符號與之相反OF=1,不然OF=0. 減法指令:SUB、SBB、DEC、NEG、CMP、CMPXCHG、CMPXCHG8B 前六種除了DEC不影響CF標誌外都影響標誌位。CMPXHG8B隻影響ZF。 CF說明無符號數相減的溢出,同時又確實是被減數最高有效位向高位的借位。 OF位則說明帶符號數的溢出 無符號運算時,若減數>被減數,有借位CF=1,不然CF=0. OF若兩個數符號相反,而結果的符號與減數相同則OF=1.不然OF=0. 乘法指令:MUL、IMUL MUL:若是乘積高一半爲0,則CF和OF位均爲0,不然CF和OF均爲1. IMUL:若是高一半是低一半符號的擴展,則CF位和OF位均爲0,不然就均爲1. 除法指令:DIV、IDIV 對全部條件位均無定義。 邏輯指令:AND、OR、NOT、XOR、TEST NOT不影響標誌位,其他4種CF、OF、置0,AF無定義,SF、ZF、PF位看狀況而定。 定位掃描指令:BSF正向位掃描、BSR反向位掃描 影響ZF位。
指令類型code |
助記符htm |
對標誌寄存器的影響blog |
備註ci |
||||||||||
ZF字符串 |
CF |
PF |
SF |
OF |
AF |
DF |
IF |
TF |
|
||||
數據傳送類 |
通用 |
MOV |
不影響標誌位 |
|
|||||||||
交換 |
XCHG |
|
|||||||||||
堆棧操做 |
PUSH |
|
|||||||||||
POP |
|
||||||||||||
地址傳送 |
LEA |
|
|||||||||||
LDS |
|
||||||||||||
LES |
|
||||||||||||
累加器專用 |
IN |
|
|||||||||||
OUT |
|
||||||||||||
XALT |
|
||||||||||||
標誌寄存器 |
LAHF |
|
|||||||||||
SAHF |
標誌寄存器低八位的內容由AH的值決定 |
CF,AF,ZF,SF,PF的值會被影響 |
|||||||||||
PUSHF |
不影響標誌位 |
|
|||||||||||
POPF |
標誌寄存器的內容由裝入的具體值決定 |
可能影響全部標誌位 |
|||||||||||
算術運算類 |
加法 |
ADD |
√ |
√ |
√ |
√ |
√ |
√ |
|
|
|
|
|
ADC |
√ |
√ |
√ |
√ |
√ |
√ |
|
|
|
|
|||
INC |
√ |
|
√ |
√ |
√ |
√ |
|
|
|
INC指令不影響CF |
|||
AAA |
? |
√ |
? |
? |
? |
√ |
|
|
|
?表示不肯定或者未定義 |
|||
DAA |
√ |
√ |
√ |
√ |
? |
√ |
|
|
|
|
|||
減法 |
SUB |
√ |
√ |
√ |
√ |
√ |
√ |
|
|
|
|
||
SBB |
√ |
√ |
√ |
√ |
√ |
√ |
|
|
|
|
|||
DEC |
√ |
|
√ |
√ |
√ |
√ |
|
|
|
DEC指令不影響CF |
|||
AAS |
? |
√ |
? |
? |
? |
√ |
|
|
|
|
|||
DAS |
√ |
√ |
√ |
√ |
? |
√ |
|
|
|
DAA指令不影響OF |
|||
乘法 |
MUL |
? |
√ |
? |
? |
√ |
? |
|
|
|
|
||
IMUL |
? |
√ |
? |
? |
√ |
? |
|
|
|
|
|||
AAM |
√ |
? |
√ |
√ |
? |
? |
|
|
|
|
|||
除法 |
DIV |
? |
? |
? |
? |
? |
? |
|
√ |
√ |
此指令可能會產生中斷,故影響IF,TF |
||
IDIV |
? |
? |
? |
? |
? |
? |
|
√ |
√ |
同上 |
|||
AAD |
√ |
? |
√ |
√ |
? |
? |
|
|
|
|
|||
符號位擴展 |
CBW |
不影響標誌位 |
|
||||||||||
CWD |
不影響標誌位 |
|
|||||||||||
比較 |
CMP |
由計算結果肯定標誌位的值 |
不會影響到DF,IF,TF |
||||||||||
邏輯運算類 |
單 操 做 數 |
求反 |
NOT |
不影響標誌位 |
|
||||||||
移位 |
SAL |
√ |
√ |
√ |
√ |
見 備 注 |
? |
|
|
|
OF標誌位只在移位次數是1時有效 AF未定義 |
||
SHL |
√ |
√ |
√ |
√ |
? |
|
|
|
|||||
SAR |
√ |
√ |
√ |
√ |
? |
|
|
|
|||||
SHR |
√ |
√ |
√ |
√ |
? |
|
|
|
|||||
循環 移位 |
ROL |
|
√ |
|
|
√ |
? |
|
|
|
循環移位指令影響OF和CF AF未定義 |
||
ROR |
|
√ |
|
|
√ |
? |
|
|
|
||||
RCL |
|
√ |
|
|
√ |
? |
|
|
|
||||
RCR |
|
√ |
|
|
√ |
? |
|
|
|
||||
|
雙 操 做 數 |
與 |
AND |
√ |
置0 |
√ |
√ |
置0 |
|
|
|
|
|
或 |
OR |
√ |
置0 |
√ |
√ |
置0 |
|
|
|
|
|
||
異或 |
XOR |
√ |
置0 |
√ |
√ |
置0 |
|
|
|
|
|
||
檢測 |
TSET |
√ |
置0 |
√ |
√ |
置0 |
|
|
|
|
|
||
字符串操做 |
傳送 |
MOVS |
不影響標誌位 |
|
|||||||||
比較 |
CMPS |
由計算結果肯定標誌位的值 |
不會影響DF,IF,TF |
||||||||||
搜索 |
SCAS |
由計算結果肯定標誌位的值 |
不會影響DF,IF,TF |
||||||||||
裝入 |
LODS |
不影響標誌位 |
|
||||||||||
填充 |
STOS |
不影響標誌位 |
|
||||||||||
前綴 |
REP |
不影響標誌位 |
|
||||||||||
程序控制類 |
無條件轉移 |
JMP |
不影響標誌位 |
|
|||||||||
條 件 轉 移 |
單個 標誌 位 |
JS/JNS |
SF=1/0,則轉移到目的地址 |
||||||||||
JZ/ JNZ |
ZF=1/0,則轉移到目的地址 |
||||||||||||
JP/JNP |
PF=1/0,則轉移到目的地址 |
||||||||||||
JB/JNB |
CF=1/0,則轉移到目的地址 |
||||||||||||
JO/JNO |
OF=1/0,則轉移到目的地址 |
||||||||||||
若干 標誌 位的 邏輯 組合 |
JA |
兩個無符號數比較,A>B |
|||||||||||
JBE |
兩個無符號數比較,A <=B |
||||||||||||
JG |
兩個帶符號數比較,A>B |
||||||||||||
JGE |
兩個帶符號數比較,A>=B |
||||||||||||
JL |
兩個帶符號數比較,A<B |
||||||||||||
JLE |
兩個帶符號數比較,A <=B |
||||||||||||
循環控制 |
LOOP |
不影響標誌位 |
|
||||||||||
LOOPE |
|
||||||||||||
LOOPNE |
|
||||||||||||
JCXZ |
|
||||||||||||
JECXZ |
|
||||||||||||
中斷控制 |
INT |
不影響標誌位 |
|
||||||||||
INTO |
|
||||||||||||
IRET |
影響全部標誌位 |
標誌位到恢復中斷之前的狀態 |
|||||||||||
CPU控制指令 |
標誌位操做 |
CLC |
|
√ |
|
|
|
|
|
|
|
此指令置CF=0 |
|
CMC |
|
√ |
|
|
|
|
|
|
|
此指令CF取反 |
|||
STC |
|
√ |
|
|
|
|
|
|
|
此指令置CF=1 |
|||
CLD |
|
|
|
|
|
|
√ |
|
|
此指令置DF=0 |
|||
STD |
|
|
|
|
|
|
√ |
|
|
此指令置DF=1 |
|||
CLI |
|
|
|
|
|
|
|
√ |
|
此指令置IF=0 |
|||
STI |
|
|
|
|
|
|
|
√ |
|
此指令置IF=1 |
|||
空操做 |
NOP |
不影響標誌位 |
|
||||||||||
暫停 |
HLT |
|
|||||||||||
等待 |
WAIT |
|
|||||||||||
交權 |
ESC |
|
|||||||||||
總線鎖定前綴 |
LOCK |
|
JMP 測試
; Test28_1.asm; .386 .model flat, stdcall include windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib .code main proc PrintText '1' jmp @F PrintText '2' PrintText '3' @@: PrintText '4' ret main endp end main ;測試結果應該是: ;1 ;4 ;如下都應該是這樣.
; Test28_2.asm; .386 .model flat, stdcall include windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib .code main proc PrintText '1' mov eax, 123 cmp eax, 123 je @F PrintText '2' PrintText '3' @@: PrintText '4' ret main endp end main
; Test28_3.asm; .386 .model flat, stdcall include windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib .code main proc PrintText '1' xor eax, eax jz @F PrintText '2' PrintText '3' @@: PrintText '4' ret main endp end main
; Test28_4.asm; .386 .model flat, stdcall include windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib .code main proc PrintText '1' xor eax, eax dec eax js @F PrintText '2' PrintText '3' @@: PrintText '4' ret main endp end main
; Test28_5.asm; .386 .model flat, stdcall include windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib .code main proc PrintText '1' mov al, 0FFh add al, 1 jc @F PrintText '2' PrintText '3' @@: PrintText '4' ret main endp end main
; Test28_6.asm; .386 .model flat, stdcall include windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib .code main proc PrintText '1' mov al, -128 sub al, 1 jo @F PrintText '2' PrintText '3' @@: PrintText '4' ret main endp end main
; Test28_7.asm; .386 .model flat, stdcall include windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib .code main proc PrintText '1' mov eax, 22 cmp eax, 11 ja @F PrintText '2' PrintText '3' @@: PrintText '4' ret main endp end main
; Test28_8.asm; .386 .model flat, stdcall include windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib .code main proc PrintText '1' mov eax, 1 cmp eax, -1 jg @F PrintText '2' PrintText '3' @@: PrintText '4' ret main endp end main
; Test28_9.asm; .386 .model flat, stdcall include windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib .code main proc PrintText '1' mov al, 00001110b inc al jp @F PrintText '2' PrintText '3' @@: PrintText '4' ret main endp end main
; Test28_10.asm; .386 .model flat, stdcall include windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib .code main proc PrintText '1' xor ecx, ecx jecxz @F PrintText '2' PrintText '3' @@: PrintText '4' ret main endp end main