DSP28335教程附录2寻址

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

AddressingModesCopyright©2009TexasInstruments.Allrightsreserved.TechnicalTrainingOrganizationTTOAppendixBTMS320C28x™MCUWorkshopLearningObjectivesExplain.sectand.usectassemblydirectivesExplainassemblyaddressingmodesUnderstandinstructionformatsDescribeoptionsforeachaddressingmode.defstartcount.set9;createanarrayxof10wordsx.usect“mydata”,10.sect“code”start:C28OBJ;operateinC28xmodeMOVACC,#1next:MOVLXAR1,#xMOVAR2,#countloop:MOV*XAR1++,ALBANZloop,AR2--bump:ADDACC,#1SBnext,UNC.refstart.sect“vectors”;makeresetvectoraddress'start'reset:.longstartLabelsandMnemonicsMnemonicsLinesofinstructionsUseupperorlowercaseBecomecomponentsofprogrammemoryLabelsOptionalforallassemblyinstructionsandmostassemblerdirectivesMustbeginincolumn1The“:”isnottreatedaspartofthelabelnameUsedaspointerstomemoryorinstructions.defstartcount.set9;createanarrayxof10wordsx.usect“mydata”,10.sect“code”start:C28OBJ;operateinC28xmodeMOVACC,#1next:MOVLXAR1,#xMOVAR2,#countloop:MOV*XAR1++,ALBANZloop,AR2--bump:ADDACC,#1SBnext,UNCAssemblyDirectives.refstart.sect“vectors”;makeresetvectoraddress'start'reset:.longstartDirectivesallowyouto:DefinealabelasglobalReservespaceinmemoryforun-initializedvariablesInitializedmemoryBeginwithaperiod(.)andarelowercaseUsedbythelinkertolocatecodeanddataintospecifiedsectionsinitializedsection.sect“name”usedforcodeorconstantsuninitializedsectionlabel.usect“name”,5usedforvariablesDirectivesAddressingModesModeSymbolPurposeRegisterOperatebetweenRegistersImmediate#ConstantsandInitializationDirect@General-purposeaccesstodataIndirect*Supportforpointers–accessarrays,lists,tables(register)(constant)(paged)(pointer)InstructionFormatsWhatisa“REG”?16-bitAccess=AR0throughAR7,AH,AL,PH,PL,TandSP32-bitAccess=XAR0throughXAR7,ACC,P,XTWhatisan“#imm”?animmediateconstantstoredintheinstructionWhatisa“mem”?AdirectlyorindirectlyaddressedoperandfromdatamemoryOr,oneoftheregistersfrom“REG”!loc16orloc32(for16-bitor32-bitdataaccess)INSTRREGNEGALINSTRREG,#immMOVACC,#1INSTRREG,memADDAL,@xINSTRmem,REGSUBAL,@AR0INSTRmem,#immMOV*XAR0++,#25INSTRdst,srcExampleRegisterAddressingAllowsforefficientregistertoregisteroperation16-bitand32-bitRegisterAddressmodesReducescodeoverhead,memoryaccesses,andmemoryoverheadAR0–AR7AHALPHPLTTLDPSP16-bitRegistersXAR0–XAR7ACCPXT32-bitRegistersRegisterAddressing–ExampleMOVLloc32,ACCMOVL@XT,ACCMOVloc16,Ax,CONDMOV@AR1,AL,GTMOVAx,loc16MOVAH,@ALUserGuide&Dis-assembleruse@forsecondregisterFormatInstructionFormatInstructionImmediateAddressing–“#”FixedvaluepartofprogrammemoryinstructionSupportsshort(8-bit)andlong(16-bit)immediateconstantsLongimmediatecanincludeashiftUsedtoinitializeregisters,andoperatewithconstantsOPCODE8-bitOPERANDonewordinstructionOPCODE16-bitOPERANDtwowordinstructionImmediateAddressing–ExampleLongImmediate,2Words(AND)loc16#16BitANDANDloc16,#16BitAx#16Bitloc16ANDANDAx,loc16,#16BitACC#16BitshiftANDANDACC,#16Bit,0-16ShortImmediate,1Word(ANDB)ANDautomaticallyreplacedbyANDBifIMMvalueis8bitsorlessANDBANDBAx,#8BitAx#8BitDirectAddressing–“@”Datamemoryspacedividedinto65,536pageswith64wordsoneachpageDatapagepointer(DP)usedtoselectactivepage16-bitDPisconcatenatedwitha6-bitoffsetfromtheinstructiontogenerateanabsolute22-bitaddressAccessdataonagivenpageinanyorder0000000000000000000000Page0:000000–00003F00000000000000001111110000000000000001000000Page1:000040–00007F00000000000000011111110000000000000010000000Page2:000080–0000BF00000000000000101111111111111111111111000000Page65,535:3FFFC0–3FFFFF1111111111111111111111OffsetDataPageDataMemoryDirectAddressing–ExampleZ=X+Yx.usect“samp”,3.sect“code”MOVAL,@xMOVWDP,#xADDAL,@yMOV@z,ALDataMemoryaddressdata0001C00001……x:0001FD1000y:0001FE0500z:0001FF64Page7[00]...Page7[3D]Page7[3E]Page7[3F]1500variations:MOVWDP,#imm;2W,16-bit(4Meg)MOVZDP,#imm;1W,10-bit(64K)MOVDP,#imm;DP(15:10)unchanged0000000000000001111111110001FFDPoffset0000150000001000AccumulatorDP=0007--------MOVAL,@xADDAL,@yMOV@z,ALDirectAddressing–CaveatsZ=X+Yx.usect“samp”,3.sect“code”ADDAL,@yMOV@z,ALDataMemoryaddressdata0001C00001……x:0001FF1000y:0002000500……Page7[00]...Page7[3F]Page8[00]MOVWDP,#x000010010007000010000007AccumulatorDP=0007--------0007MOVAL,@x000000000000000111111111DPoffset000000000000001000000000expecting1500Solution:GroupandblockvariablesinASMfile:x.usect“samp”,3,1;Forcealllocationstosamedatay.setx+1;page(1sthole,elselinkererror)z.setx+2;Assignvarswithinblock(XandYnotonthesamepage)IndirectAddressing–“*”AuxiliaryRegisters(XARn)usedtoaccessfulldatamemoryspaceAddressRegisterArithmeticUnit(ARAU)usedtomodifytheXARnAccessdatafromarraysanywhereindatamemoryinanorderlyfashionDataMemoryXAR0XAR1XAR2XAR3XAR4XAR5XAR6XAR7ARAUIndirectAddressingModesAuto-increment/decrement:*XARn++,*--XARnPost-incrementorPre-decrementOffset:*+XARn[AR0orAR1],*+XARn[3bit]Offsetby16-bitAR0orAR1,or3-bitconstantStackRelative:*-SP[6bit]Indexby6-bitoffset(optimalforC)ImmediateDirect:*(0:16bit)Accesslow64KCircular:*AR6%++AR1(7:0)isbuffersizeXAR6iscurrentaddressIndirectAddressing–Examp

1 / 24
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功