汇编语言从入门到精通-指令汇总
目录
指令汇总
1、数据传送指令
1.1、传送指令
指令的语法 |
举例 |
周期数 |
MOV reg,reg |
mov bp,sp |
1 |
MOV mem,reg |
mov array[di],bx |
1 |
MOV reg,mem |
mov bx,pointer |
1 |
MOV mem,immed |
mov [bx],15 |
1 |
MOV reg,immed |
mov cx,256 |
1 |
MOV mem,accum |
mov total,ax |
1 |
MOV accum,mem |
mov al,string |
1 |
MOV segreg,reg16 |
mov ds,ax |
2, 3 |
MOV segreg,mem16 |
mov es,psp |
2, 3 |
MOV reg16,segreg |
mov ax,ds |
1 |
MOV mem16,segreg |
mov stack_save,ss |
1 |
MOV reg32,controlreg |
mov eax,cr0 |
22 |
mov eax,cr2 |
12 |
|
mov eax,cr3 |
21, 46 |
|
mov eax,cr4 |
14 |
|
MOV controlreg,reg32 |
mov cr0,eax |
4 |
MOV reg32,debugreg |
mov edx,dr0 |
DR0-DR3, DR6,DR7=11 |
DR4,DR5=12 |
||
MOV debugreg,reg32 |
mov dr0,ecx |
DR0-DR3, |
DR4,DR5=12 DR6,DR7=11 |
1.2、传送-填充指令
MOVSX reg,reg |
movsx bx,al |
3 |
MOVSX reg,mem |
movsx eax,bsign |
3 |
MOVZX reg,reg |
movzx bx,al |
3 |
MOVZX reg,mem |
movzx eax,bunsign |
3 |
1.3、交换指令
XCHG reg,reg |
xchg cx,dx |
3 |
XCHG reg,mem |
xchg bx,pointer |
3 |
XCHG mem,reg |
xchg [bx],ax |
3 |
XCHG accum,reg |
xchg ax,cx |
2 |
XCHG reg,accum |
xchg cx,ax |
2 |
1.4、取段地址和有效地址指令
LDS reg,mem |
lds si,fpointer |
4 |
LES reg,mem |
les di,fpointer |
4 |
LFS reg,mem |
lfs edi,fpointer |
4 |
LGS reg,mem |
lgs bx,fpointer |
4 |
LSS reg,mem |
lss bp, fpointer |
4, pm=8 |
LEA reg,mem |
lea bx,npointer |
1 |
1.5、进栈指令
PUSH reg |
push dx |
1 |
PUSH mem |
push [di] |
2 |
PUSH segreg |
push es |
1 |
PUSH immed |
push 15000 |
1 |
PUSHA |
pusha |
5 |
PUSHAD |
pushad |
5 |
PUSHF |
pushf |
4, pm=3 |
PUSHFD |
pushfd |
4, pm=3 |
1.6、出栈指令
POP reg |
pop cx |
1 |
POP mem |
pop param |
3 |
POP segreg |
pop es |
3 |
POPA |
popa |
5 |
POPAD |
popad |
5 |
POPF |
popf |
6, pm=4 |
POPFD |
popfd |
6, pm=4 |
1.7、转换指令
XLAT [[segreg:]mem] |
xlat |
4 |
XLATB [[segreg:]mem] |
xlatb es:table |
4 |
1.8、输入指令
IN accum,immed |
in ax,60h |
7, pm=4,21*(注), vm=19 |
IN accum,DX |
in ax,dx |
7, pm=4,21*, vm=19 |
INS [ES:]dest, DX |
ins es:instr,dx |
9, pm=6,24*, vm=22 |
INSB |
Insb |
9, pm=6,24*, vm=22 |
INSW |
Insw |
9, pm=6,24*, vm=22 |
INSD |
Insd |
9, pm=6,24*, vm=22 |
注:当CPL≤IOPL时,执行时间是第一个时钟周期,否则是第二个时钟周期。
1.9、输出指令
OUT immed8,accum |
out 60h,al |
12, pm=9,26, VM=24 |
OUT DX,accum |
out dx,ax |
12, pm=9,25 VM=24 |
OUTS DX,[segreg:]src |
outs dx,buffer |
13, pm=10,27, VM=24 |
OUTSB [DX,[segreg:]src] |
outsb |
13, pm=10,27, VM=24 |
OUTSW [DX,[segreg:]src] |
outsw |
13, pm=10,27, VM=24 |
OUTSD [DX,[segreg:]src] |
outsd |
13, pm=10,27, VM=24 |
2、标志位操作指令
2.1、标志位操作指令
指令的语法 |
举例 |
周期数 |
CLC |
clc |
2 |
CMC |
cmc |
2 |
STC |
stc |
2 |
CLD |
cld |
2 |
STD |
std |
2 |
CLI |
cli |
7 |
STI |
sti |
7 |
2.2、标志位存取操作指令
SAHF |
Sahf |
2 |
LAHF |
lahf |
2 |
2.3、标志位堆栈操作指令
PUSHF |
pushf |
4, pm=3 |
PUSHFD |
pushfd |
4, pm=3 |
POPF |
popf |
6, pm=4 |
POPFD |
popfd |
6, pm=4 |
3、算术运算指令
3.1、加法指令
指令的语法 |
举例 |
周期数 |
ADC reg,reg |
adc dx,cx |
1 |
ADC mem,reg |
adc word ptr m16[2],dx |
3 |
ADC reg,mem |
adc dx,dword ptr m32[2] |
2 |
ADD reg,reg |
add ax,bx |
1 |
ADD mem,reg |
add total, cx |
3 |
ADD reg,mem |
add cx,incr |
2 |
ADD reg,immed |
add bx,6 |
1 |
ADD mem,immed |
add pointers[bx][si],6 |
3 |
ADD accum,immed |
add ax,10 |
1 |
INC reg |
inc bx |
1 |
INC mem |
inc vpage |
3 |
XADD reg,reg |
xadd dl,al |
3 |
XADD mem,reg |
xadd string,bl |
4 |
3.2、减法指令
SUB reg,reg |
sub ax,bx |
1 |
SUB mem,reg |
sub array[di],bi |
3 |
SUB reg,mem |
sub al,[bx] |
2 |
SUB reg,immed |
sub bl,7 |
1 |
SUB mem,immed |
sub total,4000 |
3 |
SUB accum,immed |
sub ax,32000 |
1 |
SBB accum,immed |
sbb ax,320 |
1 |
SBB reg,immed |
sbb dx,45 |
1 |
SBB mem,immed |
sbb word ptr m32[2],40 |
3 |
SBB reg,reg |
sbb dx,cx |
1 |
SBB mem,reg |
sbb word ptr m32[2],dx |
3 |
SBB reg,mem |
sbb dx,word ptr m32[2] |
2 |
DEC reg |
dec ax |
1 |
DEC mem |
dec counter |
3 |
NEG reg |
neg ax |
1 |
NEG mem |
neg balance |
3 |
3.3、乘法指令
MUL reg |
mul bx |
|
MUL memX |
mul word ptr [bx] |
8,16-bit=11 |
32-bit=10 |
||
IMUL reg |
imul dx |
11 |
IMUL mem |
imul factor |
11 |
IMUL reg,immed |
imul cx,25 |
10 |
IMUL reg,reg,immed |
imul dx,ax,18 |
10 |
IMUL reg,mem,immed |
imul bx,[si],60 |
10 |
IMUL reg,reg |
imul cx,ax |
10 |
IMUL reg,mem |
imul dx,[si] |
10 |
3.4、除法指令
DIV reg |
div cx |
byte=17 word=25 |
DIV mem |
div [bx] |
dword=41 |
IDIV reg |
idiv dl |
8-bit=22;16-bit=30 |
IDIV mem |
idiv itemp |
32-bit=46 |
3.5、类型转换指令
CBW |
cbw |
3 |
CWD |
cwd |
2 |
CWDE |
cwde |
3 |
CDQ |
cdq |
2 |
4、逻辑运算指令
4.1、逻辑与操作指令
指令的语法 |
举例 |
周期数 |
AND reg,reg |
and dx,bx |
1 |
AND mem,reg |
and bitmask,bx |
3 |
AND reg,mem |
and bx,masker |
2 |
AND reg,immed |
and dx,0F7h |
1 |
AND mem,immed |
and masker,100lb |
3 |
AND accum,immed |
and ax,0B6h |
1 |
4.2、逻辑与操作指令
OR reg,reg |
or ax,dx |
1 |
OR mem,reg |
or bits,dx |
3 |
OR reg,mem |
or dx,color[di] |
2 |
OR reg,immed |
or dx,110110b |
1 |
OR mem,immed |
or flag_rec,8 |
3 |
OR accum,immed |
or ax,40h |
1 |
4.3、逻辑与操作指令
NOT reg |
not ax |
1 |
NOT mem |
not masker |
3 |
4.4、逻辑异或操作指令
XOR reg,reg |
xor cx,bx |
1 |
XOR reg,mem |
xor cx,flags |
2 |
XOR mem,reg |
xor [bp+10],cx |
3 |
XOR reg,immed |
xor bl,1 |
1 |
XOR mem,immed |
xor switches[bx],101b |
3 |
XOR accum,immed |
xor ax,01010101b |
1 |
5、移位操作指令
5.1、算术左移指令
指令的语法 |
举例 |
周期数 |
SAL reg,1 |
sal bx,1 |
1 |
SAL mem,1 |
sal word ptr m32[0],1 |
3 |
SAL reg,CL |
sal ah,cl |
4 |
SAL mem,CL |
sal BYTE PTR [di],cl |
4 |
SAL reg,immed |
sal cx,6 |
1 |
SAL mem,immed |
sal array[bx+di],14 |
3 |
5.2、算术右移指令
SAR reg,1 |
sar di,1 |
1 |
SAR mem,1 |
sar count,1 |
3 |
SAR reg,CL |
sar bx,cl |
4 |
SAR mem,CL |
sar sign,cl |
4 |
SAR reg,immed |
sar bx,5 |
1 |
SAR mem,immed |
sar sign_count,3 |
3 |
5.3、逻辑左移指令
SHL reg,1 |
shl si,1 |
1 |
SHL mem,1 |
shl index,1 |
3 |
SHL reg,CL |
shl di,cl |
4 |
SHL mem,CL |
shl index,cl |
4 |
SHL reg,immed |
shl di,2 |
1 |
SHL mem,immed |
shl unsign,4 |
3 |
5.4、逻辑右移指令
SHR reg,1 |
shr dh,1 |
1 |
SHR mem,1 |
shr unsign[di],1 |
3 |
SHR reg,CL |
shr dx,cl |
4 |
SHR mem,CL |
shr word ptr m32[2],cl |
4 |
SHR reg,immed |
shr bx,8 |
1 |
SHR mem,immed |
shr mem16,11 |
3 |
5.5、双精度左移指令
SHLD reg16,reg16,immed8 |
shld ax,dx,10 |
4 |
SHLD reg32,reg32,immed8 |
||
SHLD mem16,reg16,immed8 |
shld bits,cx,5 |
4 |
SHLD mem32,reg32,immed8 |
||
SHLD reg16,reg16,CL |
shld ax,dx,cl |
4 |
SHLD reg32,reg32,CL |
||
SHLD mem16,reg16,CL |
shld masker,ax,cl |
5 |
SHLD mem32,reg32,CL |
5.6、双精度右移指令
SHRD reg16,reg16,immed8 |
shrd cx,si,3 |
4 |
SHRD reg32,reg32,immed8 |
|
|
SHRD mem16,reg16,immed8 |
shrd [di],dx,5 |
4 |
SHRD mem32,reg32,immed8 |
|
|
SHRD reg16,reg16,CL |
shrd ax,dx,cl |
4 |
SHRD reg32,reg32,CL |
|
|
SHRD mem16,reg16,CL |
shrd [bx],ax,cl |
5 |
SHRD mem32,reg32,CL |
|
|
5.7、循环左移指令
指令的语法 |
举例 |
周期数 |
ROL reg,1 |
rol ax,1 |
1 |
ROL mem,1 |
rol bits,1 |
3 |
ROL reg,CL |
rol ax,cl |
4 |
ROL mem,CL |
rol color,cl |
4 |
ROL reg,immed8 |
rol ax,13 |
1 |
ROL mem,immed8 |
rol byte ptr [bx],10 |
3 |
5.8、循环右移指令
ROR reg,1 |
ror ax,1 |
1 |
ROR mem,1 |
ror word ptr [bx],1 |
3 |
ROR reg,CL |
ror dx,cl |
4 |
ROR mem,CL |
ror color,cl |
5 |
ROR reg,immed8 |
ror bl,3 |
1 |
ROR mem,immed8 |
ror bits,6 |
3 |
5.9、带进位的循环左移指令
RCL reg,1 |
rcl dx,1 |
1 |
RCL mem,1 |
rcl WORD PTR [si],1 |
3 |
RCL reg,CL |
rcl dx,cl |
7-24 |
RCL mem,CL |
rcl masker,cl |
9-26 |
RCL reg,immed8 |
rcl bx,5 |
8-25 |
RCL mem,immed8 |
rcl word ptr [bp+8],3 |
10-27 |
5.10、带进位的循环右移指令
RCR reg,1 |
rcr bl,1 |
1 |
RCR mem,1 |
rcr word ptr m32[0],1 |
3 |
RCR reg,CL |
rcr bl,cl |
7-24 |
RCR mem,CL |
rcl word ptr [bx=di],cl |
9-26 |
RCR reg,immed8 |
rcr si,9 |
8-25 |
RCR mem,immed8 |
rcr masker,3 |
10-27 |
6、位操作指令
6.1、正向位扫描指令
指令的语法 |
举例 |
周期数 |
BSF reg16,reg16 |
bsf cx,bx |
6-34 |
BSF reg32,reg32 |
bsf cx,bx |
6-42 |
BSF reg16,mem16 |
bsf ecx,bitmask |
6-35 |
BSF reg32,mem32 |
bsf ecx,bitmask |
6-43 |
6.2、正向位扫描指令
BSR reg16,reg16 |
bsr cx,dx |
7-39 |
BSR reg32,reg32 |
bsr ecx, edx |
7-71 |
BSR reg16,mem16 |
bsr ax,bitmask |
7-40 |
BSR reg32,mem32 |
bsr eax,bitmask |
7-72 |
6.3、正向位扫描指令
BT reg16,immed8*(注) |
bt ax,4 |
4 |
BT mem16,immed8 |
bt [bx],4 |
4 |
BT reg16,reg16 |
bt ax,bx |
4 |
BT mem16,reg16 |
bt [bx],dx |
9 |
(注) 操作数也可以是32位数。
6.4、正向位扫描指令
BTC reg16,immed8* |
btc edi,4 |
7 |
BTC mem16,immed8* |
btc color[di],4 |
8 |
BTC reg16,reg16* |
btc eax,ebx |
7 |
BTC mem16,reg16* |
btc [bp+8],si |
13 |
6.5、正向位扫描指令
BTR reg16,immed8* |
btr bx,17 |
7 |
BTR mem16,immed8* |
btr [bx],27 |
8 |
BTR reg16,reg16* |
btr cx,di |
7 |
BTR mem16,reg16* |
btr rotate,cx |
13 |
6.6、正向位扫描指令
BTS reg16,immed8* |
bts ax,4 |
7 |
BTS mem16,immed8* |
bts maskit,4 |
8 |
BTS reg16,reg16* |
bts bx,ax |
7 |
BTS mem16,reg16* |
bts flags[bx],cx |
13 |
6.7、正向位扫描指令
TEST reg,reg |
test dx,bx |
1 |
TEST mem,reg |
test flags,dx |
2 |
TEST reg,immed |
test cx,30h |
1 |
TEST mem,immed |
test masker,1 |
2 |
TEST accum,immed |
test ax,90h |
1 |
7、比较运算指令
7.1、比较指令
指令的语法 |
举例 |
周期数 |
CMP reg,reg |
cmp dl,cl |
1 |
CMP mem,reg |
cmp array[si],bl |
2 |
CMP reg,mem |
cmp bh,array[si] |
2 |
CMP reg,immed |
cmp bx,24 |
1 |
CMP mem,immed |
cmp tester,4000 |
2 |
CMP accum,immed |
cmp ax,1000 |
1 |
7.2、比较交换指令
CMPXCHG mem,reg |
cmpxchg string,bl |
6 |
CMPXCHG reg,reg |
cmpxchg bx,cx |
6 |
CMPXCHG8B reg,mem64 |
cmpxchg8b ax,[bx] |
10 |
8、循环指令
8.1、循环指令
LOOP label |
loop wend |
5, 6 |
LOOPE label |
loope again |
7, 8 |
LOOPZ label |
loopz again |
7, 8 |
LOOPNE label |
loopne for_next |
7, 8 |
LOOPNZ label |
loopnz for_next |
7, 8 |
8.2、循环指令
JCXZ label |
jcxz notfound |
6,5 |
JECXZ label |
jecxz notfound |
6,5 |
9、转移指令
9.1、无条件转移指令
指令的语法 |
举例 |
周期数 |
JMP label |
jmp NEAR PTR distant |
1 |
jmp distant |
3 |
|
JMP reg16 |
jmp ax |
2 |
JMP mem16 |
jmp table[di] |
2 |
JMP reg32 |
jmp eax |
3 |
JMP mem32 |
jmp fpointer[si] |
2 |
JMP mem48 |
jmp FWORD PTR [di] |
4 |
9.2、条件转移指令
Jcondition label |
je next |
1 |
9.3、子程序调用指令
CALL label |
call upcase |
1 |
call distant |
4 |
|
CALL reg |
call ax |
2 |
CALL mem32 |
call [bx] |
2 |
CALL mem32 |
call dword ptr [bx] |
5 |
9.4、子程序返回指令
RETN |
retn |
2 |
RETN immed16 |
retn 8 |
3 |
RETF |
retf |
4, 23 |
RETF immed16 |
retf 32 |
4, 23 |
9.5、中断指令
INT immed8 |
int 25h |
16, pm=31, 48*(注) |
INT 3 |
int 3 |
13, pm=27, 44* |
INTO |
Into |
13, pm=27, 44* |
注:第一时间是同等优先级的中断时间,第二时间为高优先级的中断时间。
9.6、中断返回指令
IRET |
Iret |
8*(注),10, pm=27 |
IRETD |
Iretd |
10, pm=27 |
IRETF |
Iretf |
|
IRETDF |
Iretdf |
|
10、条件设置字节指令
SETcondition reg8 |
setc dh |
1 |
SETcondition mem8 |
setle flag |
2 |
11、字符串操作指令
11.1、取字符串数据指令
指令的语法 |
举例 |
周期数 |
LODS [segreg:]src |
lods es:source |
2 |
LODSB [[segreg:]src] |
Lodsb |
2 |
LODSW [[segreg:]src] |
Lodsw |
2 |
LODSD [[segreg:]src] |
Lodsd |
2 |
11.2、置字符串数据指令
STOS [ES:]dest |
stor es:dstring |
3 |
STOSB [[ES:]dest] |
stosb |
3 |
STOSW [[ES:]dest] |
stosw |
3 |
STOSD [[ES:]dest] |
stosd |
3 |
11.3、字符串传送指令
MOVS [es:]dest, [segreg:]src |
movs dest,es:source |
4 |
MOVSB [[es:]dest, [segreg:]src] |
movsb |
4 |
MOVSW [[es:]dest, [segreg:]src] |
movsw |
4 |
MOVSD [[es:]dest, [segreg:]src] |
movsd |
4 |
11.4、输入字符串指令
INS [ES:]dest, DX |
ins es:instr,dx |
9, pm=6,24*, vm=22 |
INSB |
Insb |
9, pm=6,24*, vm=22 |
INSW |
Insw |
9, pm=6,24*, vm=22 |
INSD |
Insd |
9, pm=6,24*, vm=22 |
11.5、输出字符串指令
OUTS DX,[segreg:]src |
outs dx,buffer |
13, pm=10,27, VM=24 |
OUTSB [DX,[segreg:]src] |
outsb |
13, pm=10,27, VM=24 |
OUTSW [DX,[segreg:]src] |
outsw |
13, pm=10,27, VM=24 |
OUTSD [DX,[segreg:]src] |
outsd |
13, pm=10,27, VM=24 |
11.6、字符串比较指令
CMPS [segreg:] src, [ES:]dest |
cmps source,es:dest |
5 |
CMPSB [[segreg:[src,] ES:] dest] |
cmpsb |
5 |
CMPSW [[segreg:[src,] ES:]dest] |
cmpsw |
5 |
CMPSD [[segreg:[src,] ES:] dest] |
cmpsd |
5 |
11.7、字符串扫描指令
SCAS [ES]:dest |
scas es:destin |
4 |
SCASB |
Scasb |
4 |
SCASW |
Scasw |
4 |
SCASD |
Scasd |
4 |
11.8、重复前缀指令
REP INS dest,DX |
rep ins dest,dx |
11+3n, pm=(8,25)+3n* |
REP MOVS dest,src |
rep movs dest,source |
6, 13n |
REP OUTS DX,src |
rep outs dx,source |
13+4n, pm=(10,27)+4n* |
REP LODS dest |
rep lods dest |
7, 7+3n |
REP STOS dest |
rep stos dest |
6, 9+3n |
注:当CPL≤IOPL时,执行时间是第一个时钟周期,否则是第二个时钟周期。
11.9、相等重复前缀指令
REPE CMPS src,dest |
repe cmps src,dest |
7, 9+4n |
REPE SCAS dest |
repe scas dest |
7, 9+4n |
11.10、不相等重复前缀指令
REPNE CMPS src,dest |
repne cmps src,dest |
7, 8+4n |
REPNE SCAS dest |
repne scas dest |
7, 9+4n |
12、ASCII-BCD码运算调整指令
指令的语法 |
举例 |
周期数 |
AAA |
aaa |
3 |
AAD |
aad |
10 |
AAM |
aam |
18 |
AAS |
aas |
3 |
DAA |
daa |
3 |
DAS |
das |
3 |
13、处理器指令
14、协处理器指令
指令的语法 |
举例 |
周期数 |
FBLD membcd | fbld packbck | 48-58 |
FBSTP membcd | fbstp bcds[bx] | 148-154 |
FLD reg | fld st(3) | 1 |
FLD mem32real | fld longreal | 1 |
FLD mem64real | 1 | |
FLD mem80real | 3 | |
FST reg | fst st | 1 |
FST memreal | fst longs[bx] | 2 |
FSTP reg | fstp st(3) | 1 |
FSTP mem32real | fstp longreal | 2 |
FSTP mem64real | 2 | |
FSTP mem80real | 3 | |
FXCH [reg] | fxchg st(3) | 1 |
FILD memint | fild quads[si] | 3, 1 |
FIST memint | fist doubles[8] | 6 |
FISTP memint | fistp longint | 6 |