资源描述:
《chapter 12 c and assembly interface》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、DSPC5000Chapter12CandAssemblyInterfaceCopyright©2003TexasInstruments.Allrightsreserved.UsingCandassemblyC54xC55xObjectives–C54UnderstandtheCEnvironmentRunthecompilerDescribehowtoMixCandAssemblyLanguageCRun-timeEnvironmentFunc.Cintfunc(inta,intb,intc,intd,inte){return(a+b+c+d+e);}Main.Cintfunc(int,
2、int,int,int,int);inty=0;voidmain(void){y=func(1,2,3,4,5);}Whatothersectionsgetcreated?...y(global).bss0(initval).cinitcode.textCsections.text:codeProgramROM.cinit:globalinitsProgramROM.bss:variablesDataRAM.stack:forSPDataRAMvectorsvectorsProgramROM(0xFF80).constconstintx=25;DataROM.switchforcasest
3、mtsProgramROM.sysmemheap,dynamicmemDataRAMSectionNameUsedforTypeofMemoryCCSCompile&LinkProcessfile1.cfile.objfile.mapfile.asmRun-timeLibrary(rts.lib)CompilerAssemblerfile.outVLDebug:SymbolicDebug,Level1OptimizationFullopt:Level3Optimizationfile2.asmLnk.rcpOptimizerInitializingtheCEnvironment...Boo
4、t.cinrts.lib_c_int00:InitializeglobalandstaticvariablesInitializeCenvironmentvariablesSetupstack(SP)Call_mainAllsymbolsaccessedbyCrequireanunderscoreOnreset,howdoyoutelltheCPUtobeginexecutionat_c_int00?;cvectors.asmrsv:B_c_int00.sect“vectors”.ref_c_int00Run-timeEnvironmentARPAuxiliaryRegPtr0YesASM
5、ACCshiftmodeYesBRAFBlockRptActiveFlagNoCCarrybitYesC16Dual16-bitmath0NoCMPTCompatibilitymode0NoCPLCompilermode1NoFRCTFractionalmode0NoOVA/BACCOverflowflagsYesOVMOverflowmode0*SXMSign-extensionmodeYesSMULSaturate/multiply*TCTestControlflagYesPresumedModifiedSTxBitsNameValuebyC?Iftheusermodifiesa“pr
6、esumedvalue”,thisvaluemustberestoredbythefunction*-forintrinsicsonlyWritingFunc.ASMFunc.Cintfunc(inta,intb,intc){return(a+b+c);}Main.Cintfunc(int,int,int);inty=0;voidmain(void){y=func(1,2,3);}Main.C:-prototypescalledfunction-callsfunctionHowaretheparameterspassedtofunc()?ParameterPassinguseduse
7、dSaveonentry(SOE)-childmustsaveifusedAR0AR1AR2AR3AR4AR5AR6AR7PCarg2=2arg3=3SPABarg1,retvaluey=func(1,2,3);ReturnvalueplacedinAaccumulatorArgument1ispassedinAaccumulatorArguments2,3…passedinreverseorderviastackPC