版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Chapter3INSTRUCTIONSYSTEM3.1AddressingModes3.2InstructionFormandCode3.3InstructionSet3.4TroubleShootingTechniquesOBJECTIVES
Uponfinishingthischapter,youwilllearn:
Thewaysthatmicroprocessorslocatethedatawheretobestoredandhowtobebroughtbyaninstruction.
Instructioncodeshowtoencodeanddecodeby80x86.
3.1AddressingModes
Amicroprocessorinstructionisabinaryword.Whenitisreadasaninstruction,thisbinarywordtellsthemicroprocessortodoonesimpletask.Nootherbinarywordtellsthemicroprocessortodothistask.Mostmicroprocessorinstructionsletyoumoveorprocessdata.Thedatamaybeinmemory,oritmaybeinoneofthemicroprocessor’sregisters.Afewothermicroprocessorinstructionsletyoudo“housekeeping”functions.
Theseinstructionsletyoucontrolcertainmicroprocessorinstructions.1Aninstructioncanbebrokenintotwoparts,calledtheopcode(operationcode)andtheoperands.Theopcodetellsthemicroprocessorwhattodo,andtheoperandtellsitthecontentofthisdoingaction.Oftenyouwillfindthatthefirstwordofamultiwordinstructionistheopcode.Eitherthesecondwordorthesecondandthirdwordsareoperands.
Themicroprocessor’saddressingmodesarethewaythatthemicroprocessoridentifiesthelocationoftheoperandsordata.Whenthe8086executesaninstruction,itperformsthespecifiedfunctionindata.Thesedata,calledoperands,maybeonepartoftheinstruction,mayresideinoneoftheinternalregistersofthemicroprocessor,maybestoredatanaddressinmemory,ormaybeheldatanI/Oport.Aswewillsee,thenormalmicroprocessorhasmanydifferentwaysanditcanidentifydatainaparticularlocation.
Eachdifferentwaymaybeusedatadifferenttime,dependingonothercircumstances.2Toaccessthesedifferenttypesofoperands,the8086isprovidedwithvariousaddressingmodeswhicharecategorizedintothreetypes:registeroperandaddressing,immediateoperandaddressing,andmemoryoperandaddressing.Letusnowconsiderindetailtheaddressingmodesineachofthesecategories.3.1.1RegisterAddressing
Withtheregisteraddressingmode,theoperandtobeaccessedisspecifiedasresidinginaninternalregisterofthe8086.Table3.1liststheinternalregistersthatcanbeusedasasourceoradestinationoperand.Notethatonlythedataregisterscanbeaccessedaseitherabyteoraword.
Anexampleofaninstructionthatusesthisaddressingmodeis
MOVAX,BX
Thisstandsfor“moveorcopythecontentsofBX,whichisthesourceoperand,toAX,whichisthedestinationoperand.”Boththesourceanddestinationoperandshavebeenspecifiedasthewordcontentsofinternalregisterofthe8086.
Letusnowlookattheeffectofexecutingmoveinstructionintheregisteraddressingmove.InFigure3.1(a),weseethestateofthe8086justpriortofetchingtheinstruction.NotethatthelogicaladdressformedfromCSandIP(CS:IP)pointstothe“MOVAX,BX”instructionatphysicaladdress01000H.Thisinstructionisfetchedintothe8086’sinstructionqueue,whereitisheldwaitingtobeexecuted.
Priortoexecutionofthisinstruction,thecontentsofBXareABCDH,andthecontentsofAXrepresentadon’t-carestate.Theinstructionisreadfromtheoutputsideofthequeue,thendecoded,andexecuted.AsFigure3.1(b)shows,theresultproducedbyexecutingthisinstructionisthatthevalueABCDHiscopiedintoAX,andtheIP=IP+2pointsto01002H.Figure3.1(a)Registeraddressingmodeinstructionbeforefetchingandexecution;(b)Afterexecution
Single-byteinstructionsexecutefasterthananyotherinstructions.Themicroprocessormustcompletetheexecutionofaninstruction.Asingle-byteinstructionisexecutionofaninstruction,anditisexecutedintwomicroprocessorcycles.Thefetchingtakesonecycle,andtheexecutiontakestheothercycle.
Asyougoon,paycloseattentiontohowmanymicroprocessorcyclesareneededtocarryouttheinstructionsthatuseotheraddressingmodes.Youwillseethattheinstructionsusingtheinherentaddressingmodearethefastestinstructions.
3.1.2ImmediateAddressing
Immediateaddressingiseasytounderstand.Immediatelyfollowingtheopcodearethedata.Sotheinstructionwillbeencodedwithanimmediateoperand.Theremaybeeitheroneortwobytesofdata.Thesedataaresuppliedbytheprogrammer.Immediateaddressing,therefore,requiresnomemoryaddress.Theoperandisonepartoftheinstructioninsteadofthecontentsofaregisterormemorylocation,itrepresentswhatiscalledanimmediateoperand.
Sincethedataareencodeddirectlyintotheinstruction,immediateoperandsnormallyrepresentconstantdata.Immediateaddressingrequiresonlyanopcodeimmediatelyfollowedbythedatatobeoperatedon.Thisaddressingmodecanonlybeusedtospecifyasourceoperand.
Intheinstruction:
MOVAL,15H
Thesourceoperand15Hisanexampleofabyte-wideimmediatesourceoperand.Thedestinationoperand,whichisthecontentsofAL,usesregisteraddressing.Thus,thisinstructionemploysboththeimmediateandregistersaddressingmodes.
Figure3.2(a)and(b)illustratethefetchandexecutionofthisinstruction.Herewefindthattheimmediateoperand15Hisstoredinthecodesegmentofmemoryinthebytelocationimmediatelyfollowingtheopcodeoftheinstruction.Thisvalueisfetched,alongwiththeopcodeforMOV,intotheinstructionqueuewithinthe8086.Whenitperformsthemoveoperation,thesourceoperandisfetchedfromthequeue,notfromthememory,andnoexternalmemoryoperationsareperformed.Notethattheresultproducedbyexecutingthisinstructionisthattheimmediateoperand,whichequals15H,isloadedintothelower-bytepartoftheaccumulator(AL).Figure3.2(a)Immediateaddressingmodeinstructionbeforefetchandexecution;(b)Afterexecution
[ReadingMaterial]Whenisimmediateaddressinguseful?Agoodexampleisaprogramthatrequiresloadingtheaccumulatorwiththesame8-bitnumbereachtimetheprogramisrun.Intheinstruction’sfirstbyte,youputtheopcodethattellsthemicroprocessortoloaditsaccumulatorwiththecontentsofthebytethatimmediatelyfollowstheopcode.Inthatsecondbyte,youputthedatayouwantintotheaccumulator.
Theinstructionasisdescribedaboveiscalledtheregisterimmediateinstruction.Figure3.3showshowtheloadregisterimmediateinstructionappearswhenitisinmemory.Itshowsthe
opcodeintheinstruction’sfirstbyteandthedataintheinstruction’ssecondbyte.Ofcourse,boththeopcodeandthedatawillcontainbinaryinformationratherthanthenamesusedinFigure3.3.Figure.3.3Theloadregisterimmediateinstruction,wherethedataisinabytefollowingtheopcodebyte
Theimmediateaddressingmodeusestwomicroprocessorcycles.Duringthefirstcycle,theinstructionisfetched.Whentheinstructionisexecuted,thesecondbyte(thedata)isprocessedaccordingtowhatthefirstbyte(theopcode)tellsthemicroprocessor’slogictodo.
Inimmediateaddressing,thedatamustimmediatelyfollowtheinstructioninmemory.Thatis,thedataisactuallypartofthemicroprocessor’sinstruction.Butamicroprocessoroftenneedstouseinformationstoredatothermemorylocations.Insuchcasesimmediateaddressingwillnotworkinsuchcases,whichleadsustothenextformofaddressing.3.1.3MemoryAddressing
Toaccessanoperandinmemory,the8086/8088mustcalculatethephysicaladdressoftheoperandandtheninitiateareadorwriteoperationofthisstoragelocation.The8086/8088CPUisprovidedwithagroupofaddressingmodesknownasthememoryoperandaddressingmodesforthispurpose.LookingatFigure3.4,weseethatthephysicaladdressiscomputedfromasegmentbaseaddress(SBA)andaneffectiveaddress(EA).
SBAidentifiesthestartinglocationofthesegmentinmemory,andEArepresentstheoffsetoftheoperandfromthebeginningofthissegmentofmemory.EarlierweshowedhowSBAandEAarecombinedwithinthe8086/8088toformthelogicaladdressSBA:EAandhowtocomputethephysicaladdressfromthesetwovalues.
ThevalueoftheEAcanbespecifiedinavarietyofways.Onewayistoencodetheeffectiveaddressoftheoperanddirectlyintheinstruction.Thisrepresentsthesimplesttypeofmemoryaddressing,knownasthedirectaddressingmode.Figure3.4showsthataneffectiveaddresscanbemadeupfromasmanyasthreeelements:thebase,index,anddisplacement.Usingtheseelements,theeffectiveaddresscalculationismadebythegeneralformula
EA=Base+Index+Displacement
Figure3.4alsoidentifiestheregistersthatcanbeusedtoholdthevaluesofthesegmentbase,base,andindex.Forexample,3ittellsusthatanyofthefoursegmentregistercanbethesourceofthesegmentbaseforthephysicaladdresscalculationandthatthevalueofbasefortheeffectiveaddresscanbeineitherthebaseregister(BX)orbasepointregister(BP).Italsoidentifiesthesizespermittedforthedisplacement.Figure3.4Physicalandeffectiveaddresscomputationformemoryoperands
Notalltheseelementsarealwaysusedincalculatingtheeffectiveaddress.Infact,anumberofmemoryaddressingmodesaredefinedbyusingvariouscombinationsoftheseelementswhatwecanselectinFigure3.5.Theyarecalleddirectaddressing,registerindirectaddressing,basedaddressing,
indexedaddressing,
and
based-indexedaddressing.Forinstance,usingbasedaddressingmode,theeffectiveaddresscalculationincludesjustabase.Theseaddressingmodesprovidetheprogrammerwithdifferentwaysofcomputingtheeffectiveaddressofanoperandinmemory.Next,wewillexamineeachofthememoryoperandaddressingmodesindetail.
1.Directaddressing
Instructionsthatusedirectaddressingmayhave2or3bytes.Frequently,thesearereferredtoastwodifferentaddressingmodes.Thefirstbyteoftheseinstructionsistheopcode.Thesecondbyteand,ifpresent,thethirdbyteareamemoryaddress.Thememoryaddresspointstothememorylocationthatcontainsthedatatobeworkedon.Thesecondandthirdbytescanaddresstheentire65,536memorylocationsinan8-bitmicroprocessor.Ina16-bitmicroprocessor,thesecondandthirdwordsallowthemicroprocessortoaddressthefulladdressrangeof4Gbytes.
Directaddressingisinmanywaystheeasiestaddressingmodetounderstand.Ininherentaddressing,theaddressis“builtin”.Theprogrammerdoesnothavetoaddressamemorylocationtogetdata.Inimmediateaddressing,thedataisfoundinthebyteimmediatelyfollowingtheopcode.Again,theprogrammerdoesnothavetoaddressamemorylocationtogetthedata;thedataisbuiltintotheinstruction.Indirectaddressing,however,theprogrammeris,forthefirsttime,actuallygivingtheaddressofthememorylocationwheretheneededdataislocated.
AsFigure3.6shows,thiseffectiveaddressisuseddirectlyasthe16-bitoffsetofthestoragelocationoftheoperandfromthelocationspecifiedbythecurrentvalueintheselectedsegmentregisterinFigure3.5.ThedefaultsegmentisDS.Therefore,the20-bitphysicaladdressoftheoperandinmemoryisnormallyobtainedfromlogicaladdressDS:EA.But,byusingasegmentoverrideprefix(SOP)intheinstruction,anyofthefoursegmentregisterscanbereferenced.Figure3.5Specificationofadirectmemoryaddress
Anexampleofaninstructionthatusesdirectaddressingmodeforitssourceoperandis
MOVCX,[1234H]
Thisstandsfor“movethecontentsofthememorylocationwithoffset1234HinthecurrentdatasegmentintointernalregisterCX.”Theoffsetisencodedaspartoftheinstruction’smachinecode.
InFigure3.6(a),wefindthattheoffsetisstoredinthetwobytelocationsthatfollowtheinstruction’sopcode.Astheinstructionisexecuted,the8088combines1234Hwith0200Htogetthephysicaladdressofthesourceoperandasfollows:
PA=0200016+123416=0323416
Thenitreadsthewordofdatastartingatthisaddress,whichisBEEDH,andloadsitintotheCXregister.ThisresultisillustratedinFigure3.6(b).Figure3.6(a)Directaddressingmodeinstructionbeforefetchandexecution;(b)Afterexecution
Whenyouusedirectaddressing,youuseextramicroprocessorcycles.Inthemicroprocessorcycles,firstlythemicroprocessormustfetchtheinstruction’sopcode.Whentheinstructionisdecoded,themicroprocessorknowsthatitmustfetchanadditional2bytesofinformation.Thesebytesofdatamakeuptheaddressofthememorylocationwherethedataisstored.Eachadditionalfetchtakesonemoremicroprocessorcycle.
Oncetheopcodeandthe2addressbytesarefetched,themicroprocessorstillmustexecutetheinstruction.Thistakesafourthmicroprocessorcycle.
Fromthisyoucanseethatexecutinganinstructionwithdirectaddressingtakestwiceaslongasexecutinganinstructionwithimmediateaddressing.Ofcourse,directaddressingisnecessarywhenyouneedtoplacedataatanylocationinmemory.
[ReadingMaterial]Whenyouwriteprograms,youshoulduseasfewdirectaddressinginstructionsaspossiblebecausetheytakelongertoexecute.Thisisespeciallytruewhenyouarewritingspecificpartsofaprogramwhichmustoperateatveryhighspeeds.Frequentlywhenwritingthistypeofprogram,aprogrammerwillchangefromahigh-levellanguagetoanassembly-levellanguagetoensurethatuseoftime-consuminginstructions,suchasthedirectinstructions,islimited.
Asingledatawordinan8-bitmicroprocessorisnotlongenoughtoaddressa64Kwordmemorylocation.Inan8-bitwordusedinthesecondbyteoftheinstructioncanonlyaddress256memorylocations.Toovercomethis,aspecialopcodetellsyouthattheinstructionisaspecialformofdirectaddressinstructionwhichusesasingleaddressbyte.
Usually,thesesingle-byteaddressesstartatthe“bottom”ofmemory.Thatis,theystartataddresslocation0000H.Sometimesthissingle-byterangeofmemoryiscalledmemorypage0.Forexample,an8-bitmicroprocessorusingasinglebyteofaddressinformationmightaddressthefirst256memorylocations.Thesearememorylocations0to255(00H-FFH).Ontheotherhand,the2-byteaddresswordaddressesthefirst65,536(0000HtoFFFFH).
Whatistheadvantageofdirectaddressinglimitedtoone-wordaddresses?Theansweristhatitsavesmicroprocessorcycles.Itsavestime.Thiscanbeavaluableaddressingmodeforboth8-and16-bitmicroprocessorsiftherearefewbytesofdatathatmustbeaddressedfrequently.Thesefewbytesofdatacanbestoredinthefirst256bytesofmemoryinan8-bitmicroprocessor.Ofcourse,ina16-bitmicroprocessorthesesingle-addresswordinstructionscanaddressthefirst65,536memorylocations,andarethereforeveryuseful.
Howdoyoutellthetwoaddressingmodesapartifthemicroprocessorhasbothtwo-andthree-worddirectaddressinginstructions?Themanufacturergiveseachformofdirectaddressingadifferentname.Infact,manymicroprocessormanufacturerstreatthesetwoformsofdirectaddressingastwocompletelydifferentaddressingmodes.Theopcodesfortheseformsofaddressingarealsodifferent.Forexample,somemanufacturerscall2-bytedirectaddressingdirectaddressingofpage0addressingandrefertothe3-bytedirectaddressingasextendeddirectaddressing.
2. Registerindirectaddressing
Intheregisterindirectaddressingmode,theinstructioncontainstheopcodeandalsoindicateswhichregisterpointstothememorylocationcontainingtheneededdata.Thatis,theinstructiondoesnotcontainthedata,asinimmediateaddressing,ortheaddressofthedata,asindirectaddressing.Buttheinstructionindicateswhichregistercontainstheneededdata.Dependingonthesizeofthemicroprocessor’saddressspace,theregisterindirectaddressingmodemayindicatearegisterpairwhichpointstothecorrectmemoryaddress.
Registerindirectaddressingmodeissimilartothedirectaddressingwejustdescribedinbothofthem,whichmeansaneffectiveaddressiscombinedwiththecontentsofDStoobtainaphysicaladdress.However,theydifferinthewaythattheoffsetisspecified.Figure3.7showsthatthistimeEAresidesineitherabaseregisteroranindexregisterwithinthe8088.ThebaseregistercanbeeitherbaseregisterBXorbasepointerregisterBP,andtheindexregistercanbesourceindexregisterSIordestinationindexregisterDI.Useofasegmentoverrideprefixpermitsaccessofanothersegmentregister.Figure3.7Specificationofanindirectmemoryaddress
Anexampleis
MOVAX,[SI]
ExecutionofthisinstructionmovesthecontentsofthememorylocationthatisoffsetfromthebeginningofthecurrentdatasegmentbythevalueofEAinregisterSIintotheAXregister.
Forinstance,Figure3.8(a)and(b)showthatifSIcontains1234HandDScontains0200H,theresultafterexecutingtheinstructionisthatthecontentsofthememorylocationataddress
PA=0200016+123416=0323416
aremovedtotheAXregister.NoticeinFigure3.8(b)thatthisvalueisBEEDH.Inthisexample,thevalue1234HintheSIregistermusthavebeenloadedwithanotherinstructionpriortoexecutingthemoveinstruction.IfgiveMOVAX,ES:[SI],thenPA=120016+123416=1323416,AX=BAADHinsteadofBEEDH.Figure3.8(a)Instructionusingregisterindirectaddressingmodebeforefetchandexecution;(b)Afterexecution
Theresultproducedbyexecutingthisinstructionandthatfortheexampleforthedirectaddressingmodearethesame.However,theydifferinthewaytogeneratetheirphysicaladdress.ThedirectaddressingmethodlendsitselftoapplicationswherethevalueofEAisaconstant.Ontheotherhand,registerindirectaddressingcanbeusedwhenthevalueofEAiscalculatedandstored,forexample,inSIbyapreviousinstruction—thatis,EAisavariable.Forinstance,theinstructionsexecutedjustbeforeourexampleinstructioncouldhaveincrementedthevalueinSIbytwo.
[ReadingMaterial]Indirectaddressingisveryconvenientformovingdatatoandfromfrequentlyusedmemorylocations.Thisisespeciallytruewhenthedataisinlistorfileformat.Thatis,itisveryhelpfulwhenyouwanttostoreorreaddatainsequentialmemorylocations.
Aprogramthatfilesdatainsequentiallocations(onelocationafterthenext)isshowninFigure3.9.Thisprogramusesregisterindirectaddressing.ItinputsdatafromanI/Oporttotheaccumulator.Thedataisthenstoredinsequentialmemorylocations.Thisexamplemayuseinstructionsthatyoudonotyetfullyunderstand.Whatyouneedtoseehereishowtheindirectmemoryaddressingmodeisused.
Theprogramisshowninflowchartform.Intheflowcharts,eachnumberedboxshowstheprogramminglogicforoneinstruction.Followtheflowchartasyoureadthenumberedsteps.
Step①Thefirstinstructionestablishesthememorylocationwherethedatafilewillstart.Atthestartoftheprogram,youusealoadregisterimmediateinstructiontoloadtheregisterpairwiththefile’sstartingaddress.
Step②Wearenowreadytoloadtheaccumulator.ThesecondinstructioninputsdatafromtheI/Oportandplacesitintheaccumulator.TheinputinstructionbringsdatafromI/Oport01.
Step③Thisinstructionusesastoreinstructionwithanindirectaddress.Itstorestheaccumulator’sdatainthememorylocationpointedtobytheregisterpair.Note:Youdonotstorethedataintheregisterpair.Rather,thedataisstoredinthememorylocationpointedtobytheregisterpair.Youareusingregisterindirectaddressing.Oncethedataisstored,theprogramgetsanotherbyteofdataandstoresitinthenextmemorylocation.
Step④Tomaketheregisterpairpointtothenextmemorylocation,theregisterpairisincrementedbyonecount.
Step⑤Oncetheregisterpairisincremented,itpointstothememorylocationwherethenextbyteofdataistobestored.Youmaynowrepeattheinputandstoreinstructions.Ajumpinstructionreturnsyoutotheinputinstruction.Youjumpbacktotheinstructionthatfollowstheloadregisterpairimmediateinstruction.Youdothisbecauseyoudonotwanttoreloadtheregisterpair.Ifyouwentthroughtheloadprocess,youwoulddestroytheincrementedmemorypointerandkeeploadingdatainthesamememorylocation.Figure3.9Aprogramtoloaddataintosequentialmemorylocationsusingregisterindirectaddressing
3. Registerrelativeaddressing
LikeMOVAX,1234H[SI],relativeaddressingismuchlikeindexedaddressing,buttherearesomedifferences.First,theinstruction’soffsetisaddedtoadifferentregisterineachoftheseaddressingmodes.Inrelativeaddressing,theoffsetisrelativetotheprogramcounter’scurrentvalue.Second,relativeaddressingusuallyusesaspecialformofradixcomplementarithmetic.Theuseofthisspecialarithmeticmakespossiblebranchingforwardwhentheoffsethasalogic0inthemostsignificantbit.Thespecialarithmeticalsopermitsbranchingbackwardwhentheoffsethasalogic1inthemostsignificantbit.Theoffsetisthentreatedasaradixcomplementnumber.
[ReadingMaterial]Whydowesometimesuserelativeaddressinginsteadofindexedaddressing?Forsomemicroprocessors,relativeaddressingistheonlymodeprovideforsomeinstructions.Often,theconditionalbranchinstructionusesonlyrelativeaddressing.Furthermore,relativeaddressingpermitswritingposition-independentcode.Position-independentcodeisalsocalledrelocatableorrelativecode.
Theaddressingofprogrammingcodeiswrittenrelativetothedatainthemicroprocessor’sprogramcounter.Consequently,thesamecodecanbeusedatanymemorylocation.Figure3.10showsaflowchartforaroutinethatmaybecodedineitherabsoluteorrelativecode.Absolutecodemeansthatthecodemustbeusedatafixedsetofmemorylocations.Table3.2(a)showsabsolutecode,theTable3.2(b)showsrelativecode.Figure3.10Aflowchartofaprogramtotestaninputport’sstatusregister toseeifthedataavailableisset
Thissubroutineinputsdatafromastatusregister.TheANDimmediateinstructionmasksallbutthedataavailableflaginthestatusregister(statusregisterbit1).Ifthebitissettologic1,theaccumulatorwillnotbe0aftertheANDinstructionexecutes.Thismeansnojumptakesplace.ThenextinstructioninputsadatawordfromI/Oport01H.
Ifthestatusregisterbitisnotset,alltheaccumulatorbitsarelogic0.Ajumpoccurs.Hereiswherethetwoprogramsdiffer.TheprograminTable3.2(a)jumpsbacktomemorylocation0000H.However,theprograminTable3.2(b)usesrelativeaddressing.Itjumpsbacksixmemorylocationsformtheprogramcounter’scurrentvalue.Remember,theprogramcounterispointingtothein(next)instruction,whilethejumpinstructionisexecuting.
Thejumpinstructiontellsthemicroprocessortojumpbackbyasmanystepsastheradixcomplementofthenumberintheinstruction’ssecondbyte.Inthiscase,thebackwardjumpissixlocationsbecauseFAHistheradixcomplementof6.TheinstructionJZRFAreallyjustsays,“Subtract6fromthecontentsoftheprogramcounter.”Hereisthesubtraction:
Table3.3showstheprogramfromTable3.2(b).Here,theprogramstartsatmemorylocation01AEH.Noneoftheinstructionmnemonicsinthelistingnoranyoftheaddressesaredifferent.Jumpingbacksixlocationsrelativetotheprogramcounter,eventhoughtheprogramcounternowpointstomemorylocation01B4H,stilltakesyoubacktotheinputstatusregisterinstruction(nowatmemorylocation01AEH).
Asyouhaveseen,relativeaddressingfreestheprogrammerfromworryingaboutwheretheprogram’sabsoluteaddressis.Buttheprogrammermustbegoodathexadecimalarithmetictocomputetherelativeaddresses.Usinganassemblerrelievestheprogrammeroftheneedtocalculaterelativeaddresses.Theassemblerdoesallthecalculationsitself.
4. Basedindexedaddressing
Combiningthebasedaddressingmodeandtheindexedaddressingmoderesultsinanew,morepowerfulmodeknownasbased-indexedaddressingmode.Letusconsideranexampleofamoveinstructionusingthistypeofaddressing.
MOVAH,[BX][SI]
Notethatthesourceoperandisaccessedusingbased-indexedaddressingmode.Therefore,theeffectiveaddressofthesourceoperandisobtainedas
EA=(BX)+(SI)
AndthephysicaladdressoftheoperandiscomputedfromthecurrentsofDSandthecalculatedEA.
PA=DS:(BX)+(SI)
Figure3.11(a)and(b)presentanexampleofexecutingthisinstruction.Usingthecontentsofthevariousregistersintheexample,theaddressofthesourceoperandiscalculatedas
PA=0200016+100016+200016=0500016
ExecutionoftheinstructioncausesthevaluestoredatthislocationinmemorytobereadintoAH.Figure3.11(a) Instructionusingbased-indexedaddressingmodebeforefetchandexecution;(b) Afterexecution
4Thisaddressingmodecanbeusedtoaccesscomplexdatastructuressuchastwo-dimensionalarrays.Figure3.12(a)showshowitcanbeusedtoaccesselementsinanm×narrayofdata.Noticethatthedisplacement,whichisafixedvalue,locatesthearrayinmemory.Thebaseregisterspecifiesthemcoordinateofthearray,andtheindexregisteridentifiesthencoordinate.Simplychangingthevaluesinthebaseandindexregisterspermitsaccesstoanyelementinthearray.Figure3.12(b)showstheregisterpermittedinthebased-indexedphysicaladdresscomputation.Figure3.12(a)Based-indexedaddressingofatwo-dimensionalarrayofdata;
(b)Specificationofabased-indexedaddress
5. Relativebasedindexedaddressing
Thisaddressingmodecombinesallofthefeaturesoftheaddressingmodeswehavebeenexamining.Aswithalltheothers,itstillcanaccessmemorylocationsonlywithinone64KBsegment.Itdoes,however,givetheprogrammertheoptionofusing
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 【通化】2025年吉林通化市东昌区“人才专项”引进急需紧缺人才24人(2号)笔试历年典型考题及考点剖析附带答案详解
- 2026内蒙古呼和浩特市剑桥中学小学部教师招聘备考题库含答案详解(a卷)
- 2026江西某国企场馆讲解员招聘2人笔试历年参考题库附带答案详解
- 2026天津铁路建设投资控股(集团)有限公司招聘1人笔试历年参考题库附带答案详解
- 低钾血症诊治与管理专家共识总结2026
- 城乡教育发展不平衡问题对策研究新突破真题
- 某电子厂产品组装规范细则
- GBT3787-2025手持电动工具的管理使用检查和维修安全
- 麻纺生产流程标准化制度
- 班级管理工作周记及总结模板
- 2026春统编版语文 14《赵州桥》教学课件
- 北京市2025北京市体育科学研究所招聘7人笔试历年参考题库典型考点附带答案详解
- 县教育局2026年中小学生安全教育周活动总结
- 清明细雨-在追思中看清自己的方向-2025-2026学年高三下学期主题班会
- 2026年中考英语专题复习:完形填空 专项练习题汇编(含答案 解析)
- 2026年上海数据交易所“金准估”估值模型与大宗标准定价法应用
- 肌炎特异性抗体谱精准筛查
- 2026年成都辅警招聘笔试题库含答案
- 2026年教师资格认证教育心理学试题集及答案解析
- 《成人心律失常基层诊疗指南(2025版)》
- 2025年10月自考00292市政学试题及答案
评论
0/150
提交评论