转自:http://www.cnblogs.com/del/archive/2010/04/16/1713886.html
http://pan.baidu.com/s/1gVTSi
跳转指令分三类:
一、无条件跳转:
JMP ;无条件跳转
二、根据CX、ECX寄存器的值跳转:
JCXZ ;CX 为 0 则跳转 JECXZ;ECX 为 0 则跳转
三、根据
EFLAGS
寄存器
的
PSW
标志位
跳转, 这个太多了.
根据标志位跳转的指令:
JE ;等于则跳转 同JZ JNE ;不等于则跳转 同JNZJA ;无符号大于则跳转 JNA ;无符号不大于则跳转 JAE ;无符号大于等于则跳转 同JNB JNAE ;无符号不大于等于则跳转 同JB
JB ;无符号小于则跳转 JNB ;无符号不小于则跳转 JBE ;无符号小于等于则跳转 同JNA JNBE ;无符号不小于等于则跳转 同JAJG ;有符号大于则跳转 JNG ;有符号不大于则跳转 JGE ;有符号大于等于则跳转 同JNL JNGE ;有符号不大于等于则跳转 同JL
JL ;有符号小于则跳转 JNL ;有符号不小于则跳转 JLE ;有符号小于等于则跳转 同JNG JNLE ;有符号不小于等于则跳转 同JG
JZ ;为零则跳转 JNZ ;不为零则跳转JS ;为负则跳转 JNS ;不为负则跳转JC ;进位则跳转 JNC ;不进位则跳转JO ;溢出则跳转 JNO ;不溢出则跳转
JP
;为偶则跳转JNP ;不为偶则跳转JPE ;奇偶位置位则跳转 同JPJPO ;奇偶位复位则跳转 同JNP跳转相关的PSW标志位:
11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|---|---|---|
OF | DF | IF | TF | SF | ZF | AF | PF | CF | |||
溢 出 |
方 向 |
中 断 |
陷 阱 |
符 号 |
零 |
未 用 |
辅 助 |
未 用 |
奇 偶 |
未 用 |
进 位 |
影响标志位的汇编指令:
加法指令:ADD、ADC、INC、XADD除了INC不影响CF标志位外,都影响条件标志位。CF、ZF、SF、OFCF最高位是否有进位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、IMULMUL:如果乘积高一半为0,则CF和OF位均为0,否则CF和OF均为1.IMUL:如果高一半是低一半符号的扩展,则CF位和OF位均为0,否则就均为1.除法指令:DIV、IDIV对所有条件位均无定义。逻辑指令:AND、OR、NOT、XOR、TESTNOT不影响标志位,其余4种CF、OF、置0,AF无定义,SF、ZF、PF位看情况而定。定位扫描指令:BSF正向位扫描、BSR反向位扫描影响ZF位。
指令类型 |
助记符 |
对标志寄存器的影响 |
备注 |
||||||||||
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, stdcallinclude windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib.code main procPrintText '1'jmp @FPrintText '2'PrintText '3' @@: PrintText '4'ret main endp end main ;测试结果应该是: ;1 ;4 ;以下都应该是这样.
JE 测试
; Test28_2.asm; .386 .model flat, stdcallinclude windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib.code main procPrintText '1'mov eax, 123cmp eax, 123je @FPrintText '2'PrintText '3' @@: PrintText '4'ret main endp end main
JZ 测试
; Test28_3.asm; .386 .model flat, stdcallinclude windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib.code main procPrintText '1'xor eax, eaxjz @FPrintText '2'PrintText '3' @@: PrintText '4'ret main endp end main
JS 测试
; Test28_4.asm; .386 .model flat, stdcallinclude windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib.code main procPrintText '1'xor eax, eaxdec eaxjs @FPrintText '2'PrintText '3' @@: PrintText '4'ret main endp end main
JC 测试
; Test28_5.asm; .386 .model flat, stdcallinclude windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib.code main procPrintText '1'mov al, 0FFhadd al, 1jc @FPrintText '2'PrintText '3' @@: PrintText '4'ret main endp end main
JO 测试
; Test28_6.asm; .386 .model flat, stdcallinclude windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib.code main procPrintText '1'mov al, -128sub al, 1jo @FPrintText '2'PrintText '3' @@: PrintText '4'ret main endp end main
JA 测试
; Test28_7.asm; .386 .model flat, stdcallinclude windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib.code main procPrintText '1'mov eax, 22cmp eax, 11ja @FPrintText '2'PrintText '3' @@: PrintText '4'ret main endp end main
JG 测试
; Test28_8.asm; .386 .model flat, stdcallinclude windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib.code main procPrintText '1'mov eax, 1cmp eax, -1jg @FPrintText '2'PrintText '3' @@: PrintText '4'ret main endp end main
JP 测试
; Test28_9.asm; .386 .model flat, stdcallinclude windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib.code main procPrintText '1'mov al, 00001110binc aljp @FPrintText '2'PrintText '3' @@: PrintText '4'ret main endp end main
JECXZ 测试
; Test28_10.asm; .386 .model flat, stdcallinclude windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib.code main procPrintText '1'xor ecx, ecxjecxz @FPrintText '2'PrintText '3' @@: PrintText '4'ret main endp end main