汇编指令机器执行周期.docx
《汇编指令机器执行周期.docx》由会员分享,可在线阅读,更多相关《汇编指令机器执行周期.docx(36页珍藏版)》请在冰点文库上搜索。
汇编指令机器执行周期
80x86IntegerInstructionSet(8088-Pentium)
ClickFPUopcodesforfloatingpointinstructions
Jumptoendoflegend
Legend:
General
acc=AL,AXorEAXunlessspecifiedotherwise
reg=anygeneralregister
r8=any8-bitregister
r16=anygeneralpurpose16-bitregister
r32=anygeneralpurpose32-bitregister
imm=immediatedata
imm8=8-bitimmediatedata
imm16=16-bitimmediatedata
mem=memoryaddress
mem8=addressof8-bitdataitem
mem16=addressof16-bitdataitem
mem32=addressof32-bitdataitem
mem48=addressof48-bitdataitem
dest=16/32-bitdestination
short=8-bitdestination
Integerinstructiontimings:
n-generallyreferstoanumberofrepeatedcounts
m-inajumporcall;
286:
bytesinnextinstruction
386/486:
numberofcomponents
(eachbyteofopcode)+1(ifimmeddata)+1(ifdisplacement)
EA=cyclestocalculatetheEffectiveAddress
8088/8086:
base=5BP+DIorBX+SI=7BP+DI+disporBX+SI+disp=11
index=5BX+DIorBP+SI=8BX+DI+disporBP+SI+disp=12
disp=6segmentoverride=+2
286-486:
base+index+disp=+1allothers,nopenalty
instructionlength:
Thebytecountincludestheopcodelengthandlengthofanyrequired
displacementorimmediatedata.Ifthedisplacementisoptional,it
isshownasd()withthepossiblelengthsinparentheses.Ifthe
immediatedataisoptional,itisshownasi()withthepossible
lengthsinparentheses.
pairingcategoriesforPentium:
NP=notpairable
UV=pairableintheUpipeorVpipe
PU=pairableintheUpipeonly
PV=pairableintheVpipeonly
(endoflegend)
Instructionformats,clockcyclesandPentium®Pairinginfo
AAAASCIIadjustafteraddition
bytes8088186286386486Pentium
1883433NP
Example:
aaa
AADASCIIadjustAXbeforedivision(secondbyteisdivisor)
bytes8088186286386486Pentium
2601514191410NP
Example:
aad
AAMASCIIadjustAXaftermultiply(secondbyteisdivisor)
bytes8088186286386486Pentium
2831916171518NP
Example:
aam
AASASCIIadjustALaftersubtraction
bytes8088186286386486Pentium
1873433NP
Example:
aas
ADCIntegeraddwithcarry
operandsbytes8088186286386486Pentium
reg,reg2332211PU
mem,reg2+d(0,2)24+EA107733PU
reg,mem2+d(0,2)13+EA107622PU
reg,imm2+i(1,2)443211PU
mem,imm2+d(0,2)23+EA167733PU*
+i(1,2)
acc,imm1+i(1,2)443211PU
*=notpairableifthereisadisplacementandimmediate
Example:
adceax,ebx
ADDIntegeraddition
operandsbytes8088186286386486Pentium
reg,reg2332211UV
mem,reg2+d(0,2)24+EA107733UV
reg,mem2+d(0,2)13+EA107622UV
reg,imm2+i(1,2)443211UV
mem,imm2+d(0,2)23+EA167733UV*
+i(1,2)
acc,imm1+i(1,2)443211UV
*=notpairableifthereisadisplacementandimmediate
Example:
addeax,ebx
ANDLogicalAND
operandsbytes8088186286386486Pentium
reg,reg2332211UV
mem,reg2+d(0,2)24+EA107733UV
reg,mem2+d(0,2)13+EA107622UV
reg,imm2+i(1,2)443211UV
mem,imm2+d(0,2)23+EA167733UV*
+i(1,2)
acc,imm1+i(1,2)443211UV
*=notpairableifthereisadisplacementandimmediate
Example:
andeax,ebx
ARPLAdjustRPLfieldofselector(286+)
operandsbytes286386486Pentium
reg,reg2102097NP
mem,reg2+d(0-2)112197NP
Example:
arplax,bx
BOUNDCheckarrayindexagainstbounds(186+)
operandsbytes186286386486Pentium
reg,mem435131078NP
Example:
boundbx,array
BSFBitscanforward(386+)
operandsbytes386486Pentium
r16,r16310+3n6-426-34NP
r32,r32310+3n6-426-42NP
r16,m163+d(0,1,2)10+3n7-436-35NP
r32,m323+d(0,1,2,4)10+3n7-436-43NP
Example:
bsfeax,[esi]
BSRBitscanreverse(386+)
operandsbytes386486Pentium
r16,r16310+3n6-1037-39NP
r32,r32310+3n7-1047-71NP
r16,m163+d(0,1,2)10+3n6-1037-40NP
r32,m323+d(0,1,2,4)10+3n7-1047-72NP
Example:
bsreax,[esi]
BSWAPByteswap(486+)
operandbytes486Pentium
r32211NP
Example:
bswapeax
BTBittest(386+)
operandsbytes386486Pentium
reg,reg3334NP
mem,reg3+d(0,1,2,4)1289NP
reg,imm83+i
(1)334NP
mem,imm83+d(0,1,2,4)+i
(1)634NP
Example:
bteax,4
BTCBittestandcomplement(386+)
operandsbytes386486Pentium
reg,reg3667NP
mem,reg3+d(0,1,2,4)131313NP
reg,imm83+i
(1)667NP
mem,imm83+d(0,1,2,4)+i
(1)888NP
Example:
btceax,4
BTRBittestandreset(386+)
operandsbytes386486Pentium
reg,reg3667NP
mem,reg3+d(0,1,2,4)131313NP
reg,imm83+i
(1)667NP
mem,imm83+d(0,1,2,4)+i
(1)888NP
Example:
btreax,4
BTSBittestandset(386+)
operandsbytes386486Pentium
reg,reg3667NP
mem,reg3+d(0,1,2,4)131313NP
reg,imm83+i
(1)667NP
mem,imm83+d(0,1,2,4)+i
(1)888NP
Example:
btseax,4
CALLCallsubroutine
operandbytes8088186286386486Pentium
near323147+m7+m31PV
reg220137+m7+m52NP
mem162+d(0-2)29+EA1911+m10+m52NP
far5362313+m17+m184NP
mem322+d(0-2)53+EA3816+m22+m174NP
ProtectedMode
operandbytes286386486Pentium
far526+m34+m204-13NP
mem322+d(0-2)29+m38+m205-14NP
cyclesnotshownforcallsthroughcallandtaskgates
Example:
callmy_function
CBWConvertbytetoword(AL-->AX)
bytes8088186286386486Pentium
1222333NP
Example:
cbw
CWDEConvertwordtodword(386+)(AX-->EAX)
bytes386486Pentium
1333NP
Example:
cwde
CWDConvertwordtodouble(AX-->DX:
AX)
bytes8088186286386486Pentium
1542232NP
Example:
cwd
CDQConvertdoubletoquad(EAX-->EDX:
EAX)
bytes386486Pentium
1232NP
Example:
cdq
CLCClearthecarryflag
bytes8088186286386486Pentium
1222222NP
Example:
clc
CLDClearthedirectionflag(settoforwarddirection)
bytes8088186286386486Pentium
1222222NP
Example:
cld
CLICleartheinterruptflag(disableinterrupts)
bytes8088186286386486Pentium
1223357NP
Example:
cli
CLTSCleartaskswitchedflaginCR0(286+)
bytes286386486Pentium
225710NP
Example:
clts
CMCComplementcarryflag
bytes8088186286386486Pentium
1222222NP
Example:
cmc
CMPComparetwooperands
operandsbytes8088186286386486Pentium
reg,reg2332211UV
mem,reg2+d(0,2)13+EA107522UV
reg,mem2+d(0,2)13+EA106622UV
reg,imm2+i(1,2)443211UV
mem,imm2+d(0,2)14+EA106522UV*
+i(1,2)
acc,imm1+i(1,2)443211UV
*=notpairableifthereisadisplacementandimmediate
Example:
cmpeax,3
CMPS/CMPSB/CMPSW/CMPSDComparestringoperands
variationsbytes8088186286386486Pentium
cmpsb1302281085NP
cmpsw1---1085NP
cmpsd1---1085NP
repXcmpsb29+30n5+22n5+9n5+9n7+7n*9+4nNP
repXcmpsw29+30n5+22n5+9n5+9n7+7n*9+4nNP
repXcmpsd2---5+9n7+7n*9+4nNP
repX=repe,repz,repneorrepnz
*:
5ifn=0
Example:
repnecmpsb
CMPXCHGCompareandExchange(486+)
operandsbytes486Pentium
reg,reg365NP
mem,reg3+d(0-2)7-106NP
Example:
cmpxchgebx,edx
CMPXCHG8BCompareandExchange8bytes(Pentium+)
operandsbytesPentium
mem,reg3+d(0-2)10NP
Example:
cmpxchg8b[ebx],edx
CPUIDCPUidentification(Pentium+)
bytesPentium
214NP
Example:
cpuid
DAADecimaladjustALafteraddition
bytes8088186286386486Pentium
1443423NP
Example:
daa
DASDecimaladjustALaftersubtraction
bytes8088186286386486Pentium
1443423NP
Example:
das
DECDecrement
operandbytes8088186286386486Pentium
r82332211UV
r161332211UV
r321332211UV
mem2+d(0,2)23+EA157633UV
Example:
deceax
DIVUnsigneddivide
operandbytes8088186286386486Pentium
r8280-902914141617NP
r162144-1623822222425NP
r322---384041NP
mem82+d(0-2)86-96+EA3517171617NP
mem162+d(0-2)150-168+EA4425252425NP
mem322+d(0-2)---414041NP
impliedoperandquotientremainder
dividend
AX/byte=ALAH
DX:
AX/word=AXDX
EDX:
EAX/dword=EAXEDX
Example:
divebx
ENTERMakestackframeforprocedureparameters(186+)
operandsbytes8088186286386486Pentium
imm16,03-1511101411NP
imm16,14-2515121715NP
imm16,imm84-22+16n12+4n15+4n17+3i15+2iNP
n=imm8-1;i=imm8
Example:
enter1,0
ESCEscape
escapeopcodesD8-DFareusedbyfloatingpointinstructions
HLTHalt
bytes8088186286386486Pentium
1222544NP
Example:
hlt
IDIVSigneddivide
operandbytes8088186286386486Pentium
r82101-11244-5217191922NP
r162165-18453-6125272730NP
r322---434346NP
mem82+d(0-2)107-118+EA50-5820222022NP
mem162+d(0-2)171-190+EA59-6728302830NP
mem322+d(0-2)---464446NP
impliedoperandquotientremainder
dividend
AX/byte=ALAH
DX:
AX/word=AXDX
EDX:
EAX/dword=EAXEDX
Example:
idivebx
IMULSignedmultiply
AccumulatorMultiplies
operandbytes8088186286386486Pentium
r8280-9825-28139-1413-1811NP
r162128-15434-37219-2213-2611NP
r322---9-3813-4210NP
mem82+d(0-2)86-104+EA32-341612-1713-1811NP
mem162+d(0-2)134-160+EA40-432412-2513-2611NP
mem322+d(0-2)---12-4113-4210NP
impliedoperandresult
multiplicand(multiplier)
AL*byte=AX
AX*word=DX:
AX
EAX*dword=EDX:
EAX
Example:
imulebx
2and3operandMultiplies
operandsbytes186286386486Pentium
r16,imm2+i(1,2)-219-14/9-2213-18/13-2610NP
r32,imm2+i(1,2)--9-3813-4210NP