MicroBlazeEmbeddedTools Reference

TR0129Dec01,2009 Software,hardware,documentationandrelatedmaterials:

CopyrightE2008AltiumLimited.AllRightsReserved.

Thematerialprovidedwiththisnoticeissubjecttovariousformsofnationalandinternationalintellectualpropertyprotection,includingbutnot limitedtocopyrightprotection.Youhavebeengrantedanon−exclusivelicensetousesuchmaterialforthepurposesstatedintheend−user licenseagreementgoverningitsuse.Innoeventshallyoureverseengineer,decompile,duplicate,distribute,createderivativeworksfromorin anywayexploitthemateriallicensedtoyouexceptasexpresslypermittedbythegoverningagreement.Failuretoabidebysuchrestrictionsmay resultinseverecivilandcriminalpenalties,includingbutnotlimitedtofinesandimprisonment.Provided,however,thatyouarepermittedto makeonearchivalcopyofsaidmaterialsforbackuppurposesonly,whicharchivalcopymaybeaccessedandusedonlyintheeventthatthe originalcopyofthematerialsisinoperable.Altium,AltiumDesigner,BoardInsight,DXP,InnovationStation,LiveDesign,NanoBoard,NanoTalk, OpenBus,P−CAD,SimCode,Situs,TASKING,andTopologicalAutoroutingandtheirrespectivelogosaretrademarksorregisteredtrademarks ofAltiumLimitedoritssubsidiaries.Allotherregisteredorunregisteredtrademarksreferencedhereinarethepropertyoftheirrespectiveowners andnotrademarkrightstothesameareclaimed.v8.031/3/08 TableofContents

TableofContents

CLanguage 1−1 1.1 Introduction ...................................................................... 1−1 1.2 DataTypes ...................................................................... 1−2 1.2.1 ChangingtheAlignment:__unaligned,__packed__and__align()....................... 1−2 1.3 MemoryQualifiers ................................................................ 1−3 1.3.1 PlacinganObjectatanAbsoluteAddress:__at()..................................... 1−4 1.4 UsingAssemblyintheSource:__asm()........................................... 1−5 1.5 PragmastoControltheCompiler................................................... 1−8 1.6 PredefinedPreprocessorMacros................................................... 1−12 1.7 Strings .......................................................................... 1−13 1.8 SwitchStatement ................................................................. 1−13 1.9 Functions ........................................................................ 1−14 1.9.1 ParameterPassing ...............................................................1−14 1.9.2 FunctionReturnTypes............................................................ 1−14 1.9.3 InliningFunctions:inline/__noinline................................................ 1−15 1.9.4 IntrinsicFunctions ................................................................ 1−16 1.9.5 InterruptFunctions ................................................................ 1−18 1.9.5.1 DefininganInterruptServiceRoutine:__interrupt().................................... 1−18 1.9.5.2 InterruptFrame:__frame()......................................................... 1−19 1.9.6 SoftwareBreak:__system......................................................... 1−19 1.10 Libraries ......................................................................... 1−19 1.10.1 PrintfandScanfRoutines.......................................................... 1−20

C++Language 2−1 2.1 Introduction ...................................................................... 2−1 2.2 C++LanguageExtensionKeywords................................................. 2−1 2.3 C++DialectAccepted .............................................................2−1 2.3.1 StandardLanguageFeaturesAccepted.............................................. 2−1 2.3.2 C++0xLanguageFeaturesAccepted................................................ 2−3 2.3.3 AnachronismsAccepted........................................................... 2−4 2.3.4 ExtensionsAcceptedinNormalC++Mode........................................... 2−4 2.4 GNUExtensions .................................................................. 2−5 2.5 NamespaceSupport ..............................................................2−13 2.6 TemplateInstantiation .............................................................2−14 2.6.1 AutomaticInstantiation............................................................ 2−14 2.6.2 InstantiationModes ...............................................................2−15 2.6.3 Instantiation#pragmaDirectives.................................................... 2−16 2.6.4 ImplicitInclusion .................................................................. 2−17 2.6.5 ExportedTemplates ...............................................................2−18 2.6.5.1 FindingtheExportedTemplateDefinition............................................. 2−18 2.6.5.2 SecondaryTranslationUnits....................................................... 2−19 2.6.5.3 LibrarieswithExportedTemplates.................................................. 2−19 2.7 InliningFunctions ................................................................. 2−20 2.8 ExternInlineFunctions............................................................ 2−20 2.9 PragmastoControltheC++Compiler............................................... 2−21 2.10 PredefinedMacros ................................................................ 2−22 2.11 PrecompiledHeaders .............................................................2−24 2.11.1 AutomaticPrecompiledHeaderProcessing.......................................... 2−24 2.11.2 ManualPrecompiledHeaderProcessing............................................. 2−26 2.11.3 OtherWaystoControlPrecompiledHeaders......................................... 2−26 2.11.4 PerformanceIssues ...............................................................2−26

iii MicroBlazeEmbeddedToolsReference

Libraries 3−1 3.1 Introduction ...................................................................... 3−1 3.2 LibraryFunctions ................................................................. 3−3 3.2.1 assert.h ......................................................................... 3−3 3.2.2 complex.h ....................................................................... 3−3 3.2.3 ctype.handwctype.h ..............................................................3−3 3.2.4 errno.h .......................................................................... 3−4 3.2.5 fcntl.h ........................................................................... 3−4 3.2.6 fenv.h ........................................................................... 3−5 3.2.7 float.h ........................................................................... 3−5 3.2.8 fss.h ............................................................................ 3−5 3.2.9 inttypes.handstdint.h .............................................................3−6 3.2.10 io.h ............................................................................. 3−6 3.2.11 iso646.h ......................................................................... 3−6 3.2.12 limits.h .......................................................................... 3−7 3.2.13 locale.h ......................................................................... 3−7 3.2.14 malloc.h ......................................................................... 3−7 3.2.15 math.handtgmath.h ..............................................................3−7 3.2.16 setjmp.h ......................................................................... 3−11 3.2.17 signal.h ......................................................................... 3−11 3.2.18 stdarg.h ......................................................................... 3−11 3.2.19 stdbool.h ........................................................................ 3−11 3.2.20 stddef.h ......................................................................... 3−12 3.2.21 stdint.h .......................................................................... 3−12 3.2.22 stdio.handwchar.h ...............................................................3−12 3.2.23 stdlib.handwchar.h ...............................................................3−17 3.2.24 string.handwchar.h ..............................................................3−19 3.2.25 time.handwchar.h ................................................................ 3−21 3.2.26 unistd.h ......................................................................... 3−22 3.2.27 wchar.h ......................................................................... 3−23 3.2.28 wctype.h ........................................................................ 3−24

AssemblyLanguage 4−1 4.1 AssemblySyntax ................................................................. 4−1 4.2 AssemblerSignificantCharacters................................................... 4−2 4.3 OperandsofanAssemblyInstruction................................................ 4−2 4.4 SymbolNames ................................................................... 4−2 4.4.1 PredefinedPreprocessorSymbols.................................................. 4−3 4.5 Registers ........................................................................ 4−3 4.6 AssemblyExpressions ............................................................4−3 4.6.1 NumericConstants ...............................................................4−4 4.6.2 Strings .......................................................................... 4−4 4.6.3 ExpressionOperators .............................................................4−5 4.7 Built−inAssemblyFunctions....................................................... 4−5 4.7.1 OverviewofBuilt−inAssemblyFunctions............................................ 4−6 4.7.2 DetailedDescriptionofBuilt−inAssemblyFunctions................................... 4−6 4.8 AssemblerDirectives ..............................................................4−8 4.8.1 OverviewofAssemblerDirectives................................................... 4−8 4.8.2 DetailedDescriptionofAssemblerDirectives......................................... 4−10 4.9 MacroOperations ................................................................ 4−45 4.9.1 DefiningaMacro ................................................................. 4−45 4.9.2 CallingaMacro .................................................................. 4−45 4.9.3 UsingOperatorsforMacroArguments............................................... 4−46 4.9.4 Usingthe.FORand.REPEATDirectivesasMacros................................... 4−48 4.9.5 ConditionalAssembly .............................................................4−48 4.10 GenericInstructions ...............................................................4−50

iv TableofContents

ToolOptions 5−1 5.1 CCompilerOptions ...............................................................5−1 5.2 C++CompilerOptions .............................................................5−59 5.3 AssemblerOptions ...............................................................5−160 5.4 LinkerOptions ................................................................... 5−190 5.5 ControlProgramOptions.......................................................... 5−230 5.6 MakeUtilityOptions ...............................................................5−277 5.7 LibrarianOptions ................................................................. 5−303

ListFileFormats 6−1 6.1 AssemblerListFileFormat......................................................... 6−1 6.2 LinkerMapFileFormat ............................................................6−3

ObjectFileFormats 7−1 7.1 ELF/DWARFObjectFormat........................................................ 7−1 7.2 MotorolaS−RecordFormat........................................................ 7−2 7.3 IntelHexRecordFormat........................................................... 7−5

LinkerScriptLanguage 8−1 8.1 Introduction ...................................................................... 8−1 8.2 StructureofaLinkerScriptFile..................................................... 8−1 8.3 SyntaxoftheLinkerScriptLanguage................................................ 8−3 8.3.1 Preprocessing .................................................................... 8−3 8.3.2 LexicalSyntax ................................................................... 8−3 8.3.3 Identifiers ........................................................................ 8−4 8.3.4 Expressions ..................................................................... 8−4 8.3.5 Built−inFunctions ................................................................. 8−5 8.3.6 LSLDefinitionsintheLinkerScriptFile.............................................. 8−6 8.3.7 MemoryandBusDefinitions....................................................... 8−6 8.3.8 ArchitectureDefinition .............................................................8−7 8.3.9 DerivativeDefinition ...............................................................8−9 8.3.10 ProcessorDefinitionandBoardSpecification......................................... 8−10 8.3.11 SectionLayoutDefinitionandSectionSetup.......................................... 8−10 8.4 ExpressionEvaluation .............................................................8−13 8.5 SemanticsoftheArchitectureDefinition.............................................. 8−14 8.5.1 DefininganArchitecture........................................................... 8−15 8.5.2 DefiningInternalBuses............................................................ 8−15 8.5.3 DefiningAddressSpaces.......................................................... 8−15 8.5.4 Mappings ........................................................................ 8−18 8.6 SemanticsoftheDerivativeDefinition............................................... 8−20 8.6.1 DefiningaDerivative ..............................................................8−20 8.6.2 InstantiatingCoreArchitectures..................................................... 8−20 8.6.3 DefiningInternalMemoryandBuses................................................ 8−21 8.7 SemanticsoftheBoardSpecification................................................ 8−22 8.7.1 DefiningaProcessor ..............................................................8−22 8.7.2 InstantiatingDerivatives........................................................... 8−22 8.7.3 DefiningExternalMemoryandBuses................................................ 8−23 8.8 SemanticsoftheSectionSetupDefinition............................................ 8−24 8.8.1 SettingupaSection ...............................................................8−24 8.9 SemanticsoftheSectionLayoutDefinition........................................... 8−25 8.9.1 DefiningaSectionLayout.......................................................... 8−25 8.9.2 CreatingandLocatingGroupsofSections........................................... 8−26 8.9.3 CreatingorModifyingSpecialSections.............................................. 8−30 8.9.4 CreatingSymbols ................................................................. 8−32 8.9.5 ConditionalGroupStatements...................................................... 8−33

v MicroBlazeEmbeddedToolsReference

CERTCSecureCodingStandard 9−1 9.1 Preprocessor(PRE) ..............................................................9−1 9.2 DeclarationsandInitialization(DCL)................................................. 9−2 9.3 Expressions(EXP) ................................................................ 9−2 9.4 Integers(INT) .................................................................... 9−3 9.5 FloatingPoint(FLP) ...............................................................9−3 9.6 Arrays(ARR) .................................................................... 9−3 9.7 CharactersandStrings(STR)...................................................... 9−4 9.8 MemoryManagement(MEM)...................................................... 9−4 9.9 Environment(ENV) ...............................................................9−4 9.10 Signals(SIG) .................................................................... 9−5 9.11 Miscellaneous(MSC) .............................................................9−5

MISRA−CRules 10−1 10.1 MISRA−C:1998 .................................................................. 10−1 10.2 MISRA−C:2004 .................................................................. 10−5

Index

vi ManualPurposeandStructure

ManualPurposeandStructure

WindowsUsers ThedocumentationexplainsanddescribeshowtousetheTASKINGMicroBlazetoolsettoprogramaMicroBlazeprocessor. YoucanusethetoolseitherwiththegraphicalAltiumDesignerorfromthecommandlineinacommandpromptwindow.

Structure Thetoolsetdocumentationconsistsofauser’smanual(UsingtheMicroBlazeEmbeddedTools),whichincludesaGetting Startedsection,andaseparatereferencemanual(thismanual). StartbyreadingtheGettingStartedinChapter1oftheuser’smanual. Theotherchaptersintheuser’smanualexplainhowtousethecompiler,assembler,linkerandthevariousutilities. Onceyouarefamiliarwiththesetools,youcanusethisreferencemanualtolookupspecificoptionsanddetailstomakefulluse oftheTASKINGtoolset. ThereferencemanualdescribestheC++languageimplementation,theClanguageimplementationandthe.

vii MicroBlazeEmbeddedToolsReference

ShortTableofContents

Chapter1:CLanguage TheTASKINGCcompilersarefullycompatiblewithISO−C.ThischapterdescribesthespecifictargetfeaturesoftheC language,includinglanguageextensionsthatarenotstandardinISO−C.Forexample,pragmasareawaytocontrolthe compilerfromwithintheCsource.Thefollowinglanguageextensionsaredescribed: • Datatypes • Keywords • Functionqualifiers • Intrinsicfunctions • Pragmas • Predefinedmacros Chapter2:C++Language DescribestheC++languageimplementation.TheC++languageitselfisnotdescribed.

Chapter3:Libraries ContainsoverviewsofalllibraryfunctionsyoucanuseinyourCsource.Firstlibrariesarelistedperheaderfilethatcontainsthe prototypes.Thesetablesalsoshowthelevelofimplementationperfunction.Second,alllibraryfunctionsarelistedand discussedintodetail.

Chapter4:AssemblyLanguage Describesthespecificfeaturesoftheassemblylanguageaswellas’directives’,whicharepseudoinstructionsthatare interpretedbytheassembler.

Chapter5:ToolOptions Containsadescriptionofalltooloptions: • Ccompileroptions • C++compileroptions • Assembleroptions • Linkeroptions • Controlprogramoptions • Makeutilityoptions • Librarianoptions Chapter6:ListFileFormats Containsadescriptionofthefollowinglistfileformats: • AssemblerListFileFormat • LinkerMapFileFormat Chapter7:ObjectFileFormats Containsadescriptionofthefollowingobjectfileformats: • ELF/DWARF2ObjectFormat • MotorolaS−RecordFormat • IntelHexRecordFormat Chapter8:LinkerScriptLanguage

Containsadescriptionofthelinkerscriptlanguage(LSL).

Chapter9:CERTCSecureCodingStandard ContainsanoverviewofthesupportedCERTCSecureCodingStandardrecommendationsandrules. viii ManualPurposeandStructure

Chapter10:MISRA−CRules ContainsadescriptionthesupportedandunsupportedMISRA−Ccodecheckingrules.

ConventionsUsedinthisManual

Notationforsyntax Thefollowingnotationisusedtodescribethesyntaxofcommandlineinput: bold Typethispartofthesyntaxliterally. italics Substitutetheitalicwordbyaninstance.Forexample: filename Typethenameofafileinplaceofthewordfilename. {} Enclosesalistfromwhichyoumustchooseanitem. [] Enclosesitemsthatareoptional.Forexample cmb[−?] Bothcmbandcmb−?arevalidcommands. | Separatesitemsinalist.ReaditasOR. ... Youcanrepeattheprecedingitemzeroormoretimes.

Example cmb[option]...filename Youcanreadthislineasfollows:enterthecommandcmbwithorwithoutanoption,followthisbyzeroormoreoptionsand specifyafilename.Thefollowinginputlinesareallvalid: cmbtest.c cmb−gtest.c cmb−g−stest.c

Notvalidis: cmb−g

Accordingtothesyntaxdescription,youhavetospecifyafilename.

Icons Thefollowingillustrationsareusedinthismanual:

Note:notesgiveyouextrainformation.

Warning:readtheinformationcarefully.Itpreventsyoufrommakingseriousmistakesorfromloosinginformation.

Thisillustrationindicatesactionsyoucanperformwiththemouse.SuchasAltiumDesignermenuentriesanddialogs.

Commandline:typeyourinputonthecommandline.

Reference:followthisreferencetofindrelatedtopics.

ix MicroBlazeEmbeddedToolsReference

RelatedPublications

CStandards • ISO/IEC9899:1999(E),Programminglanguages−C[ISO/IEC] Moreinformationonthestandardscanbefoundathttp://www.ansi.org • DSP−C,AnExtensiontoISO/IEC9899:1999(E), Programminglanguages−C[TASKING,TK0071−14] C++Standards • TheC++ProgrammingLanguage(secondedition) byBjarneStraustrup(1991,AddisonWesley) • ISO/IEC14882:1998C++standard[ANSI] Moreinformationonthestandardscanbefoundathttp://www.ansi.org • TheAnnotatedC++ReferenceManual byMargaretA.EllisandBjarneStraustrup(1990,AddisonWesley) CERTCSecureCodingStandard • TheCERTCSecureCodingStandard byRobertC.Seacord(October2008,AddisonWesley) • TheCERTCSecureCodingStandardwebsitehttp://www.securecoding.cert.org/ ForgeneralinformationaboutCERTsecurecoding,seehttp://www.cert.org/secure−coding MISRA−C • GuidelinesfortheUseoftheCLanguageinVehicleBasedSoftware[MIRAlimited,1998] Seealsohttp://www.misra.org.uk • MISRA−C:2004:GuidelinesfortheuseoftheCLanguageincriticalsystems[MIRAlimited,2004] Seealsohttp://www.misra−c.com TASKINGTools • UsingtheMicroBlazeEmbeddedTools [Altium,GU0114]

x 1 CLanguage

Summary ThischapterdescribesthetargetspecificfeaturesoftheClanguage,including languageextensionsthatarenotstandardinISO−C.Forexample,pragmasarea waytocontrolthecompilerfromwithintheCsource.

1.1 Introduction

TheTASKINGCcompilerfullysupportstheISOCstandardbutaddspossibilitiestoprogramthespecialfunctionsofthe MicroBlaze. InadditiontothestandardClanguage,thecompilersupportsthefollowing: • intrinsic(built−in)functionsthatresultintargetspecificassemblyinstructions • pragmastocontrolthecompilerfromwithintheCsource • predefinedmacros • thepossibilitytouseassemblyinstructionsintheCsource • keywordstospecifymemorytypesfordataandfunctions • attributetospecifyabsoluteaddresses • keywordsforinliningfunctionsandprogramminginterruptroutines • libraries Allnon−standardkeywordshavetwoleadingunderscores(__). InthischapterthetargetspecificcharacteristicsoftheClanguagearedescribed,includingtheabovementionedextensions.

1−1 MicroBlazeEmbeddedToolsReference

1.2 DataTypes

TheTASKINGCcompilerfortheMicroBlazearchitecture(cmb)supportsthefollowingdatatypes:

Size Align Type CType Limits (bit) (bit) Boolean _Bool 8 8 0or1 Character char 8 8 −27..27−1 signedchar unsignedchar 8 8 0..28−1 Integral short 16 16 −215..215−1 signedshort unsignedshort 16 16 0..216−1 enum 8 8 −27..27−1 16 16 −215..215−1 32 32 −231..231−1 int signedint 32 32 −231..231−1 long signedlong unsignedint 32 32 0..232−1 unsignedlong longlong 64 32 −263..263−1 signedlonglong unsignedlonglong 64 32 0..264−1 Pointer pointertofunctionordata 32 32 0..232−1 Floating−Point −3.402E+38..−1.175E−38 float(23−bitmantissa) 32 32 1.175E−38..3.402E+38 double −1.798E+308..−2.225E−308 64 32 longdouble(52−bitmantissa) 2.225E−308..1.798E+308

Table1−1:DataTypesfortheMicroBlaze

Whenyouusetheenumtype,thecompilerwillusethesmallestsufficienttype(char,shortorint),unlessyouuseC compileroption−−integer−enumeration(alwaysuseintegersforenumeration).

1.2.1 ChangingtheAlignment:__unaligned,__packed__and__align()

Normallydata,pointersandstructuremembersarealignedaccordingtothetableintheprevioussection.

Suppressalignment Withthetypequalifier__unalignedyoucanspecifytosuppressthealignmentofobjectsorstructuremembers.Thiscanbe usefultocreatecompactdatastructures.Inthiscasethealignmentwillbeonebitforbit−fieldsoronebyteforotherobjectsor structuremembers. Attheleftsideofapointerdeclarationyoucanusethetypequalifier__unalignedtomarkthepointervalueaspotentially unaligned.Thiscanbeusefultoaccessexternallydefineddata.Howeverthecompilercangeneratelessefficientinstructionsto dereferencesuchapointer,toavoidunalignedmemoryaccess.

1−2 CLanguage

Example: struct { charc; __unalignedinti;/*alignedatoffset1!*/ }s;

__unalignedint*up=&s.i;

Packedstructures Topreventalignmentgapsinstructures,youcanusetheattribute__packed__.Whenyouusetheattribute__packed__ directlyafterthekeywordstruct,allstructuremembersaremarked__unaligned.Forexamplethefollowingtwo declarationsarethesame: struct__packed__ { charc; int*i; }s1;

struct { char__unalignedc; int*__unalignedi;/*__unalignedatrightsideof’*’topackpointermember*/ }s2;

Theattribute__packed__hasthesameeffectasaddingthetypequalifier__unalignedtothedeclarationtosuppressthe standardalignment. Youcanalsouse__packed__inapointerdeclaration.Inthatcaseitaffectsthealignmentofthepointeritself,notthevalueof thepointer.Thefollowingtwodeclarationsarethesame: int*__unalignedp; int*p__packed__;

Changealignment Withtheattribute__align(n)youcanoverrulethedefaultalignmentofobjectsorstructurememberstonbytes.

1.3 MemoryQualifiers

Youcanusestaticmemoryqualifierstoallocatestaticobjectsinaparticularpartoftheaddressingspaceoftheprocessororto useaspecificaddressingmode. Youcanspecifythefollowingmemorytypes:

Qualifier Description __no_sdata DirectaddressableRAM __sdata Directshort(near)addressableRAM (Smalldata,64k) __sfr (Forcompatibiltywithspecialfunctionregisters) __rom DatadefinedwiththisqualifierisplacedinROM.Thissectionisexcludedfromautomaticinitializationby thestartupcode.__romalwaysimpliesthetypequalifierconst.

Table1−2:MemoryTypeQualifiersfortheMicroBlaze

1−3 MicroBlazeEmbeddedToolsReference

Bydefault,allglobalandstaticdataobjectssmallerthan4bytesareplacedinsmalldatasections.Withthe__no_sdataand __sdatakeywords,youoverrulethisdefault.

SeeCcompileroption−−sdata=sizeinsection5.1,CCompilerOptionsinChapterToolOptionstochangethesize beneathwhichdataobjectsareplacedinsmallmemory. Examplesusingexplicitmemorytypes: __romchartext[]="Nosmoking";

longlongl=1234; longlongreservedindata(bydefault) __sdatalonglongk=1234; longlongreservedinsdata Thememorytypequalifiersaretreatedlikeanyotherdatatypespecifier(suchasunsigned).Thismeanstheexamplesabove canalsobedeclaredas: char__romtext[]="Nosmoking"; longlong__sdatak=1234;

The__sfrkeywordletsyoudefineavariableasa"specialfunctionregister".Thoughspecialfunctionregistersarenot availablefortheMicroBlaze,thecompileracceptsthe__sfrkeywordasaqualifierforcompatibilityreasons.Variablesdeclared with__sfrhavesomespecialcharacteristics. BecausespecialfunctionregistersaredealingwithI/O,itisincorrecttooptimizeawaytheaccesstothem.Therefore,the compilerdealswith__sfrvariablesasiftheyweredeclaredwiththevolatilequalifier. Non−initializedglobal__sfrvariablesarenotclearedatstartup.Forexample: __sfrinti;//global__sfrvariablenotcleared

Itisnotallowedtoinitializeglobal__sfrvariablesandtheyarenotinitializedatstartup.Forexample: __sfrintj=10;//notallowedtoinitializeglobal__sfrvariable

1.3.1 PlacinganObjectatanAbsoluteAddress:__at()

Justlikeyoucandeclareavariableinaspecificpartofmemory(usingmemorytypequalifiers),youcanalsoplaceanobjectat anabsoluteaddressinmemory. Withtheattribute__at()youcanspecifyanabsoluteaddress.

Examples unsignedcharDisplay[80*24]__at(0x2000);

ThearrayDisplayisplacedataddress0x2000.Inthegeneratedassembly,anabsolutesectioniscreated.Onthisposition spaceisreservedforthevariableDisplay. inti__at(0x1000)=1;

Thevariableiisplacedataddress0x1000andisinitializedat1. voidf(void)__at(0xf0ff+1){}

Thefunctionfisplacedataddress0xf100.

Restrictions Takenoteofthefollowingrestrictionsifyouplaceavariableatanabsoluteaddress: • Theargumentofthe__at()attributemustbeaconstantaddressexpression. • Youcanplaceonlyglobalvariablesatabsoluteaddresses.Parametersoffunctions,orautomaticvariableswithinfunctions cannotbeplacedatabsoluteaddresses. • Avariablethatisdeclaredextern,isnotallocatedbythecompilerinthecurrentmodule.Henceitisnotpossibletousethe keyword__at()onanexternalvariable.Use__at()atthedefinitionofthevariable. • Youcannotplacestructuremembersatanabsoluteaddress.

1−4 CLanguage

• Absolutevariablescannotoverlapeachother.Ifyoudeclaretwoabsolutevariablesatthesameaddress,theassemblerand /orlinkerissuesanerror.Thecompilerdoesnotcheckthis.

1.4 UsingAssemblyintheCSource:__asm()

Withthe__asmkeywordyoucanuseassemblyinstructionsintheCsource.BeawarethatCmodulesthatcontainassembly arenotportableandhardertocompileinotherenvironments. Furthermore,assemblyblocksarenotinterpretedbythecompiler:theyareregardedasablackbox.So,itisyourresponsibility tomakesurethattheassemblyblockissyntacticallycorrect.

Generalsyntaxofthe__asmkeyword __asm("instruction_template" [:output_param_list [:input_param_list [:register_save_list]]]);

instruction_template Assemblyinstructionsthatmaycontainparametersfromtheinputlistor outputlistintheform:%parm_nr %parm_nr[.regnum] Parameternumberintherange0..9.Withtheoptional.regnumyoucan accessanindividualregisterfromaregisterpair. output_param_list [["=[&]constraint_char"(C_expression)],...] input_param_list [["constraint_char"(C_expression)],...] & Saysthatanoutputoperandiswrittentobeforetheinputsareread,so thisoutputmustnotbethesameregisterasanyinput. constraint_char Constraintcharacter:thetypeofregistertobeusedforthe C_expression. C_expression AnyCexpression.Foroutputparametersitmustbeanlvalue,thatis, somethingthatislegaltohaveontheleftsideofanassignment. register_save_list [["register_name"],...] register_name:q Nameoftheregisteryouwanttoreserve.

Typicalexample:addingtwoCvariablesusingassembly chara,b; intresult;

voidmain(void) { a=3; b=4; __asm("ADD%0,%1,%2":"=r"(result):"r"(a),"r"(b)); }

%0correspondswiththefirstCvariable,%1withthesecondandsoon. Generatedassemblycode: main:.labelcode addikr3,r0,3 sbir3,r13,a−_base_r13 addikr4,r0,4 sbir4,r13,b−_base_r13 ADDr3,r3,r4 swir3,r13,result−_base_r13 rtsdr15,8 orr0,r0,r0

1−5 MicroBlazeEmbeddedToolsReference

SpecifyingregistersforCvariables Withaconstraintcharacteryouspecifytheregistertypeforaparameter.Intheexampleabove,therisusedtoforcetheuseof registers(Rn)fortheparametersaandb. Youcanreservetheregistersthatarealreadyusedintheassemblyinstructions,eitherintheparameterlistsorinthereserved registerlist(register_save_list,alsocalled"clobberlist").Thecompilertakesaccountoftheselists,sonounnecessaryregister savingandrestoringinstructionsareplacedaroundtheinlineassemblyinstructions.

Constraint Type Operand Remark character r generalpurpose r0..r31 register i immediatevalue #immval number otheroperand sameas%number Inputconstraintonly.Thenumbermustrefertoanoutput parameter.Indicatesthat%numberandnumberarethesame register. Use%number.0and%number.1toindicatethefirstandsecond halfofaregisterpairwhenusedincombinationwithR.

Table1−3:Availableinput/outputoperandconstraintsfortheMicroBlaze

Loopsandconditionaljumps Thecompilerdoesnotdetectloopsthatarecodedwithmultiple__asmstatementsor(conditional)jumpsacross__asm statementsandwillgenerateincorrectcodefortheregistersinvolved. Ifyouwanttocreatealoopwith__asm,thewholeloopmustbecontainedinasingle__asmstatement.Thesamecountsfor (conditional)jumps.Asaruleofthumb,allreferencestoalabelinan__asmstatementmustbecontainedinthesame statement.

Example1:noinputoroutput Asimpleexamplewithoutinputoroutputparameters.Youcanuseanyinstructionorlabel.NotethatyoucanusestandardC escapesequences. __asm("nop\n\t" "nop");

Generatedcode: nop nop

Example2:usingoutputparameters Assigntheresultofinlineassemblytoavariable.Aregisterischosenfortheparameterbecauseoftheconstraintr;the compilerdecideswhichregisterisbesttouse.The%0intheinstructiontemplateisreplacedwiththenameofthisregister. Finally,thecompilergeneratescodetoassigntheresulttotheoutputvariable. charout;

voidmain(void) { __asm("sbi%0,0xff":"=r"(out)); }

Generatedassemblycode: sbir3,0xff sbir3,r13,out−_base_r13

1−6 CLanguage

Example3:usinginputandoutputparameters AddtwoCvariablesandassigntheresulttoathirdCvariable.Registersareusedfortheinputparameters(constraintr,%1for aand%2forbintheinstructiontemplate)andfortheoutputparameter(constraintr,%0forresultintheinstructiontemplate). Thecompilergeneratescodetomovetheinputexpressionsintotheinputregistersandtoassigntheresulttotheoutput variable. chara,b; intresult;

voidmain(void) { a=3; b=4; __asm("ADD%0,%1,%2":"=r"(result):"r"(a),"r"(b)); }

Generatedassemblycode: main:.labelcode addikr3,r0,3 sbir3,r13,a−_base_r13 addikr4,r0,4 sbir4,r13,b−_base_r13 ADDr3,r3,r4 swir3,r13,result−_base_r13 rtsdr15,8 orr0,r0,r0

Example4:reserveregisters Sometimesaninstructionknocksoutcertainspecificregisters.Themostcommonexampleofthisisafunctioncall,wherethe calledfunctionisallowedtodowhateveritlikeswithsomeregisters.Ifthisisthecase,youcanlistspecificregistersthatget clobberedbyanoperationaftertheinputs. SameasExample3,butnowregisterR3isareservedregister.Youcandothisbyaddingareservedregisterlist(:"R3").As youcanseeinthegeneratedassemblycode,registerR3isnotused. chara,b; intresult;

voidmain(void) { a=3; b=4; __asm("ADD%0,%1,%2":"=r"(result):"r"(a),"r"(b):"R3"); }

Generatedassemblycode: main:.labelcode addikr4,r0,3 sbir4,r13,a−_base_r13 addikr5,r0,4 sbir5,r13,b−_base_r13 ADDr4,r4,r5 swir4,r13,result−_base_r13 rtsdr15,8 orr0,r0,r0

1−7 MicroBlazeEmbeddedToolsReference

1.5 PragmastoControltheCompiler

PragmasarekeywordsintheCsourcethatcontrolthebehaviorofthecompiler.Pragmasoverrulecompileroptions.Put pragmasinyourCsourcewhereyouwantthemtotakeeffect.Unlessstatedotherwise,apragmaisineffectfromthepoint whereitisincludedtotheendofthecompilationunitoruntilanotherpragmachangesitsstatus. Forexample,youcansetacompileroptiontospecifywhichoptimizationsthecompilershouldperform.Withthe#pragma optimizeflagsyoucansetanoptimizationlevelforaspecificpartoftheCsource.Thisoverrulesthegeneraloptimization levelthatissetintheCcompilerOptimizationpageintheProjectOptionsdialog(commandlineoption−−optimize(−O)). Thegeneralsyntaxforpragmasis:

#pragmapragma−spec[ON|OFF|DEFAULT|RESTORE] or: _Pragma("pragma−spec[ON|OFF|DEFAULT|RESTORE]")

Pragmasmarkedwith(*)acceptthefollowingspecialarguments: default setthepragmatotheinitialvalue restore restorethepreviousvalueofthepragma Pragmasmarkedwith(+)arebooleanflags,andacceptthefollowingarguments: on switchtheflagon(sameaswithoutargument) off switchtheflagoff Thecompilerrecognizesthefollowingpragmas,otherpragmasareignored. aliassymbol=defined_symbol Definesymbolasanaliasfordefinined_symbol.Itcorrespondstoanequatedirective(.equ)atassemblylevel.Thesymbol shouldnotbedefinedelsewhere,anddefined_symbolshouldbedefinedwithstaticstorageduration(notexternor automatic).

Seeassemblerdirective.EQUinsection4.8.2,AssemblerDirectives,inChapterAssemblyLanguage. clear noclear Bydefault,uninitializedglobalorstaticvariablesareclearedtozeroonstartup.Withpragmanoclear,thisstepisskipped. Pragmaclearresumesnormalbehavior.

SeeCcompileroption−−noclearinsection5.1,CCompilerOptions,inChapterToolOptions. compactmaxmatchvalue Controlthemaximumsizeofamatch.

SeeCcompileroption−−compact−max−sizeinsection5.1,CCompilerOptions,inChapterToolOptions. extensionisuffix(*)(+) Enablesalanguageextensiontospecifyimaginaryfloating−pointconstants.Withthisextension,youcanusean"i"suffixon afloating−pointconstant,tomakethetype_Imaginary. externsymbol Forceanexternalreference(.externassemblerdirective),evenwhenthesymbolisnotusedinthemodule.

Seeassemberdirective.EXTERNinsection4.8.2,AssemblerDirectives,inChapterAssemblyLanguage.

1−8 CLanguage extern_sdata(*)(+) endextern_sdata Withthispragmayoutellthecompilertousesmalldataaddressingforexternaldataaswellasforsymbolsdefinedinthe currentmodule.endextern_sdatarestoresthedefaultsettingforthe−−extern−sdataoption.

SeeCcompileroption−−extern−sdatainsection5.1,CCompilerOptions,inChapterToolOptions. inline noinline smartinline

Insteadofthequalifierinline,youcanalsousepragmainlineandpragmanoinlinetoinlineafunctionbody: intw,x,y,z; #pragmainline intadd(inta,intb) { inti=4; return(a+b); } #pragmanoinline voidmain(void) { w=add(1,2); z=add(x,y); }

Ifafunctionhasaninlineor__noinlinefunctionqualifier,thenthisqualifierwilloverrulethecurrentpragmasetting.

Seesection1.9.3,InliningFunctions:inline/__noinline.

Bydefault,smallfuctionsthatarenottoooftencalled(fromdifferentlocations),areinlined.Thisreducesexecutionspeedat thecostofcodesize(Ccompileroption−Oi).Withthepragmanoinline/pragmasmartinlineyoucantemporarily disablethisoptimization. WiththeCcompileroptions−−inline−max−incrand−−inline−max−sizeyouhavemorecontrolovertheautomaticfunction inliningprocessofthecompiler.

SeeformoreinformationtheCcompileroptions−−inline−max−incrand−−inline−max−sizeinsection5.1,CCompiler OptionsinChapterToolOptions. macro nomacro(*)(+) Turnsmacroexpansiononoroff.Bydefault,macroexpansionisenabled. maxcalldepthvalue Controlthemaximumcalldepth.Bydefault,themaximumisinfinite(−1).

SeeCcompileroption−−max−call−depthinsection5.1,CCompilerOptions,inChapterToolOptions. message"message"... Printthemessagestring(s)onstandardoutput.

1−9 MicroBlazeEmbeddedToolsReference optimizeflags(*) endoptimize Youcanoverrulethecompileroption−Oforthecodebetweenthepragmasoptimizeandendoptimize.Thepragma worksthesameascompileroption−O.

Seesection2.6,CompilerOptimizationsinChapterUsingtheCompilerintheuser’smanual. SeeCcompileroption−−optimize(−O)insection5.1,CCompilerOptions,inChapterToolOptions. profile[flag,...](*) endprofile Controltheprofilesettings.Thepragmaworksthesameascompileroption−−profile(−p).Notethatthispragmawillonlybe checkedatthestartofafunction.endprofileswitchesbacktothepreviousprofilingsettings.

SeeCcompileroption−−profile(−p)insection5.1,CCompilerOptions,inChapterToolOptions. profiling(*)(+) Ifprofilingisenabledonthecommandline,Ccompileroption−−profile(−p),youcandisablepartofyoursourcecodefor profilingwiththepragmasprofilingoffandprofiling. protect(*)(+) endprotect Withthesepragmasyoucanprotectsectionsagainstlinkeroptimizations.Thisexcludesasectionfromunreferencedsection removalandduplicatesectionremovalbythelinker.endprotextrestoresthedefaultsectionprotection. ramstring AllocatestringsinROMandRAM.ThestringsarecopiedtoRAMatstartup. romstring Sameascompileroption−−source(−S).AllocatestringsinROMonly.

SeeCcompileroption−−source(−S)insection5.1,CCompilerOptions,inChapterToolOptions. runtime[flag,...](*) Checkforrun−timeerrors.Thepragmaworksthesameascompileroption−−runtime(−r).

SeeCcompileroption−−runtime(−r)insection5.1,CCompilerOptions,inChapterToolOptions. sdatasize(*) Withthispragmayoutellthecompilertoplacealldataobjectssmallerthanthespecifiedsize(bytes)insdataorsbss sections.Youcanstilloverrulethisoptionwiththekeywords__no_sdataand__sdataforindividiualdataobjectsinyour source.

SeeCcompileroption−−sdatainsection5.1,CCompilerOptions,inChapterToolOptions. section[name=]{suffix|−f|−m|−fm}(*) endsection Renamesectionsbyaddingasuffixtoallsectionnamesspecifiedwithname,orrestoredefaultsectionnaming.Ifyou specifyonlyasuffix(withoutaname),thesuffixisaddedtoallsectionnames.

SeeCcompileroption−−rename−sectionsinsection5.1,CCompilerOptionsinChapterToolOptions. Seeassemblerdirective.SECTION(Startorcontinuesection),insection4.8.2,AssemblerDirectives,inChapter AssemblyLanguage.

1−10 CLanguage section_code_init(*)(+) section_no_code_init CopyordonotcopycodesectionsfromROMtoRAMatapplicationstartup. section_const_init(*)(+) section_no_const_init Copyordonotcopyread−onlydatasectionsfromROMtoRAMatapplicationstartup. source(*)(+) nosource WiththesepragmasyoucanchoosewhichCsourcelinesmustbelistedascommentsinassemblyoutput.

SeealsoCcompileroption−−source(−s) stdinc(*)(+) Thispragmachangesthebehaviorofthe#includedirective.Whenset,theCcompileroptions−−include−directoryand −−no−stdincareignored. linear_switch jump_switch binary_switch smart_switch Withthesepragmasyoucanoverrulethecompilerchosenswitchmethod: linear_switch Forcejumpchaincode.Ajumpchainiscomparablewithanif/else−if/else−if/elseconstruction. jump_switch Forcejumptablecode.Ajumptableisatablefilledwithjumpinstructionsforeachpossible switchvalue.Theswitchargumentisusedasanindextojumpwithinthistable. binary_switch Forcebinarylookuptablecode.Abinarysearchtableisatablefilledwithavaluetocompare theswitchargumentwithandatargetaddresstojumpto. smart_switch Letthecompilerdecidetheswitchmethodused

SeeSection1.8,SwitchStatement. tradeofflevel(*) Specifytradeoffbetweenspeed(0)andsize(4).

SeealsoCcompileroption−−tradeoff(−t) vector_offsetoffset(*) Specifybaseaddressforinterruptvectors.

SeeCcompileroption−−vector−offsetinsection5.1,CCompilerOptionsinChapterToolOptions. novector Donotgenerateinterruptvectorsandreferencetointerrupthandlerinrun−timelibrary.

SeeCcompileroption−−novectorinsection5.1,CCompilerOptionsinChapterToolOptions.

1−11 MicroBlazeEmbeddedToolsReference warning[number,...](*) Withthispragmayoucandisablewarningmessages.Ifyoudonotspecifyawarningnumber,allwarningswillbesuppressed.

SeealsoCcompileroption−−no−warnings(−w) weaksymbol Markasymbolas"weak"(.weakassemblerdirective).Thesymbolmusthaveexternallinkage,whichmeansaglobalor externalobjectorfunction.Astaticsymbolcannotbedeclaredweak. Aweakexternalreferenceisresolvedbythelinkerwhenaglobal(orweak)definitionisfoundinoneoftheobjectfiles. However,aweakreferencewillnotcausetheextractionofamodulefromalibrarytoresolvethereference.Whenaweak externalreferencecannotberesolved,thenullpointerissubstituted. Aweakdefinitioncanbeoverruledbyanormalglobaldefinition.Thelinkerwillnotcomplainabouttheduplicatedefinition, andignoretheweakdefinition.

Seeassemblerdirective.WEAKinSection4.8.2,AssemblerDirectives,inChapterAssemblyLanguage.

1.6 PredefinedPreprocessorMacros

InadditiontothepredefinedmacrosrequiredbytheISOCstandard,suchas__DATE__and__FILE__,theTASKINGC compilersupportsthepredefinedmacrosasdefinedinthetablebelow.ThemacrosareusefultocreateconditionalCcode.

Macro Description __BIG_ENDIAN__ Expandsto1,indicatingtheprocessoraccessesdatainbig−endian. __BUILD__ Identifiesthebuildnumberofthecompiler,composedofdecimaldigitsforthebuildnumber,three digitsforthemajorbranchnumberandthreedigitsfortheminorbranchnumber.Forexample,if youusebuild1.22.1ofthecompiler,__BUILD__expandsto1022001.Ifthereisnobranch number,thebranchdigitsexpandtozero.Forexample,build127resultsin127000000. __CMB__ Expandsto1fortheMicroBlazetoolset,otherwiseunrecognizedasmacro. __DOUBLE_FP__ Expandsto1ifyoudidnotuseoption−−no−double(Treat’double’as’float’),otherwise unrecognizedasmacro. __HW_BARRELSHIFT__ Expandsto1ifyouusedoption−−use−hardware=b,otherwiseunrecognizedasmacro. __HW_DIVIDE__ Expandsto1ifyouusedoption−−use−hardware=,otherwiseunrecognizedasmacro. __HW_FPU__ Expandsto1ifyouusedoption−−use−hardware=f,otherwiseunrecognizedasmacro. __HW_MSR__ Expandsto1ifyouusedoption−−use−hardware=s,otherwiseunrecognizedasmacro. __HW_MULTIPLY__ Expandsto1ifyouusedoption−−use−hardware=m,otherwiseunrecognizedasmacro. __HW_PCMP__ Expandsto1ifyouusedoption−−use−hardware=p,otherwiseunrecognizedasmacro. __REVISION__ Identifiestherevisionnumberofthecompiler.Forexample,ifyouuseversion1.0r2ofthe compiler,__REVISION__expandsto2. __SINGLE_FP__ Expandsto1ifyouusedoption−−no−double(Treat’double’as’float’),otherwiseunrecognized asmacro. __TASKING__ IdentifiesthecompilerasaTASKINGcompiler.Expandsto1ifaTASKINGcompilerisused. __VERSION__ Identifiestheversionnumberofthecompiler.Forexample,ifyouuseversion1.0r2ofthe compiler,__VERSION__expandsto1000(dotandrevisionnumberareomitted,minorversion numberin3digits).

Table1−4:Predefinedpreprocessormacros

Example #ifdef__CMB__ /*thispartisonlycompiledfortheMicroBlaze*/ ...

#endif

1−12 CLanguage

1.7 Strings

Inthiscontexttheword’strings’meanstheseparateoccurrenceofastringinaCprogram.So,arrayvariablesinitializedwith stringsarejustinitializedcharacterarrays,whichcanbeallocatedinanymemorytype,andarenotconsideredas’strings’. TheMicroBlazecompilerplacesstringliteralsin.datasections.Ifyouusethecompileroption−S(−−romstrings)or#pragma romstring,thecompilerplacesallstringsin.rodatasections.

1.8 SwitchStatement

TheTASKINGCcompilersupportsthreewaysofcodegenerationforaswitchstatement:ajumpchain(linearswitch),ajump tableorabinarysearchtable. Ajumpchainiscomparablewithanif/else−if/else−if/elseconstruction.Ajumptableisatablefilledwithjumpinstructionsfor eachpossibleswitchvalue.Theswitchargumentisusedasanindextojumpwithinthistable.Abinarysearchtableisatable filledwithavaluetocomparetheswitchargumentwithandatargetaddresstojumpto. #pragmasmart_switchisthedefaultofthecompiler.Thecompilertriestousetheswitchmethodwhichusestheleast spaceinROM(tablesizeinROMDATApluscodetodotheindexing). Foraswitchwithalongtypeargument,onlybinarysearchtablecodeisused. Foraninttypeargument,ajumptableswitchisonlypossiblewhenallcasevaluesareinthesame256valuerange(thehigh bytevalueofallprogrammedcasesarethesame). Especiallyforlargeswitchstatements,thejumptableapproachexecutesfasterthanthebinarysearchtableapproach.Alsothe jumptablehasapredictablebehaviorinexecutionspeed:independentoftheswitchargument,everycaseisreachedinthe sameexecutiontime. Withasmallnumberofcases,thejumpchainmethodcanbefasterinexecutionandshorterinsize. Youcanoverrulethecompilerchosenswitchmethodbyusingapragma: #pragmalinear_switchforcejumpchaincode #pragmajump_switchforcejumptablecode #pragmabinary_switchforcebinarysearchtablecode #pragmasmart_switchletthecompilerdecidetheswitchmethodused Usingapragmacannotoverruletherestrictionsasdescribedearlier. Theswitchpragmasmustbeplacedbeforethefunctionbodycontainingtheswitchstatement.Nestedswitchstatementsuse thesameswitchmethod,unlessthenestedswitchisimplementedinaseparatefunctionwhichisprecededbyadifferent switchpragma.

Example /*placepragmabeforefunctionbody*/

#pragmajump_switch

voidtest(unsignedcharval) {/*functioncontainingtheswitch*/ switch(val) { /*usejumptable*/ } }

1−13 MicroBlazeEmbeddedToolsReference

1.9 Functions

1.9.1 ParameterPassing

Alotofexecutiontimeofanapplicationisspenttransferringparametersbetweenfunctions.Thefastestparametertransportis viaregisters.Therefore,functionparametersarefirstpassedviaregisters.Ifnomoreregistersareavailableforaparameter,the compilerpushesparametersonthestack.Seethetablebelow.

ParameterType ParameterNumber 1 2 3 4 5 6 7 8 9 10 _Bool r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 char r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 short r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 int/long r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 float r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 32−bitpointer r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 32−bitstruct r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 longlong r3r4 r5r6 r7r8 r9r10 r11r12 double r3r4 r5r6 r7r8 r9r10 r11r12 64−bitstruct r3r4 r5r6 r7r8 r9r10 r11r12

Table1−5:Registerusageforparameterpassing

Ifaregistercorrespondingtoaparameternumberisalreadyinusethenextregisterisused.

Examplewiththreearguments func1(inta,intb,int*c) • a(firstparameter)ispassedinregisterr3. • b(secondparameter)ispassedinregisterr4. • c(thirdparameter)ispassedinregisterr5. Examplewithonelonglong/doubleargumentsandoneotherargument func2(longlongd,chare) • d(firstparameter)ispassedinregisterr3andr4 • e(secondparameter)ispassedinregisterr5.

1.9.2 FunctionReturnTypes

TheCcompilerusesregisterstostoreCfunctionreturnvalues,dependingonthefunctionreturntypes.

ReturnType Register _Bool rn char rn short rn int/long rn float rn 32−bitpointer rn 32−bitstruct rn longlong rnrm

1−14 CLanguage

ReturnType Register double rnrm 64−bitstruct rnrm

Table1−6:Registerusageforfunctionreturntypes Objectslargerthan64bitsarereturnedviathestack.

1.9.3 InliningFunctions:inline/__noinline

WiththeCcompileroption−−optimize=+inline,theCcompilerautomaticallyinlinessmallfunctionsinordertoreduce executiontime(smartinlining).Thecompilerinsertsthefunctionbodyattheplacethefunctioniscalled.TheCcompilerdecides whichfunctionswillbeinlined.Youcanoverrulethisbehaviorwiththetwokeywordsinline(ISO−C)and__noinline. Withtheinlinekeywordyouforcethecompilertoinlinethespecifiedfunction,regardlessoftheoptimizationstrategyofthe compileritself: inlineunsignedintabs(intval) { unsignedintabs_val=val; if(val<0)abs_val=−val; returnabs_val; }

Ifafunctionwiththekeywordinlineisnotcalledatall,thecompilerdoesnotgeneratecodeforit. Youmustdefineinlinefunctionsinthesamesourcemoduleasinwhichyoucallthefunction,becausethecompileronlyinlinesa functioninthemodulethatcontainsthefunctiondefinition.Whenyouneedtocalltheinlinefunctionfromseveralsource modules,youmustincludethedefinitionoftheinlinefunctionineachmodule(forexampleusingaheaderfile). Withthe__noinlinekeyword,youpreventafunctionfrombeinginlined: __noinlineunsignedintabs(intval) { unsignedintabs_val=val; if(val<0)abs_val=−val; returnabs_val; }

Usingpragmas:inline,noinline,smartinline Insteadoftheinlinequalifier,youcanalsouse#pragmainlineand#pragmanoinlinetoinlineafunctionbody: #pragmainline unsignedintabs(intval) { unsignedintabs_val=val; if(val<0)abs_val=−val; returnabs_val; } #pragmanoinline voidmain(void) { inti; i=abs(−1); }

Ifafunctionhasaninline/__noinlinefunctionqualifier,thenthisqualifierwilloverrulethecurrentpragmasetting. Withthe#pragmanoinline/#pragmasmartinlineyoucantemporarilydisablethedefaultbehaviorthattheCcompiler automaticallyinlinessmallfunctionswhenyouturnontheCcompileroption−−optimize=+inline.

1−15 MicroBlazeEmbeddedToolsReference

1.9.4 IntrinsicFunctions

SomespecificassemblyinstructionshavenoequivalenceinC.Intrinsicfunctionsgivethepossibilitytousetheseinstructions. Intrinsicfunctionsarepredefinedfunctionsthatarerecognizedbythecompiler.Thecompilergeneratesthemostefficient assemblycodeforthesefunctions. Thecompileralwaysinlinesthecorrespondingassemblyinstructionsintheassemblysource(ratherthancallingitasa function).Thisavoidsparameterpassingandregistersavinginstructionswhicharenormallynecessaryduringfunctioncalls. Intrinsicfunctionsproduceveryefficientassemblycode.Thoughitispossibletoinlineassemblycodebyhand,intrinsic functionsuseregistersevenmoreefficiently.AtthesametimeyourCsourceremainsveryreadable. YoucanuseintrinsicfunctionsinCasiftheywereordinaryC(library)functions.Allintrinsicsbeginwithadoubleunderscore character. TheTASKINGMicroBlaceCcompilerrecognizesthefollowingintrinsicfunctions:

__alloc void*volatile__alloc(__size_tsize);

Allocatememory. Returns:apointertospaceinexternalmemoryofsizebyteslength.NULLifthereisnotenoughspaceleft.

__dotdotdot__ char*__dotdotdot__(void);

Variableargument’...’operator.Usedinlibraryfunctionva_start(). Returns:thestackoffsettothevariableargumentlist.

__free voidvolatile__free(void*p);

Deallocatesthememorypointedtobyp.pmustpointtomemoryearlierallocatedbyacallto__alloc(). Returns:nothing.

__get_return_address __codeptrvolatile__get_return_address(void);

Usedbythecompilerforprofilingwhenyoucompilewiththe−−profile(−p)option. Returns:returnaddressofafunction.

__getfsl _Boolvolatile__getfsl(unsignedcharchannel,unsignedint*data,_Boolwait);

Readdatawordsfromaspecifiedfastsimplexlink(fsl)channel.Channelmustbeaconstantvalueintherange0..7.Theread dataisstoredin*data.Withthebooleanwaityoucanchoosewhetherornottowaitforinformation.Truemeans:waitfor information,falsemeans:donotwaitforinformation(thechannelmaynotprovidedata). Returns:trueifvaliddatawasreadfromthespecifiedchannel,otherwisefalse.

__putfsl _Boolvolatile__putfsl(unsignedcharchannel,unsignedint*data,_Boolwait);

Writedatawordstoaspecifiedfastsimplexlink(fsl)channel.Channelmustbeaconstantvalueintherange0..7.Thedatato writemustbestoredin*data.Withthebooleanwaityoucanchoosewhetherornottowaitforinformation.Truemeans:waitfor information,falsemeans:donotwaitforinformation(thechannelmaynotacceptdata). Returns:trueifvaliddatawaswrittentothespecifiedchannel,otherwisefalse.

1−16 CLanguage

__getfsr unsignedintvolatile__getfsr(void);

Getthevalueofthefloating−pointstateregisterFSR. Returns:thevalueofthefloating−pointstateregisterFSR.

__putfsr voidvolatile__putfsr(unsignedintvalue);

Setthevalueofthefloating−pointstateregisterFSRtovalue. Returns:nothing.

__cgetfsl _Boolvolatile__cgetfsl(unsignedcharchannel,unsignedint*ctrl,_Boolwait);

Readcontrolwordsfromaspecifiedfastsimplexlink(fsl)channel. Returns:trueifvaliddatawasreadfromthespecifiedchannel,otherwisefalse.

__cputfsl _Boolvolatile__cputfsl(unsignedcharchannel,unsignedint*ctrl,_Boolwait);

Writecontrolwordstoaspecifiedfastsimplexlink(fsl)channel. Returns:trueifvaliddatawasreadfromthespecifiedchannel,otherwisefalse.

__getpc unsignedintvolatile__getpc(void);

GetthevalueoftheprogramcounterPC. Returns:thevalueoftheprogramcounter.

__getmsr unsignedintvolatile__getmsr(void);

GetthevalueofthemachinestateregisterMSR. Returns:thevalueofthemachinestateregisterMSR.

__putmsr voidvolatile__putmsr(unsignedintvalue);

SetthevalueofthemachinestateregisterMSRtovalue. Returns:nothing.

__msrclr unsignedint__msrclr(unsignedintvalue);

ClearanumberofbitsinthemachinestateregisterMSR.Valueshouldbea14bitmask.Ifyouspecifyavaluelargerthan214, theinstructionisignoredandthecompilerwillusethegetmsrandputmsrinstructionsinstead. Returns:thevalueoftheMSRregisterbeforebitswerecleared.

__msrset unsignedint__msrset(unsignedintvalue);

SetanumberofbitsinthemachinestateregisterMSR.Valueshouldbea14bitmask.Ifyouspecifyavaluelargerthan214, theinstructionisignoredandthecompilerwillusethegetmsrandputmsrinstructionsinstead. Returns:thevalueoftheMSRregisterbeforebitswereset.

1−17 MicroBlazeEmbeddedToolsReference

1.9.5 InterruptFunctions

TheTASKINGCcompilersupportsanumberoffunctionqualifiersandkeywordstoprograminterruptserviceroutines(ISR).An interruptserviceroutine(or:interruptfunction,interrupthandler,exceptionhandler)iscalledwhenaninterruptevent(or:service request)occurs. TheMicroBlazesupportsfivetypesofexceptions.Thenexttableliststhetypesofexceptionsandtheprocessormodethatis usedtoprocessthatexception.Whenanexceptionoccurs,executionisforcedfromafixedmemoryaddresscorrespondingto thetypeofexception.Thesefixedaddressesarecalledtheexceptionvectors.

Exceptiontype Vector Returnregister Return Functiontypequalifier address instruction Reset 0x00000000 − − __interrupt(0x00000000) Uservector(exception) 0x00000008 r15 rtsd __interrupt(0x00000008) Interrupt 0x00000010 r14 rtid __interrupt(0x00000010) Break 0x00000018 r16 rtbd __interrupt(0x00000018) Hardwareexception 0x00000020 r17 rted __interrupt(0x00000020)

Table1−7:Exceptionprocessingmodes

1.9.5.1 DefininganInterruptServiceRoutine:__interrupt()

Withthefunctiontypequalifier__interrupt()youcandeclareafunctionasaninterruptserviceroutine.Thefunctiontype qualifier__interrupt()takesonevectoraddressasargument.Withthe__interrupt()keyword,ajumptotheactual interrupthandleriscaused. Interruptfunctionscannotreturnanythingandmusthaveavoidargumenttypelist: void__interrupt(vector_address) isr(void) { ... }

Example void__interrupt(0x00000008)my_handler(void) { ... }

Suppressgenerationofinterruptvectors Whenyoudefineaninteruptserviceroutine,thecompilergeneratestheappropriateinterruptvector,consistingofaninstruction jumpingtotheinterruptfunction.Youcansuppressthiswiththecompileroption−−novectororthe#pragmanovector.The differencebetweenanormalfunctionandaninterruptfunctionisthataninterruptfunctionendswithaRTSD,RTIDorRTBD instructioninsteadofaRETinstruction,andthatallregistersthatmightpossiblybecorruptedduringtheexecutionofthe interruptfunctionaresavedonfunctionentry(thisiscalledtheinterruptframe)andrestoredonfunctionexit.

Ccompileroption−−novector(Donotgenerateinterruptvectors)insection5.1,CCompilerOptionsinChapterTool Optionsofthereferencemanual.

Specifyanothervectoroffset

ForcertainROMmonitorsitisnecessarytospecifyanoffsetforallinterruptvectors.Forthisyoucanusethecommand −−vector−offset=value.SupposeaROMmonitorhastheinterrupttableatoffset0x4000.Whenyoucompilewith −−vector−offset=0x00004000interruptvectoraddress8isbeinglocatedataddress0x00004008insteadof0x00000008.

Ccompileroption−−vector−offset(Specifya32−bitoffsetaddressforinterruptvectors)insection5.1,CCompiler OptionsinChapterToolOptionsofthereferencemanual.

1−18 CLanguage

1.9.5.2 InterruptFrame:__frame() Withthefunctiontypequalifier__frame()canspecifywhichregistersandSFRsmustbesavedforaparticularinterrupt function.Onlythespecifiedregisterswillbepushedandpoppedfromthestack.Ifyoudonotspecifythefunctionqualifier __frame(),theCcompilerdetermineswhichregistersmustbepushedandpopped.Thesyntaxis: void__interrupt(vector_address) __frame(reg[,reg]...)isr(void) { ... } where,regcanbeanyregisterdefinedasanSFR.Thecompilergeneratesawarningifsomeregistersaremissingwhichare normallyrequiredtobepushedandpoppedinaninterruptfunctionprologandepilogtoavoidrun−timeproblems.

Example __interrupt(0x00000008)__frame(r1,r2,r3)voidmy_handler(void) { ... }

Whenyoudonotwanttheinterruptframe(saving/restoringregisters)tobegeneratedyoucanusethecompileroption −−noframe.Inthatcaseyouwillhavetospecifyyourowninterruptframe.Forthisyoucanusetheinlinecapabilitiesofthe compiler.

Ccompileroption−−noframe(Donotgenerateframeforinterrupthandler)insection5.1,CCompilerOptionsinChapter ToolOptionsofthereferencemanual.

1.9.6 SoftwareBreak:__system

Withthe__systemfunctionqualifieryoudefineafunctionwhichcannotbeinterrupted.Afunctiondefinedwiththe__system qualifieriscalledwithaBRKorBRKIinstruction(insteadofabranchinstruction)andreturnswithaRTBDinstruction(insteadof theRTSorRTSDinstruction). Youcannotusethefunctionqualifier__systemoninterruptfunctions.Functionsdefinedwith__systemcannotbeinlined.

Example __systemvoidnon_interruptable(inta,intb) { ... }

ReferalsototheMicroBlazeProcessorReferenceGuide.

1.10 Libraries

TheTASKINGcompilerscomewithstandardClibraries(ISO/IEC9899:1999)andheaderfileswiththeappropriateprototypes forthelibraryfunctions.AllstandardClibrariesareavailableinobjectformatandinCorassemblysourcecode. AnumberofstandardoperationswithinCaretoocomplextogenerateinlinecodefor(toomuchcode).Theseoperationsare implementedasrun−timelibraryfunctionstosavecode.

Seesection3.2,LibraryFunctions,inChapterLibraries,foranextensivedescriptionofallstandardClibraryfunctions.

1−19 MicroBlazeEmbeddedToolsReference

1.10.1 PrintfandScanfRoutines

TheClibraryfunctionsprintf(),fprintf(),vfprintf(),vsprintf(),...callonesinglefunction,_doprint(),that dealswiththeformatstringandarguments.Thesameappliestoallscanftypefunctions,whichcallthefunction_doscan(), andalsoforthewprintfandwscanftypefunctionswhichcall_dowprint()and_dowscan()respectively.TheClibrary containsthreeversionsoftheseroutines:int,longandlonglongversions.Ifyouusefloating−pointtheformatterfunction forfloating−point_doflt()or_dowflt()iscalled.Dependingontheformattingargumentsyouuse,thecorrectroutineis usedfromthelibrary.Ofcoursethelargertheversionoftheroutinethelargeryourproducedcodewillbe. Notethatwhenyoucallanyoftheprintf/scanfroutinesindirect,theargumentsarenotknownandalwaysthelonglong versionwithfloating−pointsupportisusedfromthelibrary.

Example #include

longL;

voidmain(void) { printf("Thisisalong:%ld\n",L); }

Thelinkerextractsthelongversionwithoutfloating−pointsupportfromthelibrary.

Seealsothedescriptionof#pragmaweakinsection1.5,PragmastoControltheCompilerintheuser’smanual.

1−20 2 C++Language

Summary ThischapterdescribestheC++languageimplementationandsomespecific features.

2.1 Introduction

TheTASKINGC++compileroffersanewapproachtohigh−levellanguageprogrammingforyourtargetprocessor.TheC++ compileracceptstheC++languageasdefinedbytheISO/IEC14882:1998standardandmodifiedbyTC1forthatstandard.It alsoacceptsthelanguageextensionsoftheCcompiler(seeChapter1,CLanguage). NotethattheC++languageitselfisnotdescribedinthisdocument.FormoreinformationontheC++language,seethe followingpublications. • TheC++ProgrammingLanguage(secondedition)byBjarneStraustrup(1991,AddisonWesley) • ISO/IEC14882:1998C++standard[ANSI]Moreinformationonthestandardscanbefoundathttp://www.ansi.org/.

2.2 C++LanguageExtensionKeywords

TheC++compilersupportsthesamelanguageextensionkeywordsastheCcompiler.Whenoption−−strictisused,the extensionswillbedisabled. Additionallythefollowinglanguageextensionsaresupported: attributes Attributes,introducedbythekeyword__attribute__,canbeusedondeclarationsofvariables,functions,types,andfields. Thealias,aligned,cdecl,const,constructor,deprecated,destructor,format,format_arg,init_priority, malloc,mode,naked,no_check_memory_usage,no_instrument_function,nocommon,noreturn,packed,pure, section,sentinel,stdcall,transparent_union,unused,used,visibility,volatile,andweakattributesare supported. pragmas TheC++compilersupportsthesamepragmasastheCcompilerandsomeextrapragmasasexplainedinsection2.9,Pragmas toControltheC++Compiler.Pragmasgivedirectionstothecodegeneratorofthecompiler.

2.3 C++DialectAccepted

TheC++compileracceptstheC++languageasdefinedbytheISO/IEC14882:1998standardandmodifiedbyTC1forthat standard. Commandlineoptionsarealsoavailabletoenableanddisableanachronismsandstrictstandard−conformancechecking.

2.3.1 StandardLanguageFeaturesAccepted

ThefollowingfeaturesnotintraditionalC++(theC++languageof"TheAnnotatedC++ReferenceManual"byEllisand Stroustrup(ARM))butinthestandardareimplemented: • Thedependentstatementofanif,while,do−while,orforisconsideredtobeascope,andtherestrictiononhaving suchadependentstatementbeadeclarationisremoved. • Theexpressiontestedinanif,while,do−while,orfor,asthefirstoperandofa"?"operator,orasanoperandofthe "&&",":",or"!"operatorsmayhaveapointer−to−membertypeoraclasstypethatcanbeconvertedtoapointer−to−member typeinadditiontothescalarcasespermittedbytheARM.

2−1 MicroBlazeEmbeddedToolsReference

• Qualifiednamesareallowedinelaboratedtypespecifiers. • Aglobal−scopequalifierisallowedinmemberreferencesoftheformx.::A::Bandp−>::A::B. • Theprecedenceofthethirdoperandofthe"?"operatorischanged. • Ifcontrolreachestheendofthemain()routine,andmain()hasanintegralreturntype,itistreatedasifareturn0; statementwereexecuted. • Pointerstoarrayswithunknownboundsasparametertypesarediagnosedaserrors. • Afunctional−notationcastoftheformA()canbeusedevenifAisaclasswithouta(nontrivial)constructor.Thetemporary createdgetsthesamedefaultinitializationtozeroasastaticobjectoftheclasstype. • Acastcanbeusedtoselectoneoutofasetofoverloadedfunctionswhentakingtheaddressofafunction. • Templatefrienddeclarationsanddefinitionsarepermittedinclassdefinitionsandclasstemplatedefinitions. • Typetemplateparametersarepermittedtohavedefaultarguments. • Functiontemplatesmayhavenontypetemplateparameters. • Areferencetoconstvolatilecannotbeboundtoanrvalue. • Qualificationconversions,suchasconversionfromT** toTconst*const*areallowed. • Digraphsarerecognized. • Operatorkeywords(e.g.,not,and,bitand,etc.)arerecognized. • Staticdatamemberdeclarationscanbeusedtodeclarememberconstants. • Whenoption−−wchar_t−keywordisset,wchar_tisrecognizedasakeywordandadistincttype. • boolisrecognized. • RTTI(run−timetypeidentification),includingdynamic_castandthetypeidoperator,isimplemented. • Declarationsintestedconditions(inif,switch,for,andwhilestatements)aresupported. • Arraynewanddeleteareimplemented. • New−stylecasts(static_cast,reinterpret_cast,andconst_cast)areimplemented. • Definitionofanestedclassoutsideitsenclosingclassisallowed. • mutableisacceptedonnon−staticdatamemberdeclarations. • Namespacesareimplemented,includingusingdeclarationsanddirectives.Accessdeclarationsarebroadenedtomatch thecorrespondingusingdeclarations. • Explicitinstantiationoftemplatesisimplemented. • Thetypenamekeywordisrecognized. • explicitisacceptedtodeclarenon−convertingconstructors. • Thescopeofavariabledeclaredinthefor−init−statementofaforloopisthescopeoftheloop(notthesurrounding scope). • Membertemplatesareimplemented. • Thenewspecializationsyntax(using"template<>")isimplemented. • Cv−qualifiersareretainedonrvalues(inparticular,onfunctionreturnvalues). • Thedistinctionbetweentrivialandnontrivialconstructorshasbeenimplemented,ashasthedistinctionbetweenPODsand non−PODswithtrivialconstructors. • Thelinkagespecificationistreatedaspartofthefunctiontype(affectingfunctionoverloadingandimplicitconversions). • externinlinefunctionsaresupported,andthedefaultlinkageforinlinefunctionsisexternal. • Atypedefnamemaybeusedinanexplicitdestructorcall. • Placementdeleteisimplemented. • Anarrayallocatedviaaplacementnewcanbedeallocatedviadelete. • Covariantreturntypesonoverridingvirtualfunctionsaresupported. • enumtypesareconsideredtobenon−integraltypes. • Partialspecializationofclasstemplatesisimplemented. • Partialorderingoffunctiontemplatesisimplemented. • Functiondeclarationsthatmatchafunctiontemplateareregardedasindependentfunctions,notas"guidingdeclarations" thatareinstancesofthetemplate. • Itispossibletooverloadoperatorsusingfunctionsthattakeenumtypesandnoclasstypes. • Explicitspecificationoffunctiontemplateargumentsissupported.

2−2 C++Language

• Unnamedtemplateparametersaresupported. • Thenewlookuprulesformemberreferencesoftheformx.A::Bandp−>A::Baresupported. • Thenotation::template(and−>template,etc.)issupported. • Inareferenceoftheformf()−>g(),withgastaticmemberfunction,f()isevaluated.TheARMspecifiesthattheleft operandisnotevaluatedinsuchcases. • enumtypescancontainvalueslargerthancanbecontainedinanint. • Defaultargumentsoffunctiontemplatesandmemberfunctionsofclasstemplatesareinstantiatedonlywhenthedefault argumentisusedinacall. • Stringliteralsandwidestringliteralshaveconsttype. • Classnameinjectionisimplemented. • Argument−dependent(Koenig)lookupoffunctionnamesisimplemented. • Classandfunctionnamesdeclaredonlyinunqualifiedfrienddeclarationsarenotvisibleexceptforfunctionsfoundby argument−dependentlookup. • Avoidexpressioncanbespecifiedonareturnstatementinavoidfunction. • Function−try−blocks,i.e.,try−blocksthatarethetop−levelstatementsoffunctions,constructors,ordestructors,are implemented. • Universalcharactersetescapes(e.g.,\uabcd)areimplemented. • Onacallinwhichtheexpressiontotheleftoftheopeningparenthesishasclasstype,overloadresolutionlooksfor conversionfunctionsthatcanconverttheclassobjecttopointer−to−functiontypes,andeachsuchpointed−to"surrogate function"typeisevaluatedalongsideanyothercandidatefunctions. • Dependentnamelookupintemplatesisimplemented.Nondependentnamesarelookeduponlyinthecontextofthe templatedefinition.Dependentnamesarealsolookedupintheinstantiationcontext,viaargument−dependentlookup. • Value−initializationisimplemented.Thisformofinitializationisindicatedbyaninitializerof"()"andcauseszeroingofcertain POD−typedmembers,wheretheusualdefault−initializationwouldleavethemuninitialized. • Apartialspecializationofaclassmembertemplatecannotbeaddedoutsideoftheclassdefinition. • Qualificationconversionsmaybeperformedaspartofthetemplateargumentdeductionprocess. • Theexportkeywordfortemplatesisimplemented.

2.3.2 C++0xLanguageFeaturesAccepted

ThefollowingfeaturesaddedintheworkingpaperforthenextC++standard(expectedtobecompletedin2009orlater)are enabledinC++0xmode(withoption−−c++0x).Severalofthesefeaturesarealsoenabledindefault(nonstrict)C++mode. • A"rightshifttoken"(>>)canbetreatedastwoclosinganglebrackets.Forexample: templatestructS{}; S>s;//OK.Nowhitespaceneeded //betweenclosinganglebrackets. • Thefriendclasssyntaxisextendedtoallownonclasstypesaswellasclasstypesexpressedthroughatypedeforwithoutan elaboratedtypename.Forexample: typedefstructSST; classC{ friendS;//OK(requiresStobeinscope). friendST;//OK(sameas"friendS;"). friendint;//OK(noeffect). friendSconst;//Error:cv−qualifierscannot //appeardirectly. }; • Mixedstringliteralconcatenationsareaccepted(afeaturecarriedoverfrom): wchar_t*str="a"L"b";//OK,sameasL"ab". • Variadicmacrosandemptymacroargumentsareaccepted,asinC99. • Atrailingcommainthedefinitionofanenumerationtypeissilentlyaccepted(afeaturecarriedoverfromC99): enumE{e,};

2−3 MicroBlazeEmbeddedToolsReference

• Ifthecommandlineoption−−long−longisspecified,thetypelonglongisaccepted.Unsuffixedintegerliteralsthat cannotberepresentedbytypelong,butcouldpotentiallyberepresentedbytypeunsignedlong,havetypelonglong instead(thismatchesC99,butnotthetreatmentofthelonglongextensioninC89ordefaultC++mode). • Thekeywordtypenamefollowedbyaqualified−idcanappearoutsideatemplatedeclaration. structS{structN{};}; typenameS::N*p;//SilentlyacceptedinC++0xmode

2.3.3 AnachronismsAccepted

Thefollowinganachronismsareacceptedwhenanachronismsareenabled(with−−anachronisms): • overloadisallowedinfunctiondeclarations.Itisacceptedandignored. • Definitionsarenotrequiredforstaticdatamembersthatcanbeinitializedusingdefaultinitialization.Theanachronismdoes notapplytostaticdatamembersoftemplateclasses;theymustalwaysbedefined. • Thenumberofelementsinanarraymaybespecifiedinanarraydeleteoperation.Thevalueisignored. • Asingleoperator++()andoperator−−()functioncanbeusedtooverloadbothprefixandpostfixoperations. • Thebaseclassnamemaybeomittedinabaseclassinitializerifthereisonlyoneimmediatebaseclass. • Assignmenttothisinconstructorsanddestructorsisallowed.Thisisallowedonlyifanachronismsareenabledandthe "assignmenttothis"configurationparameterisenabled. • Aboundfunctionpointer(apointertoamemberfunctionforagivenobject)canbecasttoapointertoafunction. • Anestedclassnamemaybeusedasanon−nestedclassnameprovidednootherclassofthatnamehasbeendeclared. Theanachronismisnotappliedtotemplateclasses. • Areferencetoanon−consttypemaybeinitializedfromavalueofadifferenttype.Atemporaryiscreated,itisinitialized fromthe(converted)initialvalue,andthereferenceissettothetemporary. • Areferencetoanon−constclasstypemaybeinitializedfromanrvalueoftheclasstypeoraderivedclassthereof.No (additional)temporaryisused. • Afunctionwithold−styleparameterdeclarationsisallowedandmayparticipateinfunctionoverloadingasthoughitwere prototyped.Defaultargumentpromotionisnotappliedtoparametertypesofsuchfunctionswhenthecheckforcompatibility isdone,sothatthefollowingdeclarestheoverloadingoftwofunctionsnamedf: intf(int); intf(x)charx;{returnx;}

NotethatinCthiscodeislegalbuthasadifferentmeaning:atentativedeclarationoffisfollowedbyitsdefinition. • Whenoption−−nonconst−ref−anachronismisset,areferencetoanon−constclasscanbeboundtoaclassrvalueofthe sametypeoraderivedtypethereof. structA{ A(int); Aoperator=(A&); Aoperator+(constA&); }; main(){ Ab(1); b=A(1)+A(2);//Allowedasanachronism }

2.3.4 ExtensionsAcceptedinNormalC++Mode

Thefollowingextensionsareacceptedinallmodes(exceptwhenstrictANSI/ISOviolationsarediagnosedaserrorsorwere explicitlynoted): • Afrienddeclarationforaclassmayomittheclasskeyword: classA{ friendB;//Shouldbe"friendclassB" };

2−4 C++Language

• Constantsofscalartypemaybedefinedwithinclasses: classA{ constintsize=10; inta[size]; }; • Inthedeclarationofaclassmember,aqualifiednamemaybeused: structA{ intA::f();//Shouldbeintf(); }; • Therestrictkeywordisallowed. • Implicittypeconversionbetweenapointertoanextern"C"functionandapointertoanextern"C++"functionis permitted.Here’sanexample: extern"C"voidf();//f’stypehasextern"C"linkage void(*pf)()//pfpointstoanextern"C++"function =&f;//errorunlessimplicitconversionis //allowed

ThisextensionisallowedinenvironmentswhereCandC++functionssharethesamecallingconventions.Itisenabledby default. • A"?"operatorwhosesecondandthirdoperandsarestringliteralsorwidestringliteralscanbeimplicitlyconvertedto"char *"or"wchar_t*".(RecallthatinC++stringliteralsareconst.Thereisadeprecatedimplicitconversionthatallows conversionofastringliteralto"char*",droppingtheconst.Thatconversion,however,appliesonlytosimplestring literals.Allowingitfortheresultofa"?"operationisanextension.) char*p=x?"abc":"def"; • Defaultargumentsmaybespecifiedforfunctionparametersotherthanthoseofatop−levelfunctiondeclaration(e.g.,they areacceptedontypedefdeclarationsandonpointer−to−functionandpointer−to−member−functiondeclarations). • Non−staticlocalvariablesofanenclosingfunctioncanbereferencedinanon−evaluatedexpression(e.g.,asizeof expression)insidealocalclass.Awarningisissued. • IndefaultC++mode,thefriendclasssyntaxisextendedtoallownonclasstypesaswellasclasstypesexpressedthrougha typedeforwithoutanelaboratedtypename.Forexample: typedefstructSST; classC{ friendS;//OK(requiresStobeinscope). friendST;//OK(sameas"friendS;"). friendint;//OK(noeffect). friendSconst;//Error:cv−qualifierscannot //appeardirectly. }; • IndefaultC++mode,mixedstringliteralconcatenationsareaccepted.(ThisisafeaturecarriedoverfromC99andalso availableinGNUmodes). wchar_t*str="a"L"b";//OK,sameasL"ab". • IndefaultC++mode,variadicmacrosareaccepted.(ThisisafeaturecarriedoverfromC99andalsoavailableinGNU modes.) • IndefaultC++mode,emptymacroargumentsareaccepted(afeaturecarriedoverfromC99). • Atrailingcommainthedefinitionofanenumerationtypeissilentlyaccepted(afeaturecarriedoverfromC99): enumE{e,};

2.4 GNUExtensions

TheC++compilercanbeconfiguredtosupporttheGNUC++mode(commandlineoption−−g++).Inthismode,many extensionsprovidedbytheGNUC++compilerareaccepted.ThefollowingextensionsareprovidedinGNUC++mode. • Extendeddesignatorsareaccepted • Compoundliteralsareaccepted.

2−5 MicroBlazeEmbeddedToolsReference

• Non−standardanonymousunionsareaccepted • Thetypeofoperatorissupported.Thisoperatorcantakeanexpressionoratype(likethesizeofoperator,but parenthesesarealwaysrequired)andexpandstothetypeofthegivenentity.Itcanbeusedwhereveratypedefnameis allowed typeof(2*2.3)d;//Declaresa"double" typeof(int)i;//Declaresan"int"

Thiscanbeusefulinmacroandtemplatedefinitions. • The__extension__keywordisacceptedprecedingdeclarationsandcertainexpressions.Ithasnoeffectonthemeaning ofaprogram. __extension____inline__intf(inta){ returna>0?a/2:f(__extension__1−a); } • InallGNUCmodesandinGNUC++modeswithgnu_version<30400,thetypemodifierssigned,unsigned,longandshort canbeusedwithtypedeftypesifthespecifierisvalidwiththeunderlyingtypeofthetypedefinANSIC.E.g.: typedefintI; unsignedI*pui;//OKinGNUC++mode; //sameas"unsignedint*pui" • Ifthecommandlineoption−−long−longisspecified,theextensionsforthelonglongandunsignedlonglongtypes areenabled. • Zero−lengtharraytypes(specifiedby[0])aresupported.Thesearecompletetypesofsizezero. • C99−styleflexiblearraymembersareaccepted.Inaddition,thelastfieldofaclasstypehaveaclasstypewhoselastfieldis aflexiblearraymember.InGNUC++mode,flexiblearraymembersaretreatedexactlylikezero−lengtharrays,andcan thereforeappearanywhereintheclasstype. • TheC99_Pragmaoperatorissupported. • Thegccbuilt−inandfacilities(__builtin_va_list,__builtin_va_arg,...)areaccepted. • Thesizeofoperatorisapplicabletovoidandtofunctiontypesandevaluatestothevalueone. • Variablescanberedeclaredwithdifferenttop−levelcv−qualifiers(thenewqualificationismergedintoexistingqualifiers).For example: externintvolatilex; intconstx=32;//xisnowconstvolatile • The"assemblername"ofvariablesandroutinescanbespecified.Forexample: intcounter__asm__("counter_v1")=0; • Registervariablescanbemappedonspecificregistersusingtheasmkeyword. registerintiasm("eax"); //Map"i"ontoregistereax. • Thekeywordinlineisignored(withawarning)onvariabledeclarationsandonblock−externfunctiondeclarations. • Excessaggregateinitializersareignoredwithawarning. structS{inta,b;}; structSa1={1,2,3}; //"3"ignoredwithawarning;noerror inta2[2]={7,8,9}; //"9"ignoredwithawarning;noerror • Expressionsoftypesvoid*,voidconst*,voidvolatile*andvoidconstvolatile*canbedereferenced;the resultisanlvalue. • The__restrict__keywordisaccepted.ItisidenticaltotheC99restrictkeyword,exceptforitsspelling. • Out−of−rangefloating−pointvaluesareacceptedwithoutadiagnostic.WhenIEEEfloating−pointisbeingused,the"infinity" valueisused. • Extendedvariadicmacrosaresupported. • Dollarsigns($)areallowedinidentifiers. • Hexadecimalfloatingpointconstantsarerecognized.

2−6 C++Language

• The__asm__keywordisrecognizedandequivalenttotheasmtoken.Extendedsyntaxissupportedtoindicatehow assemblyoperandsmaptoC/C++variables. asm("fsinx%1,%0":"=f"(x):"f"(a)); //Maptheoutputoperandon"x", //andtheinputoperandon"a". • The\eescapesequenceisrecognizedandstandsfortheASCII"ESC"character. • Theaddressofastatementlabelcanbetakenbyuseoftheprefix"&&"operator,e.g.,void*a=&&L.Atransfertothe addressofalabelcanbedonebythe"goto*"statement,e.g.,goto*a. • Multi−linestringsaresupported,e.g., char*p="abc def"; • ASCII"NULL"charactersareacceptedinsourcefiles. • Asourcefilecanendwithabackslash("\")character. • Caseranges(e.g.,"case’a’...’z’:")aresupported. • AnumberofmacrosarepredefinedinGNUmode.Seesection2.10,PredefinedMacros. • Apredefinedmacrocanbeundefined. • Alargenumberofspecialfunctionsoftheform__builtin_xyz(e.g.,__builtin_alloca)arepredeclared. • Someexpressionsareconsideredtobeconstant−expressionseventhoughtheyarenotsoconsideredinstandardCand C++.Examplesinclude"((char*)&((structS*)0)−>c[0])−(char*)0"and"(int)"Hello"&0". • Themacro__GNUC__ispredefinedtothemajorversionnumberoftheemulatedGNUcompiler.Similarly,themacros __GNUC_MINOR__and__GNUC_PATCHLEVEL__arepredefinedtothecorrespondingminorversionnumberandpatch level.Finally,__VERSION__ispredefinedtoastringdescribingthecompilerversion. • The__threadspecifiercanbeusedtoindicatethatavariableshouldbeplacedinthread−localstorage(requires gnu_version>=30400). • Anexterninlinefunctionthatisreferencedbutnotdefinedispermitted(withawarning). • Trigraphsareignored(withawarning). • Non−standardcastsareallowedinnullpointerconstants,e.g.,(int)(int*)0isconsideredanullpointerconstantin spiteofthepointercastinthemiddle. • Statementexpressions,e.g.,({intj;j=f();j;)}areaccepted.Branchesintoastatementexpressionarenot allowed.InC++mode,branchesoutarealsonotallowed.Variable−lengtharrays,destructibleentities,try,catch,local non−PODclassdefinitions,anddynamically−initializedlocalstaticvariablesarenotallowedinsideastatementexpression. • Labelscanbedeclaredtobelocalinstatementexpressionsbyintroducingthemwitha__label__declaration. ({__label__lab;inti=4;lab:i=2*i−1;if(!(i%17))gotolab;i;}) • Not−evaluatedpartsofconstantexpressionscancontainnon−constantterms: inti; inta[1||i];//Acceptedingcc/g++mode • Castsonanlvaluethatdon’tfallundertheusual"lvaluecast"interpretation(e.g.,becausetheycasttoatypehavinga differentsize)areignored,andtheoperandremainsanlvalue.Awarningisissued. inti; (short)i=0;//Accepted,castisignored;entireintisset • Variablelengtharrays(VLAs)aresupported.GNUCalsoallowsVLAtypesforfieldsoflocalstructures,whichcanleadto run−timedependentsizesandoffsets.TheC++compilerdoesnotimplementthis,butinsteadtreatssucharraysashaving lengthzero(withawarning);thisenablessomepopularprogrammingidiomsinvolvingfieldswithVLAtypes. voidf(intn){ struct{ inta[n];//Warning:nignoredand //replacedbyzero }; } • Complextypeextensionsaresupported(thesearethesameastheC99complextypefeatures,withtheeliminationof _Imaginaryandtheadditionof__complex,__real,__imag,theuseof"~"todenotecomplexconjugation,andcomplex literalssuchas"1.2i").

2−7 MicroBlazeEmbeddedToolsReference

• Ifanexplicitinstantiationdirectiveisprecededbythekeywordextern,no(explicitorimplicit)instantiationisforthe indicatedspecialization. • Anexplicitinstantiationdirectivethatnamesaclassmayomittheclasskeyword,andmayrefertoatypedef. • Anexplicitinstantiationorexterntemplatedirectivethatnamesaclassisacceptedinaninvalidnamespace. • std::type_infodoesnotneedtobeintroducedwithaspecialpragma. • Aspecialkeyword__nullexpandstothesameconstantastheliteral"0",butisexpectedtobeusedasanullpointer constant. • Whengnu_version<30400,namesfromdependentbaseclassesareignoredonlyifanothernamewouldbefoundbythe lookup. constintn=0; templatestructB{ staticconstintm=1;staticconstintn=2; }; templatestructD:B{ intf(){returnm+n;} //B::m+::ning++mode }; • Anon−staticdatamemberfromadependentbaseclass,whichwouldusuallybeignoredasdescribedabove,isfoundifthe lookupwouldhaveotherwisefoundanonstaticdatamemberofanenclosingclass(whengnu_versionis<30400). templatestructC{ structA{inti;}; structB:publicA{ voidf(){ i=0;//g++usesA::inotC::i } }; inti; }; • Anewoperationinatemplateisalwaystreatedasdependent(whengnu_version>=30400). templatestructA{ voidf(){ void*p=0; new(&p)int(0);//callsoperatornew //declaredbelow } }; void*operatornew(size_t,void*p); • Whendoingnamelookupinabaseclass,theinjectedclassnameofatemplateclassisignored. namespaceN{ templatestructA{}; } structA{ inti; }; structB:N::A{ B(){Ax;x.i=1;}//g++uses::A,notN::A }; • Theinjectedclassnameisfoundincertaincontextsinwhichtheconstructorshouldbefoundinstead. structA{ A(int){}; }; A::Aa(1);

2−8 C++Language

• Inaconstructordefinition,whatshouldbetreatedasatemplateargumentlistoftheconstructorisinsteadtreatedasthe templateargumentlistoftheenclosingclass. templatestructA{}; template<>structA<1>{ templateA(Ti,intj); };

template<>A<1>::A<1>(inti,intj){} //accepteding++mode • Adifferenceincallingconventionisignoredwhenredeclaringatypedef. typedefvoidF();

extern"C"{ typedefvoidF();//AcceptedinGNUC++mode //(errorotherwise) } • Themacro__GNUG__isdefinedidenticallyto__GNUC__(i.e.,themajorversionnumberoftheGNUcompilerversionthat isbeingemulated). • Themacro_GNU_SOURCEisdefinedas"1". • Guidingdeclarations(afeaturepresentinearlydraftsofthestandard,butnotinthefinalstandard)aredisabled. • Namespacestdispredeclared. • Noconnectionismadebetweendeclarationsofidenticalnamesindifferentscopesevenwhenthesenamesaredeclared extern"C".E.g., extern"C"{voidf(int);} namespaceN{ extern"C"{ voidf(){}//Warning(noterror)ing++mode } } intmain(){f(1);}

ThisexampleisacceptedbytheC++compiler,butitwillemittwoconflictingdeclarationsforthefunctionf. • Whenausing−directivelookupencountersmorethanoneextern"C"declaration(createdwhenmorethanone namespacedeclaresanextern"C"functionofagivenname,asdescribedabove),onlythefirstdeclarationencountered isconsideredforthelookup. extern"C"intf(void); extern"C"intg(void); namespaceN{ extern"C"intf(void);//sametype extern"C"voidg(void);//differenttype }; usingnamespaceN; inti=f();//calls::f intj=g();//calls::f • Thedefinitionofamemberofaclasstemplatethatappearsoutsideoftheclassdefinitionmaydeclareanontypetemplate parameterwithatypethatisdifferentthanthetypeusedinthedefinitionoftheclasstemplate.Awarningisissued(GNU version30300andbelow). templatestructA{voidf();}; templatevoidA::f(){} • Aclasstemplatemayberedeclaredwithanontypetemplateparameterthathasatypethatisdifferentthanthetypeusedin theearlierdeclaration.Awarningisissued. templateclassA; templateclassA{};

2−9 MicroBlazeEmbeddedToolsReference

• Afrienddeclarationmayrefertoamembertypedef. classA{ classB{}; typedefBmy_b; friendclassmy_b; }; • Whenafriendclassisdeclaredwithanunqualifiedname,thelookupofthatnameisnotrestrictedtothenearestenclosing namespacescope. structS; namespaceN{ classC{ friendstructS;//::Sing++mode, //N::Sindefaultmode }; } • Afriendclassdeclarationcanrefertonamesmadevisiblebyusing−directives. namespaceN{structA{};} usingnamespaceN; structB{ voidf(){Aa;} friendstructA;//ing++modeN::A, };//notanewdeclarationof::A • Aninheritedtypenamecanbeusedinaclassdefinitionandlaterredeclaredasatypedef. structA{typedefintI;}; structB:A{ typedefIJ;//ReferstoA::I typedefdoubleI;//Accepteding++mode };//(introducesB::I) • Inacatchclause,anentitymaybedeclaredwiththesamenameasthehandlerparameter. try{} catch(inte){ chare; } • Thediagnosticissuedforanexceptionspecificationmismatchisreducedtoawarningifthepreviousdeclarationwasfound inasystemheader. • Theexceptionspecificationforanexplicittemplatespecialization(forafunctionormemberfunction)doesnothavetomatch theexceptionspecificationofthecorrespondingprimarytemplate. • Atemplateargumentlistmayappearfollowingaconstructornameinconstructordefinitionthatappearsoutsideoftheclass definition: templatestructA{ A(); }; templateA::A(){} • Whengnu_version<30400,anincompletetypecanbeusedasthetypeofanonstaticdatamemberofaclasstemplate. classB; templatestructA{ Bb; };

2−10 C++Language

• Aconstructorneednotprovideaninitializerforeverynonstaticconstdatamember(butawarningisstillissuedifsuchan initializerismissing). structS{ intconstic; S(){}//WarningonlyinGNUC++mode //(errorotherwise). }; • Exceptionspecificationsareignoredonfunctiondefinitionswhensupportforexceptionhandlingisdisabled(normally,they areonlyignoredonfunctiondeclarationsthataren’tdefinitions). • Afrienddeclarationinaclasstemplatemayrefertoanundeclaredtemplate. templatestructA{ friendvoidf<>(A); }; • Whengnu_versionis<30400,thesemanticanalysisofafriendfunctiondefinedinaclasstemplateisperformedonlyifthe functionisactuallyusedandisdoneattheendofthetranslationunit(insteadofatthepointoffirstuse). • Afunctiontemplatedefaultargumentmayberedeclared.Awarningisissuedandthedefaultfromtheinitialdeclarationis used. templatevoidf(inti=1); templatevoidf(inti=2){} intmain(){ f(); } • Adefinitionofamemberfunctionofaclasstemplatethatappearsoutsideoftheclassmayspecifyadefaultargument. templatestructA{voidf(T);}; templatevoidA::f(Tvalue=T()){} • Functiondeclarations(thatarenotdefinitions)canhaveduplicateparameternames. voidf(inti,inti);//AcceptedinGNUC++mode • Defaultargumentsareretainedaspartofdeducedfunctiontypes. • Anamespacemembermayberedeclaredoutsideofitsnamespace. • Atemplatemayberedeclaredoutsideofitsclassornamespace. namespaceN{ template<typenameT>structS{}; } template<typenameT>structN::S; • Theinjectedclassnameofaclasstemplatecanbeusedasatemplatetemplateargument. templateclassT>structA{}; templatestructB{ Aa; }; • Apartialspecializationmaybedeclaredafteraninstantiationhasbeendonethatwouldhaveusedthepartialspecialization ifithadbeendeclaredearlier.Awarningisissued. templateclassX{}; Xxi; templateclassX{}; • The"."or"−>"operatormaybeusedinanintegralconstantexpressioniftheresultisanintegralorenumerationconstant: structA{enum{e1=1};}; intmain(){ Aa; intx[a.e1];//AcceptedinGNUC++mode return0; }

2−11 MicroBlazeEmbeddedToolsReference

• Strongusing−directivesaresupported. usingnamespacedebug__attribute__((strong)); • Partialspecializationsthatareunusablebecauseofnondeductibletemplateparametersareacceptedandignored. templatestructA{classC{};}; templatestructB{enum{e=1};}; templatestructB::C>{enum{e=2};}; intmain(intargc,char**argv){ printf("%d\n",B::e); printf("%d\n",B::C>::e); } • Templateparametersthatarenotusedinthesignatureofafunctiontemplatearenotignoredforpartialorderingpurposes (i.e.,theresolutionofcorelanguageissue214isnotimplemented)whengnu_versionis<40100. templatevoidf(Tt); templatevoidf(Tt); intmain(){ f(3);//notambiguouswhengnu_version //is<40100 } • Prototypeinstantiationsoffunctionsaredeferreduntilthefirstactualinstantiationofthefunctiontoallowthecompilationof programsthatcontaindefinitionsofunusablefunctiontemplates(gnu_version30400andabove).Theexamplebelowis acceptedwhenprototypeinstantiationsaredeferred. classA{}; templatestructB{ B(){};//error:noinitializerfor //referencemember"B::a" A&a; }; • Whendoingnonclassprototypeinstantiations(e.g.,gnu_version30400andabove),theseverityofthediagnosticissuedifa consttemplatestaticdatamemberisdefinedwithoutaninitializerisreducedtoawarning. templatestructA{ staticconstinti; }; templateconstintA::i; • Whendoingnonclassprototypeinstantiations(e.g.,gnu_version30400andabove),atemplatestaticdatamemberwithan invalidaggregateinitializerisaccepted(theerrorisdiagnosedifthestaticdatamemberisinstantiated). structA{ A(doubleval); }; templatestructB{ staticconstAI[1]; }; templateconstAB::I[1]={ {1.,0.,0.,0.} };

ThefollowingGNUextensionsarenotcurrentlysupported: • Theforwarddeclarationoffunctionparameters(sotheycanparticipateinvariable−lengtharrayparameters). • GNU−stylecomplexintegraltypes(complexfloating−pointtypesaresupported) • Nestedfunctions

2−12 C++Language

2.5 NamespaceSupport

Namespacesareenabledbydefault.Youcanusethecommandlineoption−−no−namespacestodisablethefeatures. Whendoingnamelookupinatemplateinstantiation,somenamesmustbefoundinthecontextofthetemplatedefinitionwhile othersmayalsobefoundinthecontextofthetemplateinstantiation.TheC++compilerimplementstwodifferentinstantiation lookupalgorithms:theonemandatedbythestandard(referredtoas"dependentnamelookup"),andtheonethatexistedbefore dependentnamelookupwasimplemented. Dependentnamelookupisdoneinstrictmode(unlessexplicitlydisabledbyanothercommandlineoption)orwhendependent nameprocessingisenabledbyeitheraconfigurationflagorcommandlineoption.

DependentNameProcessing Whendoingdependentnamelookup,theC++compilerimplementstheinstantiationnamelookuprulesspecifiedinthe standard.Thisprocessingrequiresthatnon−classprototypeinstantiationsbedone.Thisinturnrequiresthatthecodebewritten usingthetypenameandtemplatekeywordsasrequiredbythestandard.

LookupUsingtheReferencingContext Whennotusingdependentnamelookup,theC++compilerusesanamelookupalgorithmthatapproximatesthetwo−phaselookup ruleofthestandard,butdoessoinsuchawaythatismorecompatiblewithexistingcodeandexistingcompilers. Whenanameislookedupaspartofatemplateinstantiationbutisnotfoundinthelocalcontextoftheinstantiation,itislooked upinasynthesizedinstantiationcontextthatincludesbothnamesfromthecontextofthetemplatedefinitionandnamesfrom thecontextoftheinstantiation.Here’sanexample: namespaceN{ intg(int); intx=0; templatestructA{ Tf(Tt){returng(t);} Tf(){returnx;} }; } namespaceM{ intx=99; doubleg(double); N::Aai; inti=ai.f(0);//N::A::f(int)calls //N::g(int) inti2=ai.f();//N::A::f()returns //0(=N::x) N::Aad; doubled=ad.f(0);//N::A::f(double) //callsM::g(double) doubled2=ad.f();//N::A::f()also //returns0(=N::x) }

Thelookupofnamesintemplateinstantiationsdoesnotconformtotherulesinthestandardinthefollowingrespects: • Althoughonlynamesfromthetemplatedefinitioncontextareconsideredfornamesthatarenotfunctions,thelookupisnot limitedtothosenamesvisibleatthepointatwhichthetemplatewasdefined. • Functionsfromthecontextinwhichthetemplatewasreferencedareconsideredforallfunctioncallsinthetemplate. Functionsfromthereferencingcontextshouldonlybevisiblefor"dependent"functioncalls. ArgumentDependentLookup Whenargument−dependentlookupisenabled(thisisthedefault),functionsmadevisibleusingargument−dependentlookup overloadwiththosemadevisiblebynormallookup.Thestandardrequiresthatthisoverloadingoccursevenwhenthename foundbynormallookupisablockexterndeclaration.TheC++compilerdoesthisoverloading,butindefaultmode, argument−dependentlookupissuppressedwhenthenormallookupfindsablockextern.

2−13 MicroBlazeEmbeddedToolsReference

Thismeansaprogramcanhavedifferentbehavior,dependingonwhetheritiscompiledwithorwithoutargument−dependent lookup−−no−arg−dep−lookup,eveniftheprogrammakesnouseofnamespaces.Forexample: structA{}; Aoperator+(A,double); voidf(){ Aa1; Aoperator+(A,int); a1+1.0;//callsoperator+(A,double) //witharg−dependentlookupenabledbut //otherwisecallsoperator+(A,int); }

2.6 TemplateInstantiation

TheC++languageincludestheconceptoftemplates.Atemplateisadescriptionofaclassorfunctionthatisamodelfora familyofrelatedclassesorfunctions.1Forexample,onecanwriteatemplateforaStackclass,andthenuseastackof integers,astackoffloats,andastackofsomeuser−definedtype.Inthesource,thesemightbewrittenStack, Stack,andStack.Fromasinglesourcedescriptionofthetemplateforastack,thecompilercancreate instantiationsofthetemplateforeachofthetypesrequired. Theinstantiationofaclasstemplateisalwaysdoneassoonasitisneededinacompilation.However,theinstantiationsof templatefunctions,memberfunctionsoftemplateclasses,andstaticdatamembersoftemplateclasses(hereafterreferredtoas templateentities)arenotnecessarilydoneimmediately,forseveralreasons: • Onewouldliketoendupwithonlyonecopyofeachinstantiatedentityacrossalltheobjectfilesthatmakeupaprogram. (Thisofcourseappliestoentitieswithexternallinkage.) • Thelanguageallowsonetowriteaspecializationofatemplateentity,i.e.,aspecificversiontobeusedinplaceofaversion generatedfromthetemplateforaspecificdatatype.(Onecould,forexample,writeaversionofStack,orofjust Stack::push,thatreplacesthetemplate−generatedversion;often,suchaspecializationprovidesamoreefficient representationforaparticulardatatype.)Sincethecompilercannotknow,whencompilingareferencetoatemplateentity,if aspecializationforthatentitywillbeprovidedinanothercompilation,itcannotdotheinstantiationautomaticallyinany sourcefilethatreferencesit. • C++templatescanbeexported(i.e.,declaredwiththekeywordexport).Suchtemplatescanbeusedinatranslationunit thatdoesnotcontainthedefinitionofthetemplatetoinstantiate.Theinstantiationofsuchatemplatemustbedelayeduntil thetemplatedefinitionhasbeenfound. • Thelanguagealsodictatesthattemplatefunctionsthatarenotreferencedshouldnotbecompiled,that,infact,such functionsmightcontainsemanticerrorsthatwouldpreventthemfrombeingcompiled.Therefore,areferencetoatemplate classshouldnotautomaticallyinstantiateallthememberfunctionsofthatclass. (Itshouldbenotedthatcertaintemplateentitiesarealwaysinstantiatedwhenused,e.g.,inlinefunctions.) Fromtheserequirements,onecanseethatifthecompilerisresponsiblefordoingalltheinstantiationsautomatically,itcanonly dosoonaprogram−widebasis.Thatis,thecompilercannotmakedecisionsaboutinstantiationoftemplateentitiesuntilithas seenallthesourcefilesthatmakeupacompleteprogram. ThisC++compilerprovidesaninstantiationmechanismthatdoesautomaticinstantiationatlinktime.Forcaseswhereyouwant moreexplicitcontroloverinstantiation,theC++compileralsoprovidesinstantiationmodesandinstantiationpragmas,whichcan beusedtoexertfine−grainedcontrolovertheinstantiationprocess.

2.6.1 AutomaticInstantiation

Thegoalofanautomaticinstantiationmodeistoprovidepainlessinstantiation.Youshouldbeabletocompilesourcefilesto objectcode,thenlinkthemandruntheresultingprogram,andneverhavetoworryabouthowthenecessaryinstantiationsget done. Inpractice,thisishardforacompilertodo,anddifferentcompilersusedifferentautomaticinstantiationschemeswithdifferent strengthsandweaknesses:

1Sincetemplatesaredescriptionsofentities(typically,classes)thatareparameterizableaccordingtothe typestheyoperateupon,theyaresometimescalledparameterizedtypes.

2−14 C++Language

• AT&T/USL/Novell’scfrontproductsavesinformationabouteachfileitcompilesinaspecialdirectorycalledptrepository. Itinstantiatesnothingduringnormalcompilations.Atlinktime,itlooksforentitiesthatarereferencedbutnotdefined,and whosemanglednamesindicatethattheyaretemplateentities.Foreachsuchentity,itconsultstheptrepository informationtofindthefilecontainingthesourcefortheentity,anditdoesacompilationofthesourcetogenerateanobject filecontainingobjectcodeforthatentity.Thisobjectcodeforinstantiatedobjectsisthencombinedwiththe"normal"object codeinthelinkstep. Ifyouareusingcfrontyoumustfollowaparticularcodingconvention:alltemplatesmustbedeclaredin.hfiles,andforeach suchfiletheremustbeacorresponding.ccfilecontainingtheassociateddefinitions.Thecompilerisnevertoldaboutthe .ccfilesexplicitly;onedoesnot,forexample,compiletheminthenormalway.Thelinksteplooksforthemwhenandifit needsthem,anddoessobytakingthe.hfilenameandreplacingitssuffix.2 Thisschemehasthedisadvantagethatitdoesaseparatecompilationforeachinstantiatedfunction(or,atbest,one compilationforallthememberfunctionsofoneclass).Eventhoughthefunctionitselfisoftenquitesmall,itmustbe compiledalongwiththedeclarationsforthetypesonwhichtheinstantiationisbased,andthosedeclarationscaneasilyrun intomanythousandsoflines.Forlargesystems,thesecompilationscantakeaverylongtime.Thelinksteptriestobesmart aboutrecompilinginstantiationsonlywhennecessary,butbecauseitkeepsnofine−graineddependencyinformation,itis oftenforcedto"recompiletheworld"foraminorchangeina.hfile.Inaddition,cfronthasnowayofensuringthat preprocessingsymbolsaresetcorrectlywhenitdoestheseinstantiationcompilations,ifpreprocessingsymbolsaresetother thanonthecommandline. • Borland’sC++compilerinstantiateseverythingreferencedinacompilation,thenusesaspeciallinkertoremoveduplicate definitionsofinstantiatedfunctions. IfyouareusingBorland’scompileryoumustmakesurethateverycompilationseesallthesourcecodeitneedsto instantiateallthetemplateentitiesreferencedinthatcompilation.Thatis,onecannotrefertoatemplateentityinasource fileifadefinitionforthatentityisnotincludedbythatsourcefile.Inpractice,thismeansthateitherallthedefinitioncodeis putdirectlyinthe.hfiles,orthateach.hfileincludesanassociated.cc(actually,.cpp)file. Ourapproachisalittledifferent.Itrequiresthat,foreachinstantiationofanon−exportedtemplate,thereissome(normal, top−level,explicitly−compiled)sourcefilethatcontainsthedefinitionofthetemplateentity,areferencethatcausesthe instantiation,andthedeclarationsofanytypesrequiredfortheinstantiation.3Thisrequirementcanbemetinvariousways: • TheBorlandconvention:each.hfilethatdeclaresatemplateentityalsocontainseitherthedefinitionoftheentityor includesanotherfilecontainingthedefinition. • Implicitinclusion:whenthecompilerseesatemplatedeclarationina.hfileanddiscoversaneedtoinstantiatethatentity,it isgivenpermissiontogoofflookingforanassociateddefinitionfilehavingthesamebasenameandadifferentsuffix,andit implicitlyincludesthatfileattheendofthecompilation.Thismethodallowsmostprogramswrittenusingthecfront conventiontobecompiledwithourapproach.Seesection2.6.4,ImplicitInclusion. • Theadhocapproach:youmakesurethatthefilesthatdefinetemplateentitiesalsohavethedefinitionsofalltheavailable types,andaddcodeorpragmasinthosefilestorequestinstantiationoftheentitiesthere. Exportedtemplatesarealsosupportedbyourautomaticinstantiationmethod,buttheyrequireadditionalmechanismsexplained furtheron. Theautomaticinstantiationmodeisenabledbydefault.Itcanbeturnedoffbythecommandlineoption −−no−auto−instantiation.Ifautomaticinstantiationisturnedoff,theextrainformationabouttemplateentitiesthatcouldbe instantiatedinafileisnotputintotheobjectfile.

2.6.2 InstantiationModes

Normally,whenafileiscompiled,templateentitiesareinstantiatedeverywherewheretheyareused.Theoverallinstantiation modecan,however,bechangedbyacommandlineoption: −−instantiate=used Instantiatethosetemplateentitiesthatwereusedinthecompilation.Thiswillincludeallstaticdatamembersforwhichthere aretemplatedefinitions.Thisisthedefault.

2Theactualimplementationallowsforseveraldifferentsuffixesandprovidesacommandlineoptionto changethesuffixessought. 3Isn’tthisalwaysthecase?No.SupposethatfileAcontainsadefinitionofclassXandareferenceto Stack::push,andthatfileBcontainsthedefinitionforthememberfunctionpush.Therewouldbeno filecontainingboththedefinitionofpushandthedefinitionofX. 2−15 MicroBlazeEmbeddedToolsReference

−−instantiate=all Instantiatealltemplateentitiesdeclaredorreferencedinthecompilationunit.Foreachfullyinstantiatedtemplateclass,allof itsmemberfunctionsandstaticdatamemberswillbeinstantiatedwhetherornottheywereused.Non−membertemplate functionswillbeinstantiatedeveniftheonlyreferencewasadeclaration. −−instantiate=local Similarto−−instantiate=usedexceptthatthefunctionsaregiveninternallinkage.Thisisintendedtoprovideaverysimple mechanismforthosegettingstartedwithtemplates.Thecompilerwillinstantiatethefunctionsthatareusedineach compilationunitaslocalfunctions,andtheprogramwilllinkandruncorrectly(barringproblemsduetomultiplecopiesof localstaticvariables.)However,onemayendupwithmanycopiesoftheinstantiatedfunctions,sothisisnotsuitablefor productionuse.−−instantiate=localcannotbeusedinconjunctionwithautomatictemplateinstantiation.Ifautomatic instantiationisenabledbydefault,itwillbedisabledbythe−−instantiate=localoption. Inthecasewherethecontrolprogramiscalledwithasinglefiletocompileandlink,e.g., ccmbtest.cc thecompilerknowsthatallinstantiationswillhavetobedoneinthesinglesourcefile.Therefore,itusesthe −−instantiate=usedmodeandsuppressesautomaticinstantiation.

2.6.3 Instantiation#pragmaDirectives

Instantiationpragmascanbeusedtocontroltheinstantiationofspecifictemplateentitiesorsetsoftemplateentities.Thereare threeinstantiationpragmas: • Theinstantiatepragmacausesaspecifiedentitytobeinstantiated. • Thedo_not_instantiatepragmasuppressestheinstantiationofaspecifiedentity.Itistypicallyusedtosuppressthe instantiationofanentityforwhichaspecificdefinitionwillbesupplied. • Thecan_instantiatepragmaindicatesthataspecifiedentitycanbeinstantiatedinthecurrentcompilation,butneednotbe; itisusedinconjunctionwithautomaticinstantiation,toindicatepotentialsitesforinstantiationifthetemplateentityturnsout toberequired. Theargumenttotheinstantiationpragmamaybe: • atemplateclassname A • atemplateclassdeclaration classA • amemberfunctionname A::f • astaticdatamembername A::i • astaticdatadeclaration intA::i • amemberfunctiondeclaration voidA::f(int,char) • atemplatefunctiondeclaration char*f(int,float) Apragmainwhichtheargumentisatemplateclassname(e.g.,AorclassA)isequivalenttorepeatingthe pragmaforeachmemberfunctionandstaticdatamemberdeclaredintheclass.Wheninstantiatinganentireclassagiven memberfunctionorstaticdatamembermaybeexcludedusingthedo_not_instantiatepragma.Forexample, #pragmainstantiateA #pragmado_not_instantiateA::f

Thetemplatedefinitionofatemplateentitymustbepresentinthecompilationforaninstantiationtooccur.Ifaninstantiationis explicitlyrequestedbyuseoftheinstantiatepragmaandnotemplatedefinitionisavailableoraspecificdefinitionisprovided, anerrorisissued. templatevoidf1(T);//Nobodyprovided templatevoidg1(T);//Nobodyprovided

2−16 C++Language

voidf1(int){}//Specificdefinition voidmain() { inti; doubled; f1(i); f1(d); g1(i); g1(d); } #pragmainstantiatevoidf1(int)//error−specific //definition #pragmainstantiatevoidg1(int)//error−nobody //provided f1(double)andg1(double)willnotbeinstantiated(becausenobodiesweresupplied)butnoerrorswillbeproducedduring thecompilation(ifnobodiesaresuppliedatlinktime,alinkererrorwillbeproduced). Amemberfunctionname(e.g.,A::f)canonlybeusedasapragmaargumentifitreferstoasingleuserdefined memberfunction(i.e.,notanoverloadedfunction).Compiler−generatedfunctionsarenotconsidered,soanamemayrefertoa userdefinedconstructorevenifacompiler−generatedcopyconstructorofthesamenameexists.Overloadedmemberfunctions canbeinstantiatedbyprovidingthecompletememberfunctiondeclaration,asin #pragmainstantiatechar*A::f(int,char*)

Theargumenttoaninstantiationpragmamaynotbeacompiler−generatedfunction,aninlinefunction,orapurevirtualfunction.

2.6.4 ImplicitInclusion

Whenimplicitinclusionisenabled,theC++compilerisgivenpermissiontoassumethatifitneedsadefinitiontoinstantiatea templateentitydeclaredina.hfileitcanimplicitlyincludethecorresponding.ccfiletogetthesourcecodeforthedefinition. Forexample,ifatemplateentityABC::fisdeclaredinfilexyz.h,andaninstantiationofABC::fisrequiredinacompilation butnodefinitionofABC::fappearsinthesourcecodeprocessedbythecompilation,thecompilerwilllooktoseeifafile xyz.ccexists,andifsoitwillprocessitasifitwereincludedattheendofthemainsourcefile. TofindthetemplatedefinitionfileforagiventemplateentitytheC++compilerneedstoknowthepathnamespecifiedinthe originalincludeofthefileinwhichthetemplatewasdeclaredandwhetherthefilewasincludedusingthesystemincludesyntax (e.g.,#include).Thisinformationisnotavailableforpreprocessedsourcecontaining#linedirectives. Consequently,theC++compilerwillnotattemptimplicitinclusionforsourcecodecontaining#linedirectives. Thefiletobeimplicitlyincludedisfoundbyreplacingthefilesuffixwitheachofthesuffixesspecifiedintheinstantiationfilesuffix list.Thenormalincludesearchpathmechanismisthenusedtolookforthefiletobeimplicitlyincluded. Bydefault,thelistofdefinition−filesuffixestriedis.c,.cc,.cpp,and.cxx. Implicitinclusionworkswellalongsideautomaticinstantiation,butthetwoareindependent.Theycanbeenabledordisabled independently,andimplicitinclusionisstillusefulwhenautomaticinstantiationisnotdone. Theimplicitinclusionmodecanbeturnedonbythecommandlineoption−−implicit−include.Ifthisoptionisturnedon,you cannotuseexportedtemplates. Implicitinclusionsareonlyperformedduringthenormalcompilationofafile,(i.e.,notwhendoingonlypreprocessing).A commonmeansofinvestigatingcertainkindsofproblemsistoproduceapreprocessedsourcefilethatcanbeinspected.When usingimplicitinclusionitissometimesdesirableforthepreprocessedsourcefiletoincludeanyimplicitlyincludedfiles.Thismay bedoneusingthecommandlineoption−−no−preprocessing−only.Thiscausesthepreprocessedoutputtobegeneratedas partofanormalcompilation.Whenimplicitinclusionisbeingused,theimplicitlyincludedfileswillappearaspartofthe preprocessedoutputinthepreciselocationatwhichtheywereincludedinthecompilation.

2−17 MicroBlazeEmbeddedToolsReference

2.6.5 ExportedTemplates

Exportedtemplatesaretemplatesdeclaredwiththekeywordexport.Exportingaclasstemplateisequivalenttoexportingeach ofitsstaticdatamembersandeachofitsnon−inlinememberfunctions.Anexportedtemplateisspecialbecauseitsdefinition doesnotneedtobepresentinatranslationunitthatusesthattemplate.Inotherwords,thedefinitionofanexported(non−class) templatedoesnotneedtobeexplicitlyorimplicitlyincludedinatranslationunitthatinstantiatesthattemplate.Forexample,the followingisavalidC++programconsistingoftwoseparatetranslationunits: //File1: #include staticvoidtrace(){printf("File1\n");}

exporttemplateTconst&min(Tconst&,Tconst&); intmain() { trace(); returnmin(2,3); } //File2: #include staticvoidtrace(){printf("File2\n");}

exporttemplateTconst&min(Tconst&a,Tconst&b) { trace(); returna

Notethatthesetwofilesareseparatetranslationunits:oneisnotincludedintheother.Thatallowsthetwofunctionstrace() tocoexist(withinternallinkage). Supportforexportedtemplatesisenabledbydefault,butyoucanturnitoffwithcommandlineoption−−no−export. Youcannotuseexportedtemplatestogetherwiththecommandlineoption−−implicit−include.

2.6.5.1 FindingtheExportedTemplateDefinition

Theautomaticinstantiationofexportedtemplatesissomewhatsimilar(fromauser’sperspective)tothatofregular(included) templates.However,aninstantiationofanexportedtemplateinvolvesatleasttwotranslationunits:onewhichrequiresthe instantiation,andonewhichcontainsthetemplatedefinition. Whenafilecontainingdefinitionsofexportedtemplatesiscompiled,afilewitha.etsuffixiscreatedandsomeextra informationisincludedintheassociated.tifile.The.etfilesareusedlaterbytheC++compilertofindthetranslationunitthat definesagivenexportedtemplate. Whenafilethatpotentiallymakesuseofexportedtemplatesiscompiled,thecompilermustbetoldwheretolookfor.etfiles forexportedtemplatesusedbyagiventranslationunit.Bydefault,thecompilerlooksinthecurrentdirectory.Otherdirectories maybespecifiedwiththecommandlineoption−−template−directory.Strictlyspeaking,the.etfilesareonlyreallyneeded whenitcomestimetogenerateaninstantiation.Thismeansthatcodeusingexportedtemplatescanbecompiledwithouthaving thedefinitionsofthosetemplatesavailable.Thosedefinitionsmustbeavailablewhenexplicitinstantiationisdone. The.etfilesonlyinformtheC++compileraboutthelocationofexportedtemplatedefinitions;theydonotactuallycontainthose definitions.Thesourcescontainingtheexportedtemplatedefinitionsmustthereforebemadeavailableatthetimeof instantiation.Inparticular,theexportfacilityisnotamechanismforavoidingthepublicationoftemplatedefinitionsinsource form.

2−18 C++Language

2.6.5.2 SecondaryTranslationUnits Aninstantiationofanexportedtemplatecanbetriggeredbyanexplicitinstantiationdirective,orbythecommandlineoption −−instantiate=used.Ineachcase,thetranslationunitthatcontainstheinitialpointofinstantiationwillbeprocessedasthe primarytranslationunit.Basedoninformationitfindsinthe.etfiles,theC++compilerwillthenloadandparsethetranslation unitcontainingthedefinitionofthetemplatetoinstantiate.Thisisasecondarytranslationunit.Thesimultaneousprocessingof theprimaryandsecondarytranslationunitsenablestheC++compilertocreateinstantiationsoftheexportedtemplates(which canincludeentitiesfrombothtranslationunits).Thisprocessmayrevealtheneedforadditionalinstantiationsofexported templates,whichinturncancauseadditionalsecondarytranslationunitstobeloaded4. Whensecondarytranslationunitsareprocessed,thedeclarationstheycontainarecheckedforconsistency.Thisprocessmay reporterrorsthatwouldotherwisenotbecaught.Manytheseerrorsareso−called"ODRviolations"(ODRstandsfor "one−definitionrule").Forexample: //File1: structX{ intx; };

intmain(){ returnmin(2,3); } //File2: structX{ unsignedx;//Error:X::xdeclareddifferently //inFile1 };

exporttemplateTconst&min(Tconst&a,Tconst&b) { returna

Iftherearenoerrors,theinstantiationsaregeneratedintheoutputassociatedwiththeprimarytranslationunit.Thismayalso requirethatentitieswithinternallinkageinsecondarytranslationunitsbe"externalized"sotheycanbeaccessedfromthe instantiationsintheprimarytranslationunit.

2.6.5.3 LibrarieswithExportedTemplates

Typicallya(non−export)libraryconsistsofanincludedirectoryandalibdirectory.Theincludedirectorycontainsthe headerfilesrequiredbyusersofthelibraryandthelibdirectorycontainstheobjectcodelibrariesthatclientprogramsmust usewhenlinkingprograms. Withexportedtemplates,usersofthelibrarymustalsohaveaccesstothesourcecodeoftheexportedtemplatesandthe informationcontainedintheassociated.etfiles.Thisinformationshouldbeplacedinadirectorythatisdistributedalongwith theincludeandlibdirectories:Thisistheexportdirectory.Itmustbespecifiedusingthecommandlineoption −−template−directorywhencompilingclientprograms. Therecommendedproceduretobuildtheexportdirectoryisasfollows: 1. Foreach.etfileintheoriginalsourcedirectory,copytheassociatedsourcefiletotheexportdirectory. 2. Concatenateallofthe.etfilesintoasingle.etfile(e.g.,mylib.et)intheexportdirectory.Theindividual.etfiles couldbecopiedtotheexportdirectory,buthavingallofthe.etinformationinonefilewillmakeuseofthelibrarymore efficient. 3. Createanexport_infofileintheexportdirectory.Theexport_infofilespecifiestheincludesearchpathstobeused whenrecompilingfilesintheexportdirectory.Ifnoexport_infofileisprovided,theincludesearchpathusedwhen compilingtheclientprogramthatusesthelibrarywillalsobeusedtorecompilethelibraryexportedtemplatefiles.

4Asaconsequence,usingexportedtemplatesmayrequireconsiderablymorememorythatsimilarusesof regular(included)templates.

2−19 MicroBlazeEmbeddedToolsReference

Theexport_infofileconsistsofaseriesoflinesoftheform include=x or sys_include=x wherexisapathnametobeplacedontheincludesearchpath.Thedirectoriesaresearchedintheorderinwhichtheyare encounteredintheexport_infofile.Thefilecanalsocontaincomments,whichbeginwitha"#",andblanklines.Spacesare ignoredbuttabsarenotcurrentlypermitted.Forexample: #Theincludedirectoriestobeusedforthexyzlibrary

include=/disk1/xyz/include sys_include=/disk2/abc/include include=/disk3/jkl/include

TheincludesearchpathspecifiedforaclientprogramisignoredbytheC++compilerwhenitprocessesthesourceintheexport library,exceptwhennoexport_infofileisprovided.commandlinemacrodefinitionsspecifiedforaclientprogramarealso ignoredbytheC++compilerwhenprocessingasourcefilefromtheexportlibary;thecommandlinemacrosspecifiedwhenthe corresponding.etfilewasproduceddoapply.Allothercompilationoptions(otherthantheincludesearchpathandcommand linemacrodefinitions)usedwhenrecompilingtheexportedtemplateswillbeusedtocompiletheclientprogram. Whenalibraryisinstalledonanewsystem,itislikelythattheexport_infofilewillneedtobeadaptedtoreflectthelocation oftherequiredheadersonthatsystem.

2.7 InliningFunctions

TheC++compilersupportsaminimalformoffunctioninlining.WhentheC++compilerencountersacallofafunctiondeclared inlineitcanreplacethecallwiththebodyofthefunctionwiththeparametersreplacedbythecorrespondingarguments. Whenafunctioncalloccursasastatement,thestatementsofthefunctionbodyareinsertedinplaceofthecall.Whenthe functioncalloccurswithinanexpression,thebodyofthefunctionisrewrittenasonelargeexpressionandthatexpressionis insertedintheproperplaceinthecontainingexpression.Itisnotalwayspossibletodothissortofinlining:therearecertain constructs(e.g.loopsandinlineassembly)thatcannotberenderedinexpressionform.Evenwheninliningisdoneatthe statementlevel,therearecertainconstructsthatarenotpracticaltoinline.Callsthatcannotbeinlinedareleftintheiroriginal callform,andanout−of−linecopyofthefunctionisused.Whenenabled,aremarkisissued. Afunctionisdisqualifiedforinliningimmediatelyifanyofthefollowingaretrue: • Thefunctionhaslocalstaticvariables. • Thefunctionhaslocalconstants. • Thefunctionhaslocaltypes. • Thefunctionhasblockscopes. • Thefunctionincludespragmas. • Thefunctionhasavariableargumentlist.

2.8 ExternInlineFunctions

DependingonthewayinwhichtheC++compilerisconfigured,out−of−linecopiesofexterninlinefunctionsareeither implementedusingstaticfunctions,orareinstantiatedusingamechanismlikethetemplateinstantiationmechanism.Notethat out−of−linecopiesofinlinefunctionsareonlyrequiredincaseswherethefunctioncannotbeinlined,orwhentheaddressofthe functionistaken(whetherexplicitlybytheuser,byimplicitlygeneratedfunctions,orbycompiler−generateddatastructuressuch asvirtualfunctiontablesorexceptionhandlingtables). Whenstaticfunctionsareused,localstaticvariablesofthefunctionsarepromotedtoglobalvariableswithspeciallyencoded names,sothateventhoughtheremaybemultiplecopiesofthecode,thereisonlyonecopyofsuchglobalvariables.This mechanismdoesnotstrictlyconformtothestandardbecausetheaddressofanexterninlinefunctionisnotconstantacross translationunits.

2−20 C++Language

Whentheinstantiationmechanismisused,theaddressofanexterninlinefunctionisconstantacrosstranslationunits,butatthe costofrequiringtheuseofoneofthetemplateinstantiationmechanisms,evenforprogramsthatdon’tusetemplates. Definitionsofexterninlinefunctionscanbeprovidedeitherthroughuseoftheautomaticinstantiationmechanismorbyuseof the−−instantiate=usedor−−instantiate=allinstantiationmodes.Thereisnomechanismtomanuallycontrolthedefinitionof externinlinefunctionbodies.

2.9 PragmastoControltheC++Compiler

PragmasarekeywordsintheC++sourcethatcontrolthebehaviorofthecompiler.Pragmasoverrulecompileroptions. Thesyntaxis: #pragmapragma−spec

TheC++compilersupportsthefollowingpragmasandallCcompilerpragmasthataredescribedinsection1.5,Pragmasto ControltheCompiler. instantiate/do_not_instantiate/can_instantiate Thesearetemplateinstantiationpragmas.Theyaredescribedindetailinsection2.6.3,Instantiation#pragmaDirectives. hdrstop/no_pch Theseareprecompiledheaderpragmas.Theyaredescribedindetailinsection2.11,PrecompiledHeaders. once Whenplacedatthebeginningofaheaderfile,indicatesthatthefileiswritteninsuchawaythatincludingitseveraltimeshas thesameeffectasincludingitonce.Thus,iftheC++compilersees#pragmaonceatthestartofaheaderfile,itwillskipover itifthefileis#includedagain. Atypicalidiomistoplacean#ifndefguardaroundthebodyofthefile,witha#defineoftheguardvariableafterthe#ifndef: #pragmaonce//optional #ifndefFILE_H #defineFILE_H ...bodyoftheheaderfile... #endif

The#pragmaonceismarkedasoptionalinthisexample,becausetheC++compilerrecognizesthe#ifndefidiomanddoes theoptimizationeveninitsabsence.#pragmaonceisacceptedforcompatibilitywithothercompilersandtoallowthe programmertouseotherguard−codeidioms. ident Thispragmaisgivenintheform: #pragmaident"string" or #ident"string"

2−21 MicroBlazeEmbeddedToolsReference

2.10 PredefinedMacros

TheC++compilerdefinesanumberofpreprocessingmacros.Manyofthemareonlydefinedundercertaincircumstances.This sectiondescribesthemacrosthatareprovidedandthecircumstancesunderwhichtheyaredefined.

Macro Description __ABI_COMPATIBILITY_VERSION DefinestheABIcompatibilityversionbeingused.Thismacroissetto 9999,whichmeansthelatestversion.Thismacroisusedwhen buildingtheC++library. __ABI_CHANGES_FOR_RTTI ThismacroissettoTRUE,meaningthattheABIchangesforRTTI areimplemented.ThismacroisusedwhenbuildingtheC++library. __ABI_CHANGES_FOR_ARRAY_NEW_AND_DELETE ThismacroissettoTRUE,meaningthattheABIchangesforarray newanddeleteareimplemented.Thismacroisusedwhenbuilding theC++library. __ABI_CHANGES_FOR_PLACEMENT_DELETE ThismacroissettoTRUE,meaningthattheABIchangesfor placementdeleteareimplemented.Thismacroisusedwhen buildingtheC++library. __ARRAY_OPERATORS Definedwhenarraynewanddeleteareenabled.Thisisthe default. __BASE_FILE__ Similarto__FILE__butindicatestheprimarysourcefileratherthan thecurrentone(i.e.,whenthecurrentfileisanincludedfile). __BIG_ENDIAN__ Expandsto1,indicatingbig−endianmode. _BOOL Definedwhenboolisakeyword.Thisisthedefault. __BUILD__ IdentifiesthebuildnumberoftheC++compiler,composedof decimaldigitsforthebuildnumber,threedigitsforthemajorbranch numberandthreedigitsfortheminorbranchnumber.Forexample,if youusebuild1.22.1ofthecompiler,__BUILD__expandsto 1022001.Ifthereisnobranchnumber,thebranchdigitsexpandto zero.Forexample,build127resultsin127000000. __CHAR_MIN/__CHAR_MAX Usedinlimits.htodefinetheminimum/maximumvalueofaplain charrespectively. __CPMB__ IdentifiestheC++compiler.Youcanusethissymboltoflagpartsof thesourcewhichmustberecognizedbytheC++compileronly.It expandsto1. __cplusplus Alwaysdefined. __DATE__ Definedtothedateofthecompilationintheform"Mmmddyyyy". __DELTA_TYPE Definesthetypeoftheoffsetfieldinthevirtualfunctiontable.This macroisusedwhenbuildingtheC++library. __DOUBLE_FP__ Expandsto1ifyoudidnotuseoption−−no−double(Treat’double’ as’float’),otherwiseunrecognizedasmacro. __embedded_cplusplus Definedas1inEmbeddedC++mode. __EXCEPTIONS Definedwhenexceptionhandlingisenabled(−−exceptions). __FILE__ Expandstothecurrentsourcefilename. __func__ Sameas__FUNCTION__inGNUmode. __IMPLICIT_USING_STD Definedwhenthestandardheaderfilesshouldimplicitlydoa using−directiveonthestdnamespace(−−using−std). __JMP_BUF_ELEMENT_TYPE Specifiesthetypeofanelementofthesetjmpbuffer.Thismacrois usedwhenbuildingtheC++library. __JMP_BUF_NUM_ELEMENTS Definesthenumberofelementsinthesetjmpbuffer.Thismacrois usedwhenbuildingtheC++library. __LINE__ Expandstothelinenumberofthelinewherethismacroiscalled. __NAMESPACES Definedwhennamespacesaresupported(thisisthedefault,you candisablesupportfornamespaceswith−−no−namespaces). __NO_LONG_LONG Definedwhenthelonglongtypeisnotsupported.Thisisthe default.

2−22 C++Language

Macro Description __NULL_EH_REGION_NUMBER Definesthevalueusedasthenullregionnumbervalueinthe exceptionhandlingtables.ThismacroisusedwhenbuildingtheC++ library. __PLACEMENT_DELETE Definedwhenplacementdeleteisenabled. __PRETTY_FUNCTION__ Definedtothenameofthecurrentfunction.Thisincludesthereturn typeandparametertypesofthefunction.Anerrorisissuedifitis usedoutsideofafunction. __PTRDIFF_MIN/__PTRDIFF_MAX Usedinstdint.htodefinetheminimum/maximumvalueofa ptrdiff_ttyperespectively. __REGION_NUMBER_TYPE Definesthetypeofaregionnumberfieldintheexceptionhandling tables.ThismacroisusedwhenbuildingtheC++library. __REVISION__ ExpandstotherevisionnumberoftheC++compiler.Digitsare representedastheyare;characters(forprototypes,alphas,betas) arerepresentedby−1.Examples:v1.0r1−>1,v1.0rb−>−1 __RTTI DefinedwhenRTTIisenabled(−−rtti). __RUNTIME_USES_NAMESPACES Definedwhentherun−timeusesnamespaces. __SIGNED_CHARS__ Definedwhenplaincharissigned. __SINGLE_FP__ Expandsto1ifyouusedoption−−no−double(Treat’double’as ’float’),otherwiseunrecognizedasmacro. __SIZE_MIN/__SIZE_MAX Usedinstdint.htodefinetheminimum/maximumvalueofa size_ttyperespectively. __STDC__ Alwaysdefined,butthevaluemayberedefined. __STDC_VERSION__ IdentifiestheISO−Cversionnumber.Expandsto199901LforISO C99,butthevaluemayberedefined. _STLP_NO_IOSTREAMS Definedwhenoption−−io−streamsisnotused.ThisdisablesI/O streamfunctionsintheSTLportC++library. __TASKING__ AlwaysdefinedfortheTASKINGC++compiler. __TIME__ Expandstothecompilationtime:"hh:mm:ss" __TYPE_TRAITS_ENABLED Definedwhentypetraitspseudo−functions(toeasethe implementationofISO/IECTR19768;e.g.,__is_union)are enabled.ThisisthedefaultinC++mode. __VAR_HANDLE_TYPE Definesthetypeofthevariable−handlefieldintheexception handlingtables.ThismacroisusedwhenbuildingtheC++library. __VERSION__ IdentifiestheversionnumberoftheC++compiler.Forexample,if youuseversion2.1r1ofthecompiler,__VERSION__expandsto 2001(dotandrevisionnumberareomitted,minorversionnumberin 3digits). __VIRTUAL_FUNCTION_INDEX_TYPE Definesthetypeofthevirtualfunctionindexfieldofthevirtual functiontable.ThismacroisusedwhenbuildingtheC++library. __VIRTUAL_FUNCTION_TYPE Definesthetypeofthevirtualfunctionfieldofthevirtualfunction table.ThismacroisusedwhenbuildingtheC++library. __WCHAR_MIN/__WCHAR_MAX Usedinstdint.htodefinetheminimum/maximumvalueofa wchar_ttyperespectively. _WCHAR_T Definedwhenwchar_tisakeyword.

Table2−1:Predefinedmacros

2−23 MicroBlazeEmbeddedToolsReference

2.11 PrecompiledHeaders

Itisoftendesirabletoavoidrecompilingasetofheaderfiles,especiallywhentheyintroducemanylinesofcodeandtheprimary sourcefilesthat#includethemarerelativelysmall.TheC++compilerprovidesamechanismfor,ineffect,takingasnapshot ofthestateofthecompilationataparticularpointandwritingittoadiskfilebeforecompletingthecompilation;then,when recompilingthesamesourcefileorcompilinganotherfilewiththesamesetofheaderfiles,itcanrecognizethe"snapshot point",verifythatthecorrespondingprecompiledheader(PCH)fileisreusable,andreaditbackin.Undertheright circumstances,thiscanproduceadramaticimprovementincompilationtime;thetrade−offisthatPCHfilescantakealotof diskspace.

2.11.1 AutomaticPrecompiledHeaderProcessing

When−−pchappearsonthecommandline,automaticprecompiledheaderprocessingisenabled.ThismeanstheC++ compilerwillautomaticallylookforaqualifyingprecompiledheaderfiletoreadinand/orwillcreateoneforuseonasubsequent compilation. ThePCHfilewillcontainasnapshotofallthecodeprecedingthe"headerstop"point.Theheaderstoppointistypicallythefirst tokenintheprimarysourcefilethatdoesnotbelongtoapreprocessingdirective,butitcanalsobespecifieddirectlyby #pragmahdrstop(seebelow)ifthatcomesfirst.Forexample: #include"xxx.h" #include"yyy.h" inti;

Theheaderstoppointisint(thefirstnon−preprocessortoken)andthePCHfilewillcontainasnapshotreflectingtheinclusion ofxxx.handyyy.h.Ifthefirstnon−preprocessortokenorthe#pragmahdrstopappearswithina#ifblock,theheader stoppointistheoutermostenclosing#if.Toillustrate,heresamorecomplicatedexample: #include"xxx.h" #ifndefYYY_H #defineYYY_H1 #include"yyy.h" #endif #ifTEST inti; #endif

Here,thefirsttokenthatdoesnotbelongtoapreprocessingdirectiveisagainint,buttheheaderstoppointisthestartofthe #ifblockcontainingit.ThePCHfilewillreflecttheinclusionofxxx.handconditionallythedefinitionofYYY_Handinclusionof yyy.h;itwillnotcontainthestateproducedby#ifTEST. APCHfilewillbeproducedonlyiftheheaderstoppointandthecodeprecedingit(mainly,theheaderfilesthemselves)meet certainrequirements: • Theheaderstoppointmustappearatfilescope−−itmaynotbewithinanunclosedscopeestablishedbyaheaderfile.For example,aPCHfilewillnotbecreatedinthiscase: //xxx.h classA{ //xxx.C #include"xxx.h" inti;}; • Theheaderstoppointmaynotbeinsideadeclarationstartedwithinaheaderfile,nor(inC++)mayitbepartofadeclaration listofalinkagespecification.Forexample,inthefollowingcasetheheaderstoppointisint,butsinceitisnotthestartofa newdeclaration,noPCHfilewillbecreated: //yyy.h static //yyy.C #include"yyy.h" inti; • Similarly,theheaderstoppointmaynotbeinsidea#ifblockora#definestartedwithinaheaderfile.

2−24 C++Language

• Theprocessingprecedingtheheaderstopmustnothaveproducedanyerrors.(Note:warningsandotherdiagnosticswill notbereproducedwhenthePCHfileisreused.) • Noreferencestopredefinedmacros__DATE__or__TIME__mayhaveappeared. • Nouseofthe#linepreprocessingdirectivemayhaveappeared. • #pragmano_pch(seebelow)mustnothaveappeared. • Thecodeprecedingtheheaderstoppointmusthaveintroducedasufficientnumberofdeclarationstojustifytheoverhead associatedwithprecompiledheaders.Theminimumnumberofdeclarationsrequiredis1. Whenthehostsystemdoesnotsupportmemorymapping,sothateverythingtobesavedintheprecompiledheaderfileis assignedtopreallocatedmemory(MS−Windows),twoadditionalrestrictionsapply: • Thetotalmemoryneededattheheaderstoppointcannotexceedthesizeoftheblockofpreallocatedmemory. • Nosingleprogramentitysavedcanexceed16384,thepreallocationunit. Whenaprecompiledheaderfileisproduced,itcontains,inadditiontothesnapshotofthecompilerstate,someinformationthat canbecheckedtodetermineunderwhatcircumstancesitcanbereused.Thisincludes: • Thecompilerversion,includingthedateandtimethecompilerwasbuilt. • Thecurrentdirectory(i.e.,thedirectoryinwhichthecompilationisoccurring). • Thecommandlineoptions. • Theinitialsequenceofpreprocessingdirectivesfromtheprimarysourcefile,including#includedirectives. • Thedateandtimeoftheheaderfilesspecifiedin#includedirectives. ThisinformationcomprisesthePCHprefix.Theprefixinformationofagivensourcefilecanbecomparedtotheprefix informationofaPCHfiletodeterminewhetherthelatterisapplicabletothecurrentcompilation. Asanillustration,considertwosourcefiles: //a.cc #include"xxx.h" ...//Startofcode //b.cc #include"xxx.h" ...//Startofcode

Whena.cciscompiledwith−−pch,aprecompiledheaderfilenameda.pchiscreated.Then,whenb.cciscompiled(or whena.ccisrecompiled),theprefixsectionofa.pchisreadinforcomparisonwiththecurrentsourcefile.Ifthecommandline optionsareidentical,ifxxx.hhasnotbeenmodified,andsoforth,then,insteadofopeningxxx.handprocessingitlinebyline, theC++compilerreadsintherestofa.pchandtherebyestablishesthestatefortherestofthecompilation. ItmaybethatmorethanonePCHfileisapplicabletoagivencompilation.Ifso,thelargest(i.e.,theonerepresentingthemost preprocessingdirectivesfromtheprimarysourcefile)isused.Forinstance,consideraprimarysourcefilethatbeginswith #include"xxx.h" #include"yyy.h" #include"zzz.h"

IfthereisonePCHfileforxxx.handasecondforxxx.handyyy.h,thelatterwillbeselected(assumingbothareapplicable tothecurrentcompilation).Moreover,afterthePCHfileforthefirsttwoheadersisreadinandthethirdiscompiled,anewPCH fileforallthreeheadersmaybecreated. Whenaprecompiledheaderfileiscreated,ittakesthenameoftheprimarysourcefile,withthesuffixreplacedbyan implementation−specifiedsuffix(pchbydefault).Unless−−pch−dirisspecified(seebelow),itiscreatedinthedirectoryofthe primarysourcefile. Whenaprecompiledheaderfileiscreatedorused,amessagesuchas "test.cc":creatingprecompiledheaderfile"test.pch" isissued.Theusermaysuppressthemessagebyusingthecommandlineoption−−no−pch−messages. Whentheoption−−pch−verboseisused,theC++compilerwilldisplayamessageforeachprecompiledheaderfilethatis consideredthatcannotbeusedgivingthereasonthatitcannotbeused.

2−25 MicroBlazeEmbeddedToolsReference

Inautomaticmode(i.e.,when−−pchisused)theC++compilerwilldeemaprecompiledheaderfileobsoleteanddeleteitunder thefollowingcircumstances: • iftheprecompiledheaderfileisbasedonatleastoneout−of−dateheaderfilebutisotherwiseapplicableforthecurrent compilation;or • iftheprecompiledheaderfilehasthesamebasenameasthesourcefilebeingcompiled(e.g.,xxx.pchandxxx.cc)butis notapplicableforthecurrentcompilation(e.g.,becauseofdifferentcommandlineoptions). Thishandlessomecommoncases;otherPCHfileclean−upmustbedealtwithbyothermeans(e.g.,bytheuser). Supportforprecompiledheaderprocessingisnotavailablewhenmultiplesourcefilesarespecifiedinasinglecompilation:an errorwillbeissuedandthecompilationabortedifthecommandlineincludesarequestforprecompiledheaderprocessingand specifiesmorethanoneprimarysourcefile.

2.11.2 ManualPrecompiledHeaderProcessing

Commandlineoption−−create−pch=filenamespecifiesthataprecompiledheaderfileofthespecifiednameshouldbecreated. Commandlineoption−−use−pch=filenamespecifiesthattheindicatedprecompiledheaderfileshouldbeusedforthis compilation;ifitisinvalid(i.e.,ifitsprefixdoesnotmatchtheprefixforthecurrentprimarysourcefile),awarningwillbeissued andthePCHfilewillnotbeused. Wheneitheroftheseoptionsisusedinconjunctionwith−−pch−dir,theindicatedfilename(whichmaybeapathname)is tackedontothedirectoryname,unlessthefilenameisanabsolutepathname. Theoptions−−create−pch,−−use−pch,and−−pchmaynotbeusedtogether.Ifmorethanoneoftheseoptionsisspecified, onlythelastonewillapply.Nevertheless,mostofthedescriptionofautomaticPCHprocessingappliestooneortheotherof thesemodes−−headerstoppointsaredeterminedthesameway,PCHfileapplicabilityisdeterminedthesameway,andso forth.

2.11.3 OtherWaystoControlPrecompiledHeaders

Thereareseveralwaysinwhichtheusercancontroland/ortunehowprecompiledheadersarecreatedandused. • #pragmahdrstopmaybeinsertedintheprimarysourcefileatapointpriortothefirsttokenthatdoesnotbelongtoa preprocessingdirective.Itenablesyoutospecifywherethesetofheaderfilessubjecttoprecompilationends.Forexample, #include"xxx.h" #include"yyy.h" #pragmahdrstop #include"zzz.h"

Here,theprecompiledheaderfilewillincludeprocessingstateforxxx.handyyy.hbutnotzzz.h.(Thisisusefulifthe userdecidesthattheinformationaddedbywhatfollowsthe#pragmahdrstopdoesnotjustifythecreationofanotherPCH file.) • #pragmano_pchmaybeusedtosuppressprecompiledheaderprocessingforagivensourcefile. • Commandlineoption−−pch−dir=directory−nameisusedtospecifythedirectoryinwhichtosearchforand/orcreateaPCH file. Moreover,whenthehostsystemdoesnotsupportmemorymappingandpreallocatedmemoryisusedinstead,thenoneofthe commandlineoptions−−pch,−−create−pch,or−−use−pch,ifitappearsatall,mustbethefirstoptiononthecommandline.

2.11.4 PerformanceIssues

Therelativeoverheadincurredinwritingoutandreadingbackinaprecompiledheaderfileisquitesmallforreasonablylarge headerfiles. Ingeneral,itdoesnotcostmuchtowriteaprecompiledheaderfileoutevenifitdoesnotendupbeingused,andifitisusedit almostalwaysproducesasignificantspeedupincompilation.Theproblemisthattheprecompiledheaderfilescanbequite large(fromaminimumofabout250Kbytestoseveralmegabytesormore),andsooneprobablydoesnotwantmanyofthem sittingaround.

2−26 C++Language

Thus,despitethefasterrecompilations,precompiledheaderprocessingisnotlikelytobejustifiedforanarbitrarysetoffileswith nonuniforminitialsequencesofpreprocessingdirectives.Rather,thegreatestbenefitoccurswhenanumberofsourcefilescan sharethesamePCHfile.Themoresharing,thelessdiskspaceisconsumed.Withsharing,thedisadvantageoflarge precompiledheaderfilescanbeminimized,withoutgivinguptheadvantageofasignificantspeedupincompilationtimes. Consequently,totakefulladvantageofheaderfileprecompilation,usersshouldexpecttoreorderthe#includesectionsof theirsourcefilesand/ortogroup#includedirectiveswithinacommonlyusedheaderfile. Belowisanexampleofhowthiscanbedone.Acommonidiomisthis: #include"comnfile.h" #pragmahdrstop #include... wherecomnfile.hpullsin,directlyandindirectly,afewdozenheaderfiles;the#pragmahdrstopisinsertedtogetbetter sharingwithfewerPCHfiles.ThePCHfileproducedforcomnfile.hcanbeabitoveramegabyteinsize.Anotheridiom,used bythesourcefilesinvolvedindeclarationprocessing,isthis: #include"comnfile.h" #include"decl_hdrs.h" #pragmahdrstop #include... decl_hdrs.hpullsinanotherdozenheaderfiles,andasecond,somewhatlarger,PCHfileiscreated.Inall,thesourcefilesof aparticularprogramcansharejustafewprecompiledheaderfiles.Ifdiskspacewereatapremium,youcoulddecidetomake comnfile.hpullinalltheheaderfilesused−−then,asinglePCHfilecouldbeusedinbuildingtheprogram. Differentenvironmentsanddifferentprojectswillhavedifferentneeds,butingeneral,usersshouldbeawarethatmakingthe bestuseoftheprecompiledheadersupportwillrequiresomeexperimentationandprobablysomeminorchangestosource code.

2−27 MicroBlazeEmbeddedToolsReference

2−28 3 Libraries

Summary ThischapterlistsalllibraryfunctionsthatyoucancallinyourCsource.

3.1 Introduction

ThischaptercontainsanoverviewofalllibraryfunctionsthatyoucancallinyourCsource.Thisincludesallfunctionsofthe standardClibrary(ISOC99)andsomefunctionsofthefloating−pointlibrary. AnumberofstandardoperationswithinCaretoocomplextogenerateinlinecodefor(toomuchcode).Theseoperationsare implementedasrun−timelibraryfunctionstosavecode. Section3.2,LibraryFunctions,givesanoverviewofalllibraryfunctionsyoucanuse,groupedperheaderfile.Anumberof functionsdeclaredinwchar.hareparalleltofunctionsinotherheaderfiles.Thesearediscussedtogether. Thefollowinglibrariesareavailable.AltiumDesignerautomaticallyselectstheappropriatelibrariesdependingonthespecified options.

CLibrary

Libraries Description cmba.lib Clibrary cmbab.lib (somefunctionsalsoneedthefloating−pointlibrary) cmbabf.lib cmbad.lib b=usebarrelshiftinstructions cmbadb.lib d=usedivideinstructions cmbadbf.lib f=usefloating−pointinstructions cmbadf.lib m=usemultiplyinstructions cmbaf.lib cmbam.lib cmbamb.lib cmbambf.lib cmbamd.lib cmbamdb.lib cmbamdbf.lib cmbamdf.lib cmbamf.lib cmbas.lib SingleprecisionClibrary cmba*s.lib (somefunctionsalsoneedthefloating−pointlibrary) fpmba.lib Floating−pointlibrary fpmba*.lib rtmba.lib Run−timelibrary rtmba*b.lib pbmba*.lib Profilinglibraries:pb=block/functioncounter pcmba*.lib pc=callgraph pctmba*.lib pct=callgraphandtiming pdmba*.lib pd=dummy ptmba*.lib pt=functiontiming

Table3−1:Overviewoflibraries

3−1 MicroBlazeEmbeddedToolsReference

C++Library TheTASKINGC++compilersupportstheSTLportC++libraries.STLportisamultiplatformISOC++StandardLibrary implementation.Itisafree,open−sourceproduct,whichisdeliveredwiththeTASKINGC++compiler.Thelibrarysupports standardtemplatesandI/Ostreams. TheincludefilesfortheSTLportC++librariesarepresentindirectoryinclude.stlrelativetotheproductinstallationdirectory. YoucanfindmoreinformationontheSTLportlibraryonthefollowingsite:http://stlport.sourgeforge.net/ Alsoreadthelicenseagreementonhttp://stlport.sourgeforge.net/License.shtml.Thislicenseagreementisapplicabletothe STLportC++libraryonly.AllotherproductcomponentsfallundertheTASKINGlicenseagreement. ForanSTLProgrammer’sGuideyoucanseehttp://www.sgi.com/tech/stl/index.html. ThefollowingC++librariesaredeliveredwiththeproduct:

Libraries Description cpmb*[x][s].lib C++libraries x=exceptionhandling s=singleprecisionfloating−point stlmb*[x][s].lib STLportC++libraries

3−2 Libraries

3.2 LibraryFunctions

Thefollowingsectionslistalllibraryfunctions,groupedperheaderfileinwhichtheyaredeclared.Somefunctionsarenot completelyimplementedbecausetheirimplementationdependsonthecontextwhereyourapplicationwillrun.Thesefunctions areforexampleallI/Orelatedfunctions.Wherepossible,thesefunctionsareimplementedusingfilesystemsimulation(FSS). ThissystemcanbeusedbythedebuggertosimulateanI/Oenvironmentwhichenablesyoutodebugyourapplication. Anumberofwide−characterfunctionsareavailableasCsourcecode,buthavenotbeencompiledwiththeClibrary.Touse completewide−characterfunctionality,youmustrecompilethelibrarieswiththemacroWCHAR_SUPPORT_ENABLEDand keepthismacroalsodefinedwhencompilingyourownsources.(SeeCcompileroption−−define(−D)insection5.1,C CompilerOptions,inChapter5,Tooloptions.)

3.2.1 assert.h

assert(expr) PrintsadiagnosticmessageifNDEBUGisnotdefined. (Implementedasmacro)

3.2.2 complex.h

TheMicroBlazedoesnotsupportcomplexnumbers.

3.2.3 ctype.handwctype.h

Theheaderfilectype.hdeclaresthefollowingfunctionswhichtakeacharactercasanintegertypeargument.Theheaderfile wctype.hdeclaresparallelwide−characterfunctionswhichtakeacharactercofthewchar_ttypeasargument.

ctype.h wctype.h Description isalnum iswalnum Returnsanon−zerovaluewhencisanalphabeticcharacteroranumber([A−Z][a−z][0−9]). isalpha iswalpha Returnsanon−zerovaluewhencisanalphabeticcharacter([A−Z][a−z]). isblank iswblank Returnsanon−zerovaluewhencisablankcharacter(tab,space...) iscntrl iswcntrl Returnsanon−zerovaluewhencisacontrolcharacter. isdigit iswditit Returnsanon−zerovaluewhencisanumericcharacter([0−9]). isgraph iswgraph Returnsanon−zerovaluewhencisprintable,butnotaspace. islower iswlower Returnsanon−zerovaluewhencisalowercasecharacter([a−z]). isprint iswprint Returnsanon−zerovaluewhencisprintable,includingspaces. ispunct iswpunct Returnsanon−zerovaluewhencisapunctuationcharacter (suchas’.’,’,’,’!’). isspace iswspace Returnsanon−zerovaluewhencisaspacetypecharacter(space,tab,verticaltab, formfeed,linefeed,carriagereturn). isupper iswupper Returnsanon−zerovaluewhencisanuppercasecharacter([A−Z]). isxdigit iswxdigit Returnsanon−zerovaluewhencisahexadecimaldigit([0−9][A−F][a−f]). tolower towlower Returnscconvertedtoalowercasecharacterifitisanuppercasecharacter,otherwisecis returned. toupper towupper Returnscconvertedtoanuppercasecharacterifitisalowercasecharacter,otherwisecis returned. _tolower − Convertsctoalowercasecharacter,doesnotcheckifcreallyisanuppercasecharacter. Implementedasmacro.ThismacrofunctionisnotdefinedinISOC99. _toupper − Convertsctoanuppercasecharacter,doesnotcheckifcreallyisalowercasecharacter. Implementedasmacro.ThismacrofunctionisnotdefinedinISOC99. isascii Returnsanon−zerovaluewhencisintherangeof0and127. ThisfunctionisnotdefinedinISOC99. toascii ConvertsctoanASCIIvalue(striphighestbit). ThisfunctionisnotdefinedinISOC99.

3−3 MicroBlazeEmbeddedToolsReference

3.2.4 errno.h

interrno Externalvariablethatholdsimplementationdefinederrorcodes.

Thefollowingerrorcodesaredefinedasmacrosinerrno.h:

EPERM1Notowner ENOENT2Nosuchfileordirectory EINTR3Interruptedsystemcall EIO4I/Oerror EBADF5Badfilenumber EAGAIN6Nomoreprocesses ENOMEM7Notenoughcore EACCES8Permissiondenied EFAULT9Badaddress EEXIST10Fileexists ENOTDIR11Notadirectory EISDIR12Isadirectory EINVAL13Invalidargument ENFILE14Filetableoverflow EMFILE15Toomanyopenfiles ETXTBSY16Textfilebusy ENOSPC17Nospaceleftondevice ESPIPE18Illegalseek EROFS19Read−onlyfilesystem EPIPE20Brokenpipe ELOOP21Toomanylevelsofsymboliclinks ENAMETOOLONG22Filenametoolong Floating−pointerrors

EDOM23Argumenttoolarge ERANGE24Resulttoolarge Errorsreturnedbyprinff/scanf

ERR_FORMAT25Illegalformatstringforprintf/scanf ERR_NOFLOAT26Floating−pointnotsupported ERR_NOLONG27Longnotsupported ERR_NOPOINT28Pointersnotsupported Encodingerrorstoredinerrnobyfunctionslikefgetwc,getwc,mbrtowc,etc...

EILSEQ29Invalidorincompletemultibyteorwidecharacter ErrorssetbyRTOS

EILSEQ30Operationcanceled ENODEV31Nosuchdevice

3.2.5 fcntl.h

Thefilefcntl.hcontainsthefunctionopen(),whichcallsthelowlevelfunction_open(),anddefinitionsofflagsusedbythe lowlevelfunction_open().ThisheaderfileisnotdefinedinISOC99.

open Opensafileforreadingorwriting.Calls_open. (FSSimplementation)

3−4 Libraries

3.2.6 fenv.h

Containsmechanismstocontrolthefloating−pointenvironment.Thefunctionsinthisheaderfilearenotimplemented.

fegetenv Storesthecurrentfloating−pointenvironment.(Notimplemented) feholdexept Savesthecurrentfloating−pointenvironmentandinstallsanenvironmentthatignoresallfloating−point exceptions.(Notimplemented) fesetenv Restoresapreviouslysaved(fegetenvorfeholdexcept)floating−pointenvironment.(Notimplemented) feupdateenv Savesthecurrentlyraisedfloating−pointexceptions,restoresapreviouselysavedfloating−pointenvironĆ mentandfinallyraisesthesavedexceptions.(Notimplemented)

feclearexcept Clearsthecurrentexceptionstatusflagscorrespondingtotheflagsspecifiedintheargument.(NotimĆ plemented) fegetexceptflag Storesthecurrentsettingofthefloating−pointstatusflags.(Notimplemented) feraiseexcept Raisestheexceptionsrepresentedintheargument.Asaresult,otherexceptionsmayberaisedaswell. (Notimplemented) fesetexceptflag Setsthecurrentfloating−pointstatusflags.(Notimplemented) fetestexcept Returnsthebitwise−ORoftheexceptionmacroscorrespondingtotheexceptionflagswhicharecurrentĆ lysetandarespecifiedintheargument.(Notimplemented)

Foreachsupportedexception,amacroisdefined.Thefollowingexceptionsaredefined:

FE_DIVBYZERO FE_INEXACT FE_INVALID FE_OVERFLOW FE_UNDERFLOWFE_ALL_EXCEPT

fegetround Returnsthecurrentroundingdirection,representedasoneofthevaluesoftheroundingdirectionmacĆ ros.(Notimplemented) fesetround Setsthecurrentroundingdirections.(Notimplemented)

Currentlynoroundingmodemacrosareimplemented.

3.2.7 float.h

Theheaderfilefloat.hdefinesthecharacteristicsoftherealfloating−pointtypesfloat,doubleandlongdouble.

Float.husedtocontainprototypesforthefunctionscopysign(f),isinf(f),isfinite(f),isnan(f)andscalb(f). ThesefunctionshaveaccordinglytotheISOC99standardbeenmovedtotheheaderfilemath.h.Seealsosection 3.2.15,math.handtgmath.h.

3.2.8 fss.h

Theheaderfilefss.hcontainsdefinitionsforthedebugger’sfilesystemsimulation(FSS).ThisheaderfileisnotdefinedinISO C99.

fss.h Description _fss_break(void) Bufferandbreakpointfunctionsforthedebugger.

_fss_init(fd,is_close) Opensfiledescriptors0(stdin),1(stdout)and2(stderr)andassociatesthemwithterminal windowFSS0ofthedebugger.

3−5 MicroBlazeEmbeddedToolsReference

3.2.9 inttypes.handstdint.h

Theheaderfilesstdint.handinttypes.hprovideadditionaldeclarationsforintegertypesandhavevariouscharacteristics. Thestdint.hheaderfilecontainsbasicdefinitionsofintegertypesofcertainsizes,andcorrespondingsetsofmacros.This headerfileclearlyreferstothecorrespondingsectionsintheISOC99standard. Theinttypes.hheaderfileincludesstdint.handaddsportableformattingandconversionfunctions.Belowtheconversion functionsfrominttypes.harelisted.

intmax_timaxabs(intmax_tj); Returnstheabsolutevalueofj imaxdiv_timaxdiv(intmax_tnumer, Computesnumer/denomandnumer%denom.Theresultisstoredinthequot intmax_tdenom); andremcomponentsoftheimaxdiv_tstructuretype. intmax_tstrtoimax(constchar* Convertstringtomaximumsizedinteger.(Comparestrtol) restrictnptr,char**restrict endptr,intbase); uintmax_tstrtoumax(constchar* Convertstringtomaximumsizedunsignedinteger.(Comparestrtoul) restrictnptr,char**restrict endptr,intbase); intmax_twcstoimax(constwchar_t Convertwidestringtomaximumsizedinteger.(Comparewctol) *restrictnptr,wchar_t**reĆ strictendptr,intbase); uintmax_twcstoumax(constwchar_t Convertwidestringtomaximemsizedunsignedinteger.(Comparewctoul) *restrictnptr,wchar_t**reĆ strictendptr,intbase);

3.2.10 io.h

Theheaderfileio.hcontainsdefinitionsandprototypesforlowlevelI/Ofunctions.Thisheaderfileisnotdefinedin ISO/IEC9899.

_close(fd) Usedbythefunctionscloseandfclose. (FSSimplementation) _lseek(fd,offset,whence) Usedbyallfilepositioningfunctions:fgetpos,fseek,fsetpos,ftell,rewind.(FSSimpleĆ mentation) _open(fd,flags) Usedbythefunctionsfopenandfreopen. (FSSimplementation) _read(fd,*buff,cnt) Readsasequenceofcharactersfromafile. (FSSimplementation) _unlink(*name) Usedbythefunctionremove. (FSSimplementation) _write(fd,*buffer,cnt) Writesasequenceofcharacterstoafile. (FSSimplementation)

3.2.11 iso646.h

Theheaderfileiso646.haddstokensthatcanbeusedinsteadofregularoperatortokens. #defineand&& #defineand_eq&= #definebitand& #definebitor| #definecompl~ #definenot! #definenot_eq!= #defineor|| #defineor_eq|= #definexor^ #definexor_eq^=

3−6 Libraries

3.2.12 limits.h

Containsthesizesofintegraltypes,definedasmacros.

3.2.13 locale.h

TokeepCcodereasonableportableaccrossdifferentlanguagesandcultures,anumberoffacilitiesareprovidedintheheader filelocal.h. char*setlocale(intcategory,constchar*locale)

Thefunctionabovechangeslocale−specificfeaturesoftherun−timelibraryasspecifiedbythecategorytochangeandthe nameofthelocale. Thefollowingcategoriesaredefinedandcanbeusedasinputforthisfunction: LC_ALL0 LC_NUMERIC3 LC_COLLATE1 LC_TIME4 LC_CTYPE2 LC_MONETARY5 structlconv*localeconv(void)

Returnsapointertotypestuctlconvwithvaluesappropriatefortheformattingofnumericquantitiesaccordingtothe rulesofthecurrentlocale.ThestructlconvinthisheaderfileisconformingtheISOstandard.

3.2.14 malloc.h

Theheaderfilemalloc.hcontainsprototypesformemoryallocationfunctions.ThisincludefileisnotdefinedinISOC99,itis includedforbackwardscompatibilitywithISOC90.ForISOC99,thememoryallocationfunctionsarepartofstdlib.h.See section3.2.23,stdlib.handwchar.h.

malloc(size) Allocatesspaceforanobjectwithsizesize.Theallocatedspaceisnotinitialized.ReturnsapointĆ ertotheallocatedspace. calloc(nobj,size) Allocatesspacefornobjectswithsizesize.Theallocatedspaceisinitializedwithzeros.Returns apointertotheallocatedspace. free(*ptr) Deallocatesthememoryspacepointedtobyptrwhichshouldbeapointerearlierreturnedbythe mallocorcallocfunction. realloc(*ptr,size) Deallocatestheoldobjectpointedtobyptrandreturnsapointertoanewobjectwithsizesize, whilepreservingitscontents.Ifthenewsizeissmallerthantheoldsize,somecontentsatthe endoftheoldregionwillbediscarded.Ifthenewsizeislargerthantheoldsize,alloftheold contentsarepreservedandanybytesinthenewobjectbeyondthesizeoftheoldobjectwillhave indeterminatevalues.

3.2.15 math.handtgmath.h

Theheaderfilemath.hcontainstheprototypesformanymathematicalfunctions.BeforeISOC99,allfunctionswerecomputed usingthedoubletype(thefloatwasautomaticallyconvertedtodouble,priortocalculation).InthisISOC99version,parallelsets offunctionsaredefinedfordouble,floatandlongdouble.Theyarerespectivelynamedfunction,functionf,functionl.Alllong typefunctions,thoughdeclaredinmath.h,areimplementedasthedoubletypevariantwhichnearlyalwaysmeetsthe requirementinembeddedapplications. Theheaderfiletgmath.hcontainsparalleltypegenericmathmacroswhoseexpansiondependsontheusedtype.tgmath.h includesmath.handtheeffectofexpansionisthatthecorrectmath.hfunctionsarecalled.Thetypegenericmacro,if available,islistedinthesecondcolumnofthetablesbelow.

Trigonometricandhyperbolicfunctions

math.h tgmath.h Description sin sinf sinl sin Returnsthesineofx. cos cosf cosl cos Returnsthecosineofx. tan tanf tanl tan Returnsthetangentofx. asin asinf asinl asin Returnsthearcsinesin−1(x)ofx.

3−7 MicroBlazeEmbeddedToolsReference

math.htgmath.h Description acos acosf acosl acos Returnsthearccosinecos−1(x)ofx. atan atanf atanl atan Returnsthearctangenttan−1(x)ofx. atan2 atan2f atan2l atan2 Returnstheresultof:tan−1(y/x). sinh sinhf sinhl sinh Returnsthehyperbolicsineofx. cosh coshf coshl cosh Returnsthehyperboliccosineofx. tanh tanhf tanhl tanh Returnsthehyperbolictangentofx. asinh asinhf asinhl asinh Returnsthearchyperbolicsinusofx. acosh acoshf acoshl acosh Returnsthenon−negativearchyperboliccosinusofx. atanh atanhf atanhl atanh Returnsthearchyperbolictangentofx.

Exponentialandlogarithmicfunctions AllofthesefunctionsarenewinISOC99,exceptforexp,logandlog10.

math.h tgmath.h Description exp expf expl exp Returnstheresultoftheexponentialfunctionex. exp2 exp2f exp2l exp2 Returnstheresultoftheexponentialfunction2x. (Notimplemented) expm1 expm1f expm1l expm1 Returnstheresultoftheexponentialfunctionex−1 (Notimplemented) log logf logl log Returns thenaturallogarithmln(x),x>0. log10 log10f log10l log10 Returnsthebase−10logarithmofx,x>0. log1p log1pf log1pl log1p Returnsthebase−elogarithmof(1+x).x<>−1. (Notimplemented) log2 log2f log2l log2 Returnsthebase−2logarithmofx.x>0. (Notimplemented) ilogbilogbf ilogbl ilogb Returnsthesignedexponentofxasaninteger.x>0. (Notimplemented) logb logbf logbl logb Returnstheexponentofxasasignedintegerinvalueinfloating−pointnotation.x >0. (Notimplemented) frexp,ldexp,modf,scalbn,scalbln

math.h tgmath.h Description frexp frexpl frexpf frexp Splitsafloatxintofractionfandexponentn,sothat: f=0.0or0.5≤|f|≤1.0andf*2n=x.Returnsf,storesn. ldexp ldexpl ldexpf ldexp Inverseoffrexp.Returnstheresultofx*2n. (xandnarebotharguments). modf modfl modff − Splitsafloatxintofractionfandintegern,sothat: |f|<1.0andf+n=x.Returnsf,storesn. scalbn scalbnl scalbnf scalbn Computestheresultofx*FLT_RADIXn.efficiently,notnormallybycomputing FLT_RADIXnexplicitly. scalbln scalblnl scalblnf scalbln Sameasscalbnbutwithargumentnaslongint.

3−8 Libraries

Roundingfunctions

math.h tgmath.h Description ceil ceilf ceill ceil Returnsthesmallestintegernotlessthanx,asadouble. floor floorf floorl floor Returnsthelargestintegernotgreaterthanx,asadouble. rint rintl rintf rint Returnstheroundedintegervalueasanintaccordingtothecurrentrounding direction.Seefenv.h.(Notimplemented) lrint lrintf lrintl lrint Returnstheroundedintegervalueasalongintaccordingtothecurrent roundingdirection.Seefenv.h.(Notimplemented) llrint lrintf lrintl llrint Returnstheroundedintegervalueasalonglongintaccordingtothe currentroundingdirection.Seefenv.h.(Notimplemented) nearbyintnearbyintf nearbyint Returnstheroundedintegervalueasafloating−pointaccordingtothecurrent nearbyintl roundingdirection.Seefenv.h.(Notimplemented) round roundl roundf round Returnsthenearestintegervalueofxasint.(Notimplemented) lround lroundl lroundf lround Returnsthenearestintegervalueofxaslongint.(Notimplemented) llround llroundl llroundf llround Returnsthenearestintegervalueofxaslonglongint.(Notimplemented) trunc truncl truncf trunc Returnsthetruncatedintegervaluex.(Notimplemented)

Remainderafterdevision

math.h tgmath.h Description fmod fmodl fmodf fmod Returnstheremainderrofx−ny.nischosenastrunc(x/y).rhasthesame signasx. remainderremainderl remainder Returnstheremainderrofx−ny.nischosenastrunc(x/y).rmaynothave remainderf thesamesignasx.(Notimplemented) remquo remquol remquof remquo Sameasremainder.Inaddition,theargument*quoisgivenaspecificvalue (seeISO).(Notimplemented)

Powerandabsolute−valuefunctions

math.h tgmath.h Description cbrt cbrtl cbrtf cbrt Returnstherealcuberootofx(=x1/3). (Notimplemented) fabs fabsl fabsf fabs Returnstheabsolutevalueofx(|x|).(abs,labs,llabs,div,ldiv,lldiv aredefinedinstdlib.h) fma fmal fmaf fma Floating−pointmultiplyadd.Returnsx*y+z. (Notimplemented) hypot hypotl hypotf hypot Returnsthesquarerootofx2+y2. pow powl powf power Returnsxraisedtothepowery(xy). sqrt sqrtl sqrtf sqrt Returnsthenon−negativesquarerootofx.x00.

Manipulationfunctions:copysign,nan,nextafter,nexttoward

math.h tgmath.h Description copysigncopysignl copysign Returnsthevalueofxwiththesignofy. copysignf nan nanl nanf − ReturnsaquietNaN,ifavailable,withcontentindcatedthroughtagp.(Not implemented) nextafternextafterl nextafter Returnsthenextrepresentablevalueinthespecifiedformatafterxinthe nextafterf directionofy.Returnsyisx=y.(Notimplemented) nexttowardnexttowardl nexttoward Sameasnextafter,exceptthatthesecondargumentinallthreevariantsis nexttowardf oftypelongdouble.Returnsyifx=y.(Notimplemented)

3−9 MicroBlazeEmbeddedToolsReference

Positivedifference,maximum,minimum

math.h tgmath.h Description fdim fdiml fdimf fdim Returnsthepositivedifferencebetween:|x−y|. (Notimplemented) fmax fmaxl fmaxf fmax Returnsthemaximumvalueoftheirarguments. (Notimplemented) fmin fminl fminf fmin Returnstheminimumvalueoftheirarguments. (Notimplemented)

Errorandgamma(Notimplemented)

math.h tgmath.h Description erf erfl erff erf Computestheerrorfunctionofx. (Notimplemented) erfc erfcl erfcf erc Computesthecomplementaryerrorfunctionofx. (Notimplemented)

lgamma lgammal lgammaf lgamma Computesthe*loge|Γ(x)| (Notimplemented) tgamma tgammal tgammaf tgamma ComputesΓ(x) (Notimplemented)

Comparisonmacros Thenextareimplementedasmacros.Foranyorderedpairofnumericvaluesexactlyoneoftherelationships−less,greater, andequal−istrue.Thesemacrosaretypegenericandtherefordonothaveaparallelfunctionintgmath.h.Allarguments mustbeexpressionsofreal−floatingtype.

math.h tgmath.h Description isgreater − Returnsthevalueof(x)>(y) isgreaterequal − Returnsthevalueof(x)>=(y) isless − Returnsthevalueof(x)<(y) islessequal − Returnsthevalueof(x)<=(y) islessgreater − Returnsthevalueof(x)<(y)||(x)>(y) isunordered − Returns1ifitsargumentsareunordered,0otherwise.

Classificationmacros Thenextareimplementedasmacros.Thesemacrosaretypegenericandtherefordonothaveaparallelfunctionintgmath.h. Allargumentsmustbeexpressionsofreal−floatingtype.

math.h tgmath.h Description fpclassify − Returnstheclassofitsargument: FP_INFINITE,FP_NAN,FP_NORMAL,FP_SUBNORMALorFP_ZERO isfinite − Returnsanonzerovalueifandonlyifitsargumenthasafinitevalue isinf − Returnsanonzerovalueifandonlyifitsargumenthasaninfinitvalue isnan − ReturnsanonzerovalueifandonlyifitsargumenthasNaNvalue. isnormal − Returnsanonzerovalueifanonlyifitsargumenthasanormalvalue. signbit − Returnsanonzerovalueifandonlyifitsargumentvalueisnegative.

3−10 Libraries

3.2.16 setjmp.h

Thesetjmpandlongjmpinthisheaderfileimplementaprimitiveformofnonlocaljumps,whichmaybeusedtohandle exceptionalsituations.Thisfacilityistraditionallyconsideredmoreportablethansignal.h.

intsetjmp(jmp_bufenv) Recordsitscaller’senvironmentinenvandreturns0. voidlongjmp(jmp_bufenv, Restorestheenvironmentpreviouslysavedwithacalltosetjmp(). intstatus)

3.2.17 signal.h

Signalsarepossibleasynchronouseventsthatmayrequirespecialprocessing.Eachsignalisnamedbyanumber.The followingsignalsaredefined: SIGINT1 Receiptofaninteractiveattentionsignal SIGILL2 Detectionofaninvalidfunctionmessage SIGFPE3 Anerrouneousarithmeticoperation(forexample,zerodevide,overflow) SIGSEGV4 Aninvalidaccesstostorage SIGTERM5 Aterminationrequestsenttotheprogram SIGABRT6 Abnormalterminiation,suchasisinitiatedbytheabortfunction. Thenextfunctionsendsthesignalsigtotheprogram:

intraise(intsig)

Thenextfunctiondetermineshowsubsequentsignalswillbehandled:

signalfunction*signal(int,signalfunction*);

Thefirstargumentspecifiesthesignal,thesecondargumentpointstothesignal−handlerfunctionorhasoneofthefollowing values: SIG_DFL Defaultbehaviourisused SIG_IGN Thesignalisignored Thefunctionreturnsthepreviousvalueofsignalfunctionforthespecificsignal,orSIG_ERRifanerroroccurs.

3.2.18 stdarg.h

Thefacilitiesinthisheaderfilegivesyouaportablewaytoaccessvariableargumentslists,suchasneededforasfprintf andvfprintf.va_copyisnewinISOC99.Thisheaderfilecontainsthefollowingmacros:

va_arg(ap,type) Returnsthevalueofthenextargumentinthevariableargumentlist.It’sreturntypehasthetype ofthegivenargumenttype.Anextcalltothismacrowillreturnthevalueofthenextargument. va_copy(va_listdest, Thismacroduplicatesthecurrentstateofsrcindest,creatingasecondpointerintothe va_listsrc) argumentlist.Afterthiscall,va_arg()maybeusedonsrcanddestindependently. va_end(va_listap) Thismacromustbecalledaftertheargumentshavebeenprocessed.Itshouldbecalledbefore thefunctionusingthemacro’va_start’isterminated(ANSIspecification). va_start(va_listap, Thismacroinitializesap.Afterthiscall,eachcalltova_arg()willreturnthevalueofthenext lastarg); argument.Inourimplementation,va_listcannotcontainanybittypevariables.Alsothe givenargumentlastargmustbethelastnon−bittypeargumentinthelist.

3.2.19 stdbool.h

Thisheaderfilecontainsthefollowingmacrodefinitions.ThesenamesforbooleantypeandvaluesareconsistentwithC++.You areallowedto#undefineorredefinethemacrosbelow. #definebool_Bool #definetrue1 #definefalse0 #define__bool_true_false_are_defined1

3−11 MicroBlazeEmbeddedToolsReference

3.2.20 stddef.h

Thisheaderfiledefinesthetypesforcommonuse:

ptrdiff_t signedintegertypeoftheresultofsubtractingtwopointers. size_t unsignedintegraltypeoftheresultofthesizeofoperator. wchar_t integertypetorepresentcharactercodesinlargecharactersets.

Besidesthesetypes,thefollowingmacrosaredefined:

NULL expandstothenullpointerconstant offsetof(_type,_member) expandstoanintegerconstantexpressionwithtypesize_tthatistheoffsetinbytesof _memberwithinstructuretype_type.

3.2.21 stdint.h

Seesection3.2.9,inttypes.handstdint.h

3.2.22 stdio.handwchar.h

Types Theheaderfilestdio.hcontainsfunctionsforperforminginputandoutput.Anumberoffunctionsalsohaveaparallelwide characterfunctionormacro,definedinwchar.h.Theheaderfilewchar.halsoincludesstdio.h. IntheClanguage,manyI/Ofacilitiesarebasedontheconceptofstreams.Thestdio.hheaderfiledefinesthedatatype FILEwhichholdstheinformationaboutastream.AnFILEobjectiscreatedwiththefunctionfopen.Thepointertothisobject isusedasanargumentinmanyoftheinthisheaderfile.TheFILEobjectcancontainthefollowinginformation: • thecurrentpositionwithinthestream • pointerstoanyassociatedbuffers • indicationsofforread/writeerrors • endoffileindication Theheaderfilealsodefinestypefpos_tasanunsignedlong.

Macros

stdio.h/wchar.h Description NULL expandstothenullpointerconstant BUFSIZ Sizeofthebufferusedbythesetbuf/setvbuffunction:512 EOF Endoffileindicator.Expandsto−1. WEOF Endoffileindicator.ExpandstoUINT_MAX(definedinlimits.h) NOTE:WEOFneednottobeanegativenumberaslongasitsvaluedoesnotcorrespondtoamember ofthewidecharacterset.(Definedinwchar.h). FOPEN_MAX Numberoffilesthatcanbeopenedsimultaneously:10 FILENAME_MAX Maximumlengthofafilename:100 _IOFBF Expandtoanintegerexpression,suitableforuseasargumenttothesetvbuffunction. _IOLBF _IONBF L_tmpnam Sizeofthestringusedtoholdtemporaryfilenames:8(tmpxxxxx) TMP_MAX Maximumnumberofuniquetemporaryfilenamesthatcanbegenerated:0x8000 SEEK_CUR Expandtoanintegerexpression,suitableforuseasthethirdargumenttothefseekfunction. SEEK_END SEEK_SET stderr Expressionsoftype"pointertoFILE"thatpointtotheFILEobjectsassociatedwithstandarderror,input stdin andoutputstreams. stdout

3−12 Libraries

Fileaccess

stdio.h Description fopen(name,mode) Opensafileforagivenmode.Availablemodesare: "r" read;opentextfileforreading "w" write;createtextfileforwriting;ifthefilealreadyexistsitscontentsisdiscarded "a" append;openexistingtextfileorcreatenewtextfileforwritingatendoffile "r+" opentextfileforupdate;readingandwriting "w+" createtextfileforupdate;previouscontentsifanyisdiscarded "a+" append;openorcreatetextfileforupdate,writesatendoffile fclose(name) Flushesthedatastreamandclosesthespecifiedfilethatwaspreviouslyopenedwith fopen. fflush(name) Ifstreamisanoutputstream,anybufferedbutunwrittendateiswritten.Else,theeffectis undefined. freopen(name,mode,stream) Similartofopen,butratherthengeneratinganewvalueoftypeFILE*,theexistingvalue isassociatedwithanewstream. setbuf(stream,buffer) IfbufferisNULL,bufferingisturnedoffforthestream. Otherwise,setbufisequivalentto: (void)setvbuf(stream,buf,_IOFBF,BUFSIZ). setvbuf(stream,buffer, Controlsbufferingforthestream;thisfunctionmustbecalledbeforereadingorwriting. mode,size) Modecanhavethefollowingvalues: _IOFBF causesfullbuffering _IOLBF causeslinebufferingoftextfiles _IONBF causesnobuffering IfbufferisnotNULL,itwillbeusedasabuffer;otherwiseabufferwillbeallocated.size determinesthebuffersize.

Characterinput/output

Theformatstringofprintfrelatedfunctionscancontainplaintextmixedwithconversionspecifiers.Eachconversion specifiershouldbeprecededbya’%’character.Theconversionspecifiershouldbebuildinorder: − Flags(inanyorder): − specifiesleftadjustmentoftheconvertedargument. + anumberisalwaysprecededwithasigncharacter. +hashigherprecedencethanspace. space anegativenumberisprecededwithasign,positivenumberswithaspace. 0 specifiespaddingtothefieldwidthwithzeros(onlyfornumbers). # specifiesanalternateoutputform.Foro,thefirstdigitwillbezero.ForxorX,"0x"and"0X"willbeprefixedtothe number.Fore,E,f,g,G,theoutputalwayscontainsadecimalpoint,trailingzerosarenotremoved. − Anumberspecifyingaminimumfieldwidth.Theconvertedargumentisprintedinafieldwithatleastthelengthspecified here.Iftheconvertedargumenthasfewercharactersthanspecified,itwillbepaddedattheleftside(orattherightwhenthe flag’−’wasspecified)withspaces.Paddingtonumericfieldswillbedonewithzeroswhentheflag’0’isalsospecified(only whenpaddingleft).Insteadofanumericvalue,also’*’maybespecified,thevalueisthentakenfromthenextargument, whichisassumedtobeoftypeint. − Aperiod.Thisseparatestheminimumfieldwidthfromtheprecision. − Anumberspecifyingthemaximumlengthofastringtobeprinted.Orthenumberofdigitsprintedafterthedecimalpoint (onlyforfloating−pointconversions).Ortheminimumnumberofdigitstobeprintedforanintegerconversion.Insteadofa numericvalue,also’*’maybespecified,thevalueisthentakenfromthenextargument,whichisassumedtobeoftype int. − Alengthmodifier’h’,’hh’,’l’,’ll’,’L’,’j’,’z’or’t’.’h’indicatesthattheargumentistobetreatedasashortorunsigned short.’hh’indicatesthattheargumentistobetreatedasacharorunsignedchar.’l’shouldbeusediftheargumentis alonginteger,’ll’foralonglong.’L’indicatesthattheargumentisalongdouble.’j’indicatesapointertointmax_t oruintmax_t,’z’indicatesapointertosize_tand’t’indicatesapointertoptrdiff_t.

3−13 MicroBlazeEmbeddedToolsReference

Flags,lengthspecifier,period,precisionandlengthmodifierareoptional,theconversioncharacterisnot.Theconversion charactermustbeoneofthefollowing,ifacharacterfollowing’%’isnotinthelist,thebehaviorisundefined.

Character Printedas d,i int,signeddecimal o int,unsignedoctal x,X int,unsignedhexadecimalinlowercaseoruppercaserespectively u int,unsigneddecimal c int,singlecharacter(convertedtounsignedchar) s char*,thecharactersfromthestringareprinteduntilaNULLcharacterisfound.Whenthegivenprecisionis metbefore,printingwillalsostop f double e,E double g,G double a,A double n int*,thenumberofcharacterswrittensofariswrittenintotheargument.ThisshouldbeapointertoaninteĆ gerindefaultmemory.Novalueisprinted. p pointer(hexadecimal24−bitvalue) % Noargumentisconverted,a’%’isprinted.

Table3−2:Printfconversioncharacters Allargumentstothescanfrelatedfunctionsshouldbepointerstovariables(indefaultmemory)ofthetypewhichisspecifiedin theformatstring. Theformatstringcancontain: − Blanksortabs,whichareskipped. − Normalcharacters(not’%’),whichshouldbematchedexactlyintheinputstream. − Conversionspecifications,startingwitha’%’character. Conversionspecificationsshouldbebuiltasfollows(inorder): − A’*’,meaningthatnoassignmentisdoneforthisfield. − Anumberspecifyingthemaximumfieldwidth. − Theconversioncharactersd,i,n,o,uandxmaybeprecededby’h’iftheargumentisapointertoshortratherthanint, orby’hh’iftheargumentisapointertochar,orby’l’(letterell)iftheargumentisapointertolong,orby’ll’forapointerto longlong,’j’forapointertointmax_toruintmax_t,’z’forapointertosize_tor’t’forapointertoptrdiff_t.The conversioncharacterse,f,andgmaybeprecededby’l’iftheargumentisapointertodoubleratherthanfloat,andby ’L’forapointertoalongdouble. − Aconversionspecifier.’*’,maximumfieldwidthandlengthmodifierareoptional,theconversioncharacterisnot.The conversioncharactermustbeoneofthefollowing,ifacharacterfollowing’%’isnotinthelist,thebehaviorisundefined. Lengthspecifierandlengthmodifierareoptional,theconversioncharacterisnot.Theconversioncharactermustbeoneofthe following,ifacharacterfollowing’%’isnotinthelist,thebehaviorisundefined.

Character Scannedas d int,signeddecimal. i int,theintegermaybegivenoctal(i.e.aleading0isentered)orhexadecimal(leading"0x"or"0X"),orjust decimal. o int,unsignedoctal. u int,unsigneddecimal. x int,unsignedhexadecimalinlowercaseoruppercase. c singlecharacter(convertedtounsignedchar). s char*,astringofnonwhitespacecharacters.Theargumentshouldpointtoanarrayofcharacters,large enoughtoholdthestringandaterminatingNULLcharacter.

3−14 Libraries

Character Scannedas f float e,E float g,G float a,A float n int*,thenumberofcharacterswrittensofariswrittenintotheargument.Noscanningisdone. p pointer;hexadecimal24−bitvaluewhichmustbeenteredwithout0x−prefix. [...] Matchesastringofinputcharactersfromthesetbetweenthebrackets.ANULLcharacterisaddedtotermiĆ natethestring.Specifying[]...]includesthe’]’characterinthesetofscanningcharacters. [^...] Matchesastringofinputcharactersnotinthesetbetweenthebrackets.ANULLcharacterisaddedtotermiĆ natethestring.Specifying[^]...]includesthe’]’characterintheset. % Literal’%’,noassignmentisdone.

Table3−3:Scanfconversioncharacters

stdio.h wchar.h Description fscanf(stream, fwscanf(stream, Performsaformattedreadfromthegivenstream.Returnsthenumberof format,...) format,...) itemsconvertedsuccesfully.(FSSimplementation) scanf(format,...) wscanf(format,...) Performsaformattedreadfromthestdinstream.Returnsthenumber ofitemsconvertedsuccesfully.(FSSimplementation) sscanf(*s, swscanf(*s, Performsaformattedreadfromthestrings.Returnsthenumberofitems format,...) format,...) convertedsuccesfully. vfscanf(stream, vfwscanf(stream, Sameasfscanf/fwscanf,butextraargumentsaregivenasvariable format,arg) format,arg) argumentlistarg. (Seesection3.2.18,stdarg.h) vscanf(format,arg) vwscanf(format,arg) Sameasscanf/wscanf,butextraargumentsaregivenasvariablearĆ gumentlistarg. (Seesection3.2.18,stdarg.h) vsscanf(s,format, vswscanf(s,format, Sameasscanf/wscanf,butextraargumentsaregivenasvariablearĆ arg) arg) gumentlistarg. (Seesection3.2.18,stdarg.h) fprintf(stream, fwprintf(stream, Performsaformattedwritetothegivenstream.ReturnsEOF/WEOFon format,...) format,...) error. (FSSimplementation) printf(format,...) wprintf(format,...) Performsaformattedwritetothestreamstdout.ReturnsEOF/WEOF onerror. (FSSimplementation) sprintf(*s, − Performsaformattedwritetostrings.ReturnsEOF/WEOFonerror. format,...) snprintf(*s,n swprintf(*s,n Sameassprintf,butnspecifiesthemaximumnumberofcharacters format,...) format,...) (includingtheterminatingnullcharacter)tobewritten. vfprintf(stream, vfwprintf(stream, Sameasfprintf/fwprintf,butextraargumentsaregivenasvariable format,arg) format,arg) argumentlistarg.(Seesection3.2.18,stdarg.h) (FSSimplementation) vprintf(format, vwprintf(format, Sameasprintf/wprintf,butextraargumentsaregivenasvariable arg) arg) argumentlistarg.(Seesection3.2.18,stdarg.h) (FSSimplementation) vsprintf(*s, vswprintf(*s, Sameassprintf/swprintf,butextraargumentsaregivenasvariable format,arg) format,arg) argumentlistarg.(Seesection3.2.18,stdarg.h) (FSSimplementation)

3−15 MicroBlazeEmbeddedToolsReference

Characterinput/output

stdio.h wchar.h Description fgetc(stream) fgetwc(stream) Readsonecharacterfromstream.Returnsthereadcharacter,orEOF/ WEOFonerror. (FSSimplementation) getc(stream) getwc(stream) Sameasfgetc/fgetwcexceptthatisimplementedasamacro.(FSS implementation) NOTE:Currently#definedasgetchar()/getwchar()becauseFILE I/Oisnotsupported.Returnsthereadcharacter,orEOF/WEOFonerror. getchar(stdin) getwchar(stdin) Readsonecharacterfromthestdinstream.Returnsthecharacterread orEOF/WEOFonerror.Implementedasmacro. (FSSimplementation) fgets(*s,n, fgetws(*s,n, Readsatmostthenextn−1charactersfromthestreamintoarraysuntil stream) stream) anewlineisfound.ReturnssorNULLorEOF/WEOFonerror. (FSSimplementation) gets(*s,n,stdin) − Readsatmostthenextn−1charactersfromthestdinstreamintoarray s.Anewlineisignored.ReturnssorNULLorEOF/WEOFonerror. (FSSimplementation) ungetc(c,stream) ungetwc(c,stream) Pushescharactercbackontotheinputstream.ReturnsEOF/WEOFon error. fputc(c,stream) fputwc(c,stream) Putcharactercontothegivenstream. ReturnsEOF/WEOFonerror. (FSSimplementation) putc(c,stream) putwc(c,stream) Sameasfpuc/fputwcexceptthatisimplementedasamacro.(FSS implementation) putchar(c,stdout) putwchar(c,stdout) Putcharactercontothestdoutstream. ReturnsEOF/WEOFonerror. Implementedasmacro.(FSSimplementation) fputs(*s,stream) fputws(*s,stream) Writesstringstothegivenstream. ReturnsEOF/WEOFonerror. puts(*s)− Writesstringstothestdoutstream. ReturnsEOF/WEOFonerror. (FSSimplementation)

Directinput/output

stdio.h Description fread(ptr,size,nobj,stream) Readsnobjmembersofsizebytesfromthegivenstreamintothearraypointedtoby ptr.Returnsthenumberofelementssuccesfullyread. (FSSimplementation) fwrite((ptr,size,nobj,stream) Writesnobjmembersofsizebytesfromtothearraypointedtobyptrtothegiven stream.Returnsthenumberofelementssuccesfullywritten. (FSSimplementation)

Randomaccess

stdio.h Description fseek(stream,offset, Setsthepositionindicatorforstream.(FSSimplementation) origin)

Whenrepositioningabinaryfile,thenewpositionoriginisgivenbythefollowingmacros:

SEEK_SET0 offsetcharactersfromthebeginningofthefile SEEK_CUR1 offsetcharactersfromthecurrentpositioninthefile SEEK_END2 offsetcharactersfromtheendofthefile

3−16 Libraries

ftell(stream) Returnsthecurrentfilepositionforstream,or−1Lonerror. (FSSimplementation) rewind(stream) Setsthefilepositionindicatorforthestreamtothebeginningofthefile.Thisfunctionis equivalentto: (void)fseek(stream,0L,SEEK_SET); clearerr(stream); (FSSimplementation) fgetpos(stream,pos) Storesthecurrentvalueofthefilepositionindicatorforstreamintheobjectpointedtoby pos. (FSSimplementation) fsetpos(stream,pos) Positionsstreamatthepositionrecordedbyfgetposin*pos. (FSSimplementation)

Operationsonfiles

stdio.h Description remove(file) Removesthenamedfile,sothatasubsequentattempttoopenitfails.Returnsanon−zero valueifnotsuccesful. rename(old,new) Changesthenameofthefilefromoldnametonewname.Returnsanon−zerovalueifnot succesful. tmpfile() Createsatemporaryfileofthemode"wb+"thatwillbeautomaticallyremovedwhen closedorwhentheprogramterminatesnormally.Returnsafilepointer. tmpnam(buffer) Createsnewfilenamesthatdonotconflictwithotherfilenamescurrentlyinuse.Thenew filenameisstoredinabufferwhichmusthaveroomforL_tmpnamcharacters.Returnsa pointertothetemporaryname.Thefilenamesarecreatedinthecurrentdirectoryandall startwith"tmp".AtmostTMP_MAXuniquefilenamescanbegenerated.

Errorhandling

stdio.h Description clearerr(stream) Clearstheendoffileanderrorindicatorsforstream. ferror(stream) Returnsanon−zerovalueiftheerrorindicatorforstreamisset. feof(stream) Returnsanon−zerovalueiftheendoffileindicatorforstreamisset. perror(*s) Printssandtheerrormessagebelongingtotheintegererrno. (Seesection3.2.4,errno.h)

3.2.23 stdlib.handwchar.h

Theheaderfilestdlib.hcontainsgeneralutilityfunctionswhichfallintothefollowingcategories(Somehaveparallel wide−character,declaredinwchar.h) • Numericconversions • Randomnumbergeneration • Memorymanagement • Envirnomentcommunication • Searchingandsorting • Integerarithmetic • Multibyte/widecharacterandstringconversions. Macros

EXIT_SUCCES0 Predefinedexitcodesthatcanbeusedintheexitfunction. EXIT_FAILURE1 RAND_MAX32767 Highestnumberthatcanbereturnedbytherand/srandfunction. MB_CUR_MAX1 Maximumnumberofbytesinamultibytecharacterfortheextendedcharactersetspecifiedbythe currentlocale(categoryLC_CTYPE,seesection3.2.13,locale.h).

3−17 MicroBlazeEmbeddedToolsReference

Numericconversions Thefollowingfunctionsconverttheintialportionofastring*stoadouble,int,longintandlonglongintvalue respectively.

doubleatof(*s) intatoi(*s) longatol(*s) longlongatoll(*s)

Thefollowingfunctionsconverttheinitialportionofthestring*stoafloat,doubleandlongdoublevaluerespectively.*endpwill pointtothefirstcharacternotusedbytheconversion.

stdlib.h wchar.h floatstrtof(*s,**endp) floatwcstof(*s,**endp) doublestrtod(*s,**endp) doublewcstod(*s,**endp) longdoublestrtold(*s,**endp) longdoublewcstold(*s,**endp)

Thefollowingfunctionsconverttheinitialportionofthestring*stoalong,longlong,unsignedlongandunsigned longlongrespectively.Basespecifiestheradix.*endpwillpointtothefirstcharacternotusedbytheconversion.

stdlib.h wchar.h longstrtol(*s,**endp,base) longwcstol(*s,**endp,base) longlongstrtoll(*s,**endp,base) longlongwcstoll(*s,**endp,base) unsignedlongstrtoul(*s,**endp,base) unsignedlongwcstoul(*s,**endp,base) unsignedlonglong unsignedlonglong strtoull(*s,**endp,base) wcstoull(*s,**endp,base)

Randomnumbergeneration

rand Returnsapseudorandomintegerintherange0toRAND_MAX. srand(seed) Sameasrandbutusesseedforanewsequenceofpseudorandomnumbers.

Memorymanagement

malloc(size) Allocatesspaceforanobjectwithsizesize.Theallocatedspaceisnotinitialized.Returnsa pointertotheallocatedspace. calloc(nobj,size) Allocatesspacefornobjectswithsizesize.Theallocatedspaceisinitializedwithzeros.Returns apointertotheallocatedspace. free(*ptr) Deallocatesthememoryspacepointedtobyptrwhichshouldbeapointerearlierreturnedbythe mallocorcallocfunction. realloc(*ptr,size) Deallocatestheoldobjectpointedtobyptrandreturnsapointertoanewobjectwithsizesize, whilepreservingitscontents.Ifthenewsizeissmallerthantheoldsize,somecontentsatthe endoftheoldregionwillbediscarded.Ifthenewsizeislargerthantheoldsize,alloftheold contentsarepreservedandanybytesinthenewobjectbeyondthesizeoftheoldobjectwillhave indeterminatevalues.

Environmentcommunication

abort() Causesabnormalprogramtermination.IfthesignalSIGABRTiscaught,thesignalhandlermay takeovercontrol.(Seesection3.2.17,signal.h). atexit(*func) Funcpointstoafunctionthatiscalled(withoutarguments)whentheprogramnormally terminates. exit(status) Causesnormalprogramtermination.Actsasifmain()returnswithstatusasthereturnvalue. StatuscanalsobespecifiedwiththepredefinedmacrosEXIT_SUCCESorEXIT_FAILURE. _Exit(status) Sameasexit,butnoregisteredbytheatexitfunctionorsignalhandlersregisterdbythe signalfunctionarecalled.

3−18 Libraries

getenv(*s) Searchesanenvironmentlistforastrings.Returnsapointertothecontentsofs. NOTE:thisfunctionisnotimplementedbecausethereisnoOS. system(*s) Passesthestringstotheenvironmentforexecution. NOTE:thisfunctionisnotimplementedbecausethereisnoOS.

Searchingandsorting

bsearch(*key,*base, Thisfunctionsearchesinanarrayofnmembers,fortheobjectpointedtobykey.Theinitialbase n,size,*cmp) ofthearrayisgivenbybase.Thesizeofeachmemberisspecifiedbysize.Thegivenarraymust besortedinascendingorder,accordingtotheresultsofthefunctionpointedtobycmp.Returnsa pointertothematchingmemberinthearray,orNULLwhennotfound. qsort(*base,n, Thisfunctionsortsanarrayofnmembersusingthequicksortalgorithm.Theinitialbaseofthe size,*cmp) arrayisgivenbybase.Thesizeofeachmemberisspecifiedbysize.ThearrayissortedinasĆ cendingorder,accordingtotheresultsofthefunctionpointedtobycmp.

Integerarithmetic

intabs(j) Computetheabsolutevalueofanint,longint,andlonglongintjresepectively. longlabs(j) longlongllabs(j) div_tdiv(x,y) Computex/yandx%yinasingleoperation.Xandyhaverespectivelytypeint,longintand ldiv_tldiv(x,y) longlongint.Theresultisstoredinthemembersquotandremofstructdiv_t, lldiv_tlldiv(x,y) ldiv_tandlldiv_twhichhavethesametypes.

Multibyte/widecharacterandstringconversions

mblen(*s,n) Determinesthenumberofbytesinthemulti−bytecharacterpointedtobys.Atmostncharacters willbeexamined.(Seealsombrleninsection3.2.27,wchar.h) mbtowc(*pwc,*s,n) Convertsthemulti−bytecharacterinstoawide−charactercodeandstoresitinpwc.Atmostn characterswillbeexamined. wctomb(*s,wc) Convertsthewide−characterwcintoamulti−byterepresentationandstoresitinthestringpointed tobys.AtmostMB_CUR_MAXcharactersarestored. mbstowcs(*pwcs,*s,n) Convertsasequenceofmulti−bytecharactersinthestringpointedtobysintoasequenceof widecharactersandstoresatmostnwidecharactersintothearraypointedtobypwcs.(Seealso mbsrtowcsinsection3.2.27,wchar.h) wcstombs(*s,*pwcs,n) Convertsasequenceofwidecharactersinthearraypointedtobypwcsintomulti−bytecharacĆ tersandstoresatmostnmulti−bytecharactersintothestringpointedtobys.(Seealso wcsrtowmbinsection3.2.27,wchar.h)

3.2.24 string.handwchar.h

Thisheaderfileprovidesnumerousfunctionsformanipulatingstrings.Byconvention,stringsinCarearraysofcharacterswitha terminatingnullcharacter.Mostfunctionsthereforetakeargumentsoftype*char.However,manyfunctionshavealsoparallel wide−characterfunctionswhichtakeargumentsoftype*wchar_t.Thesefunctionsaredeclaredinwchar.h.

Copyingandconcatenationfunctions

stdio.h wchar.h Description memcpy(*s1,*s2,n) wmemcpy(*s1,*s2,n) Copiesncharactersfrom*s2into*s1andreturns*s1.If*s1and*s2 overlaptheresultisundefined. memmove(*s1,*s2,n) wmemmove(*s1,*s2,n) Sameasmemcpy,butoverlappingstringsarehandledcorrectly.Returns *s1. strcpy(*s1,*s2) wcscpy(*s1,*s2) Copies*s2into*s1andreturns*s1.If*s1and*s2overlaptheresultis undefined. strncpy(*s1,*s2,n) wcsncpy(*s1,*s2,n) Copiesnotmorethanncharactersfrom*s2into*s1andreturns*s1.If *s1and*s2overlaptheresultisundefined.

3−19 MicroBlazeEmbeddedToolsReference

stdio.h wchar.h Description strcat(*s1,*s2) wcscat(*s1,*s2) Appendsacopyof*s2to*s1andreturns*s1.If*s1and*s2overlapthe resultisundefined. strncat(*s1,*s2,n) wcsncat(*s1,*s2,n) Appendsnotmorethanncharactersfrom*s2to*s1andreturns*s1.If *s1and*s2overlaptheresultisundefined.

Comparisonfunctions

stdio.h wchar.h Description memcmp(*s1,*s2,n) wmemcmp(*s1,*s2,n) Comparesthefirstncharactersof*s1tothefirstncharactersof*s2. Returns<0if*s1<*s2,0if*s1==*s2,or>0if*s1>*s2. strcmp(*s1,*s2) wcscmp(*s1,*s2) Comparesstring*s1tostring*s2.Returns<0if*s1<*s2,0if*s1== *s2,or>0if*s1>*s2. strncmp(*s1,*s2,n) wcsncmp(*s1,*s2,n) Comparesthefirstncharactersof*s1tothefirstncharactersof*s2. Returns<0if*s1<*s2,0if*s1==*s2,or>0if*s1>*s2. strcoll(*s1,*s2) wcscoll(*s1,*s2) Performsalocal−specificcomparisonbetweenstring*s1andstring*s2 accordingtotheLC_COLLATEcategoryofthecurrentlocale.Returns< 0if*s1<*s2,0if*s1==*s2,or>0if*s1>*s2.(Seesection3.2.13, locale.h) strxfrm(*s1,*s2,n) wcsxfrm(*s1,*s2,n) Transforms(alocal)string*s2sothatacomparisonbetween transformedstringswithstrcmpgivesthesameresultasacomparison betweennon−transformedstringswithstrcoll.Returnsthe transformedstring*s1.

Searchfunctions

stdio.h wchar.h Description memchr(*s,c,n) wmemchr(*s,c,n) Checksthefirstncharactersof*sontheoccurenceofcharacterc. Returnsapointertothefoundcharacter. strchr(*s,c) wcschr(*s,c) Returnsapointertothefirstoccurenceofcharactercinstring*sorthe nullpointerifnotfound. strrchr(*s,c) wcsrchr(*s,c) Returnsapointertothelastoccurenceofcharactercinstring*sorthe nullpointerifnotfound. strspn(*s,*set) wcsspn(*s,*set) Searches*sforasequenceofcharactersspecifiedin*set.Returnsthe lengthofthefirstsequencefound. strcspn(*s,*set) wcscspn(*s,*set) Searches*sforasequenceofcharactersnotspecifiedin*set.Returns thelengthofthefirstsequencefound. strpbrk(*s,*set) wcspbrk(*s,*set) Sameasstrspn/wcsspnbutreturnsapointertothefirstcharacterin*s thatalsoisspecifiedin*set. strstr(*s,*sub) wcsstr(*s,*sub) Searchesforasubstring*subin*s.Returnsapointertothefirst occurenceof*subin*s. strtok(*s,*delim) wcstok(*s,*delim) Asequenceofcallstothisfunctionbreaksthestring*sintoasequence oftokensdelimitedbyacharacterspecifiedin*delim.Thetokenfoundin *sisterminatedwithanullcharacter.Thefunctionreturnsapointertothe firstpositionin*softhetoken.

Miscellaneousfunctions

stdio.h wchar.h Description memset(*s,c,n) wmemset(*s,c,n) Fillsthefirstnbytesof*swithcharactercandreturns*s. strerror(errno)− Typically,thevaluesforerrnocomefrominterrno.ThisfunctionreĆ turnsapointertotheassociatederrormessage.(Seealsosection3.2.4, errno.h) strlen(*s) wcslen(*s) Returnsthelengthofstring*s.

3−20 Libraries

3.2.25 time.handwchar.h

Theheaderfiletime.hprovidesfacilitiestoretrieveandusethe(calendar)dateandtime,andtheprocesstime.Timecanbe representedasanintegervalue,orcanbebroken−downincomponents.Twoarithmeticdatatypesaredefinedwhichare capableofholdingtheintegerrepresentationoftimes: clock_t unsignedlonglong time_t unsignedlong

ThetypestructtmbelowisdefinedaccordingtoISO/IEC9899withoneexception:thisimplementationdoesnotsupportleap seconds.Thestructtmtypeisdefinesasfollows: structtm { inttm_sec;/*secondsaftertheminute−[0,59]*/ inttm_min;/*minutesafterthehour−[0,59]*/ inttm_hour;/*hourssincemidnight−[0,23]*/ inttm_mday;/*dayofthemonth−[1,31]*/ inttm_mon;/*monthssinceJanuary−[0,11]*/ inttm_year;/*yearsince1900*/ inttm_wday;/*dayssinceSunday−[0,6]*/ inttm_yday;/*dayssinceJanuary1−[0,365]*/ inttm_isdst;/*DaylightSavingTimeflag*/ };

Timemanipulation

clock Returnstheapplication’sbestapproximationtotheprocessortimeusedbytheprogramsinceitwas started.Thislow−levelroutineisnotimplementedbecauseitstronglydependsonthehardware.To determinethetimeinseconds,theresultofclockshouldbedividedbythevaluedefinedas CLOCKS_PER_SEC12000000 difftime(t1,t0) Returnsthedifferencet1−t0inseconds. mktime(tm*tp) Convertsthebroken−downtimeinthestructurepointedtobytp,toavalueoftypetime_t.The returnvaluehasthesameencodingasthereturnvalueofthetimefunction. time(*timer) Returnsthecurrentcalendartime.Thisvalueisalsoassignedto*timer.

Timeconversion

asctime(tm*tp) Convertsthebroken−downtimeinthestructurepointedtobytpintoastringintheformMonJan 2116:15:142004\n\0.Returnsapointertothisstring. ctime(*timer) Convertsthecalendertimepointedtobytimertolocaltimeintheformofastring.Thisisequivalent to:asctime(localtime(timer)) gmtime(*timer) Convertsthecalendertimepointedtobytimertothebroken−downtime,expressedasUTC. Returnsapointertothebroken−downtime. localtime(*timer) Convertsthecalendartimepointedtobytimertothebroken−downtime,expressedaslocaltime. Returnsapointertothebroken−downtime.

Formattedtime Thenextfunctionhasaparallelfunctiondefinedinwchar.h:

stdio.h wchar.h strftime(*s,smax,*fmt,tm*tp) wstrftime(*s,smax,*fmt,tm*tp)

Formatsdateandtimeinformationfromstructtm*tpinto*saccordingtothespecifiedformat*fmt.Nomorethansmax charactersareplacedinto*s.Theformattingofstrftimeislocale−specificusingtheLC_TIMEcategory(seesection3.2.13, locale.h).Youcanusethenextconversionspecifiers:

3−21 MicroBlazeEmbeddedToolsReference

%a abbreviatedweekdayname %A fullweekdayname %b abbreviatedmonthname %B fullmonthname %c localdateandtimerepresentation(sameas%a%b%e%T%Y) %C lasttwooftheyear %d dayofthemonth(01−31) %D sameas%m/%d/%y %e dayofthemonth(1−31),withsingledigitsprecededbyaspace %F ISO8601dateformat:%Y−%m−%d %g lasttwodigitsoftheweekbasedyear(00−99) %G weekbasedyear(0000˘9999) %h sameas%b %H hour,24−hourclock(00−23) %I hour,12−hourclock(01−12) %j dayoftheyear(001−366) %m month(01−12) %M minute(00−59) %n replacedbythenewlinecharacter %p localequivalentofAMorPM %r locale’s12−hourclocktime;sameas%I:%M:%S%p %R sameas%H:%M %S second(00−59) %t replacedbyhorizontaltabcharacter %T ISO8601timeformat:%H:%M:%S %u ISO8601weekdaynumber(1−7),Mondayasfirstdayoftheweek %U weeknumberoftheyear,Sundayasfirstdayoftheweek(00−53) %V ISO8601weeknumber(01−53)intheweek−basedyear %w weekday(0−6,Sundayis0) %W weeknumberoftheyear(00−53),week1hasthefirstMonday %x localdaterepresentation %X localtimerepresentation %y yearwithoutcentury(00−99) %Y yearwithcentury %z ISO8601offsetoftimezonefromUTC,ornothing %Z timezonename,ifany %% %

3.2.26 unistd.h

Thefileunistd.hcontainsstandardUNIXI/Ofunctions.Thesefunctionsareallimplementedusingthedebugger’sfilesystem simulation.Exceptforlstatandfstatwhicharenotimplemented.ThisheaderfileisnotdefinedinISOC99.

access(*name,mode) Usethefilesystemsimulationofthedebuggertocheckthepermissionsofafileonthehost.mode specifiesthetypeofaccessandisabitpatternconstructedbyalogicalORofthefollowingvalues: R_OK Checksreadpermission. W_OK Checkswritepermission. X_OK Checksexecute(search)permission. F_OK Checkstoseeifthefileexists. (FSSimplementation) chdir(*path) Usethefilesystemsimulationfeatureofthedebuggertochangethecurrentdirectoryonthehost tothedirectoryindicatedbypath. (FSSimplementation) close(fd) Fileclosefunction.Thegivenfiledescriptorshouldbeproperlyclosed.Thisfunctioncalls _close(). (FSSimplementation) getcwd(*buf,size) Usethefilesystemsimulationfeatureofthedebuggertoretrievethecurrentdirectoryonthehost. Returnsthedirectoryname. (FSSimplementation)

3−22 Libraries

lseek(fd,offset, Movesread−writefileoffset.Calls_lseek(). whence) (FSSimplementation) read(fd,*buff,cnt) Readsasequenceofcharactersfromafile.Thisfunctioncalls_read().(FSSimplementation) stat(*name,*buff) Usethefilesystemsimulationfeatureofthedebuggertostat()afileonthehostplatform. (FSSimplementation) lstat(*name,*buff) Thisfunctionisidenticaltostat(),exceptinthecaseofasymboliclink,wherethelinkitselfis ’stat’−ed,notthefilethatitrefersto. (Notimplemented) fstat(fd,*buff) Thisfunctionisidenticaltostat(),exceptthatitusesafiledescriptorinsteadofaname.(Not implemented)

unlink(*name) Removesthenamedfile,sothatasubsequentattempttoopenitfails.Calls_unlink(). (FSSimplementation) write(fd,*buff,cnt) Writeasequenceofcharacterstoafile.Calls_write(). (FSSimplementation)

3.2.27 wchar.h

Manyinwchar.hrepresentthewide−charactervariantofothersothesearediscussedtogether.(Seesections3.2.22,stdio.h andwchar.h,3.2.23,stdlib.handwchar.h,3.2.24,string.handwchar.hand3.2.25,time.handwchar.h). Theremainingaredescribedbelow.Theyperformconversionsbetweenmulti−bytecharactersandwidecharacters.Inthese,ps pointstostructmbstate_twhichholdstheconversionstateinformationnecessarytoconvertbetweensequencesofmultibyte charactersandwidecharacters: typedefstruct { wchar_twc_value;/*widecharactervaluesolvedsofar*/ unsignedshortn_bytes;/*numberofbytesofsolvedmultibyte*/ unsignedshortencoding;/*encodingruleforwidecharacter<=> multibyteconversion*/ }mbstate_t;

Whenmultibytecharacterslargerthan1byteareused,thisstructwillbeusedtostoretheconversioninformationwhennotall thebytesofaparticularmultibytecharacterhavebeenreadfromthesource.Inthisimplementation,multi−bytecharactersare1 bytelong(MB_CUR_MAXandMB_LEN_MAXaredefinedas1)andthiswillneveroccur.

mbsinit(*ps) Determineswhethertheobjectpointedtobyps,isaninitialconversionstate.Returns anon−zerovalueifso. mbsrtowcs(*pwcs,**src,n,*ps) Restartableversionofmbstowcs.Seesection3.2.23,stdlib.handwchar.h.Theinitial conversionstateisspecifiedbyps.Theinputsequenceofmultibytecharactersis specifiedindirectlybysrc. wcsrtombs(*s,**src,n,*ps) Restartableversionofwcstombs.Seesection3.2.23,stdlib.handwchar.h.Theinitial conversionstateisspecifiedbyps.Theinputwidestringisspecifiedindirectlybysrc. mbrtowc(*pwc,*s,n,*ps) Convertsamultibytecharacter*stoawidecharacter*pwcaccordingtoconversionstate ps.Seealsombtowcinsection3.2.23,stdlib.handwchar.h. wcrtomb(*s,wc,*ps) Convertsawidecharacterwctoamulti−bytecharacteraccordingtoconversionstate psandstoresthemulti−bytecharacterin*s. btowc(c) Returnsthewidecharactercorrespondingtocharacterc.ReturnsWEOFonerror. wctob(c) Returnsthemulti−bytecharactercorrespondingtothewidecharacterc.Thereturned multi−bytecharacterisrepresentedasonebyte.ReturnsEOFonerror. mbrlen(*s,n,*ps) Inspectsuptonbytesfromthestring*stoseeifthosecharactersrepresentvalid multibytecharacters,relativetotheconversionstateheldin*ps.

3−23 MicroBlazeEmbeddedToolsReference

3.2.28 wctype.h

Mostinwctype.hrepresentthewide−charactervariantofdeclaredinctype.handarediscussedinsection3.2.3,ctype.hand wctype.h.Inaddition,thisheaderfileprovidesextensible,localespecific,widecharacterclassification.

wctype(*property) Constructsavalueoftypewctype_tthatdescribesaclassofwidecharactersidentifiedbythe string*property.IfpropertyidentifiesavalidclassofwidecharactersaccordingtotheLC_TYPE category(seesection3.2.13,locale.h)ofthecurrentlocale,anon−zerovalueisreturnedthatcan beusedasanargumentintheiswctypefunction. iswctype(wc,desc) Testswhetherthewidecharacterwcisamemberoftheclassrepresentedbywctype_tdesc. Returnsanon−zerovalueiftestedtrue.

Function Equivalenttolocalespecifictest iswalnum(wc) iswctype(wc,wctype("alnum")) iswalpha(wc) iswctype(wc,wctype("alpha")) iswcntrl(wc) iswctype(wc,wctype("cntrl")) iswdigit(wc) iswctype(wc,wctype("digit")) iswgraph(wc) iswctype(wc,wctype("graph")) iswlower(wc) iswctype(wc,wctype("lower")) iswprint(wc) iswctype(wc,wctype("print")) iswpunct(wc) iswctype(wc,wctype("punct")) iswspace(wc) iswctype(wc,wctype("space")) iswupper(wc) iswctype(wc,wctype("upper")) iswxditig(wc) iswctype(wc,wctype("xdigit"))

wctrans(*property) Constructsavalueoftypewctype_tthatdescribesamappingbetweenwidecharactersidentiĆ fiedbythestring*property.Ifpropertyidentifiesavalidmappingofwidecharactersaccordingto theLC_TYPEcategory(seesection3.2.13,locale.h)ofthecurrentlocale,anon−zerovalueis returnedthatcanbeusedasanargumentinthetowctransfunction. towctrans(wc,desc) Transformswidecharacterwcintoanotherwide−character,describedbydesc.

Function Equivalenttolocalespecifictransformation towlower(wc) towctrans(wc,wctrans("tolower") towupper(wc) towctrans(wc,wctrans("toupper")

3−24 4 AssemblyLanguage

Summary ThischapterdescribesthemostimportantaspectsoftheTASKINGassembly languageandcontainsadetaileddescriptionofallbuilt−inassemblyfunctionsand assemblerdirectives.Foracompleteoverviewofthearchitectureyouareusingand adescriptionoftheassemblyinstructionset,refertothetarget’sCoreReference Manual.

4.1 AssemblySyntax

Anassemblyprogramconsistsofzeroormorestatements.Astatementmayoptionallybefollowedbyacomment.Anysource statementcanbeextendedtomorelinesbyincludingthelinecontinuationcharacter(\)asthelastcharacterontheline.The lengthofasourcestatement(firstlineandcontinuationlines)isonlylimitedbytheamountofavailablememory. Mnemonicsanddirectivesarecaseinsensitive.Labels,symbols,directivearguments,andliteralstringsarecasesensitive. Thesyntaxofanassemblystatementis: [label[:]][instruction|directive|macro_call][;comment] label Alabelisaspecialsymbolwhichisassignedthevalueandtypeofthecurrentprogramlocationcounter.Alabel canconsistofletters,digitsandunderscorecharacters(_).Thefirstcharactercannotbeadigit.Alabelwhichis prefixedbywhitespace(spacesortabs)hastobefollowedbyacolon(:).Thesizeofanidentifierisonlylimited bytheamountofavailablememory. Examples: LAB1:;Thislabelisfollowedbyacolonand ;canbeprefixedbywhitespace LAB1;Thislabelhastostartatthebeginning ;ofaline instruction Aninstructionconsistsofamnemonicandzero,oneormoreoperands.Itmustnotstartinthefirstcolumn. Operandsaredescribedinsection4.3,OperandsofanAssemblyInstruction.Theinstructionsaredescribedin thetarget’sCoreReferenceManual. Theinstructioncanalsobeaso−called’genericinstruction’.Genericinstructionsarepseudoinstructions(no instructionsfromtheinstructionset).Dependingonthesituationinwhichagenericinstructionisused,the assemblerreplacesthegenericinstructionwithappropriaterealassemblyinstruction(s).Foracompletelist,see section4.10,GenericInstructions. directive Withdirectivesyoucancontroltheassemblerfromwithintheassemblysource.Exceptforpreprocessing directives,thesemustnotstartinthefirstcolumn.Directivesaredescribedinsection4.8,AssemblerDirectives. macro_call Acalltoapreviouslydefinedmacro.Itmustnotstartinthefirstcolumn.Seesection4.9MacroOperations. comment Comment,precededbya;(semicolon). Youcanuseemptylinesorlineswithonlycomments.

4−1 MicroBlazeEmbeddedToolsReference

4.2 AssemblerSignificantCharacters

YoucanuseallASCIIcharactersintheassemblysourcebothinstringsandincomments.Alsotheextendedcharactersfrom theISO8859−1(Latin−1)setareallowed. Somecharactershaveaspecialmeaningtotheassembler.Specialcharactersassociatedwithexpressionevaluationare describedinsection4.6.3,ExpressionOperators.Otherspecialassemblercharactersare:

Character Description ; Startofacomment \ Linecontinuationcharacteror Macrooperator:argumentconcatenation ? Macrooperator:returndecimalvalueofasymbol % Macrooperator:returnhexvalueofasymbol ^ Macrooperator:overridelocallabel " Macrostringdelimiteror Quotedstring.DEFINEexpansioncharacter ’ Stringconstantsdelimiter @ Startofabuilt−inassemblyfunction $ Locationcountersubstitution [] Substringdelimiter

Notethatmacrooperatorshaveahigherprecedencethanexpressionoperators.

4.3 OperandsofanAssemblyInstruction

Inaninstruction,themnemonicisfollowedbyzero,oneormoreoperands.Anoperandhasoneofthefollowingtypes:

Operand Description symbol Asymbolicnameasdescribedinsection4.4,SymbolNames.Symbolscanalsooccurinexpressions. register Anyvalidregisteraslistedinsection4.5,Registers. expression Anyvalidexpressionasdescribedinsection4.6,AssemblyExpressions. address Acombinationofexpression,registerandsymbol.

4.4 SymbolNames

User−definedsymbols Auser−definedsymbolcanconsistofletters,digitsandunderscorecharacters(_).Thefirstcharactercannotbeadigit.Thesize ofanidentifierisonlylimitedbytheamountofavailablememory.Thecaseofthesecharactersissignificant.Youcandefinea symbolbymeansofalabeldeclarationoranequateorsetdirective.

Predefinedpreprocessorsymbols Thesesymbolsstartandendwithtwounderscorecharacters,__symbol__,andyoucanusetheminyourassemblysourceto createconditionalassembly.Seesection4.4.1,PredefinedPreprocessorSymbols.

Labels Symbolsusedformemorylocationsarereferredtoaslabels. Itisallowedtousereservedsymbolsaslabelsaslongasthelabelisfollowedbyacolonorstartsatthefirstcolumn

4−2 AssemblyLanguage

Reservedsymbols Symbolnamesandotheridentifiersbeginningwithaperiod(.)arereservedforthesystem(forexamplefordirectivesorsection names).Instructionsarealsoreserved.Thecaseofthesebuilt−insymbolsisinsignificant.

Examples Validsymbolnames: loop_1 ENTRY a_B_c _aBC

Invalidsymbolnames: 1_loop(startswithanumber) .DEFINE(reserveddirectivename)

4.4.1 PredefinedPreprocessorSymbols

TheTASKINGassemblerknowsthepredefinedsymbolsasdefinedinthetablebelow.Thesymbolsareusefultocreate conditionalassembly.

Macro Description __BUILD__ Identifiesthebuildnumberoftheassembler,composedofdecimaldigitsforthebuildnumber, threedigitsforthemajorbranchnumberandthreedigitsfortheminorbranchnumber.For example,ifyouusebuild1.22.1ofthecompiler,__BUILD__expandsto1022001.Ifthereisno branchnumber,thebranchdigitsexpandtozero.Forexample,build127resultsin127000000. __MB__ Expandsto1fortheMicroBlazetoolset,otherwiseunrecognizedasmacro. __REVISION__ Identifiestherevisionnumberoftheassembler.Forexample,ifyouuseversion1.0r2ofthe compiler,__REVISION__expandsto2. __TASKING__ IdentifiestheassemblerasaTASKINGassembler.Expandsto1ifaTASKINGcompilerisused. __VERSION__ Identifiestheversionnumberoftheassembler.Forexample,ifyouuseversion1.0r2ofthe assembler,__VERSION__expandsto1000(dotandrevisionnumberareomitted,minorversion numberin3digits).

Table4−1:Assemblerpredefinedpreprocessorsymbols

4.5 Registers

Thefollowingregisternames,eitherupperorlowercase,shouldnotbeusedforuser−definedsymbolnamesinanassembly languagesourcefile:

MicroBlazeregisters R0..R31

4.6 AssemblyExpressions

Anexpressionisacombinationofsymbols,constants,operators,andparentheseswhichrepresentavaluethatisusedasan operandofanassemblerinstruction(ordirective). Expressionsmaycontainuser−definedlabels(andtheirassociatedintegervalues),andanycombinationofintegersorASCII literalstrings. Expressionsfollowtheconventionalrulesofalgebraandbooleanarithmetic. Expressionsthatcanbeevaluatedatassemblytimearecalledabsoluteexpressions.Expressionswheretheresultisunknown untilallsectionshavebeencombinedandlocated,arecalledrelocatableorrelativeexpressions. Whenanyoperandofanexpressionisrelocatable,theentireexpressionisrelocatable.Relocatableexpressionsareemittedin theobjectfileandevaluatedbythelinker. 4−3 MicroBlazeEmbeddedToolsReference

Theassemblerevaluatesexpressionswith64−bitprecisionintwo’scomplement. Thesyntaxofanexpressioncanbeanyofthefollowing: − numericcontant − string − symbol − expressionbinary_operatorexpression − unary_operatorexpression − (expression) − functioncall Alltypesofexpressionsareexplainedinseparatesections.

4.6.1 NumericConstants

Numericconstantscanbeusedinexpressions.Ifthereisnoprefix,bydefaulttheassemblerassumesthenumberisadecimal number.

Base Description Example 0b1101 Binary A0bprefixfollowedbybinarydigits(0,1).Oruseabsuffix 11001010b 0x12FF Hexadecimal A0xprefixfollowedbyahexadecimaldigits(0−9,A−F,a−f).Oruseahsuffix 0x45 0fa10h Decimal, 12 Decimaldigits(0−9). integer 1245

Table4−2:Numericconstants

4.6.2 Strings

ASCIIcharacters,enclosedinsingle(’)ordouble(″)quotesconstitueanASCIIstring.Stringsbetweendoublequotesallow symbolsubstitutionbya.DEFINEdirective,whereasstringsbetweensinglequotesarealwaysliteralstrings.Bothtypesof stringscancontainescapecharacters. Stringsconstantsinexpressionsareevaluatedtoanumber(eachcharacterisreplacedbyitsASCIIvalue).Stringsin expressionscanhaveasizeofupto8charactersorlessdependingontheoperandofaninstructionordirective;any subsequentcharactersinthestringareignored.Inthiscasetheassemblerissuesawarning.Anexceptiontothisruleiswhena stringisusedina.DBassemblerdirective;inthatcaseallcharactersresultinaconstantvalueofthespecifiedsize.Nullstrings haveavalueof0. Squarebrackets([])delimitasubstringoperationintheform: [string,offset,length] offsetisthestartpositionwithinstring.lengthisthelengthofthedesiredsubstring.Bothvaluesmaynotexceedthesizeof string.

Examples ’ABCD’;(0x41424344) ’’’79’;toencloseaquotedoubleit "A\"BC";ortoencloseaquoteescapeit ’AB’+1;(0x4143)stringusedinexpression ’’;nullstring [’TASKING’,0,4];resultsinthesubstring’TASK’

4−4 AssemblyLanguage

4.6.3 ExpressionOperators

Thenexttableshowstheassembleroperators.Theyareorderedaccordingtotheirprecedence.Operatorsofthesame precedenceareevaluatedlefttoright.Parentheticalexpressionshavethehighestpriority(innermostfirst). Validoperandsincludenumericconstants,literalASCIIstringsandsymbols.

Type Oper Name Description ator () parenthesis Expressionsenclosedbyparenthesisareevaluatedfirst. Unary + plus Returnsthevalueofitsoperand. − minus Returnsthenegativeofitsoperand. ~ complement Returnscomplement,integeronly ! logicalnegate Returns1iftheoperands’valueis0;otherwise0.Forexample,ifbufis0then !bufis1. Arithmetic * multiplication Yieldstheproductoftwooperands. / division Yieldsthequotientofthedivisionofthefirstoperandbythesecond. Withintegers,thedivideoperationproducesatruncatedinteger. % modulo Integeronly:yieldstheremainderfromadivisionofthefirstoperandbythe second. + addition Yieldsthesumofitsoperands. − subtraction Yieldsthedifferenceofitsoperands. Shift << shiftleft Integeronly:shiftstheleftoperandtotheleft(zero−filled)bythenumberofbits specifiedbytherightoperand. >> shiftright Integeronly:shiftstheleftoperandtotheright(signbitextended)bythenumber ofbitsspecifiedbytherightoperand. Relational < lessthan <= lessorequal Returns: > greaterthan aninteger1iftheindicatedconditionisTRUE. >= greaterorequal aninteger0iftheindicatedconditionisFALSE. == equal != notequal Bitwise & AND Integeronly:yieldsbitwiseAND | OR Integeronly:yieldsbitwiseOR ^ exclusiveOR Integeronly:yieldsbitwiseexlusiveOR Logical && logicalAND Returnsaninteger1ifbothoperandsarenon−zero;otherwise,itreturnsan integer0. || logicalOR Returnsaninteger1ifeitheroftheoperandsisnon−zero;otherwise,itreturnsan integer1

Table4−3:Assemblyexpressionoperators

4.7 Built−inAssemblyFunctions

TheTASKINGassemblershaveseveralbuilt−infunctionstosupportdataconversion,stringcomparison,andmath computations.Youcanusefunctionsastermsinanyexpression.

Syntaxofanassemblyfunction @function_name([argument[,argument]...]) Functionsstartwith’@’characterandhavezeroormorearguments,andarealwaysfollowedbyopeningandclosing parentheses.Whitespace(ablankortab)isnotallowedbetweenthefunctionnameandtheopeningparenthesisandbetween the(comma−separated)arguments.

4−5 MicroBlazeEmbeddedToolsReference

4.7.1 OverviewofBuilt−inAssemblyFunctions

Thefollowingtableprovidesanoverviewofallbuilt−inassemblyfunctions.Nextallfunctionsaredescribedintomoredetail.expr canbeanyassemblyexpressionresultinginanintegervalue.Expressionsareexplainedinsection4.6,AssemblyExpressions.

Overviewofassemblyfunctions

Function Description @ARG(’symbol’|expr) Testwhethermacroargumentispresent @CAST(type,expr) Castresultofexprtotype @CNT() Returnnumberofmacroarguments @DEFINED(’symbol’|symbol) Testwhethersymbolexists @LSB(expr) Leastsignificantbyteoftheexpression @LSH(expr) Leastsignificanthalfwordoftheabsoluteexpression @LSW(expr) Leastsignificantwordoftheexpression @MSB(expr) Mostsignificantbyteoftheexpression @MSH(expr) Mostsignificanthalfwordoftheabsoluteexpression @MSW(expr) Mostsignificantwordoftheexpression @STRCAT(str1,str2) Concatenatestr1andstr2 @STRCMP(str1,str2) Comparestr1withstr2 @STRLEN(str) Returnlengthofstring @STRPOS(str1,str2[,start]) Returnpositionofstr1instr2 @USE_BARREL_SHIFT() Testifhardwarebarrelshiftisenabled @USE_DIVIDE() Testifhardwaredivideisenabled @USE_MULTIPLY() Testifhardwaremultiplyisenabled

4.7.2 DetailedDescriptionofBuilt−inAssemblyFunctions

@ARG(’symbol’|expression) Returnsinteger1ifthemacroargumentrepresentedbysymbolorexpressionispresent,0otherwise. Youcanspecifytheargumentwithasymbolname(thenameofamacroargumentenclosedinsinglequotes)orwithexpression (theordinalnumberoftheargumentinthemacroformalargumentlist). Ifyouusethisfunctionwhenmacroexpansionisnotactive,theassemblerissuesawarning. Example: .IF@ARG(’TWIDDLE’);isargumenttwiddlepresent? .IF@ARG(1);isfirstargumentpresent?

@CAST(type,expression) Returnstheresultofexpression,butwiththespecifiedtype. Thisfunctioncanbeusefulwhenyouassemblewithexpressiontype−checkingenabled(option−−type−checking),andthe assemblerreportsatypeconflict.Youcanthencasttheexpressiontothecorrecttype. Thefollowingtypesareallowed: data,code,debug

@CNT()

Returnsthenumberofmacroargumentsofthecurrentmacroexpansionasaninteger. Ifyouusethisfunctionwhenmacroexpansionisnotactive,theassemblerissuesawarning.

4−6 AssemblyLanguage

Example: ARGCOUNT.SET@CNT();reserveargumentcount

@DEFINED(’symbol’|symbol) Returns1ifsymbolhasbeendefined,0otherwise.Ifsymbolisquoted,itislookedupasa.DEFINEsymbol;ifitisnotquoted,it islookedupasanordinarysymbol,macroorlabel. Example: .IF@DEFINED(’ANGLE’);issymbolANGLEdefined? .IF@DEFINED(ANGLE);doeslabelANGLEexist?

@LSB(expression) Returnstheleastsignificantbyteoftheresultoftheexpression. Theresultoftheexpressioniscalculatedas16bits.

@LSH(expression) Returnstheleastsignificanthalfword(bits0..15)oftheresultoftheabsoluteexpression. Theresultoftheexpressioniscalculatedasaword(32bits).

@LSW(expression) Returnstheleastsignificantword(bits0..31)oftheresultoftheexpression. Theresultoftheexpressioniscalculatedasadouble−word(64bits).

@MSB(expression) Returnsthemostsignificantbyteoftheresultoftheexpression. Theresultoftheexpressioniscalculatedas16bits.

@MSH(expression) Returnsthemostsignificanthalfword(bits16..31)oftheresultoftheabsoluteexpression. Theresultoftheexpressioniscalculatedasaword(32bits).@MSH(expression)isequivalentto((expression>>16)& 0xffff).

@MSW(expression) Returnsthemostsignificantword(bits32..63)oftheresultoftheexpression. Theresultoftheexpressioniscalculatedasadouble−word(64bits).

@STRCAT(string1,string2) Concatenatesstring1andstring2andreturnsthemasasinglestring. Youmustenclosestring1andstring2eitherwithsinglequotesorwithdoublequotes. Example: .DEFINEID"@STRCAT(’TAS’,’KING’)";ID=’TASKING’

@STRCMP(string1,string2) Comparesstring1withstring2bycomparingthecharactersinthestring.Thefunctionreturnsthedifferencebetweenthe charactersatthefirstpositionwheretheydisagree,orzerowhenthestringsareequal: <0 ifstring1<string2 0 ifstring1==string2 >0 ifstring1>string2 Example: .IF(@STRCMP(STR,’MAIN’))==0;doesSTRequal’MAIN’?

4−7 MicroBlazeEmbeddedToolsReference

@STRLEN(string) Returnsthelengthofstringasaninteger. Example: SLENSET@STRLEN(’string’);SLEN=6

@STRPOS(string1,string2[,start]) Returnsthepositionofstring2instring1asaninteger.Ifstring2doesnotoccurinstring1,thelaststringpostition+1isreturned. Withstartyoucanspecifythestartingpositionofthesearch.Ifyoudonotspecifystart,thesearchisstartedfromthebeginning ofstring1. Example: ID.set@STRPOS(’TASKING’,’ASK’);ID=1 ID.set@STRPOS(’TASKING’,’BUG’);ID=7

@USE_BARREL_SHIFT() Returns1ifhardwarebarrelshiftisavailable,0otherwise.

@USE_DIVIDE() Returns1ifhardwaredivideisavailable,0otherwise.

@USE_MULTIPLY() Returns1ifhardwaremultiplyisavailable,0otherwise.

4.8 AssemblerDirectives

Anassemblerdirectiveissimplyamessagetotheassembler.Assemblerdirectivesarenottranslatedintomachineinstructions, butcanproducedata.Therearethreetypesofassemblerdirectives. • Assemblerdirectivesthattelltheassemblerhowtogoabouttranslatinginstructionsintomachinecode.Thisisthemost typicalformofassemblydirectives.Typicallytheytelltheassemblerwheretoputaprograminmemory,whatspaceto allocateforvariables,andallowyoutoinitializememorywithdata.Whentheassemblysourceisassembled,alocation counterintheassemblerkeepstrackofwherethecodeanddataistogoinmemory. Thefollowingdirectivesfallunderthisgroup: − Assemblycontroldirectives − Symboldefinitiondirectives − Datadefinition/Storageallocationdirectives − HLLdirectives • Directivesthatareinterpretedbythemacropreprocessor.Thesedirectivestellthemacropreprocessorhowtomanipulate yourassemblycodebeforeitisactuallybeingassembled.Youcanusethesedirectivestowritemacrosandtowrite conditionalsourcecode.Partsofthecodethatdonotmatchthecondition,willnotbeassembledatall.Unlikeother directives,preprocesssordirectivescanstartinthefirstcolumn. • Somedirectivesactasassembleroptionsandmostofthemindeeddohaveanequivalentassembler(commandline)option. Theadvantageofusingadirectiveisthatwithsuchadirectiveyoucanoverruletheassembleroptionforaparticularpartof thecode.Atypicalexampleistotelltheassemblerwithanoptiontogeneratealistfilewhilewiththedirectives.NOLIST and.LISTyouoverrulethisoptionforapartofthecodethatyoudonotwanttoappearinthelistfile.Directivesofthiskind sometimesarecalledcontrols. Eachassemblerdirectivehasitsownsyntax.Someassemblerdirectivescanbeprecededwithalabel.Ifyoudonotprecedean assemblerdirectivewithalabel,youmustusewhitespaceinstead(spacesortabs).Youcanuseassemblerdirectivesinthe assemblycodeaspseudoinstructions.

4.8.1 OverviewofAssemblerDirectives

Thefollowingtablesprovideanoverviewofallassemblerdirectives.Foradetaileddescriptionofthesedirectives,referto section4.8.2,DetailedDescriptionofAssemblerDirectives.

4−8 AssemblyLanguage

Overviewofassemblycontroldirectives

Directive Description .END Indicatestheendofanassemblymodule .INCLUDE Includefile .MESSAGE Programmergeneratedmessage

Overviewofsymboldefinitiondirectives

Directive Description .EQU Setpermanentvaluetoasymbol .EXTERN Importglobalsectionsymbol .GLOBAL Declareglobalsectionsymbol .LABEL Definealabelofspecifiedtype .RESUME Resumeapreviouslydefinedsection .SECTION Startanewsection .SET Settemporaryvaluetoasymbol .SIZE SetsizeofsymbolintheELFsymboltable .SOURCE SpecifynameoforiginalCsourcefile .TYPE SetsymboltypeintheELFsymboltable .WEAK Markasymbolas’weak’

Overviewofdatadefinition/storageallocationdirectives

Directive Description .ALIGN Alignlocationcounter .BS/.BSB/.BSH/ Defineblockstorage(initialized) .BSW/.BSD .DB Definebyte .DH Definehalfword .DW Defineword .DD Definedouble−word .DS/.DSB/.DSH/ Definestorage .DSW/.DSD .OFFSET Movelocationcounterforwards

Overviewofmacroandconditionalassemblydirectives

Directive Description .DEFINE Definesubstitutionstring .BREAK Breakoutofcurrentmacroexpansion .REPEAT/.ENDREP Repeatsequenceofsourcelines .FOR/.ENDFOR Repeatsequenceofsourcelinesntimes .IF/.ELIF/.ELSE Conditionalassemblydirective .ENDIF Endofconditionalassemblydirective .MACRO/.ENDM Definemacro .UNDEF Undefine.DEFINEsymbolormacro

4−9 MicroBlazeEmbeddedToolsReference

Overviewoflistingcontrolassemblydirectives

Directive Description .LIST/.NOLIST Print/donotprintsourcelinestolistfile .PAGE Settopofpage/sizeofpage .TITLE Setprogramtitleinheaderofassemblylistfile

OverviewofHLLdirectives

Directive Description .CALLS Passcalltreeinformation

4.8.2 DetailedDescriptionofAssemblerDirectives

.ALIGN

Syntax .ALIGNexpression

Description Withthe.ALIGNdirectiveyoutelltheassemblertoalignthelocationcounter. Whentheassemblerencountersthe.ALIGNdirective,itmovesthelocationcounterforwardstoanaddressthatisalignedas specifiedbyexpressionandplacesthenextinstructionordirectiveonthataddress.Thealignmentisinminimaladdressable units(MAUs).Theassemblerfillsthe’gap’withNOPinstructionsforcodesectionsorwithzerosfordatasections.Ifthelocation counterisalreadyalignedonthespecifiedalignment,itremainsunchanged.Thelocationofabsolutesectionswillnotbe changed. Theexpressionmustbeapoweroftwo:2,4,8,16,...Ifyouspecifyanothervalue,theassemblerchangesthealignmenttothe nexthigherpoweroftwoandissuesawarning.

Examples .SECTION.text .ALIGN16;theassembleraligns instruction;thisinstructionat16MAUsand ;fillsthe’gap’withNOPinstructions. .SECTION.text .ALIGN12;WRONG:notapoweroftwo,the instruction;assembleralignsthisinstructionat ;16MAUsandissuesawarning.

4−10 AssemblyLanguage

.BREAK

Syntax .BREAK

Description The.BREAKdirectivecausesimmediateterminationofamacroexpansion,a.FORloopexansionora.REPEATloop expansion.Incaseofnestedloopsormacros,the.BREAKdirectivereturnstothepreviouslevelofexpansion. The.BREAKdirectiveis,forexample,usefulincombinationwiththe.IFdirectivetoterminateexpansionwhenerrorconditions aredetected.

Example .FORMYVARIN10TO20 ...; ...;assemblysourcelines ...; .IFMYVAR>15 .BREAK .ENDIF .ENDREP

4−11 MicroBlazeEmbeddedToolsReference

.BS/.BSB/.BSH/.BSW/.BSD

Syntax [label].BSexpression1[,expression2] [label].BSBexpression1[,expression2] [label].BSHexpression1[,expression2] [label].BSWexpression1[,expression2] [label].BSDexpression1[,expression2]

Description Withthe.BSdirective(BlockStorage)theassemblerreservesablockofmemory.Thereservedblockofmemoryisinitializedto thevalueofexpression2,orzeroifomitted. Withexpression1youspecifythenumberofminimumaddressableunits(MAUs)youwanttoreserve,andhowmuchthe locationcounterwilladvance.Theexpressionmustbeanintegergreaterthanzeroandcannotcontainanyforwardreferences toaddresslabels(labelsthathavenotyetbeendefined). Withexpression2youcanspecifyavaluetoinitializetheblockwith.OnlytheleastsignificantMAUofexpression2isused.If youomitexpression2,thedefaultiszero. Ifyouspecifylabel,itgetsthevalueofthelocationcounteratthestartofthedirectiveprocessing.

Initializationofablockofmemoryonlyhappensinsectionswithsectionattributeinitorromdata.Inothersections,the assemblerissuesawarningandonlyreservesspace,justaswith.DS. The.BSB,.BSH,.BSWand.BSDdirectivesarevariantsofthe.BSdirective: .BSB Theexpression1argumentspecifiesthenumberofbytestoreserve. .BSH Theexpression1argumentspecifiesthenumberofhalfwordstoreserve(onehalfwordis16bits). .BSW Theexpression1argumentspecifiesthenumberofwordstoreserve(onewordis32bits). .BSD Theexpression1argumentspecifiesthenumberofdouble−wordstoreserve(onedouble−wordis64bits).

Example The.BSBdirectiveisforexampleusefultodefineandinitializeanarraythatisonlypartiallyfilled: .section.data .DB84,101,115,116;initialize4bytes .BSB96,0xFF;reserveanother96bytes,initializedwith0xFF

Relatedinformation

.DS(DefineStorage)

4−12 AssemblyLanguage

.CALLS

Syntax .CALLS’caller’,’callee’ or .CALLS’caller’,’’,stack0_usage[,stack1_usage]...

Description Thefirstsyntaxcreatesacallgraphreferencebetweencallerandcallee.Thelinkerneedsthisinformationtobuildacallgraph. Ifapplicablethecallgraphisusedtocreateastaticstackoverlay.callerandcalleearenamesoffunctions. Thesecondsyntaxspecifiesstackinformation.Whencalleeisanemptyname,thismeanswedefinethestackusageofthe functionitself.Thevaluesspecifiedarethestackusageinbytesatthetimeofthecallincludingthereturnaddress.This informationisusedbythelinkertocomputetheusedstackwithintheapplication.Theinformationisfoundinthegenerated linkermapfilewithintheMemoryUsage. Normally.CALLSdirectivesareautomaticallygeneratedbythecompiler.Usethe.CALLSdirectiveinhandcodedassembly whentheassemblycodecallsaCfunction.Ifyoumanuallyadd.CALLSdirectives,makesuretheyconnecttothecompiler generated.CALLSdirectives:thenameofthecallermustalsobenamedasacalleeinanotherdirective.

Example .CALLS’_main’,’_nfunc’

Indicatesthatthefunction_maincallsthefunction_nfunc .CALLS’main’,’’,8

Thefunctionmainuses8bytesonthestack.

4−13 MicroBlazeEmbeddedToolsReference

.DB

Syntax [label].DBargument[,argument]...

Description Withthe.DBdirective(DefineByte)theassemblerallocatesandinitializesonebyteofmemoryforeachargument. Anargumentcanbe: • asingleormultiplecharacterstringconstant • anintegerexpression • NULL(indicatedbytwoadjacentcommas:,,) Ifyouspecifylabel,itgetsthevalueofthelocationcounteratthestartofthedirectiveprocessing. Multipleargumentsarestoredinsuccessiveaddresslocations.IfanargumentisNULL,itscorrespondingaddresslocationis flledwithzeros. Integerargumentsarestoredasis,butmustbebytevalues(withintherange0−255);floating−pointnumbersarenotallowed.If theevaluatedexpressionisoutoftherange[−256,+255]theassemblerissuesanerror.Fornegativevalueswithinthatrange, theassembleradds256tothespecifiedvalue(forexample,−254isstoredas2). Incaseofsingleandmultiplecharacterstrings,eachcharacterisstoredinconsecutivebyteswhoselowersevenbitsrepresent theASCIIvalueofthecharacter.ThestandardCescapesequencesareallowed: .DB’R’;=0x52 .DB’AB’,,’D’;=0x41420043(secondargumentisempty)

Example TABLE:.DB14,253,0x62,’ABCD’ CHARS:.DB’A’,’B’,,’C’,’D’

Relatedinformation

.BS(BlockStorage) .DS(DefineStorage) .DH(DefineHalfWord) .DW(DefineWord) .DD(DefineDouble−Word)

4−14 AssemblyLanguage

.DD

Syntax [label].DDargument[,argument]...

Description Withthe.DDdirective(DefineDouble−Word)youallocateandinitializeonedouble−wordofmemoryforeachargument. Onedouble−wordis64bits. Anargumentis: • asingleormultiplecharacterstringconstant • anexpression • NULL(indicatedbytwoadjacentcommas:,,) Ifyouspecifylabel,itgetsthevalueofthelocationcounteratthestartofthedirectiveprocessing. Multipleargumentsarestoredinsetsofeightbytes.IfanargumentisNULL,itscorrespondingaddresslocationsareflledwith zeros. Double−wordargumentsarestoredasis.Floating−pointvaluesarenotallowed.Iftheevaluatedargumentistoolargetobe representedinadouble−word,theassemblerissuesawarningandtruncatesthevalue. Incaseofcharacterstrings,eachASCIIvalueofthecharacterisstoredinsuccessivelocationsstartingattheleastsignificant byteofadouble−word: .DD’AB’,,’D’=>0x000000000004142 0x000000000000000(secondargumentisempty) 0x000000000000044

Example TABLE:.DD14,253,0x62,’ABCD’ CHARS:.DD’A’,’B’,,’C’,’D’

Relatedinformation

.BS(BlockStorage) .DS(DefineStorage) .DB(DefineByte) .DH(DefineHalfWord) .DW(DefineWord)

4−15 MicroBlazeEmbeddedToolsReference

.DEFINE

Syntax .DEFINEsymbolstring

Description Withthe.DEFINEdirectiveyoudefineasubstitutionstringthatyoucanuseonallfollowingsourcelines.Theassembler searchesallsucceedinglinesforanoccurrenceofsymbol,andreplacesitwithstring.Ifthesymboloccursinadoublequoted stringitisalsoreplaced.Stringsbetweensinglequotesarenotexpanded. Thisdirectiveisusefulforprovidingbetterdocumentationinthesourceprogram.Asymbolcanconsistofletters,digitsand underscorecharacters(_),andthefirstcharactercannotbeadigit. Theassemblerissuesawarningifyouredefineanexistingsymbol.

Example SupposeyoudefinedthesymbolLENwiththesubstitutionstring"32": .DEFINELEN"32"

ThenyoucanusethesymbolLENforexampleasfollows: .DSLEN .MESSAGEI"Thelengthis:LEN"

TheassemblerpreprocessorreplacesLENwith32"andassemblesthefollowinglines: .DS32 .MESSAGEI"Thelengthis:32"

Relatedinformation

.UNDEF(Undefinea.DEFINEsymbolormacro) .MACRO/.ENDM(Defineamacro)

4−16 AssemblyLanguage

.DH

Syntax [label].DHargument[,argument]...

Description Withthe.DHdirective(DefineHalfWord)youallocateandinitializeahalfwordofmemoryforeachargument. Ahalfwordis16bits. Anargumentis: • asingleormultiplecharacterstringconstant • anexpression • NULL(indicatedbytwoadjacentcommas:,,) Ifyouspecifylabel,itgetsthevalueofthelocationcounteratthestartofthedirectiveprocessing. Multipleargumentsarestoredinsuccessivehalfwordaddresslocations.IfanargumentisNULL,itscorrespondingaddress locationisfilledwithzeros. Halfwordargumentsarestoredasis.Floating−pointvaluesarenotallowed. Iftheevaluatedargumentistoolargetoberepresentedinahalfword,theassemblerissuesawarningandtruncatesthevalue. Incaseofsingleandmultiplecharacterstrings,eachASCIIvalueofthecharacterisstoredinsuccessivelocationsstartingat theleastsignificantbyteofahalfword.ThestandardCescapesequencesareallowed: .DH’AB’,,’D’=>0x4142 0x0000(secondargumentisempty) 0x0044

Example TABLE:.DH14,253,0x62,’ABCD’ CHARS:.DH’A’,’B’,,’C’,’D’

Relatedinformation

.BS(BlockStorage) .DS(DefineStorage) .DB(DefineByte) .DW(DefineWord) .DD(DefineDouble−Word)

4−17 MicroBlazeEmbeddedToolsReference

.DS/.DSB/.DSH/.DSW/.DSD

Syntax [label].DSexpression [label].DSBexpression [label].DSHexpression [label].DSWexpression [label].DSDexpression

Description Withthe.DSdirective(DefineStorage)theassemblerreservesablockofmemory.Thereservedblockofmemoryisnot initializedtoanyvalue. Withtheexpressionyouspecifythenumberofminimumaddressableunits(MAUs)thatyouwanttoreserve.Theexpression mustevaluatetoanintegerlargerthanzeroandcannotcontainreferencestosymbolsthatarenotyetdefinedintheassembly source. Ifyouspecifylabel,itgetsthevalueofthelocationcounteratthestartofthedirectiveprocessing.

Youcannotusethe.DSdirectiveinsectionswithattributeinit.Ifyouneedtoreserveinitializedspaceinaninitsection, usethe.BSdirectiveinstead. The.DSB,.DSH,.DSWand.DSDdirectivesarevariantsofthe.DSdirective: .DSB Theexpressionargumentspecifiesthenumberofbytestoreserve. .DSH Theexpressionargumentspecifiesthenumberofhalfwordstoreserve(onehalfwordis16bits). .DSW Theexpressionargumentspecifiesthenumberofwordstoreserve(onewordis32bits). .DSD Theexpressionargumentspecifiesthenumberofdouble−wordstoreserve(onedouble−wordis64bits).

Example RES:.DS5+3;allocate8bytes

Relatedinformation

.BS(BlockStorage) .DB(DefineByte) .DH(DefineHalfWord) .DW(DefineWord) .DD(DefineDouble−Word)

4−18 AssemblyLanguage

.DW

Syntax [label].DWargument[,argument]...

Description Withthe.DWdirective(DefineWord)youallocateandinitializeonewordofmemoryforeachargument. Onewordis32bits. Anargumentis: • asingleormultiplecharacterstringconstant • anexpression • NULL(indicatedbytwoadjacentcommas:,,) Ifyouspecifylabel,itgetsthevalueofthelocationcounteratthestartofthedirectiveprocessing. Multipleargumentsarestoredinsetsoffourbytes.IfanargumentisNULL,itscorrespondingaddresslocationsareflledwith zeros. Wordargumentsarestoredasis.Floating−pointvaluesarenotallowed.Iftheevaluatedargumentistoolargetoberepresented inaword,theassemblerissuesawarningandtruncatesthevalue. Incaseofsingleandmultiplecharacterstrings,eachASCIIvalueofthecharacterisstoredinsuccessivelocationsstartingat theleastsignificantbyteofaword.ThestandardCescapesequencesareallowed: .DW’AB’,,’D’=>0x0004142 0x0000000(secondargumentisempty) 0x0000044

Example TABLE:.DW14,253,0x62,’ABCD’ CHARS:.DW’A’,’B’,,’C’,’D’

Relatedinformation

.BS(BlockStorage) .DS(DefineStorage) .DB(DefineByte) .DH(DefineHalfWord) .DD(DefineDouble−Word)

4−19 MicroBlazeEmbeddedToolsReference

.END

Syntax .END

Description Withthe.ENDdirectiveyoutelltheassemblerthattheendofthemoduleisreached.Iftheassemblerfindsassemblysource linesbeyondthe.ENDdirective,itignoresthoselinesandissuesawarning.

Example .section.text ;sourcelines .END;Endofassemblymodule

4−20 AssemblyLanguage

.EQU

Syntax symbol.EQUexpression

Description Withthe.EQUdirectiveyouassignthevalueofexpressiontosymbolpermanently.Oncedefined,youcannotredefinethe symbol.Withthe.GLOBALdirectiveyoucandefinethesymbolglobal. Theexpressioncaneitherbeabsoluteorrelocatableandcannotcontainforwardreferences.Normally,thedefinedsymbolgets thesametypeastheresultoftheexpression.However,whentheresultingexpressionhastypenone"thesymbolgetsnotype whenthe.EQUisusedoutsideasectionanditgetsthetypeofthesectionwhenitisdefinedinsideasection.

Example MYSYMBOL1.EQU0x4000;getsnotype .SECTION.text _START: .SECTION.data MYSYMBOL2.EQU0x4100;getstypedata MYSYMBOL3.EQU_START;getstypeoftheexpression: ;because_STARTisdefinedin ;asectionwithtypeCODE,the ;symbolgetstypeCODE. .END

Youcannotredefinetheusedsymbols.

Relatedinformation

.SET(Settemporaryvaluetoasymbol)

4−21 MicroBlazeEmbeddedToolsReference

.EXTERN

Syntax .EXTERNsymbol[:type][,symbol[:type]]...

Description Withthe.EXTERNdirectiveyoudefineanexternalsymbol.Itmeansthatthesymbolisreferencedinthecurrentmodulewhileit isdefinedoutsidethecurrentmodule. Youmustdefinethesymbolseitheroutsideanymoduleordeclareitasgloballyaccessiblewithinanothermodulewiththe .GLOBALdirective. Thetypeoftheglobalsymbolwhichisreferencedwiththe.EXTERNdirectiveisdeterminedfromitsdefinition.Theassembler thenusesthetypeinformationofthe.EXTERNdirectivetocheckthesymbol’suse:ifthesymboldoesnotfittheinstruction’s operand,theassemblerissuesawarning. Ifyoudonotspecifytype,theassemblerdoesnotchecktheuseofthespecifiedsymbol. Eachtargethasaspecificsetoftypesasdescribedinthe.SECTION(Startanewsection)directive. Ifyoudonotusethe.EXTERNdirectiveandthesymbolisnotdefinedwithinthecurrentmodule,theassemblerissuesa warningandinsertsthe.EXTERNdirective.

Example .EXTERNAA,CC,DD;definedelsewhere .EXTERNAA:DATA;assemblerchecksfortype

Relatedinformation

.GLOBAL(Declareglobalsectionsymbol)

4−22 AssemblyLanguage

.FOR/.ENDFOR

Syntax [label].FORvarINexpression[,expression]...... ENDFOR or: [label].FORvarINstartTOend[STEPstep] .... .ENDFOR

Description Withthe.FOR/.ENDFORdirectiveyoucanrepeatasequenceofassemblysourcelineswithaniterator.Asshownbythe syntax,youcanusethe.FOR/.ENDFORintwoways. 1. Inthefirstmehod,theloopisrepeatedasmanytimesasthenumberofargumentsfollowingIN.Ifyouusethesymbolvarin theassemblylinesbetween.FORand.ENDFOR,foreachrepetitionthesymbolvarissubstitutedbyasubsequent expressionfromtheargumentlist.Iftheargumentisanull,thentheloopisrepeatedwitheachoccurrenceofthesymbolvar removed. 2. Inthesecondmethod,theloopisrepeatedusingthesymbolvarasacounter.Thecounterpassesallintegervaluesfrom starttoendwithastep.Ifyoudonotspecifystep,thecounterisincreasedbyoneforeveryrepetition. Ifyouspecifylabel,itgetsthevalueofthelocationcounteratthestartofthedirectiveprocessing.

Example Inthefollowingexampletheloopisrepeated4times(therearefourarguments).Withthe.DBdirectiveyouallocateand initializeabyteofmemoryforeachrepetitionoftheloop(awordforthe.DWdirective).Effectively,thepreprocessorduplicates the.DBand.DWdirectivesfourtimesintheassemblysource. .FORVAR1IN1,2+3,4,12 .DBVAR1 .DW(VAR1*VAR1) .ENDFOR

Inthefollowingexampletheloopisrepeated16times.Withthe.DWdirectiveyouallocateandinitializefourbytesofmemoryfor eachrepetitionoftheloop.Effectively,thepreprocessorduplicatesthe.DWdirective16timesintheassembledfile,and substitutesVAR2withthesubsequentnumbers. .FORVAR2IN1to0x10 .DW(VAR1*VAR1) .ENDFOR

Relatedinformation

.REPEAT/.ENDREP(Repeatsequenceofsourcelines)

4−23 MicroBlazeEmbeddedToolsReference

.GLOBAL

Syntax .GLOBALsymbol[,symbol]...

Description Allsymbolsorlabelsdefinedinthecurrentsectionormodulearelocaltothemodulebydefault.Youcanchangethisdefault behaviorwithassembleroption−ig. Withthe.GLOBALdirectiveyoudeclareoneofmoresymbolsasglobal.Itmeansthatthespecifiedsymbolsaredefinedwithin thecurrentsectionormodule,andthatthosedefinitionsshouldbeaccessiblebyallmodules. Thetypeoftheglobaldefinedsymbolisdeterminedbyitsdefinition. Toaccessasymbol,definedwith.GLOBAL,fromanothermodule,usethe.EXTERNdirective. Onlyprogramlabelsandsymbolsdefinedwith.EQUcanbemadeglobal.

Example LOOPA.EQU1;definitionofsymbolLOOPA .GLOBALLOOPA;LOOPAwillbeglobally ;accessiblebyothermodules

Relatedinformation

.EXTERN(Importglobalsectionsymbol)

4−24 AssemblyLanguage

.IF/.ELIF/.ELSE/.ENDIF

Syntax .IFexpression . . [.ELIFexpression] (the.ELIFdirectiveisoptional) . . [.ELSE] (the .ELSEdirectiveisoptional) . . .ENDIF

Description Withthe.IF/.ENDIFdirectivesyoucancreateapartofconditionalassemblycode.Theassemblerassemblesonlythecode thatmatchesaspecifiedcondition. Theexpressionmustevaluatetoanintegerandcannotcontainforwardreferences.Ifexpressionevaluatestozero,the IF−conditionisconsideredFALSE,anynon−zeroresultofexpressionisconsideredasTRUE. Youcannest.IFdirectivestoanylevel.The.ELSEand.ELIFdirectivealwaysrefertothenearestprevious.IFdirective.

Example Supposeyouhaveanassemblesourcefilewithspecificcodeforatestversion,forademoversionandforthefinalversion. Withintheassemblysourceyoudefinethiscodeconditionallyasfollows: .IFTEST ...;codeforthetestversion .ELIFDEMO ...;codeforthedemoversion .ELSE ...;codeforthefinalversion .ENDIF

BeforeassemblingthefileyoucansetthevaluesofthesymbolsTESTandDEMOintheassemblysourcebeforethe.IF directiveisreached.Forexample,toassemblethedemoversion: TEST.SET0 DEMO.SET1

YoucanalsodefinethesymbolsinAltiumDesigneraspreprocessormacrosindialogProject»ProjectOptions»Assembler »Preprocessing(assembleroption−−define).

Relatedinformation

Assembleroption−−define(Definepreprocessormacro)inSection5.3,AssemblerOptions,ofChapterToolOptions.

4−25 MicroBlazeEmbeddedToolsReference

.INCLUDE

Syntax .INCLUDE"filename"|

Description Withthe.INCLUDEdirectiveyouincludeanotherfileattheexactlocationwherethe.INCLUDEoccurs.Thishappensbefore theresultingfileisassembled.The.INCLUDEdirectiveworkssimilarlytothe#includestatementinC.Thesourcefromthe includefileisassembledasifitfollowedthepointofthe.INCLUDEdirective.Whentheendoftheincludedfileisreached, assemblyoftheoriginalfilecontinues. Thestringspecifiesthefilenameofthefiletobeincluded.Thefilenamemustbecompatiblewiththeoperatingsystem (forward/backwardslashes)andcancontainadirectoryspecification.Ifyouomitafilenameextension,theassemblerassumes theextension.asm. Ifanabsolutepathnameisspecified,theassemblersearchesforthatfile.Ifarelativepathisspecifiedorjustafilename,the orderinwhichtheassemblersearchesforincludefilesis: 1. Thecurrentdirectoryifyouusethe"filename"construction. Thecurrentdirectoryisnotsearchedifyouusethesyntax. 2. Thepaththatisspecifiedwiththeassembleroption−−include−directory(−I). 3. ThepaththatisspecifiedintheenvironmentvariableAStargetINCwhentheproductwasinstalled. 4. Thedefaultdirectory...\ctarget\include.

Example Supposethatyourassemblysourcefiletest.srccontainsthefollowingline: .INCLUDE"c:\myincludes\myinc.inc"

Theassemblerissuesanerrorifitcannotfindthefileatthespecifiedlocation. .INCLUDE"myinc.inc"

Theassemblersearchesthefilemyinc.incaccordingtotherulesdescribedabove.

Relatedinformation

Assembleroption−−include−directory(Adddirectorytoincludefilesearchpath)inSection5.3,AssemblerOptions,of ChapterToolOptions.

4−26 AssemblyLanguage

.LABEL

Syntax label.LABELtype

Description Withthe.LABELdirectiveyoudefinealabelofaspecifiedtype. Usethisdirectiveifthelabelthatyoudefine,musthaveanothertypethanitreceivesbydefault.Bydefault,alabelinheritsits typefromthetypeofthesectioninwhichyoudefinethelabel.

Example Inthenextexample,thefirstlabelreceivesthetypeofthesection.Thesecondlabelisdefinedwiththe.LABELdirectiveand receivesthetypedata. .SECTION.text mylabel1.EQU2 mylabel2.LABELdata

4−27 MicroBlazeEmbeddedToolsReference

.LIST/.NOLIST

Syntax .NOLIST . .;assemblysourcelines . .LIST

Description Ifyougeneratealistfile(seeassembleroption−−list−file),youcanusethe.LISTand.NOLISTdirectivestospecifywhich sourcelinestheassemblermustwritetothelistfile. Theassemblerprintsallsourcelinestothelistfile,untillitencountersa.NOLISTdirective.Theassemblerdoesnotprintthe .NOLISTdirectiveandsubsequentsourcelines.Whentheassemblerencountersthe.LISTdirective,itresumesprintingtothe listfile,startingwiththe.LISTdirectiveitself. Itispossibletonestthe.LIST/.NOLISTdirectives.

Example Supposeyouassemblethefollowingassemblycodewiththeassembleroption−−list−file: .SECTION.text ...;sourceline1 .NOLIST ...;sourceline2 .LIST ...;sourceline3 .END

Theassemblergeneratesalistfilewiththefollowinglines: .SECTION.text ...;sourceline1 .LIST ...;sourceline3 .END

Relatedinformation

Assembleroption−−list−file(Generatelistfile)inSection5.3,AssemblerOptions,ofChapterToolOptions.

4−28 AssemblyLanguage

.MACRO/.ENDM

Syntax macro_name.MACRO[argument[,argument]...] ... macro_definition_statements ... .ENDM

Description Withthe.MACROdirectiveyoudefineamacro.Macrosprovideashorthandmethodforhandlingarepeatedpatternofcodeor groupofinstructions.Youcandefinethepatternasamacro,andthencallthemacroatthepointsintheprogramwherethe patternwouldrepeat. Thedefinitionofamacroconsistsofthreeparts: • Header,whichassignsanametothemacroanddefinesthearguments. • Body,whichcontainsthecodeorinstructionstobeinsertedwhenthemacroiscalled. • Terminator,whichindicatestheendofthemacrodefinition(.ENDMdirective). Theargumentsaresymbolicnamesthatthemacroprocessorreplaceswiththeliteralargumentswhenthemacroisexpanded (called).Eachformalargumentmustfollowthesamerulesassymbolnames:thenamecanconsistofletters,digitsand underscorecharacters(_).Thefirstcharactercannotbeadigit.Argumentnamescannotstartwithapercentsign(%). Macrodefinitionscanbenestedbutthenestedmacrowillnotbedefineduntiltheprimarymacroisexpanded. Youcanusethefollowingoperatorsinmacrodefinitionstatements:

Operator Name Description \ Macroargument Concatenatesamacroargumentwithadjacentalphanumericcharacters. concatenation ? Returndecimal Substitutesthe?symbolsequencewithacharacterstringthatrepresentsthedecimalvalue valueofsymbol ofthesymbol. % Returnhex Substitutesthe%symbolsequencewithacharacterstringthatrepresentsthehexadecimal valueofsymbol valueofthesymbol. " Macrostring Allowstheuseofmacroargumentsasliteralstrings. delimiter ^ Macrolocallabel Preventsnamemanglingonlabelsinmacros. override

Example Themacrodefinition: macro_a.MACROarg1,arg2;header .dbarg1;body .dw(arg1*arg2) .ENDM;terminator

Themacrocall: .section.data macro_a2,3

Themacroexpandsasfollows: .db2 .dw(2*3)

4−29 MicroBlazeEmbeddedToolsReference

Relatedinformation

.DEFINE(Defineasubstitutionstring) Section4.9,MacroOperations.

4−30 AssemblyLanguage

.MESSAGE

Syntax .MESSAGEtype[{str|exp|symbol}[,{str|exp|symbol}]...]

Description Withthe.MESSAGEdirectiveyoutelltheassemblertoprintamessagetostdoutduringtheassemblingprocess. Withtypeyoucanspecifythefollowingtypesofmessages: I Informationmessage.Errorandwarningcountsarenotaffectedandtheassemblercontinuestheassemblingprocess. W Warningmessage.Incrementsthewarningcountandtheassemblercontinuestheassemblingprocess. E Errormessage.Incrementstheerrorcountandtheassemblercontinuestheassemblingprocess. F Fatalerrormessage.Theassemblerimmediatelyabortstheassemblingprocessandgeneratesnoobjectfileorlistfile. The.MESSAGEdirectiveisforexampleusefulincombinationwithconditionalassemblytoindicatewhichpartisassembled.

Example .MESSAGEI’Generatingtables’ ID.EQU4 .MESSAGEE’ThevalueofIDis’,ID .DEFINELONG"SHORT" .MESSAGEI’ThisisaLONGstring’ .MESSAGEI"ThisisaLONGstring"

Withinsinglequotes,thedefinedsymbolLONGisnotexpanded.WithindoublequotesthesymbolLONGisexpandedsothe actualmessageisprintedas: ThisisaLONGstring ThisisaSHORTstring

4−31 MicroBlazeEmbeddedToolsReference

.OFFSET

Syntax .OFFSETexpression

Description Withthe.OFFSETdirectiveyoutelltheassemblertogivethelocationcounteranewoffsetrelativetothestartofthesection. Whentheassemblerencountersthe.OFFSETdirective,itmovesthelocationcounterforwardstothespecifiedaddress,relative tothestartofthesection,andplacesthenextinstructiononthataddress.Ifyouspecifyanaddressequaltoorlowerthanthe currentpositionofthelocationcounter,theassemblerissuesanerror.

Example .SECTION.text nop nop nop .OFFSET0x20;theassemblerplaces nop;thisinstructionataddress0x20 ;relativetothestartofthesection. .SECTION.text nop nop nop .OFFSET0x02;WRONG:thecurrentpositionofthe nop;locationcounteris0x0C.

4−32 AssemblyLanguage

.PAGE

Syntax .PAGE[width,length,blanktop,blankbtm,blankleft]

Description Ifyougeneratealistfile(seeassembleroption−−list−file),youcanusethe.PAGEdirectivetoformatthegeneratedlistfile. width Numberofcharactersonaline(1−255).Defaultis132. length Numberoflinesperpage(10−255).Defaultis66. blanktop Numberofblanklinesatthetopofthepage.Default=0. Specifyavaluesothatblanktop+blankbtm≤length−10. blankbtm Numberofblanklinesatthebottomofthepage.Default=0. Specifyavaluesothatblanktop+blankbtm≤length−10. blankleft Numberofblankcolumnsattheleftofthepage.Default=0.Specifyavaluesmallerthanwidth. Ifyouusethe.PAGEdirectivewithoutarguments,itcausesa’formfeed’:thenextsourcelineisprintedonthenextpageinthe listfile. Youcanomitanargumentbyusingtwoadjacentcommas.Iftheremainingargumentsafteranargumentareallempty,youcan omitthem. Alabelisnotallowedwiththisdirective.

Example .PAGE;formfeed,thenextsourcelineisprinted ;onthenextpageinthelistfile. .PAGE96;setpagewidthto96.Notethatyoucan ;omitthelastfourarguments .PAGE,,5;insertfiveblanklinesatthetop.Note ;thatyoucanomitthelasttwoarguments.

Relatedinformation

.TITLE(Setprogramtitleinheaderofassemblerlistfile) Assembleroption−−list−file(Generatelistfile)inSection5.3,AssemblerOptions,ofChapterToolOptions.

4−33 MicroBlazeEmbeddedToolsReference

.REPEAT/.ENDREP

Syntax [label].REPEATexpression .... .ENDREP

Description Withthe.REPEAT/.ENDREPdirectiveyoucanrepeatasequenceofassemblysourcelines.Withexpressionyouspecifythe numberoftimestheloopisrepeated. Ifyouspecifylabel,itgetsthevalueofthelocationcounteratthestartofthedirectiveprocessing.

Example Inthisexampletheloopisrepeated3times.Effectively,thepreprocessorrepeatsthesourcelines(.DB10)threetimes,then theassemblerassemblestheresult: .REPEAT3 .DB10;assemblysourcelines .ENDREP

Relatedinformation

.FOR/.ENDFOR(Repeatsequenceofsourcelinesntimes)

4−34 AssemblyLanguage

.RESUME

Syntax .RESUMEname[,attribute]...

Description Withthe.SECTIONdirectiveyoualwaysstartanewsection.Withthe.RESUMEdirectiveyoucanreactivateapreviously definedsection.Seethe.SECTIONdirectiveforalistofavailablesectionattributes.Ifyouomittheattribute,thepreviously definedsectionwiththesamenameisreactivated(ignoringtheattribute(s)).Ifyouspecifyanattributeyoureactivatethesection withthatsameattribute. Youcannotresumesectionsthathavethegrouporoverlayattribute.Inthiscasetheassemblerissuesawarning.

Example .SECTION.text;First.textsection ... .SECTION.data;First.datasection ... .SECTION.text;Second.textsection ... .SECTION.data,at(0x0);Second.datasection ... .RESUME.text;Resumeinthesecond.textsection ... .RESUME.data;Resumeinthefirst.datasection ... .RESUME.data,at(0x0);Resumeinthesecond.datasection

Relatedinformation

.SECTION(Startanewsection)

4−35 MicroBlazeEmbeddedToolsReference

.SECTION

Syntax .SECTIONname[,attribute]...... [.ENDSEC]

Description Withthe.SECTIONdirectiveyoudefineanewsection.Eachtimeyouusethe.SECTIONdirective,anewsectioniscreated.It ispossibletocreatemultiplesectionswithexactlythesamename. Toresumeapreviouslydefinedsection,usethe.RESUMEdirective. Ifyoudefineasection,youmustalwaysspecifythesectionname.Thenameshaveaspecialmeaningtothelocatingprocess andhavetostartwithapredefinedname,optionallyextendedbyadot’.’andauserdefinedname.Thepredefinedsection namealsodeterminesthetypeofthesection(code,dataordebug).Optionally,youcanspecifyoneormoreattributes. Youcanusethefollowingpredefinedsectionnames:

SectionName Description SectionType .text Codesections code .data Initializeddata data .sdata Initializeddatainread−writesmalldataarea data .bss Uninitializeddata(cleared) data .sbss Uninitializeddatainread−writesmalldataarea(cleared) data .rodata ROMdata(constants) data .debug Debugsections debug

Table4−4:Predefinedsectionnames Sectionsofaspecifiedtypearelocatedbythelinkerinamemoryspace.Thespacenamesaredefinedinaso−called’linker scriptfile’(fileswiththeextension.lsl)deliveredwiththeproductinthedirectory\ProgramFiles\Altium Designer\System\Tasking\include.lsl. Youcanspecifythefollowingsectionattributes:

Attribute Description Allowedon align(expression) Alignsectionstothespecifiedvalue .text,.data, .sdata,.bss, .sbss,.rodata at(address) Locatethesectionatthespecifiedaddress .text,.data, .sdata,.bss, .sbss,.rodata clear CleartheDATAsectionatprogramstartup(defaultfor.bssand.sbss) .bss,.sbss noclear DonotcleartheDATAsectionatprogramstartup(defaultfor.text,.data,.sdataand .text,.data, .rodata) .sdata,.bss, .sbss,.rodata init CopiesthedatafromthesectionfromROMtoRAMatprogramsetup(defaultfor .data,.sdata .dataand.sdata) noinit Donotinitializesection(defaultfor.text,.bss,.sbssand.rodata) .text,.data, .sdata,.bss, .sbss,.rodata inpage Indicatesthatthesectionmustfitwithina256bytepage. .text,.data, .sdata,.bss, .sbss,.rodata max Whensectionswiththesamenameoccurindifferentobjectmodules,withtheMAX .data,.sdata, attribute,thelinkergeneratesasectionofwhichthesizeisthemaximumofthesizes .bss,.sbss, intheindividualobjectmodules. .rodata

4−36 AssemblyLanguage

Attribute Description Allowedon noalloc .debug page Alignsectionstoapageboundary.Cannotbeusedtogetherwithalign .text,.data, .sdata,.bss, .sbss,.rodata romdata IndicatesthatthesectioncontainsdatatobeplacedinROM(defaultfor.rodata) .rodata overlay(’overlay’) GeneratedbytheCcompilertocreateoverlaidsections .data,.sdata, .bss,.sbss, .rodata group(’group’) Usedtogroupsections,forexampleforplacinginthesamepage. .text,.data, .sdata,.bss, .sbss,.rodata

Table4−5:MicroBlazesectionattributes

Example .SECTION.data;Declarea.datasection

.SECTION.data.abs,at(0x0);Declarea.data.abssectionat ;anabsoluteaddress

.RESUME(Resumeapreviouslydefinedsection)

4−37 MicroBlazeEmbeddedToolsReference

.SET

Syntax symbol .SETexpression .SETsymbolexpression

Description Withthe.SETdirectiveyouassignthevalueofexpressiontosymboltemporarily.Ifasymbolwasdefinedwiththe.SET directive,youcanredefinethatsymbolinanotherpartoftheassemblysource,usingthe.SETdirectiveagain.Symbolsthatyou definewiththe.SETdirectivearealwayslocal:youcannotdefinethesymbolglobalwiththe.GLOBALdirective. The.SETdirectiveisusefulinestablishingtemporaryorreusablecounterswithinmacros.expressionmustbeabsoluteand cannotincludeasymbolthatisnotyetdefined(noforwardreferencesareallowed). Normally,thedefinedsymbolgetsthesametypeastheresultoftheexpression.However,whentheresultingexpressionhas type"none",thesymbolgetsnotype.

Example COUNT.SET0;Initializecount.Lateronyoucan ;assignothervaluestothesymbol

Relatedinformation

.EQU(Setapermanentvaluetoasymbol)

4−38 AssemblyLanguage

.SIZE

Syntax .SIZEsymbol,expression

Description Withthe.SIZEdirectiveyousetthesizeofthespecifiedsymboltothevaluerepresentedbyexpression. The.SIZEdirectivemayoccuranywhereinthesourcefileunlessthespecifiedsymbolisafunction.Inthiscase,the.SIZE directivemustoccurafterthefunctionhasbeendefined.

Example .section.text .align4 .global_main ;Function_main _main:.typefunc ; .SIZE_main,$−_main .endsec

Relatedinformation

.TYPE(SetSymbolType)

4−39 MicroBlazeEmbeddedToolsReference

.SOURCE

Syntax .SOURCEstring

Description Withthe.SOURCEdirectiveyouspecifythenameoftheoriginalCsourcemodule.ThisdirectiveisgeneratedbytheCcompiler. Youdonotneedthisdirectiveinhand−writtenassembly.

Example .SOURCE"test.c"

Relatedinformation

4−40 AssemblyLanguage

.TITLE

Syntax .TITLE[title]

Description Ifyougeneratealistfile(seeassembleroption−−list−file),youcanusethe.TITLEdirectivetospecifytheprogramtitlewhich isprintedatthetopofeachpageintheassemblerlistfile. Ifyouusethe.TITLEdirectivewithouttheargument,thetitlebecomesempty.Thisisalsothedefault.Thespecifiedtitleisvalid untiltheassemblerencoutersanew.TITLEdirective.

Example .TITLE"Thebestprogram"

Intheheaderofeachpageintheassemblerlistfile,thetitleoftheprogamisprinted.Inthiscase:Thebestprogram

Relatedinformation

.PAGE(Formattheassemblerlistfile) Assembleroption−−list−file(Generatelistfile)inSection5.3,AssemblerOptions,ofChapterToolOptions.

4−41 MicroBlazeEmbeddedToolsReference

.TYPE

Syntax symbol.TYPEtypeid

Description Withthe.TYPEdirectiveyousetasymbol’stypetothespecifiedvalueintheELFsymboltable.Validsymboltypesare: FUNC Thesymbolisassociatedwithafunctionorotherexecutablecode. OBJECT Thesymbolisassociatedwithanobjectsuchasavariable,anarray,orastructure. FILE Thesymbolnamerepresentsthefilenameofthecompilationunit. LabelsincodesectionshavethedefaulttypeFUNC.LabelsindatasectionshavethedefaulttypeOBJECT.

Example _Afunc:.TYPEFUNC

Relatedinformation

.SIZE(SetSymbolSize)

4−42 AssemblyLanguage

.UNDEF

Syntax .UNDEFsymbol

Description Withthe.UNDEFdirectiveyoucanundefineasubstitutionstringthatwaspreviouslydefinedwiththe.DEFINEdirective.The substitutionstringassociatedwithsymbolisreleased,andsymbolwillnolongerrepresentavalid.DEFINEsubstitution. Theassemblerissuesawarningifyouredefineanexistingsymbol.

Example .UNDEFLEN

UndefinestheLENsubstitutionstringthatwaspreviouslydefinedwiththe.DEFINEdirective.

Relatedinformation

.DEFINE(Definesubstitutionstring)

4−43 MicroBlazeEmbeddedToolsReference

.WEAK

Syntax .WEAKsymbol[,symbol]...

Description Withthe.WEAKdirectiveyoumarkoneormoresymbolsas’weak’.Thesymbolcanbedefinedinthesamemodulewiththe .GLOBALdirectiveorthe.EXTERNdirective.Ifthesymboldoesnotalreadyexist,itwillbecreated. A’weak’externalreferenceisresolvedbythelinkerwhenaglobal(orweak)definitionisfoundinoneoftheobjectfiles. However,aweakreferencewillnotcausetheextractionofamodulefromalibrarytoresolvethereference. Youcanoverruleaweakdefinitionwitha.GLOBALdefinitioninanothermodule.Thelinkerwillnotcomplainabouttheduplicate definition,andignoretheweakdefinition. Onlyprogramlabelsandsymbolsdefinedwith.EQUcanbemadeweak.

Example LOOPA.EQU1;definitionofsymbolLOOPA .GLOBALLOOPA;LOOPAwillbeglobally ;accessiblebyothermodules .WEAKLOOPA;marksymbolLOOPAasweak

Relatedinformation

.EXTERN(Importglobalsectionsymbol) .GLOBAL(Declareglobalsectionsymbol)

4−44 AssemblyLanguage

4.9 MacroOperations

Macrosprovideashorthandmethodforinsertingarepeatedpatternofcodeorgroupofinstructions.Youcandefinethepattern asamacro,andthencallthemacroatthepointsintheprogramwherethepatternwouldrepeat. Somepatternscontainvariableentrieswhichchangeforeachrepetitionofthepattern.Othersaresubjecttoconditional assembly. Whenamacroiscalled,theassemblerexecutesthemacroandreplacesthecallbytheresultingin−linesourcestatements. ’In−line’meansthatallreplacementsactasiftheyareonthesamelineasthemacrocall.Thegeneratedstatementsmay containsubstitutablearguments.Thestatementsproducedbyamacrocanbeanyprocessorinstruction,almostanyassembler directive,oranypreviously−definedmacro.Sourcestatementsresultingfromamacrocallaresubjecttothesameconditions andrestrictionsasanyotherstatements. Macroscanbenested.Theassemblerprocessesnestedmacroswhentheoutermacroisexpanded.

4.9.1 DefiningaMacro

Thefirststepinusingamacroistodefineit. Thedefinitionofamacroconsistsofthreeparts: • Header,whichassignsanametothemacroanddefinesthearguments. • Body,whichcontainsthecodeorinstructionstobeinsertedwhenthemacroiscalled. • Terminator,whichindicatestheendofthemacrodefinition(.ENDMdirective). Amacrodefinitiontakesthefollowingform: macro_name.MACRO[arg[,arg]...][;comment] . sourcestatements . .ENDM Ifthemacronameisthesameasanexistingassemblerdirectiveormnemonicopcode,theassemblerreplacesthedirectiveor mnemonicopcodewiththemacroandissuesawarning. Theargumentsaresymbolicnamesthatthemacropreprocessorreplaceswiththeliteralargumentswhenthemacrois expanded(called).Eachargumentmustfollowthesamerulesasglobalsymbolnames.Argumentnamescannotstartwitha percentsign(%).

Example Considerthefollowingmacrodefinition:

RESERV.MACROval;reservespace .DSval .ENDM

Afterthefollowingmacrocall: .section.text RESERV8 .endsec

Themacroexpandsto: .DS8

4.9.2 CallingaMacro

Toinvokeamacro,constructasourcestatementwiththefollowingformat: [label]macro_name[arg[,arg...]][;comment] where: label Anoptionallabelthatcorrespondstothevalueofthelocationcounteratthestartofthemacroexpansion.

4−45 MicroBlazeEmbeddedToolsReference macro_name Thenameofthemacro.Thismaynotstartinthefirstcolumn. arg Oneormoreoptional,substitutablearguments.Multipleargumentsmustbeseparatedbycommas. comment Anoptionalcomment. Thefollowingappliestomacroarguments: • Eachargumentmustcorrespondone−to−onewiththeformalargumentsofthemacrodefinition.Ifthemacrocalldoesnot containthesamenumberofargumentsasthemacrodefinition,theassemblerissuesawarning. • Ifanargumenthasanembeddedcommaorspace,youmustsurroundtheargumentbysinglequotes(’). • Youcandeclareamacrocallargumentasnullinthreeways: − enterdelimitingcommasinsuccessionwithnointerveningspaces macronameARG1,,ARG3;thesecondargumentisanullargument − terminatetheargumentlistwithacomma,theargumentsthatnormallywouldfollow,arenowconsiderednull macronameARG1,;thesecondandallfollowingargumentsarenull − declaretheargumentasanullstring • Nocharacterissubstitutedinthegeneratedstatementsthatreferenceanullargument.

4.9.3 UsingOperatorsforMacroArguments

Theassemblerrecognizescertaintextoperatorswithinmacrodefinitionswhichallowtextsubstitutionofargumentsduring macroexpansion.Youcanusetheseoperatorsfortextconcatenation,numericconversion,andstringhandling.

Operator Name Description \ Macroargument Concatenatesamacroargumentwithadjacentalphanumericcharacters. concatenation ? Returndecimal Substitutesthe?symbolsequencewithacharacterstringthatrepresentsthedecimalvalue valueofsymbol ofthesymbol. % Returnhex Substitutesthe%symbolsequencewithacharacterstringthatrepresentsthehexadecimal valueofsymbol valueofthesymbol. " Macrostring Allowstheuseofmacroargumentsasliteralstrings. delimiter ^ Macrolocallabel Preventsnamemanglingonlabelsinmacros. override

Example:ArgumentConcatenationOperator−\ Considerthefollowingmacrodefinition: MAC_A.MACROreg,val addikr\reg,r\reg,val .ENDM

Themacroiscalledasfollows: MAC_A3,1

Themacroexpandsasfollows: addikr3,r3,1

Themacropreprocessorsubstitutesthecharacter’3’fortheargumentreg,andthecharacter’1’fortheargumentval.The concatenationoperator(\)indicatestothemacropreprocessorthatthesubstitutioncharactersfortheargumentsaretobe concatenatedwiththecharacters’r’. Withoutthe’\’operatorthemacrowouldexpandas: addikrreg,rreg,1 whichresultsinanassemblererror(invalidoperand).

4−46 AssemblyLanguage

Example:DecimalValueOperator−? Insteadofsubstitutingtheformalargumentswiththeactualmacrocallarguments,youcanalsousethevalueofthemacrocall arguments. ConsiderthefollowingsourcecodethatcallsthemacroMAC_AaftertheargumentAVALhasbeensetto1. AVAL.SET1 MAC_A3,AVAL

IfyouwanttoreplacetheargumentvalwiththevalueofAVALratherthanwiththeliteralstring’AVAL’,youcanusethe? operatorandmodifythemacroasfollows: MAC_A.MACROreg,val addikr\reg,r\reg,?val .ENDM

Example:HexValueOperator−%

Thepercentsign(%)issimilartothestandarddecimalvalueoperator(?)exceptthatitreturnsthehexadecimalvalueofa symbol. Considerthefollowingmacrodefinition: GEN_LAB.MACROLAB,VAL,STMT LAB\%VALSTMT .ENDM

ThemacroiscalledafterNUMhasbeensetto10: NUM.SET10 GEN_LABHEX,NUM,NOP

Themacroexpandsasfollows: HEXANOP

The%VALargumentisreplacedbythecharacter’A’whichrepresentsthehexadecimalvalue10oftheargumentVAL.

Example:ArgumentStringOperator−" Togeneratealiteralstring,enclosedbysinglequotes(’),youmustusetheargumentstringoperator(")inthemacrodefinition. Considerthefollowingmacrodefinition: STR_MAC.MACROSTRING .DB"STRING" .ENDM

Themacroiscalledasfollows: STR_MACABCD

Themacroexpandsasfollows: .DB’ABCD’

Withindoublequotes.DEFINEdirectivedefinitionscanbeexpanded.Takecarewhenusingconstructionswithquotesand doublequotestoavoidinappropriateexpansions.Since.DEFINEexpansionoccursbeforemacrosubstitution,any.DEFINE symbolsarereplacedfirstwithinamacroargumentstring: .DEFINELONG’short’ STR_MAC.MACROSTRING .MESSAGEI’ThisisaLONGSTRING’ .MESSAGEI"ThisisaLONGSTRING" .ENDM

Ifthemacroiscalledasfollows: STR_MACsentence

4−47 MicroBlazeEmbeddedToolsReference itexpandsas: .MESSAGEI’ThisisaLONGSTRING’ .MESSAGEI’Thisisashortsentence’

MacroLocalLabelOverrideOperator−^ Ifyouuselabelsinmacros,theassemblernormallygeneratesanotheruniquenameforthelabels(suchas LOCAL__M_L000001). Themacro^−operatorpreventsnamemanglingonmacrolocallabels. Considerthefollowingmacrodefinition: INIT.MACROaddr LOCAL:lwir3,r13,^addr−__base_r13 .ENDM

Themacroiscalledasfollows: LOCAL: INITLOCAL

Themacroexpandsas: LOCAL__M_L000001:lwir3,r13,LOCAL−__base_r13

Ifyouwouldnothaveusedthe^operator,themacropreprocessorwouldchooseanothernameforLOCALbecausethelabel alreadyexists.Themacrowouldexpandlike: LOCAL__M_L000001:lwir3,r13,LOCAL__M_L000001−__base_r13

4.9.4 Usingthe.FORand.REPEATDirectivesasMacros

The.FORand.REPEATdirectivesarespecializedmacroformstorepeatablockofsourcestatements.Youcanthinkofthem asasimultaneousdefinitionandcallofanunnamedmacro.Thesourcestatementsbetweenthe.FORand.ENDFORdirectives and.REPEATand.ENDREPdirectivesfollowthesamerulesasmacrodefinitions.

Foradetaileddescriptionofthesedirectives,seesection4.8,AssemblerDirectives.

4.9.5 ConditionalAssembly

Withtheconditionalassemblydirectivesyoucaninstructthemacropreprocessortouseapartofthecodethatmatchesa certaincondition. Youcanspecifyassemblyconditionswithargumentsinthecaseofmacros,orthroughdefinitionofsymbolsviathe.DEFINE, .SET,and.EQUdirectives. Thebuilt−infunctionsoftheassemblerprovideaversatilemeansoftestingmanyconditionsoftheassemblyenvironment. Youcanuseconditionaldirectivesalsowithinamacrodefinitiontocheckatexpansiontimeifargumentsfallwithinarangeof allowablevalues.Inthiswaymacrosbecomeself−checkingandcangenerateerrormessagestoanydesiredlevelofdetail. Theconditionalassemblydirective.IF/.ENDIFhasthefollowingform: .IFexpression . . [.ELIFexpression];(the.ELIFdirectiveisoptional) . . [.ELSE];(the.ELSEdirectiveisoptional) . . .ENDIF

4−48 AssemblyLanguage

Asectionofaprogramthatistobeconditionallyassembledmustbeboundedbyan.IF−.ENDIFdirectivepair.Iftheoptional .ELSEand/or.ELIFdirectivesarenotpresent,thenthesourcestatementsfollowingthe.IFdirectiveanduptothenext .ENDIFdirectivewillbeincludedaspartofthesourcefilebeingassembledonlyiftheexpressionhadanon−zeroresult. Iftheexpressionhasavalueofzero,thesourcefilewillbeassembledasifthosestatementsbetweenthe.IFandthe.ENDIF directiveswereneverencountered. Ifthe.ELSEdirectiveispresentandexpressionhasanonzeroresult,thenthestatementsbetweenthe.IFand.ELSE directiveswillbeassembled,andthestatementbetweenthe.ELSEand.ENDIFdirectiveswillbeskipped.Alternatively,if expressionhasavalueofzero,thenthestatementsbetweenthe.IFand.ELSEdirectiveswillbeskipped,andthestatements betweenthe.ELSEand.ENDIFdirectiveswillbeassembled.

4−49 MicroBlazeEmbeddedToolsReference

4.10 GenericInstructions

Theassemblersupportsso−called’genericinstructions’.Genericinstructionsarepseudoinstructions(noinstructionsfromthe instructionset).Dependingonthesituationinwhichagenericinstructionisused,theassemblerreplacesthegenericinstruction withappropriaterealassemblyinstruction(s). TheMicroBlazeassemblerrecognizesthefollowinggenericinstructions:

Instruction Replacement NOP ORR0,R0,R0 CLRRd XORRd,Rd,Rd CPRd,Ra ADDIKRd,Ra,0 LIRd,#Imm ADDIKRd,R0,Imm NEGRd,Ra RSUBIRd,Ra,0 NOTRd,Ra XORIRd,Ra,−1 SUBRd,Rb,Ra RSUBRd,Ra,Rb

4−50 5 ToolOptions

Summary ThischapterprovidesadetaileddescriptionoftheoptionsfortheCcompiler,C++ compiler,assembler,linker,controlprogram,makeprogramandthelibrarian.

5.1 CCompilerOptions

AltiumDesignerusesamakefiletobuildyourentireproject.ThismeansthatinAltiumDesigneryoucannotrunthecompiler separately.IfyoucompileasingleCsourcefilefromwithinAltiumDesigner,thefileisalsoassembled.However,youcanset optionsspecificforthecompiler.

OptionsinAltiumDesignerversusoptionsonthecommandline MostcommandlineoptionshaveanequivalentoptioninAltiumDesignerbutsomeoptionsareonlyavailableonthecommand line(forexampleinaWindowsCommandPrompt).IfthereisnoequivalentoptioninAltiumDesigner,youcanspecifya commandlineoptioninAltiumDesignerasfollows: 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMiscellaneous. 3. EnteroneormorecommandlineoptionsintheAdditionalCcompileroptionsfield.

Invocationsyntaxonthecommandline(WindowsCommandPrompt) Tocallthecompilerfromthecommandline,usethefollowingsyntax: cmb[[option]...[file]...]...

TheinputfilemustbeaCsourcefile(.cor.ic).

5−1 MicroBlazeEmbeddedToolsReference

Shortandlongoptionnames Optionscanhavebothshortandlongnames.Shortoptionnamesalwaysbeginwithasingleminus(−)character,longoption namesalwaysbeginwithdoubleminus(−−)characters.Youcanabbreviatelongoptionnamesaslongasthenameisunique. Youcanmixshortandlongoptionnamesonthecommandline. Optionscanhaveflagsorsub−options.Toswitchaflag’on’,usealowercaseletterora+longflag.Toswitchaflagoff,usean uppercaseletterora−longflag.Separatelongflagswithcommas.Thefollowingtwoinvocationsareequivalent: cmb−Oactest.c cmb−−optimize=+coalesce,+csetest.c

Whenyoudonotspecifyanoption,adefaultvaluemaybecomeactive.

5−2 ToolOptions−CCompiler

CCompiler:−−align−composites

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectCodeGeneration. 3. SelecttheAlignmentofcompositetypes:NaturalalignmentorOptimalalignment

Commandlinesyntax −−align−composites=alignment Youcanspecifythefollowingalignments: n Naturalalignment(default) o Optimalalignment

Description Withthisoptionyoucansetthealignmentforcompositetypes(structs,unionsandarrays). Naturalalignment(n)usesthenaturalalignmentofthemost−alignedmemberofthecompositetype. Optimalalignment(o)setsthealignmentto8,16,or32bitsdependingonthesizeofthecompositetype.

Relatedinformation

5−3 MicroBlazeEmbeddedToolsReference

CCompiler:−−cert

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectCERTCSecureCodeChecking. 3. MakeaselectionfromtheCERTCsecurecodecheckinglist. 4. IfyouselectCustomconfiguration,expandtheCustomConfigurationentryandenableoneormoreindividual recommendations/rules.

Commandlinesyntax −−cert={all|name[−name],...}

Description WiththisoptionyoucanenableoneormorechecksforCERTCSecureCodingStandardrecommendations/rules.Whenyou omittheargument,allchecksareenabled.nameisthenameofaCERTrecommendation/rule,consistingofthreelettersand twodigits.Specifyonlythethree−lettermnemonictoselectawholecategory.Forthelistofnamesyoucanuse,seeChapter9, CERTCSecureCodingStandard. Onthecommandlineyoucanuse−−diag=certtoseealistoftheavailablechecks,oryoucanuseathree−lettermnemonicto listonlythechecksinaparticularcategory.Forexample,−−diag=prelistsallsupportedpreprocessorchecks.

Example ToenablethecheckforCERTruleSTR30−C,enter: cmb−−cert=str30test.c

Relatedinformation

Chapter9,CERTCSecureCodingStandard Ccompileroption−−diag(Explanationofdiagnosticmessages)

5−4 ToolOptions−CCompiler

CCompiler:−−check

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMiscellaneous. 3. Addtheoption−−checktotheAdditionalCcompileroptionsfield.

Commandlinesyntax −−check

Description Withthisoptionyoucancheckthesourcecodeforsyntaxerrors,withoutgeneratingcode.Thissavestimeindevelopingyour applicationbecausethecodewillnotactuallybecompiled. Thecompilerreportsanywarningsand/orerrors.

Relatedinformation

Assembleroption−−check(Checksyntax)

5−5 MicroBlazeEmbeddedToolsReference

CCompiler:−−compact−max−size

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMiscellaneous. 3. Addtheoption−−compact−max−sizetotheAdditionalCcompileroptionsfield.

Commandlinesyntax −−compact−max−size=value (Default:75)

Description Thisoptionisrelatedtothecompileroptimization−−optimize=+compact(Codecompactionorreverseinlining).Code compactionistheoppositeofinliningfunctions:largesequencesofcodethatoccurmorethanonce,aretransformedintoa function.Thisreducescodesize(possiblyatthecostofexecutionspeed). However,intheprocessoffindingsequencesofmatchinginstructions,compiletimeandcompilermemoryusageincrease quadraticallywiththenumberofinstructionsconsideredforcodecompaction.Withthisoptionyoutellthecompilertolimitthe numberofmatchinginstructionsitconsidersforcodecompaction.

Example Tolimitthemaximumnumberofinstructionsinfunctionsthatthecompilergeneratesduringcodecompaction: cmb−−optimize=+compact−−compact−max−size=100test.c

Relatedinformation

Ccompileroption−−optimize=+compact(Optimization:codecompaction) Ccompileroption−−max−call−depth(Maximumcalldepthforcodecompaction)

5−6 ToolOptions−CCompiler

CCompiler:−−debug−info(−g)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectDebugInformation. 3. EnabletheoptionGeneratesymbolicdebuginformation. 4. Enableordisablethesuboptions.

Commandlinesyntax −−debug−info[=suboption] −g[suboption] Youcansetthefollowingsuboptions(whenyouspecify−gwithoutsuboption,thedefaultis−gd): small (1|c) Emitsmallsetofdebuginformation. default (2|d) Emitdefaultsymbolicdebuginformation. all (3|a) Emitfullsymbolicdebuginformation.

Description Withthisoptionyoutellthecompilertoadddirectivestotheoutputfileforincludingsymbolicinformation.Thisfacilitateshigh leveldebuggingbutincreasesthesizeoftheresultingassemblerfile(andthusthesizeoftheobjectfile).Forthefinal application,compileyourCfileswithoutdebuginformation. Whenyouspecifyahighoptimizationlevel,debugcomfortmaydecrease.Therefore,thecompilerissuesawarningifthe chosenoptimizationsexpecttoaffecteaseofdebugging. Smallsetofdebuginformation WiththissuboptiononlyDWARFcallframeinformationandtypeinformationaregenerated.Thisenablesyoutoinspect parametersofnestedfunctions.Thetypeinformationimprovesdebugging.Youcanperformastacktrace,butsteppingisnot possiblebecausedebuginformationonfunctionbodiesisnotgenerated.Youcanusethissuboption,forexample,to compactlibraries. Defaultdebuginformation Thisprovidesalldebuginformationyouneedtodebugyourapplication.Itmeetsthedebuggingrequirementsinmostcases withoutresultinginover−sizedassembler/objectfiles. Fulldebuginformation Withthisinformationextradebuginformationisgenerated.Inextra−ordinarycasesyoumayusethisdebuginformation(for instance,ifyouuseyourowndebuggerwhichmakesuseofthisinformation).Withthissuboption,theresulting assembler/objectfileincreasessignificantly.

Relatedinformation

5−7 MicroBlazeEmbeddedToolsReference

CCompiler:−−define(−D)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectPreprocessing. 3. SelectUsermacroandclickonthedownarrowintherightpanetoexpandmacroinput. 4. ClickonanemptyMacrofieldandenteramacroname.(Thenclickanemptycelltoconfirm) 5. Optionally,clickintheValuefieldandenteradefinition.(Thenclickanemptycelltoconfirm)

Commandlinesyntax

−−define=macro_name[=macro_definition] −Dmacro_name[=macro_definition]

Description Withthisoptionyoucandefineamacroandspecifyittothepreprocessor.Ifyouonlyspecifyamacroname(nomacro definition),themacroexpandsas’1’.Youcanspecifyasmanymacrosasyoulike. Onthecommandline,youcanusetheoption−−define(−D)multipletimes.Ifthecommandlineexceedsthelengthlimitofthe operatingsystem,youcandefinethemacrosinanoptionfilewhichyouthenmustspecifytothecompilerwiththeoption −−option−file=file(−f). Definingmacroswiththisoption(insteadofintheCsource)is,forexample,usefultocompileconditionalCsourceasshownin theexamplebelow.

Example ConsiderthefollowingCprogramwithconditionalcodetocompileademoprogramandarealprogram: voidmain(void) { #ifDEMO==1 demo_func();/*compileforthedemoprogram*/ #else real_func();/*compilefortherealprogram*/ #endif }

YoucannowuseamacrodefinitiontosettheDEMOflag: Macro Value DEMO 1(orempty) Onthecommandline,usetheoptionasfollows: cmb−−define=DEMOtest.c cmb−−define=DEMO=1test.c

Notethatbothinvocationshavethesameeffect. Thenextexampleshowshowtospecifyamacrowitharguments.Macrodefinitionsfollowexactlythesamerulesasthe #definestatementintheClanguage. Macro Value MAX(A,B) ((A)>(B)?(A):(B))

Onthecommandline,usetheoption−Dasfollows: cmb−D"MAX(A,B)=((A)>(B)?(A):(B))"test.c

5−8 ToolOptions−CCompiler

Notethatthemacronameanddefinitionareplacedbetweendoublequotesbecauseotherwisethespaceswouldindicateanew option.

Relatedinformation

Ccompileroption−−undefine(Undefinepreprocessormacro) Ccompileroption−−option−file(Readoptionsfromfile)

5−9 MicroBlazeEmbeddedToolsReference

CCompiler:−−dep−file

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMiscellaneous. 3. Addtheoption−−dep−filetotheAdditionalCcompileroptionsfield.

Commandlinesyntax −−dep−file[=file]

Description WiththisoptionyoutellthecompilertogeneratedependencylinesthatcanbeusedinaMakefile.Incontrasttotheoption −−preprocess=+make(−Em),thedependencyinformationwillbegeneratedinadditiontothenormaloutputfile. Bydefault,theinformationiswrittentoafilewithextension.d(oneforeveryinputfile).Whenyouspecifyafilename,all dependencieswillbecombinedinthespecifiedfile.

Example cmb−−dep−file=test.deptest.c

Thecompilercompilesthefiletest.c,whichresultsintheoutputfiletest.src,andgeneratesdependencylinesinthefile test.dep.

Relatedinformation

Ccompileroption−−preprocess=+make(Generatedependenciesformake)

5−10 ToolOptions−CCompiler

CCompiler:−−diag

Menuentry 1. FromtheViewmenu,selectWorkspace»Panels»SystemMessages. TheMessagepannelappears. 2. IntheMessagepanel,right−clickonthemessageyouwantmoreinformationon. Apopupmenuappears. 3. SelectMoreInfo. AMessageInfoboxappearswithadditionalinformation.

Commandlinesyntax

−−diag=[format:]{all|msg[−msg],...}

Description Withthisoptionyoucanaskforanextendeddescriptionoferrormessagesintheformatyouchoose.Theoutputisdirectedto stdout(normallyyourscreen)andintheformatyouspecify.Youcanspecifythefollowingformats:html,rtfortext(default). Tocreateafilewiththedescriptions,youmustredirecttheoutput. Withthesuboptionall,thedescriptionsofallerrormessagesaregiven(exceptfortheCERTchecks).Ifyouwantthe descriptionofoneormoreselectederrormessages,youcanspecifytheerrormessagenumbers,separatedbycommas,oryou canspecifyarange. With−−diag=certyoucanseealistoftheavailableCERTchecks,oryoucanuseathree−lettermnemonictolistonlythe checksinaparticularcategory.Forexample,−−diag=prelistsallsupportedpreprocessorchecks. Withthisoptionthecompilerdoesnotcompileanyfiles.

Example Todisplayanexplanationofmessagenumber282,enter: cmb−−diag=282

Thisresultsinthefollowingmessageandexplanation: E282:unterminatedcomment Makesurethateverycommentstartingwith/*hasamatching*/.Nestedcommentsarenot possible.

TowriteanexplanationofallerrorsandwarningsinHTMLformattofilecerrors.html,useredirectionandenter: cmb−−diag=html:all>cerrors.html

Relatedinformation

Ccompileroption−−cert(EnableindividualCERTchecks)

5−11 MicroBlazeEmbeddedToolsReference

CCompiler:−−error−file

Menuentry Commandlineonly.

Commandlinesyntax

−−error−file[=file]

Description Withthisoptionthecompilerredirectserrormessagestoafile. Ifyoudonotspecifyafilename,theerrorfilewillbenamedaftertheinputfilewithextension.err.

Example Towriteerrorstoerrors.errinsteadofstderr,enter: cmb−−error−file=errors.errtest.c

Relatedinformation

5−12 ToolOptions−CCompiler

CCompiler:−−extern−sdata

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectCodeGeneration. 3. EnabletheoptionEnableallocationinsdata. 4. SpecifyasizeforAllocationinsdataforobjectssmallerthanthreshold(default:4) 5. EnabletheoptionAssumeexternaldataobjectswillalsobeplacedinsdata.

Commandlinesyntax −−extern−sdata

Description Withthisoptionyoutellthecompilertousesmalldataaddressingforexternaldataaswellasforsymbolsdefinedinthecurrent module. Thisoptionisanadditiontotheoption−−sdata.Externaldatathatfallswithinthethresholdofoption−−sdata,isnotconsidered partofsdata.Ifyouwantexternaldatatobepartofthistoo,alsospecifyoption−−extern−sdata.

Ifyouuseoption−−extern−sdata,youmustusetheoption−−sdatawiththesamevalueforallmodulesinyour application.

Example Toputallglobal,staticandexternaldataobjectswithasizeof8bytesorsmallerintothesdatasection: cmb−−sdata=8−−extern−datatest.c

Relatedinformation

Ccompileroption−−sdata=size

5−13 MicroBlazeEmbeddedToolsReference

CCompiler:−−global−type−checking

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectDiagnostics. 3. EnabletheoptionPerformglobaltypecheckingonCcode.

Commandlinesyntax −−global−type−checking

Description TheCcompileralreadyperformstypecheckingwithineachmodule.Usethisoptionwhenyouwantthelinkertoperformtype checkingbetweenmodules.

Relatedinformation

5−14 ToolOptions−CCompiler

CCompiler:−−help(−?)

Menuentry Commandlineonly.

Commandlinesyntax

−−help[=item,...] −? Youcanspecifythefollowingarguments: intrinsics (i) Showthelistofintrinsicfunctions options (o) Showextendedoptiondescriptions pragmas (p) Showthelistofsupportedpragmas typedefs (t) Showthelistofpredefinedtypedefs

Description Displaysanoverviewofallcommandlineoptions.Withanargumentyoucanspecifywhichextendedinformationisshown.

Example Thefollowinginvocationsalldisplayalistoftheavailablecommandlineoptions: cmb−? cmb−−help cmb

Thefollowinginvocationdisplaysalistoftheavailablepragmas: cmb−−help=pragmas

5−15 MicroBlazeEmbeddedToolsReference

CCompiler:−−include−directory(−I)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. SelectBuildOptions. 3. AddapathnameintheIncludefilespathfield. Ifyouentermultiplepaths,separatethemwithasemicolon(;).

Commandlinesyntax −−include−directory=path,... −Ipath,...

Description Withthisoptionyoucanspecifythepathwhereyourincludefilesarelocated.Arelativepathwillberelativetothecurrent directory. Theorderinwhichthecompilersearchesforincludefilesis: 1. ThepathnameintheCsourcefileandthedirectoryoftheCsource (onlyfor#includefilesthatareenclosedin""). 2. Thepaththatisspecifiedwiththisoption. 3. ThepaththatisspecifiedintheenvironmentvariableCMBINCwhentheproductwasinstalled. 4. Thedefaultincludedirectoryrelativetotheinstallationdirectory (unlessyouspecifiedoption−−no−stdinc).

Example SupposethattheCsourcefiletest.ccontainsthefollowinglines: #include #include"myinc.h"

YoucanspecifytheincludedirectorymyincludetotheCcompiler: cmb−−include−directory=myincludetest.c

Firstthecompilerlooksforthefilestdio.hinthedirectorymyincluderelativetothecurrentdirectory.Ifitwasnotfound,the compilersearchesintheenvironmentvariableandtheninthedefaultincludedirectory. Thecompilernowlooksforthefilemyinc.h,inthedirectorywheretest.cislocated.Ifthefileisnottherethecompiler searchesinthedirectorymyinclude.Ifitwasstillnotfound,thecompilersearchesintheenvironmentvariableandtheninthe defaultincludedirectory.

Relatedinformation

Ccompileroption−−include−file(Includefileatthestartofacompilation) Ccompileroption−−no−stdinc(Skipstandardincludefilesdirectory)

5−16 ToolOptions−CCompiler

CCompiler:−−include−file(−H)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectPreprocessing. 3. EnterthenameofthefileintheIncludethisfilebeforesourcefieldorclick...andselectafile.

Commandlinesyntax −−include−file=file,... −Hfile,...

Description Withthisoption(setatprojectlevel)youincludeoneextrafileatthebeginningofeachCsourcefileinyourproject.Ona documentlevel(Project»DocumentOptions),youcanoverrulethisoptionwithanotherfileornofileatall. Thespecifiedincludefileisincludedbeforeallotherincludes.Thisisthesameasspecifying#include"file"atthevery beginningof(eachof)yourCsourcefiles.

Example cmb−−include−file=stdio.htest1.ctest2.c

Thefilestdio.hisincludedatthebeginningofbothtest1.candtest2.c.

Relatedinformation

Ccompileroption−−include−directory(Adddirectorytoincludefilesearchpath) Section2.4,HowtheCompilerSearchesIncludeFiles,inchapterUsingtheCompileroftheuser’smanual.

5−17 MicroBlazeEmbeddedToolsReference

CCompiler:−−inline

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectOptimization. 3. EnabletheoptionAlwaysinlinefunctioncalls.

Commandlinesyntax −−inline

Description Withthisoptionyouinstructthecompilertoinlinecallstofunctionswithoutthe__noinlinefunctionqualifierwhenever possible.Thisoptionhasthesameeffectasa#pragmainlineatthestartofthesourcefile.

Thisoptioncanbeusefultoincreasethepossibilitiesforcodecompaction (compileroption−−optimize=+compact).

Relatedinformation

Ccompileroption−−optimize=+compact(Codecompaction)

5−18 ToolOptions−CCompiler

CCompiler:−−inline−max−incr/−−inline−max−size

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectOptimization. 3. SettheoptionMaximumcodesizeincreasecausedbyinliningtoavalue. 4. SettheoptionMaximumsizeforfunctionstoalwaysinlinetoavalue.

Commandlinesyntax

Description Withtheseoptionsyoucancontroltheautomaticfunctioninliningoptimizationprocessofthecompiler.Theseoptionshaveonly effectwhenyouhaveenabledtheinliningoptimization(option−Oi).

Regardlessoftheoptimizationprocess,thecompileralwaysinlinesallfunctionsthathavethefunctionqualifierinline. Withtheoption−−inline−max−sizeyoucanspecifythemaximumsizeoffunctionsthatthecompilerinlinesaspartofthe optimizationprocess.Thecompileralwaysinlinesallfunctionsthataresmallerthanthespecifiedthreshold.Thethresholdis measuredincompilerinternalunitsandthecompilerusesthismeasuretodecidewhichfunctionsaresmallenoughtoinline. Thedefaultthresholdis−1,whichmeansthatthethresholddependsontheoption−−tradeoff. Afterthecompilerhasinlinedallfunctionsthathavethefunctionqualifierinlineandallfunctionsthataresmallerthanthe specifiedthreshold,thecompilerlookswhetheritcaninlinemorefunctionswithoutincreasingthecodesizetoomuch.Withthe option−−inline−max−incryoucanspecifyhowmuchthecodesizeisallowedtoincrease.Thedefaultvalueis−1,which meansthatthevaluedependsontheoption−−tradeoff.

Example cmb−−inline−max−incr=40−−inline−max−size=15test.c

Thecompilerfirstinlinesallfunctionswiththefunctionqualifierinlineandallfunctionsthataresmallerthanthespecified thresholdof15.Ifthecodesizehasstillnotincreasedwith40%,thecompilerdecideswhichotherfunctionsitcaninline.

Relatedinformation

Ccompileroption−−optimize=+inline(Optimization:automaticfunctioninlining) Section1.9.3,InliningFunctions,inchapterCLanguage. Section2.6.3,OptimizeforSizeorSpeed,inchapterUsingtheCompileroftheuser’smanual.

5−19 MicroBlazeEmbeddedToolsReference

CCompiler:−−integer−enumeration

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectLanguage. 3. EnabletheoptionTreatenumeratedtypesalwaysasinteger.

Commandlinesyntax −−integer−enumeration

Description Normallythecompilertreatsenumeratedtypesasthesmallestdatatypepossible(charinsteadofint).Thisreducescode size.Withthisoptionthecompileralwaystreatsenum−typesasintasdefinedintheISOC99standard.

Relatedinformation

5−20 ToolOptions−CCompiler

CCompiler:−−iso(−c)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectLanguage. 3. SelecttheISOCstandardC90orC99.

Commandlinesyntax −−iso={90|99} −c{90|99}

Description WiththisoptionyouselecttheISOCstandard.ThecompilercheckstheCsourceagainstthisstandardandmaygenerate warningsorerrorsifyouuseClanguagethatisnotdefinedinthestandard. C90isalsoreferredtoasthe"ANSICstandard".C99referstothenewerISO/IEC9899:1999(E)standard.C99isthedefault. cmb−−iso=90test.c

Relatedinformation

Ccompileroption−−language(Languageextensions)

5−21 MicroBlazeEmbeddedToolsReference

CCompiler:−−keep−output−files(−k)

Menuentry AltiumDesigneralwaysremovesthe.srcfilewhenerrorsoccurduringcompilation.

Commandlinesyntax −−keep−output−files −k

Description Ifanerroroccursduringcompilation,theresulting.srcfilemaybeincompleteorincorrect.Withthisoptionyoukeepthe generatedoutputfile(.src)whenanerroroccurs. Bydefaultthecompilerremovesthegeneratedoutputfile(.src)whenanerroroccurs.Thisisusefulwhenyouusethemake utility.Iftheerroneousfilesarenotremoved,themakeutilitymayprocesscorruptfilesonasubsequentinvocation. Usethisoptionwhenyoustillwanttoinspectthegeneratedassemblysource.Evenifitisincompleteorincorrect.

Relatedinformation

5−22 ToolOptions−CCompiler

CCompiler:−−language(−A)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectLanguage. 3. Enableordisablethefollowingoptions: • AllowGNUCextensions • AllowC++stylecommentsinISOC90mode(onlyavailablewhenISOC90isselected) • Checkassignmentofstringliteraltonon−conststringpointer • Allowoptimizationacrossvolatileaccess Commandlinesyntax

−−language=[flags] −A[flags] Youcansetthefollowingflags: +/−gcc (g/G) Enableanumberofgccextensions +/−comments (p/P) AllowC++stylecommentsinCsourcecode +/−volatile (v/V) Donotoptimizeacrossvolatileaccess +/−strings (x/X) Relaxedconstcheckforstringliterals Theoption−−language(−A)istheequivalentof−AGPVXwhichdisablesalllanguageextensions. Thedefaultis−AGpVx.

Description Withthisoptionyoucontrolthelanguageextensionsthecompileraccepts.DefaulttheCcompilerallowsalllanguage extensions. WithAllowC++stylecommentsinISOC90mode(−−language=+comments),youtellthecompilertoallowC++style comments(//)inISOC90mode(option−c90).InISOC99modethisstyleofcommentsisalwaysaccepted. WithCheckassignmentofstringliteraltonon−conststringpointer(−−language=−strings)youtellthecompilerto generateawarningwhenyouassignaconstantstringtoanon−constantstringpointer.Whenyoudisablethisoptionthe followingexampleproducesnowarning: char*p; voidmain(void){p="hello";}

WithoptionAllowGNUCextensions(−−language=+gcc)youtellthecompilertoenablethefollowinggcclanguages extensions: • Theidentifier__FUNCTION__expandstothecurrentfunctionname • Alternativesyntaxforvariadicmacros • Alternativesyntaxfordesignatedinitializers • Allowzerosizedarrays • Allowemptystruct/union • Allowemptyinitializerlist • Allowinitializationofstaticobjectsbycompoundliterals • Themiddleoperandofa?:operatormaybeomitted • Allowacompoundstatementinsidebracesasexpression • Allowarithmeticonvoidpointersandfunctionpointers • Allowarangeofvaluesafterasinglecaselabel • Additionalpreprocessordirective#warning • Allowcommaoperator,conditionaloperatorandcastaslvalue • Aninlinefunctionwithout"static"or"extern"willbeglobal

5−23 MicroBlazeEmbeddedToolsReference

• An"externinline"functionwillnotbecompiledonitsown • An__attribute__directlyfollowingastruct/uniondefinitionrelatestothattaginsteadoftotheobjectsinthedeclaration. Foranexactdescriptionofthesegccextensions,pleaserefertothegccinfopages(infogcc). WhenyoudisabletheoptionAllowoptimizationacrossvolatileaccess(with−−language=+volatile),youtellthecompilerto blockoptimizationswhenreadingorwritingavolatileobject,bytreatingtheaccessasacalltoanunknownfunction.Thisway youcanpreventforexamplethatcodebelowthevolatileobjectisoptimizedawaytosomewhereabovethevolatileobject. Example: externunsignedintvariable; externvolatileunsignedintaccess;

voidTestFunc(unsignedintflag) { access=0; variable|=flag; if(variable==3) { variable=0; } variable|=0x8000; access=1; }

Resultwith−−language=−volatile(default): Resultwith−−language=+volatile:

Example cmb−AGPx−c90test.c cmb−−language=−ggc,−comments,+strings−−iso=90test.c

Ccompileroption−−iso(ISOCstandard)

5−24 ToolOptions−CCompiler

CCompiler:−−make−target

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMiscellaneous. 3. Addtheoption−−make−targettotheAdditionalCcompileroptionsfield.

Commandlinesyntax −−make−target=name

Description Withthisoptionyoucanoverrulethedefaulttargetnameinthemakedependenciesgeneratedbytheoptions −−preprocess=+make(−Em)and−−dep−file.Thedefaulttargetnameisthebasenameoftheinputfile,withextension.obj.

Relatedinformation

Ccompileroption−−preprocess=+make(Generatedependenciesformake) Ccompileroption−−dep−file(Generatedependenciesinafile)

5−25 MicroBlazeEmbeddedToolsReference

CCompiler:−−max−call−depth

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMiscellaneous. 3. Addtheoption−−max−call−depthtotheAdditionalCcompileroptionsfield.

Commandlinesyntax −−max−call−depth=value(Default:−1)

Description Thisoptionisrelatedtothecompileroptimization−−optimize=+compact(Codecompactionorreverseinlining).Code compactionistheoppositeofinliningfunctions:largesequencesofcodethatoccurmorethanonce,aretransformedintoa function.Thisreducescodesize(possiblyatthecostofexecutionspeed). Duringcodecompactionthecompilergeneratesnestedcalls.Thismaycausetheprogramtorunoutofitsstack.Toprevent stackoverflowcausedbytoodeeplynestedfunctioncalls,youcanusethisoptiontolimitthecalldepth.Thisoptioncanhave thefollowingvalues: −1 Posesnolimittothecalldepth(default) 0 Thecompilerwillnotgenerateanyfunctioncalls.(Effectivelythesameasifyouturnedofcodecompactionwithoption −−optimize=−compact) >0 Codesequencesareonlyreversedifthiswillnotleadtocodeatacalldepthlargerthanspecifiedwithvalue.Function callswillbeplacedatacalldepthnolargerthanvalue−1.(Notethatifyouspecifiedavalueof1,theoption −−optimize=+compactmayremainwithouteffectwhencodesequencesforreversingcontainfunctioncalls.) Thisoptiondoesnotinfluencethecalldepthofuserwrittenfunctions.

IfyouusethisoptionwithvariousCmodules,thecalldepthisvalidforeachindividualmodule.Thecalldepthafter linkingmaydiffer,dependingonthenatureofthemodules.

Relatedinformation

Ccompileroption−−optimize=+compact(Optimization:codecompaction) Ccompileroption−−compact−max−size(Maximumsizeofamatchforcodecompaction)

5−26 ToolOptions−CCompiler

CCompiler:−−mil/−−mil−split

Menuentry Commandlineonly.

Commandlinesyntax −−mil −−mil−split[=file,...]

Description Withoption−−miltheCcompilerskipsthecodegeneratorphaseandwritestheoptimizedintermediaterepresentation(MIL)to afilewiththesuffix.mil.TheCcompileraccepts.milfilesasinputfilesonthecommandline. Option−−mil−splitdoesthesameasoption−−mil,butinaddition,theCcompilersplitstheMILrepresentationandwritesitto separatefileswithsuffix.ms.OnefileiswrittenforeachinputfileorMILlibraryspecifiedonthecommandline.The.msfiles areonlyupdatedonachange.TheCcompileraccepts.msfilesasinputfilesonthecommandline. Withoption−−mil−splityoucanperformapplication−wideoptimizationsduringthefrontendphasebyspecifyingallmodulesat once,andstillinvokethebackendphaseonemoduleatatimetoreducethetotalcompilationtime. Optionally,youcanspecifyanotherfilenameforthe.msfiletheCcompilergenerates.Withoutanargument,thebasenameof theCsourcefileisusedtocreatethe.msfilename.Notethatifyouspecifyafilename,youhavetospecifyonefilenamefor everyinputfile.

Relatedinformation

Controlprogramoption−−mil−link/−−mil−split

5−27 MicroBlazeEmbeddedToolsReference

CCompiler:−−misrac

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMISRA−C. 3. IntheMISRA−CcheckingboxselectaMISRA−Cconfiguration. IfyouselectCustomMISRA−Cconfiguration: 4. Intheleftpane,expandtheMISRA−CentryandselectCustom2004orCustom1998. 5. Enableordisabletheindividualrules.

Commandlinesyntax

−−misrac={all|number[−number],...}

Description

WiththisoptionyouspecifytothecompilerwhichMISRA−Crulesmustbechecked.Withtheoption−−misrac=allthecompiler checksforallsupportedMISRA−Crules.

Example cmb−−misrac=9−13test.c

ThecompilergeneratesanerrorforeachMISRA−Crule9,10,11,12or13violationinfiletest.c.

Relatedinformation

Ccompileroption−−misrac−advisory−warnings Ccompileroption−−misrac−required−warnings Linkeroption−−misrac−report

5−28 ToolOptions−CCompiler

CCompiler:−−misrac−advisory−warnings/−−misrac−required−warnings

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMISRA−C. 3. EnableoneorbothoptionsTurnadvisoryruleviolationintowarningandTurnrequiredruleviolationintowarning.

Commandlinesyntax −−misrac−advisory−warnings −−misrac−required−warnings

Description Normally,ifanadvisoryruleorrequiredruleisviolated,thecompilergeneratesanerror.Asaconsequence,nooutputfileis generated.Withthisoption,thecompilergeneratesawarninginsteadofanerror.

Relatedinformation

Ccompileroption−−misrac Linkeroption−−misrac−report

5−29 MicroBlazeEmbeddedToolsReference

CCompiler:−−misrac−version

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogappears. 2. ExpandtheCCompilerentryandselectMISRA−C. 3. SelecttheMISRA−Cstandard:1998or2004.

Commandlinesyntax −−misrac−version={1998|2004}

Description MISRA−Crulesexistintwoversions:MISRA−C:1998andMISRA−C:2004.Bydefault,theCsourceischeckedagainstthe MISRA−C:2004rules.WiththisoptionyoucanspecifytocheckagainsttheMISRA−C:1998rules.

Relatedinformation

SeeChapter10,MISRA−CRules,foralistofallsupportedMISRA−Crules. Ccompileroption−−misrac

5−30 ToolOptions−CCompiler

CCompiler:−−noclear

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMiscellaneous. 3. Addtheoption−−nocleartotheAdditionalCcompileroptionsfield.

Commandlinesyntax −−noclear

Description Normallyvariablesareclearedatprogramstartup.Withthisoptionyoutellthecompilertogeneratecodetoprevent non−initializedglobalvariablesfrombeingclearedatprogramstartup.

Relatedinformation

5−31 MicroBlazeEmbeddedToolsReference

CCompiler:−−no−double(−F)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectFloating−Point. 3. EnabletheoptionUsesingleprecisionfloating−pointonly.

Commandlinesyntax −−no−double −F

Description

Withthisoptionyoutellthecompilertotreatvariablesofthetypedoubleasfloat.Becausethefloattypetakeslessspace, executionspeedincreasesandcodesizedecreases,bothatthecostoflessprecision.

Relatedinformation

5−32 ToolOptions−CCompiler

CCompiler:−−noframe

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectCodeGeneration. 3. DisabletheoptionGenerateframeforinterrupthandler.

Commandlinesyntax −−noframe

Description Withthisoptionyoucanspecifywhetherthecompilershouldgenerateaninterruptframe(saving/restoringregisters)for interrupthandlersornot.

Relatedinformation

Ccompileroption−−vector−offset(Reset/interruptvectoroffset) Ccompileroption−−novector(Generatecodeforinterruptvector) Section1.9.5,InterruptFunctions,inchapterCLanguage.

5−33 MicroBlazeEmbeddedToolsReference

CCompiler:−−no−stdinc

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMiscellaneous. 3. Addtheoption−−no−stdinctotheAdditionalCcompileroptionsfield.

Commandlinesyntax −−no−stdinc

Description Withthisoptionyoutellthecompilernottolookinthedefaultincludedirectoryrelativetotheinstallationdirectory,when searchingforincludefiles.Thiswaythecompileronlysearchesintheincludefilesearchpathsyouspecified.

Relatedinformation

Ccompileroption−−include−directory(Adddirectorytoincludefilesearchpath)

5−34 ToolOptions−CCompiler

CCompiler:−−novector

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectCodeGeneration. 3. DisabletheoptionGeneratecodeforinterruptvector.

Commandlinesyntax −−novector

Description Withthisoptionyoutellthecompilernottogeneratecodeforinterruptvectorsandreferencestotheinterrupthandlerinthe run−timelibrary.Usethisoptionifyoudonotuseinterruptsinyourapplication,orifyouwanttowriteyourowninterruptvectors.

Relatedinformation

Ccompileroption−−vector−offset(Specifyabaseaddressforinterruptvectors) Ccompileroption−−noframe(Donotgenerateframeforinterrupthandler) Section1.9.5,InterruptFunctions,inchapterCLanguage.

5−35 MicroBlazeEmbeddedToolsReference

CCompiler:−−no−warnings(−w)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectDiagnostics. 3. IntheErrorreportingfield,selectoneofthefollowingoptions: • Reportallwarnings • Suppressallwarnings • Suppressspecificwarningsn IfyouselectSuppressspecificwarnings: 4. Enterthenumbers,separatedbycommasorasarange,ofthewarningsyouwanttosuppress.

Commandlinesyntax −−no−warnings[=number[−number],...] −w[number[−number],...]

Description Withthisoptionyoucansuppressallwarningmessagesorspecificwarningmessages. Onthecommandlinethisoptionworksasfollows: • Ifyoudonotspecifythisoption,allwarningsarereported. • Ifyouspecifythisoptionbutwithoutnumbers,allwarningsaresuppressed. • Ifyouspecifythisoptionwithanumberorarange,onlythespecifiedwarningissuppressed. Youcanspecifytheoption−−no−warnings=numbermultipletimes. Example Tosuppresswarnings135and136,enter135,136intheSpecificwarningstosuppressfield,orenterthefollowingonthe commandline: cmbtest.c−−no−warnings=135,136

Relatedinformation

Ccompileroption−−warnings−as−errors(Treatwarningsaserrors)

5−36 ToolOptions−CCompiler

CCompiler:−−optimize(−O)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectOptimization. 3. SelectanoptimizationlevelintheOptimizationlevelbox. 4. IfyouselectCustomOptimization,enableordisabletheoptimizationsyouwant. 5. Inaddition,intheSize/speedtrade−offfield,selectalevelbetweenfullyoptimizeforsizeorfullyoptimizeforspeed.

Commandlinesyntax

−−optimize[=flags] −O[flags] Usethefollowingoptionsforpredefinedsetsofflags: −−optimize=0 (−O0) Nooptimization Aliasfor:−OaBCEFGIKLOPRSY −−optimize=1 (−O1) Fewoptimizations Aliasfor:−OabcefgIKLOPRSy −−optimize=2 (−O2) Mediumoptimization(default) Aliasfor:−OabcefgIkloprsy −−optimize=3 (−O3) Fulloptimization Aliasfor:−Oabcefgikloprsy Youcanenablethefollowingindividualoptimizations: +/−coalesce (a/A) Coalescer(removeunnecessarymoves) +/−ipro (b/B) InterproceduralRegisterOptimization +/−cse (c/C) Commonsubexpressionelimination(CSE) +/−expression (e/E) Expressionsimplification +/−flow (f/F) Controlflowsimplification(optimizationandcodereordering) +/−glo (g/G) Genericassemblycodeoptimizations +/−inline (i/I) Functioninlining +/−schedule (k/K) Instructionscheduler +/−loop (l/L) Looptransformations +/−forward (o/O) Forwardstore +/−propagate (p/P) Constantpropagation +/−compact (r/R) Codecompaction(reverseinlining) +/−subscript (s/S) Subscriptstrengthreduction +/−peephole (y/Y) Peepholeoptimizations Foranextensivedescriptionoftheseoptimizations,pleaserefertosection2.6,CompilerOptimizationsinchapterUsingthe Compileroftheuser’smanual.

Description TheTASKINGCcompilersofferfouroptimizationlevelsandacustomlevel,ateachlevelaspecificsetofoptimizationsis enabled. • Nooptimization(−O0):Nooptimizationsareperformedexceptforthecoalescer(toallowbetterdebuginformation).The compilertriestoachievea1−to−1resemblancebetweensourcecodeandproducedcode.Expressionsareevaluatedinthe orderwritteninthesourcecode,associativeandcommutativepropertiesarenotused. • Fewoptimizations(−O1):Enablesoptimizationsthatdonotaffectthedebug−abilityofthesourcecode.Usethislevelwhen youencounterproblemsduringdebuggingyoursourcecodewithoptimizationlevel2. • Mediumoptimization(−O2):Enablesmoreoptimizationstoreducecodesizeand/orexecutiontime.Thisisthedefault optimizationlevel.

5−37 MicroBlazeEmbeddedToolsReference

• Fulloptimization(−O3):Thisisthehighestoptimizationlevel.Usethisleveltodecreaseexecutiontimetomeetyour real−timerequirements. • Customoptimization(−Ox/X):youcanenable/disablespecificoptimizations. Withtheseoptionsyoucancontrolthelevelofoptimization.ThedefaultoptimizationlevelisMediumoptimization(option−O2 or−Oor−OabcefgIkloprsy). YoucanoverrulethesesettingsinyourCsourcefilewiththepragmapair#pragmaoptimizeflagand#pragma endoptimize.

Inadditiontothecommandlineoption−−optimize(−O),youcanspecifytheoption−−tradeoff(−t).Withthisoptionyou specifywhethertheusedoptimizationsshouldoptimizeformorespeed(regardlessofcodesize)orforsmallercodesize (regardlessofspeed).

Example Thefollowinginvocationsareequivalentandresultallinthedefaultoptimizationset: cmbtest.c cmb−O2test.c cmb−−optimize=2test.c cmb−Otest.c cmb−−optimizetest.c cmb−OabcefgIkloprsytest.c cmb−−optimize=+coalesce,+ipro,+cse,+expression,+flow,+glo, −inline,+schedule,+loop,+forward,+propagate,+compact,+subscript, +peepholetest.c

Relatedinformation

Section2.6,CompilerOptimizations,inchapterUsingtheCompileroftheuser’smanual. Ccompileroption−−tradeoff(−t)(Tradeoffbetweenspeed(−t0)andsize(−t4))

5−38 ToolOptions−CCompiler

CCompiler:−−option−file(−f)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMiscellaneous. 3. Addtheoption−−option−filetotheAdditionalCcompileroptionsfield. BeawarethattheoptionsintheoptionfileareaddedtotheCcompileroptionsyouhavesetintheotherdialogs.Onlyin extraordinarycasesyoumaywanttousethemincombination.AltiumDesignerautomaticallysavestheoptionswithyour project.

Commandlinesyntax −−option−file=file,... −ffile,...

Description

Thisoptionisprimarilyintendedforcommandlineuse.Insteadoftypingalloptionsonthecommandline,youcancreatean optionfilewhichcontainsalloptionsandflagsyouwanttospecify.Withthisoptionyouspecifytheoptionfiletothecompiler. Useanoptionfilewhenthecommandlinewouldexceedthelimitsoftheoperatingsystem,orjusttostoreoptionsandsave typing. Youcanspecifytheoption−−option−filemultipletimes. Formatofanoptionfile • Multipleargumentsononelineintheoptionfileareallowed. • Toincludewhitespaceinanargument,surroundtheargumentwithsingleordoublequotes. • Ifyouwanttousesinglequotesaspartoftheargument,surroundtheargumentbydoublequotesandviseversa: "Thishasasinglequote’embedded" ’Thishasadoublequote"embedded’ ’Thishasadoublequote"andasinglequote’"’embedded" • Whenatextlinereachesitslengthlimit,usea\tocontinuetheline.Whitespacebetweenquotesispreserved. "Thisisacontinuation\ line"

−>"Thisisacontinuationline" • Itispossibletonestcommandlinefilesupto25levels. Example Supposethefilemyoptionscontainsthefollowinglines: −g −DDEMO=1 test.c

SpecifytheoptionfiletotheCcompiler: cmb−−option−file=myoptions

Thisisequivalenttothefollowingcommandline: cmb−g−DDEMO=1test.c

Relatedinformation

5−39 MicroBlazeEmbeddedToolsReference

CCompiler:−−output(−o)

Menuentry AltiumDesignernamestheoutputfilealwaysaftertheCsourcefile.

Commandlinesyntax

−−output=file −ofile

Description Withthisoptionyoucanspecifyanotherfilenamefortheoutputfileofthecompiler.WithoutthisoptionthebasenameoftheC sourcefileisusedwithextension.src.

Example Tocreatethefileoutput.srcinsteadoftest.src,enter: cmb−−output=output.srctest.c

Relatedinformation

5−40 ToolOptions−CCompiler

CCompiler:−−preprocess(−E)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectPreprocessing. 3. EnabletheoptionStoretheCCompilerpreprocessoutput(.pre).

Commandlinesyntax −−preprocess[=flags] −E[flags] Youcansetthefollowingflags(whenyouspecify−Ewithoutflags,thedefaultis−ECILMP): +/−comments (c/C) KeepcommentsfromtheCsourceinthepreprocessedoutput +/−includes (i/I) Generatealistofincludedsourcefiles +/−list (l/L) Generatealistofmacrodefinitions +/−make (m/M) Generatedependencylinesthatcanbeusedforthemakefile +/−noline (p/P) Strip#linesourcepositioninfo(linesstartingwith#line) Thecompilersendsthepreprocessedfiletostdout.Tocapturetheinformationinafile,specifyanoutputfilewiththeoption −−output.

Description Whencompiling,eachfileispreprocessedfirst.WiththisoptionyoucanstoretheresultofpreprocessedCfiles.Altium Designerstoresthepreprocessedfileinafilecalledname.pre(wherenameisthenameoftheCsourcefilebeingcompiled).C commentsarenotpreserved(similarto−ECILMP) With−−preprocess=+commentsyoutellthepreprocessortokeepthecommentsfromtheCsourcefileinthepreprocessed output. With−−preprocess=+includesthecompilerwillgeneratealistofallincludedsourcefiles.Thepreprocessoroutputis discarded. With−−preprocess=+listthecompilerwillgeneratealistofallmacrodefinitions.Thepreprocessoroutputisdiscarded. With−−preprocess=+makethecompilerwillgeneratedependencylinesthatcanbeusedinaMakefile.Thepreprocessor outputisdiscarded.Thedefaulttargetnameisthebasenameoftheinputfile,withtheextension.obj.Withtheoption −−make−targetyoucanspecifyatargetnamewhichoverrulesthedefaulttargetname. With−−preprocess=+nolineyoutellthepreprocessortostripthe#linesourcepositioninformation(linesstartingwith#line). Theselinesarenormallyprocessedbytheassemblerandnotneededinthepreprocessedoutput.Whenyouleavetheselines out,theoutputiseasiertoread.

Relatedinformation

Ccompileroption−−make−target(Specifytargetnamefor−Emoutput)

5−41 MicroBlazeEmbeddedToolsReference

CCompiler:−−profile(−p)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectDebugInformation. 3. EnabletheoptionGenerateprofilinginformation. 4. Enableoneormoreofthefollowingsuboptionstoselectwhichprofilesshouldbeobtained: • Blockcounters(notincombinationwithwithCallgraphorFunctiontimers) • Callgraph • Functioncounters • Functiontimers

Notethatthemoredetailledinformationyourequest,thelargertheoverheadintermsofexecutiontime,codesizeand heapspaceneeded.TheoptionGenerateDebuginformation(−−debugor−g)doesnotaffectprofiling,executiontime orcodesize.

Commandlinesyntax −−profile[=flags] −p[flags] Usethefollowingoptionforapredefinedsetofflags: −−profile=g (−pg) profilingwithcallgraphandfunctiontimers Aliasfor:−pBcFt Youcansetthefollowingflags(whenyouspecify−pwithoutflags,thedefaultis−pBCfST): +/−block (b/B) blockcounters +/−callgraph (c/C) callgraph +/−function (f/F) functioncounters +/−static (s/S) staticprofilegeneration +/−time (t/T) functiontimers

Description Profilingistheprocessofcollectingstatisticaldataaboutarunningapplication.Withthesedatayoucananalyzewhichfunctions arecalled,howoftentheyarecalledandwhattheirexecutiontimeis. Severalmethodsofprofilingexist.Onemethodiscodeinstrumentationwhichaddscodetoyourapplicationthattakescareof theprofilingprocesswhentheapplicationisexecuted.

ForanextensivedescriptionofprofilingrefertoChapter4,Profiling,intheuser’smanual.

Withthisoption,thecompileraddstheextracodetoyourapplicationthattakescareoftheprofilingprocess.Youcanobtainthe followingprofilingdata(seeflagsabove): Blockcounters(notincombinationwithCallgraphorFunctiontimers) Thiswillinstrumentthecodetoperformbasicblockcounting.Astheprogramruns,itcountsthenumberofexecutionsof eachbranchinanifstatement,eachiterationofaforloop,andsoon.NotethatthoughyoucancombineBlockcounters withFunctioncounters,thishasnoeffectbecauseFunctioncountersisonlyasubsetofBlockcounters. Callgraph(notincombinationwithBlockcounters) Thiswillinstrumentthecodetoreconstructtherun−timecallgraph.Astheprogramrunsitassociatesthecallerwiththe gatheredprofilingdata.

5−42 ToolOptions−CCompiler

Functioncounters Thiswillinstrumentthecodetoperformfunctioncallcounting.ThisisasubsetofthebasicBlockcounters. Functiontimers(notincombinationwithBlockcounters/Functioncounters) Thiswillinstrumentthecodetomeasurethetimespentinafunction.Thisincludesthetimespentinallsubfunctions (callees). Staticprofiling Withthisoptionyoudonotneedtoruntheapplicationtogetprofilingresults.Thecompilergeneratesprofilinginformationat compiletime.

Ifyouusetheprofilingoption,youmustlinkthecorrespondinglibrariestoo!RefertoSection6.4,LinkingwithLibrariesin ChapterUsingtheLinkeroftheuser’smanual,foranoverviewofthe(profiling)libraries.WhenyouuseAltiumDesigner, automaticallythecorrectlibrariesarelinked.

Example Togenerateblockcountinformationforthemoduletest.cduringexecution,compileasfollows: cmb−−profile=+blocktest.c

Inthiscaseyoumustlinkthelibrarypbmba.lib. Relatedinformation

Chapter4,Profilingintheuser’smanual.

5−43 MicroBlazeEmbeddedToolsReference

CCompiler:−−rename−sections(−R)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMiscellaneous. 3. Addtheoption−−rename−sectionstotheAdditionalCcompileroptionsfield.

Commandlinesyntax −−rename−sections=[name]={suffix|−f|−m|−fm} −R[name]={suffix|−f|−m|−fm}

Description

Incaseamodulemustbeloadedatafixedaddress,oradatasectionneedsaspecialplaceinmemory,youcanusethisoption togeneratedifferentsectionnames.Youcanthenusethisuniquesectionnameinthelinkerscriptfileforlocating.Because sectionshavereservednames,thecompilerwillnotactuallychangethesectionname,butwilladdasuffixtothename.

Withthesectionnameyouselectwhichsectionsarerenamed.Withsuffixyouspecifythesuffixpartwhichwillbeattachedto theexistingname.Thefollowingnamevalueshavespecialmeaning:

Withthesuboption−f,thecompilerusesthefunctionname(onlyforcode).

Withthesuboption−m,thecompilerusesthenameofthecurrentmodule.

Withthesuboption−fm(or−mf),thecompilerusesthenameofthecurrentmodulefordatasectionsandthefunctionnamefor codesections.

Ifyoudonotspecifyasectionname,allsectionswillreceivethespecifiedsuffix.

Example Tochangeallsectionsnamed.datainto.data.NEW: cmb−−rename−sections=.data=NEWtest.c

Toaddthenameofthecurrentmodulenameassuffixtoalldatasections,resultingin.data.test): cmb−−rename−sections=.data=−mtest.c

Relatedinformation

Assemblerdirective.SECTION

5−44 ToolOptions−CCompiler

CCompiler:−−romstrings(−S)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectCodeGeneration. 3. EnabletheoptionPutstringsinROMonly.

Commandlinesyntax −−romstrings −S

Description Bydefault,constantstringsarecopiedfromROMtoRAMatprogramstartup.Withthisoptionyoutellthecompilertokeep constantstringsinROM.Ifyouusethisoption,youcanaccessthesestringsonlywiththe__romkeyword. Withthisoptionenabled,stringsarenotcopiedtoRAMatstartuptosaveRAMmemory.StringsinROMcannotbemodifiedand accessisslowerthanaccesstostringsinRAM.

Relatedinformation

5−45 MicroBlazeEmbeddedToolsReference

CCompiler:−−runtime(−r)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectDebugInformation. 3. EnabletheoptionRun−timechecks. 4. Enableoneormoreofthefollowingsuboptionstoselectwhichrun−timechecksshouldbeperformed: • Boundschecking • Reportunhandledcaseinaswitch • Mallocconsistencychecks Commandlinesyntax −−runtime[=flags] −r[flags] Youcansetthefollowingflags(whenyouspecify−rwithoutflags,thedefaultis−rbcm): +/−bounds (b/B) boundschecking +/−case (c/C) reportunhandledcaseinaswitch +/−malloc (m/M) mallocconsistencychecks

Description Thisoptioncontrolsanumberofrun−timecheckstodetecterrorsduringprogramexecution.Someofthesechecksrequire additionalcodetobeinsertedintheoriginalapplicationcode,andmaythereforeslowdowntheprogramexecution.The followingchecksareavailable: Boundschecking Everypointerupdateanddereferencewillbecheckedtodetectout−of−boundsaccesses,nullpointersanduninitialized automaticpointervariables.Thischeckwillincreasethecodesizeandslowdowntheprogramconsiderably.Inaddition,some heapmemoryisallocatedtostoretheboundsinformation.Youmayenableboundscheckingforindividualmodulesoreven partsofmodulesonly(see#pragmaruntime). Reportunhandledcaseinaswitch Reportanunhandledcasevalueinaswitchwithoutadefaultpart.Thischeckwilladdonefunctioncalltoeveryswitchwithouta defaultpart,butitwillhavelittleimpactontheexcutionspeed. Mallocconsistencychecks Thisoptionenablestheuseofwrappersaroundthefunctionsmalloc/realloc/freethatwillcheckforcommondynamicmemory allocationerrorslike: • bufferoverflow • writetofreedmemory • multiplecallstofree • passinginvalidpointertofree Enablingthischeckwillextractsomeadditionalcodefromthelibrary,butitwillnotenlargeyourapplicationcode.Thedynamic memoryusagewillincreasebyacoupleofbytesperallocation.

Relatedinformation

5−46 ToolOptions−CCompiler

CCompiler:−−sdata

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectCodeGeneration. 3. EnabletheoptionEnableallocationinsdata. 4. SpecifyasizeforAllocationinsdataforobjectssmallerthanthreshold(default:4)

Commandlinesyntax −−sdata=size (Default:4bytes)

Description Withthisoptionyoutellthecompilertoplaceallglobalandstaticdataobjectssmallerthanthespecifiedsize(bytes)intothe smalldatasection(sdata)orsmallbsssection(sbss).Thisresultsinsmallerandfastercode.Intotal,64kBisavailableforthis kindofaddressing. Withoutthisoption,allglobalandstaticdataobjectsof4bytesandsmallerareplacedintothesmalldatasectionsandsmallbss sections. Youcanstilloverrulethisoptionwiththekeywords__sdataand__no_sdataforindividiualdataobjectsinyoursource. Externaldatathatfallswithinthethreshold,isnotconsideredpartofsdata.Ifyouwantexternaldatatobepartofthistoo,also specifyoption−−extern−sdata.

Ifyouuseoption−−extern−sdata,youmustusetheoption−−sdatawiththesamevalueforallmodulesinyour application.

Example Toputallglobalandstaticdataobjectswithasizeof8bytesorsmallerintothesdatasection: cmb−−sdata=8test.c

Relatedinformation

Ccompileroption−−extern−sdata Section1.3,MemoryQualifiers.

5−47 MicroBlazeEmbeddedToolsReference

CCompiler:−−signed−bitfields

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectLanguage. 3. EnabletheoptionTreat’int’bit−fieldsassigned.

Commandlinesyntax −−signed−bitfields

Description Forbit−fieldsitdependsontheimplementationwhetheraplainintistreatedassignedintorunsignedint.By defaultanintbit−fieldistreatedasunsignedint.Thisoffersthebestperformance.Withthisoptionyoutellthecompiler totreatintbit−fieldsassignedint.Inthiscase,youcanstilladdthekeywordunsignedtotreataparticularint bit−fieldasunsigned.

Relatedinformation

5−48 ToolOptions−CCompiler

CCompiler:−−source(−s)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMiscellaneous. 3. EnabletheoptionMergeCsourcecodewithassemblyinoutputfile(.src).

Commandlinesyntax −−source −s

Description WiththisoptionyoutellthecompilertomergeCsourcecodewithgeneratedassemblycodeintheoutputfile.TheCsource linesareincludedascomments.

Relatedinformation

5−49 MicroBlazeEmbeddedToolsReference

CCompiler:−−static

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMiscellaneous. 3. Addtheoption−−statictotheAdditionalCcompileroptionsfield.

Commandlinesyntax −−static

Description Withthisoption,thecompilertreatsexternaldefinitionsatfilescope(exceptformain)asiftheyweredeclaredstatic.Asa result,unusedfunctionswillbeeliminated,andthealiascheckingalgorithmassumesthatobjectswithstaticstoragecannotbe referencedfromfunctionsoutsidethecurrentmodule.

Onthecommandlinethisoptiononlymakessensewhenyouspecifyallmodulesofanapplicationonthecommandline.

Example cmb−−staticmodule1.cmodule2.cmodule3.c...

Relatedinformation

5−50 ToolOptions−CCompiler

CCompiler:−−stdout(−n)

Menuentry Commandlineonly.

Commandlinesyntax −−stdout −n

Description Withthisoptionyoutellthecompilertosendtheoutputtostdout(usuallyyourscreen).Nofilesarecreated.Thisoptionisfor exampleusefultoquicklyinspecttheoutputortoredirecttheoutputtoothertools.

Relatedinformation

5−51 MicroBlazeEmbeddedToolsReference

CCompiler:−−tradeoff(−t)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectOptimization. 3. IntheSize/speedtrade−offfield,selectalevelbetweenfullyoptimizeforsizeorfullyoptimizeforspeed.

Commandlinesyntax −−tradeoff={0|1|2|3|4} −t{0|1|2|3|4}

Description Ifthecompilerusescertainoptimizations(option−−optimize),youcanusethisoptiontospecifywhethertheusedoptimizations shouldoptimizeformorespeed(regardlessofcodesize)orforsmallercodesize(regardlessofspeed). Bydefaultthecompileroptimizesformorespeed(−−tradeoff=0).

Ifyouhavenotusedtheoption−−optimize,thecompilerusesthedefaultoptimization.Inthiscaseitisstillusefulto specifyatrade−offlevel.

Relatedinformation

Ccompileroption−−optimize(Specifyoptimizationlevel)

5−52 ToolOptions−CCompiler

CCompiler:−−uchar(−u)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectLanguage. 3. EnabletheoptionTreat’char’variablesasunsigned.

Commandlinesyntax −−uchar −u

Description Bydefaultcharisthesameasspecifyingsignedchar.Withthisoptioncharisthesameasunsignedchar.

Relatedinformation

5−53 MicroBlazeEmbeddedToolsReference

CCompiler:−−undefine(−U)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMiscellaneous. 3. Addtheoption−−undefinetotheAdditionalCcompileroptionsfield.

Commandlinesyntax −−undefine=macro_name −Umacro_name

Description Withthisoptionyoucanundefineanearlierdefinedmacroaswith#undef. Thisoptionisforexampleusefultoundefinepredefinedmacros. However,thefollowingpredefinedISOCstandardmacroscannotbeundefined: __FILE__ currentsourcefilename __LINE__ currentsourcelinenumber(inttype) __TIME__ hh:mm:ss __DATE__ mmmddyyyy __STDC__ levelofANSIstandard

Example Toundefinethepredefinedmacro__TASKING__: cmb−−undefine=__TASKING__test.c

Relatedinformation

Ccompileroption−−define(Definepreprocessormacro)

5−54 ToolOptions−CCompiler

CCompiler:−−use−hardware

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheProcessorentryandselectProcessorDefinition. 3. Enableoneormoreoftheoptions: • Barrelshifterpresent • Divideunitpresent • Multiplyunitpresent • Floating−pointunitpresent • MSRSETandMSRCLRinstructionspresent • PCMPBF,PCMPEQandPCMPNEinstructionspresent Commandlinesyntax −−use−hardware=flag,... Youcansetthefollowingflags: +/−barrel−shift (b/B) Barrelshifter +/−divide (d/D) Divideunit +/−fpu (f/F) Floating−pointunit +/−multiply (m/M) Multiplyunit +/−pcmp (p/P) Patterncompareinstructions +/−msr (s/S) msrclrandmsrsetinstructions Default:BDFMPS

Description WiththisoptionyoutellthecompilerwhethertheMicroBlazetargethasahardwarebarrelshifter,divider,floating−point, multiplierand/orhardwaresupportforpatterncompareinstructionsand/orthemsrsetandmsrclrinstructions.Thiswaythe compilercanusetheoptionalbarrelshift,divide,multiply,patterncompareand/ormsrset,msrclrinstructions.Ifyoudisable thegenerationoftheseinstructions,thecompilergeneratesalternativeinstructions.

Relatedinformation

5−55 MicroBlazeEmbeddedToolsReference

CCompiler:−−vector−offset

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectCodeGeneration. 3. EnabletheoptionGeneratecodeforinterruptvector. 4. IntheReset/interruptvectoroffsetfield,enteranoffsetaddressintherange0x0000−0xFFFF.

Commandlinesyntax −−vector−offset=address

Description Withthisoptionyoucanspecifya16−bitoffsetaddressfortheinterruptvectortable.Thedefaultoffsetaddressis0x0000. ThisoptionisforexampleusefultoplacethevectortableinRAM.

Example Type0x4000asthebaseaddressoftheinterruptvectortableintheReset/interruptvectoroffsetfield,orenterthefollowing onthecommandline: cmb−−vector−offset=0x4000test.c

SupposeyourCsourcecontainsthefollowinginterruptfunction: __interrupt(0x0013)voidisr(void)

ThecompileraddstheoffsetaddresstothevectoraddressintheCsourcesotheactualvectoraddressbecomes0x4013.

Relatedinformation

Ccompileroption−−novector(Donotgenerateinterruptvectors) Ccompileroption−−noframe(Donotgenerateframeforinterrupthandler) Section1.9.5,InterruptFunctions,inchapterCLanguage.

5−56 ToolOptions−CCompiler

CCompiler:−−version(−V)

Menuentry Commandlineonly.

Commandlinesyntax −−version −V

Description Displaysversioninformationofthecompiler.Thecompilerignoresallotheroptionsorinputfiles.

Relatedinformation

5−57 MicroBlazeEmbeddedToolsReference

CCompiler:−−warnings−as−errors

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectDiagnostics. 3. IntheTreatwarningsaserrors.field,selectNone,TreatallwarningsaserrorsorTreatspecificwarningsaserrors. IfyouselectTreatspecificwarningsaserrors: 4. Enterthenumbers,separatedbycommasorasarange,ofthewarningsyouwanttotreataserrors.

Commandlinesyntax

−−warnings−as−errors[=number[−number],...]

Description Ifthecompilerencountersanerror,itstopscompiling.Whenyouusethisoptionwithoutarguments,youtellthecompilertotreat allwarningsaserrors.Thismeansthattheexitstatusofthecompilerwillbenon−zeroafteroneormorecompilerwarnings.As aconsequence,thecompilernowalsostopsafterencounteringawarning. Youcanalsolimitthisoptiontospecificwarningsbyspecifyingacomma−separatedlistofwarningnumbersorranges.

Relatedinformation

Ccompileroption−−no−warnings(Suppresssomeorallwarnings)

5−58 ToolOptions−C++Compiler

5.2 C++CompilerOptions

AltiumDesignerusesamakefiletobuildyourentireproject.ThismeansthatinAltiumDesigneryoucannotruntheC++ compilerseparately.IfyoucompileasingleC++sourcefilefromwithinAltiumDesigner,thefileisalsocompiledandassembled. However,youcansetoptionsspecificfortheC++compiler.

OptionsinAltiumDesignerversusoptionsonthecommandline MostcommandlineoptionshaveanequivalentoptioninAltiumDesignerbutsomeoptionsareonlyavailableonthecommand line(forexampleinaWindowsCommandPrompt).IfthereisnoequivalentoptioninAltiumDesigner,youcanspecifya commandlineoptioninAltiumDesignerasfollows: 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. EnteroneormorecommandlineoptionsintheAdditionalC++compileroptionsfield.

Invocationsyntaxonthecommandline(WindowsCommandPrompt) TocalltheC++compilerfromthecommandline,usethefollowingsyntax: cpmb[[option]...[file]...]...

TheinputfilemustbeaC++sourcefile(.cc,.cxxor.cpp).

Shortandlongoptionnames Optionscanhavebothshortandlongnames.Shortoptionnamesalwaysbeginwithasingleminus(−)character,longoption namesalwaysbeginwithdoubleminus(−−)characters.Youcanabbreviatelongoptionnamesaslongasthenameisunique. Youcanmixshortandlongoptionnamesonthecommandline. Ifalongoptionrequiresanargument,theargumentmaybeseparatedfromthekeywordbywhitespace,orthekeywordmaybe immediatelyfollowedby=option.Whenthesecondformisusedtheremaynotbeanywhitespaceoneithersideoftheequal sign. Optionscanhaveflagsorsub−options.Toswitchaflag’on’,usealowercaseletterora+longflag.Toswitchaflagoff,usean uppercaseletterora−longflag.Separatelongflagswithcommas.Thefollowingtwoinvocationsareequivalent: cpmb−Ecptest.cc cpmb−−preprocess=+comments,+nolinetest.cc

Whenyoudonotspecifyanoption,adefaultvaluemaybecomeactive. Thepriorityoftheoptionsisleft−to−right:whentwooptionsconflict,thefirst(mostleft)onetakeseffect.Theoptions−−define and−−undefinearenotconsideredconflictingoptions,sotheyareprocessedleft−to−rightforeachsourcefile.Youcanoverrule thedefaultoutputfilenamewiththeoption−−output−file.

5−59 MicroBlazeEmbeddedToolsReference

C++Compiler:−−alternative−tokens

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−alternative−tokenstotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−alternative−tokens

Description Enablerecognitionofalternativetokens.ThiscontrolsrecognitionofthedigraphtokensinC++,andcontrolsrecognitionofthe operatorkeywords(e.g.,not,and,bitand,etc).

Example Toenableoperatorkeywords(e.g.,"not","and")anddigraphs,enter: cpmb−−alternative−tokenstest.cc

Relatedinformation

5−60 ToolOptions−C++Compiler

C++Compiler:−−anachronisms

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectC++Language. 3. EnabletheoptionAnachronisms.

Commandlinesyntax −−anachronisms

Description EnableC++anachronisms.Thisoptionalsoenables−−nonconst−ref−anachronism.Butyoucanturnthisoffindividuallywith option−−no−nonconst−ref−anachronism.

Relatedinformation

C++compileroption−−nonconst−ref−anachronism(Nonconstreferenceanachronism) Section2.3.3,AnachronismsAcceptedinchapterC++Language.

5−61 MicroBlazeEmbeddedToolsReference

C++Compiler:−−base−assign−op−is−default

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−base−assign−op−is−defaulttotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−base−assign−op−is−default

Description Enabletheanachronismofacceptingacopyassignmentoperatorthathasaninputparameterthatisareferencetoabase classasadefaultcopyassignmentoperatorforthederivedclass.

Relatedinformation

5−62 ToolOptions−C++Compiler

C++Compiler:−−building−runtime

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−building−runtimetotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−building−runtime

Description SpecialoptionforbuildingtheC++run−timelibrary.UsedtoindicatethattheC++run−timelibraryisbeingcompiled.This causesadditionalmacrostobepredefinedthatareusedtopassconfigurationinformationfromtheC++compilertothe run−time.

Relatedinformation

5−63 MicroBlazeEmbeddedToolsReference

C++Compiler:−−c++0x

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−c++0xtotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−c++0x

Description EnabletheC++extensionsthataredefinedbythelatestC++workingpaper.

Relatedinformation

5−64 ToolOptions−C++Compiler

C++Compiler:−−check

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−checktotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−check

Description Withthisoptionyoucancheckthesourcecodeforsyntaxerrors,withoutgeneratingcode.Thissavestimeindevelopingyour applicationbecausethecodewillnotactuallybecompiled. TheC++compilerreportsanywarningsand/orerrors.

Relatedinformation

Ccompileroption−−check(Checksyntax) Assembleroption−−check(Checksyntax)

5−65 MicroBlazeEmbeddedToolsReference

C++Compiler:−−context−limit

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−context−limittotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−context−limit=number(Default:10)

Description Setthecontextlimittonumber.Thecontextlimitisthemaximumnumberoftemplateinstantiationcontextentriestobe displayedaspartofadiagnosticmessage.Ifthenumberofcontextentriesexceedsthelimit,thefirstandlastNcontextentries aredisplayed,whereNishalfofthecontextlimit.Avalueofzeroisusedtoindicatethatthereisnolimit.

Example Tosetthecontextlimitto5,enter: cpmb−−context−limit=5test.cc

Relatedinformation

5−66 ToolOptions−C++Compiler

C++Compiler:−−create−pch

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectPrecompiledHeaders. 3. EnterafilenameintheCreateprecompiledheaderfilefield.

Commandlinesyntax −−create−pch=filename

Description Ifotherconditionsaresatisfied,createaprecompiledheaderfilewiththespecifiedname.If−−pch(automaticPCHmode)or −−use−pchappearsonthecommandlinefollowingthisoption,itseffectiserased.

Example Tocreateaprecompiledheaderfilewiththenametest.pch,enter cpmb−−create−pch=test.pchtest.cc

Relatedinformation

C++compileroption−−pch(AutomaticPCHmode) C++compileroption−−use−pch(Useprecompiledheaderfile) Section2.11,PrecompiledHeadersinchapterC++Language.

5−67 MicroBlazeEmbeddedToolsReference

C++Compiler:−−define(−D)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectPreprocessing. 3. SelectUsermacroandclickonthedownarrowintherightpanetoexpandmacroinput. 4. ClickonanemptyMacrofieldandenteramacroname.(Thenclickanemptycelltoconfirm) 5. Optionally,clickintheValuefieldandenteradefinition.(Thenclickanemptycelltoconfirm)

Commandlinesyntax

−−define=macro_name[(parm_list)][=macro_definition] −Dmacro_name[(parm_list)][=macro_definition]

Description Withthisoptionyoucandefineamacroandspecifyittothepreprocessor,asin#define.Ifyouonlyspecifyamacroname(no macrodefinition),themacroexpandsas’1’.Youcanspecifyasmanymacrosasyoulike. Function−stylemacroscanbedefinedbyappendingamacroparameterlisttomacro_name. Onthecommandline,youcanusetheoption−−define(−D)multipletimes.Ifthecommandlineexceedsthelengthlimitofthe operatingsystem,youcandefinethemacrosinanoptionfilewhichyouthenmustspecifytotheC++compilerwiththeoption −−option−file=file(−f). Definingmacroswiththisoption(insteadofintheCsource)is,forexample,usefultocompileconditionalCsourceasshownin theexamplebelow. Thedefinitioncanbetestedbythepreprocessorwith#if,#ifdefand#ifndef,forconditionalcompilations.

Example Considerthefollowingprogramwithconditionalcodetocompileademoprogramandarealprogram: voidmain(void) { #ifDEMO==1 demo_func();/*compileforthedemoprogram*/ #else real_func();/*compilefortherealprogram*/ #endif }

YoucannowuseamacrodefinitiontosettheDEMOflag: cpmb−−define=DEMOtest.cc cpmb−−define=DEMO=1test.cc

Notethatbothinvocationshavethesameeffect. Thenextexampleshowshowtodefineamacrowitharguments.Notethatthemacronameanddefinitionareplacedbetween doublequotesbecauseotherwisethespaceswouldindicateanewoption. cpmb−−define="MAX(A,B)=((A)>(B)?(A):(B))"test.cc

Relatedinformation

C++compileroption−−undefine(Removepreprocessormacro) C++compileroption−−option−file(Specifyanoptionfile)

5−68 ToolOptions−C++Compiler

C++Compiler:−−dep−file

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−dep−filetotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−dep−file[=file]

Description WiththisoptionyoutelltheC++compilertogeneratedependencylinesthatcanbeusedinaMakefile.Incontrasttotheoption −−preprocess=+make(−Em),thedependencyinformationwillbegeneratedinadditiontothenormaloutputfile. Bydefault,theinformationiswrittentoafilewithextension.d(oneforeveryinputfile).Whenyouspecifyafilename,all dependencieswillbecombinedinthespecifiedfile.

Example cpmb−−dep−file=test.deptest.cc

TheC++compilercompilesthefiletest.cc,whichresultsintheoutputfiletest.ic,andgeneratesdependencylinesinthe filetest.dep.

Relatedinformation

C++compileroption−−preprocess=+make(Generatedependenciesformake)

5−69 MicroBlazeEmbeddedToolsReference

C++Compiler:−−dollar

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−dollartotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−dollar Defaultformat:Nodollarsignsareallowedinidentifiers.

Description Acceptdollarsignsinidentifiers.NameslikeA$VARareallowed.

Relatedinformation

5−70 ToolOptions−C++Compiler

C++Compiler:−−embedded−c++

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectC++Language. 3. EnabletheoptionComplytoembeddedC++subset.

Commandlinesyntax −−embedded−c++

Description The"EmbeddedC++"subsetdoesnotsupporttemplates,exceptions,namespaces,new−stylecasts,RTTI,multipleinheritance, virtualbaseclasses,andthemutablekeyword.SelectthisoptionwhenyouwanttheC++compilertogiveanerrorwhenyou useanyoftheminyourC++source.

Relatedinformation

5−71 MicroBlazeEmbeddedToolsReference

C++Compiler:−−error−file

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−error−filetotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−error−file[=file]

Description WiththisoptiontheC++compilerredirectserrormessagestoafile.Ifyoudonotspecifyafilename,theerrorfilewillbenamed aftertheinputfilewithextension.ecp.

Example Towriteerrorstoerrors.ecpinsteadofstderr,enter: cpmb−−error−file=errors.ecptest.cc

Relatedinformation

5−72 ToolOptions−C++Compiler

C++Compiler:−−error−limit(−e)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−error−limittotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−error−limit=number(Default:100) −enumber

Description Settheerrorlimittonumber.TheC++compilerwillabandoncompilationafterthisnumberoferrors(remarksandwarningsare notcounted).Bydefault,thelimitis100.

Example Whenyouwantcompilationtostopwhen10errorsoccurred,enter: cpmb−−error−limit=10test.cc

Relatedinformation

5−73 MicroBlazeEmbeddedToolsReference

C++Compiler:−−exceptions(−x)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectC++Language. 3. EnabletheoptionSupportforexceptionhandling.

Commandlinesyntax −−exceptions −x

Description WiththisoptionyouenablesupportforexceptionhandlingintheC++compiler. Themacro__EXCEPTIONSisdefinedwhenexceptionhandlingsupportisenabled.

Relatedinformation

5−74 ToolOptions−C++Compiler

C++Compiler:−−exported−template−file

Menuentry −

Commandlinesyntax

−−exported−template−file=file

Description Thisoptionspecifiesthenametobeusedfortheexportedtemplatefileusedforprocessingofexportedtemplates. ThisoptionissuppliedforusebythecontrolprogramthatinvokestheC++compilerandisnotintendedtobeusedby end−users.

Relatedinformation

5−75 MicroBlazeEmbeddedToolsReference

C++Compiler:−−extended−variadic−macros

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−extended−variadic−macrostotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−extended−variadic−macros Default:macroswithavariablenumberofargumentsarenotallowed.

Description Allowmacroswithavariablenumberofarguments(implies−−variadic−macros)andallowthenamingofthevariableargument list.

Relatedinformation

C++compileroption−−variadic−macros(Allowvariadicmacros)

5−76 ToolOptions−C++Compiler

C++Compiler:−−force−vtbl

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. IntheVirtualfunctiontablesfield,selectForcedefinitionofvirtualfunctiontables.

Commandlinesyntax −−force−vtbl

Description ForcedefinitionofvirtualfunctiontablesincaseswheretheheuristicusedbytheC++compilertodecideondefinitionofvirtual functiontablesprovidesnoguidance.

Relatedinformation

C++compileroption−−suppress−vtbl(Suppressdefinitionofvirtualfunctiontables)

5−77 MicroBlazeEmbeddedToolsReference

C++Compiler:−−friend−injection

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−friend−injectiontotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−friend−injection Default:friendnamesarenotinjected.

Description Controlswhetherthenameofaclassorfunctionthatisdeclaredonlyinfrienddeclarationsisvisiblewhenusingthenormal lookupmechanisms.Whenfriendnamesareinjected,theyarevisibletosuchlookups.Whenfriendnamesarenotinjected (asrequiredbythestandard),functionnamesarevisibleonlywhenusingargument−dependentlookup,andclassnamesare nevervisible.

Relatedinformation

C++compileroption−−no−arg−dep−lookup(Disableargumentdependentlookup)

5−78 ToolOptions−C++Compiler

C++Compiler:−−g++

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectC++Language. 3. EnabletheoptionAllowGNUC++extensions.

Commandlinesyntax −−g++

Description EnableGNUC++compilerlanguageextensions.

Relatedinformation

Section2.4,GNUExtensionsinchapterC++Language.

5−79 MicroBlazeEmbeddedToolsReference

C++Compiler:−−gnu−version

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−gnu−versiontotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−gnu−version=version Default:30300(version3.3.0)

Description ItdependsontheGNUC++compilerversionifaparticularGNUextensionissupportedornot.WiththisoptionyousettheGNU C++compilerversionthatshouldbeemulatedinGNUC++mode.Versionx.y.zoftheGNUC++compilerisrepresentedbythe valuex*10000+y*100+z.

Example Tospecifyversion3.4.1oftheGNUC++compiler,enter: cpmb−−g++−−gnu−version=30401test.cc

Relatedinformation

Section2.4,GNUExtensionsinchapterC++Language.

5−80 ToolOptions−C++Compiler

C++Compiler:−−guiding−decls

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−guiding−declstotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−guiding−decls

Description Enablerecognitionof"guidingdeclarations"oftemplatefunctions.Aguidingdeclarationisafunctiondeclarationthatmatches aninstanceofafunctiontemplatebuthasnoexplicitdefinition(sinceitsdefinitionderivesfromthefunctiontemplate).For example: templatevoidf(T){...} voidf(int);

Whenregardedasaguidingdeclaration,f(int)isaninstanceofthetemplate;otherwise,itisanindependentfunctionfor whichadefinitionmustbesupplied.

Relatedinformation

C++compileroption−−old−specializations(Old−styletemplatespecializations)

5−81 MicroBlazeEmbeddedToolsReference

C++Compiler:−−help(−?)

Menuentry Commandlineonly.

Commandlinesyntax

−−help[=item,...] −? Youcanspecifythefollowingarguments: options Showextendedoptiondescriptions

Description Displaysanoverviewofallcommandlineoptions.Withanargumentyoucanspecifywhichextendedinformationisshown.

Example Thefollowinginvocationsalldisplayalistoftheavailablecommandlineoptions: cpmb−? cpmb−−help cpmb

Thefollowinginvocationdisplaysanextendedlistoftheavailableoptions: cpmb−−help=options

Relatedinformation

5−82 ToolOptions−C++Compiler

C++Compiler:−−implicit−extern−c−type−conversion

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−implicit−extern−c−type−conversiontotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−implicit−extern−c−type−conversion

Description Enabletheimplicittypeconversionbetweenpointerstoextern"C"andextern"C++"functiontypes.

Relatedinformation

5−83 MicroBlazeEmbeddedToolsReference

C++Compiler:−−implicit−include

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. EnabletheoptionImplicitinclusionofsourcefilesforfindingtemplates.

Commandlinesyntax −−implicit−include

Description Enableimplicitinclusionofsourcefilesasamethodoffindingdefinitionsoftemplateentitiestobeinstantiated.

Relatedinformation

C++compileroption−−instantiate(Instantiationmode) Section2.6.4,ImplicitInclusioninchapterC++Language.

5−84 ToolOptions−C++Compiler

C++Compiler:−−incl−suffixes

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−incl−suffixestotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−incl−suffixes=suffixes Default:noextensionand.stdh.

Description Specifiesthelistofsuffixestobeusedwhensearchingforanincludefilewhosenamewasspecifiedwithoutasuffix.Ifanull suffixistobeallowed,itmustbeincludedinthesuffixlist.suffixesisacolon−separatedlistofsuffixes(e.g.,"::stdh").

Example Toallowonlythesuffixes.hand.stdhasincludefileextensions,enter: cpmb−−incl−suffixes=h:stdhtest.cc

Relatedinformation

C++compileroption−−include−file(Includefileatthestartofacompilation) Section3.3,HowtheC++CompilerSearchesIncludeFilesinchapterUsingtheC++Compileroftheuser’smanual.

5−85 MicroBlazeEmbeddedToolsReference

C++Compiler:−−include−directory(−I)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. SelectBuildOptions. 3. AddapathnameintheIncludefilespathfield. Ifyouentermultiplepaths,separatethemwithasemicolon(;).

Commandlinesyntax −−include−directory=path,... −Ipath,...

Description Addpathtothelistofdirectoriessearchedfor#includefileswhosenamesdonothaveanabsolutepathname.Youcan specifymultipledirectoriesseparatedbycommas.

Example Toaddthedirectory/proj/includetotheincludefilesearchpath,enter: cpmb−−include−directory=/proj/includetest.cc

Relatedinformation

C++compileroption−−include−file(Includefileatthestartofacompilation) C++compileroption−−sys−include(Adddirectorytosystemincludefilesearchpath) Section3.3,HowtheC++CompilerSearchesIncludeFilesinchapterUsingtheC++Compileroftheuser’smanual.

5−86 ToolOptions−C++Compiler

C++Compiler:−−include−file(−H)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectPreprocessing. 3. EnterthenameofthefileintheIncludethisfilebeforesourcefieldorclick...andselectafile.

Commandlinesyntax −−include−file=file,... −Hfile,...

Description Withthisoption(setatprojectlevel)youincludeoneextrafileatthebeginningofeachC++sourcefileinyourproject.Ona documentlevel(Project»DocumentOptions),youcanoverrulethisoptionwithanotherfileornofileatall. Thespecifiedincludefileisincludedatthebeginningofthecompilation.Thisisthesameasspecifying#include"file"at theverybeginningof(eachof)yourC++sourcefiles. Allfilesincludedwith−−include−fileareprocessedafteranyofthefilesincludedwith−−include−macros−file. Thefilenameissearchedforinthedirectoriesontheincludesearchlist.

Example cpmb−−include−file=extra.htest1.cctest2.cc

Thefileextra.hisincludedatthebeginningofbothtest1.ccandtest2.cc.

Relatedinformation

C++compileroption−−include−directory(Adddirectorytoincludefilesearchpath) Section3.3,HowtheC++CompilerSearchesIncludeFilesinchapterUsingtheC++Compileroftheuser’smanual.

5−87 MicroBlazeEmbeddedToolsReference

C++Compiler:−−include−macros−file

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−include−macros−filetotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−include−macros−file=file

Description Includethemacrosoftheindicatedfileatthebeginningofthecompilation.Onlythepreprocessingdirectivesfromthefileare evaluated.Alloftheactualcodeisdiscarded.Theeffectofthisoptionisthatanymacrodefinitionsfromthespecifiedfilewillbe ineffectwhentheprimarysourcefileiscompiled.Allofthemacro−onlyfilesareprocessedbeforeanyofthenormalincludes (−−include−file).Withineachgroup,thefilesareprocessedintheorderinwhichtheywerespecified.

Relatedinformation

C++compileroption−−include−file(Includefileatthestartofacompilation) Section3.3,HowtheC++CompilerSearchesIncludeFilesinchapterUsingtheC++Compileroftheuser’smanual.

5−88 ToolOptions−C++Compiler

C++Compiler:−−init−priority

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−init−prioritytotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−init−priority=number(Default:0)

Description Normally,theC++compilerassignsnoprioritytotheglobalinitializationfunctionsandtheexactorderisdeterminedbythe linker.Thisoptionsetsthedefaultpriorityforglobalinitializationfunctions.Defaultvalueis"0".Youcanalsosetthedefault prioritywiththe#pragmainit_priority. Valuesfrom1to100areforinternaluseonlyandshouldnotbeused.Values101to65535areavailableforusercode.Alower numbermeansahigherpriority.

Example cpmb−−init−priority=101test.cc

Relatedinformation

5−89 MicroBlazeEmbeddedToolsReference

C++Compiler:−−instantiate

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. SelectaninstantiationmodeintheInstantiationmodeofexternaltemplateentitiesbox

Commandlinesyntax −−instantiate=mode −tmode Youcanspecifythefollowingmodes: used(default) all local

Description Controlinstantiationofexternaltemplateentities.Externaltemplateentitiesareexternal(thatis,non−inlineandnon−static) templatefunctionsandtemplatestaticdatamembers.Theinstantiationmodedeterminesthetemplateentitiesforwhichcode shouldbegeneratedbasedonthetemplatedefinition.Normally,whenafileiscompiled,templateentitiesareinstantiated wherevertheyareused(thelinkerwilldiscardduplicatedefinitions).Theoverallinstantiationmodecan,however,bechanged withthisoption.Youcanspecifythefollowingmodes: used Instantiatethosetemplateentitiesthatwereusedinthecompilation.Thiswillincludeallstaticdatamembersfor whichtherearetemplatedefinitions.Thisisthedefault. all Instantiatealltemplateentitiesdeclaredorreferencedinthecompilationunit.Foreachfullyinstantiatedtemplate class,allofitsmemberfunctionsandstaticdatamemberswillbeinstantiatedwhetherornottheywereused. Non−membertemplatefunctionswillbeinstantiatedeveniftheonlyreferencewasadeclaration. local Similarto−−instantiate=usedexceptthatthefunctionsaregiveninternallinkage.Thisisintendedtoprovidea verysimplemechanismforthosegettingstartedwithtemplates.Thecompilerwillinstantiatethefunctionsthatare usedineachcompilationunitaslocalfunctions,andtheprogramwilllinkandruncorrectly(barringproblemsdue tomultiplecopiesoflocalstaticvariables).However,onemayendupwithmanycopiesoftheinstantiated functions,sothisisnotsuitableforproductionuse. Youcannotuse−−instantiate=localinconjunctionwithautomatictemplateinstantiation.

Relatedinformation

C++compileroption−−no−auto−instantiation(DisableautomaticC++instantiation) Section2.6,TemplateInstantiationinchapterC++Language.

5−90 ToolOptions−C++Compiler

C++Compiler:−−io−streams

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectC++Language. 3. EnabletheoptionSupportforI/Ostreams.

Commandlinesyntax −−io−streams

Description AsI/Ostreamsrequiresubstantialresourcestheyaredisabledbydefault.UsethisoptiontoenableI/Ostreamssupportinthe C++library. Thisoptionalsoenablesexceptionhandling.

Relatedinformation

5−91 MicroBlazeEmbeddedToolsReference

C++Compiler:−−late−tiebreaker

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−late−tiebreakertotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−late−tiebreaker Default:earlytiebreakerprocessing.

Description Selectthewaythattie−breakers(e.g.,cv−qualifierdifferences)applyinoverloadresolution.In"early"tie−breakerprocessing, thetie−breakersareconsideredatthesametimeasothermeasuresofthegoodnessofthematchofanargumentvalueandthe correspondingparametertype(thisisthestandardapproach). In"late"tie−breakerprocessing,tie−breakersareignoredduringtheinitialcomparison,andconsideredonlyiftwofunctionsare otherwiseequallygoodonallarguments;thetie−breakerscanthenbeusedtochooseonefunctionoveranother.

Relatedinformation

5−92 ToolOptions−C++Compiler

C++Compiler:−−list−file(−L)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−list−filetotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−list−file=file −Lfile Default:−1

Description Generaterawlistinginformationinthefile.Thisinformationislikelytobeusedtogenerateaformattedlisting.Therawlistingfile containsrawsourcelines,informationontransitionsintoandoutofincludefiles,anddiagnosticsgeneratedbytheC++ compiler. Eachlineofthelistingfilebeginswithakeycharacterthatidentifiesthetypeofline,asfollows: N: Anormallineofsource;therestofthelineisthetextoftheline. X: Theexpandedformofanormallineofsource;therestofthelineisthetextoftheline.ThislineappearsfollowingtheNline, andonlyifthelinecontainsnon−trivialmodifications(commentsareconsideredtrivialmodifications;macroexpansions,line splices,andtrigraphsareconsiderednon−trivialmodifications).Commentsarereplacedbyasinglespaceinthe expanded−formline. S: Alineofsourceskippedbyan#iforthelike;therestofthelineistext.Notethatthe#else,#elif,or#endifthatendsa skipismarkedwithanN. L: Anindicationofachangeinsourceposition.Thelinehasaformatsimilartothe#line−identifyingdirectiveoutputbythe,thatistosay Lline_number"file−name"key wherekeyis, 1 forentryintoanincludefile; 2 forexitfromanincludefile; andomittedotherwise. ThefirstlineintherawlistingfileisalwaysanLlineidentifyingtheprimaryinputfile.Llinesarealsooutputfor#line directives(keyisomitted).Llinesindicatethesourcepositionofthefollowingsourcelineintherawlistingfile. R,W,E,orC:anindicationofadiagnostic(Rforremark,Wforwarning,Eforerror,andCforcatastrophicerror).Thelinehas theform S"file−name"line_numbercolumn−numbermessage−text whereSisR,W,E,orC,asexplainedabove.Errorsattheendoffileindicatethelastlineoftheprimarysourcefileanda columnnumberofzero.Commandlineerrorsarecatastropheswithanemptyfilename("")andalineandcolumnnumberof zero.Internalerrorsarecatastropheswithpositioninformationasusual,andmessage−textbeginningwith(internalerror). Whenadiagnosticdisplaysalist(e.g.,allthecontendingroutineswhenthereisambiguityonanoverloadedcall),theinitial diagnosticlineisfollowedbyoneormorelineswiththesameoverallformat(codeletter,filename,linenumber,column number,andmessagetext),butinwhichthecodeletteristhelowercaseversionofthecodeletterintheinitialline.The sourcepositioninsuchlinesisthesameasthatinthecorrespondinginitialline.

5−93 MicroBlazeEmbeddedToolsReference

Example Towriterawlistinginformationtothefiletest.lst,enter: cpmb−−list−file=test.lsttest.cc

Relatedinformation

5−94 ToolOptions−C++Compiler

C++Compiler:−−long−lifetime−temps

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−long−lifetime−tempstotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−long−lifetime−temps

Description Selectthelifetimefortemporaries:shortmeanstoendoffullexpression;longmeanstotheearliestofendofscope,endof switchclause,orthenextlabel.Shortisthedefault.

Relatedinformation

5−95 MicroBlazeEmbeddedToolsReference

C++Compiler:−−long−long

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−long−longtotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−long−long

Description Permittheuseoflonglonginstrictmodeindialectsinwhichitisnon−standard.

Relatedinformation

5−96 ToolOptions−C++Compiler

C++Compiler:−−make−target

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMiscellaneous. 3. Addtheoption−−make−targettotheAdditionalCcompileroptionsfield.

Commandlinesyntax −−make−target=name

Description Withthisoptionyoucanoverrulethedefaulttargetnameinthemakedependenciesgeneratedbytheoptions −−preprocess=+make(−Em)and−−dep−file.Thedefaulttargetnameisthebasenameoftheinputfile,withextension.obj.

Relatedinformation

C++compileroption−−preprocess=+make(Generatedependenciesformake) C++compileroption−−dep−file(Generatedependenciesinafile)

5−97 MicroBlazeEmbeddedToolsReference

C++Compiler:−−multibyte−chars

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−multibyte−charstotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−multibyte−chars Default:multibytecharactersequencesarenotallowed.

Description Enableprocessingformultibytecharactersequencesincomments,stringliterals,andcharacterconstants.Multibyteencodings areusedforcharactersetsliketheJapaneseSJIS.

Relatedinformation

5−98 ToolOptions−C++Compiler

C++Compiler:−−namespaces

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−namespacestotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−namespaces −−no−namespaces Default:namespacesaresupported.

Description Withoption−−no−namespacesyoudisablesupportfornamespaces. Whenyouusedoption−−embedded−c++,namespacesaredisabled.Withoption−−namespacesyoucanenablesupportfor namespacesinthiscase. Themacro__NAMESPACESisdefinedwhennamespacesupportisenabled.

Relatedinformation

C++compileroption−−embedded−c++(EmbeddedC++compliancytests) C++compileroption−−using−std(Implicituseofthestdnamespace) Section2.5,NamespaceSupportinchapterC++Language.

5−99 MicroBlazeEmbeddedToolsReference

C++Compiler:−−no−arg−dep−lookup

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−arg−dep−lookuptotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−arg−dep−lookup Default:argumentdependentlookupofunqualifiedfunctionnamesisperformed.

Description Withthisoptionyoudisableargumentdependentlookupofunqualifiedfunctionnames.

Relatedinformation

5−100 ToolOptions−C++Compiler

C++Compiler:−−no−array−new−and−delete

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−array−new−and−deletetotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−array−new−and−delete Default:arraynewanddeletearesupported.

Description Disablesupportforarraynewanddelete. Themacro__ARRAY_OPERATORSisdefinedwhenarraynewanddeleteisenabled.

Relatedinformation

5−101 MicroBlazeEmbeddedToolsReference

C++Compiler:−−no−auto−instantiation

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−auto−instantiationtotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−auto−instantiation Default:theC++compilerautomaticallyinstantiatestemplates.

Description Withthisoptionautomaticinstantiationoftemplatesisdisabled.

Relatedinformation

C++compileroption−−instantiate(Instantiationmode) Section2.6,TemplateInstantiationinchapterC++Language.

5−102 ToolOptions−C++Compiler

C++Compiler:−−no−bool

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−booltotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−bool Default:boolisrecognizedasakeyword.

Description Disablerecognitionoftheboolkeyword. Themacro_BOOLisdefinedwhenboolisrecognizedasakeyword.

Relatedinformation

5−103 MicroBlazeEmbeddedToolsReference

C++Compiler:−−no−class−name−injection

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−class−name−injectiontotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−class−name−injection Default:thenameofaclassisinjectedintothescopeoftheclass(asrequiredbythestandard).

Description Donotinjectthenameofaclassintothescopeoftheclass(aswastrueinearlierversionsoftheC++language).

Relatedinformation

5−104 ToolOptions−C++Compiler

C++Compiler:−−no−const−string−literals

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−const−string−literalstotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−const−string−literals Default:C++stringliteralsandwidestringliteralsareconst(asrequiredbythestandard).

Description WiththisoptionC++stringliteralsandwidestringliteralsarenon−const(aswastrueinearlierversionsoftheC++language).

Relatedinformation

5−105 MicroBlazeEmbeddedToolsReference

C++Compiler:−−no−dep−name

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−dep−nametotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−dep−name Default:dependentnameprocessingisenabled.

Description Disabledependentnameprocessing;i.e.,thespeciallookupofnamesusedintemplatesasrequiredbytheC++standard.This optionimpliestheuseof−−no−parse−templates.

Relatedinformation

C++compileroption−−no−parse−templates(Disableparsingofnonclasstemplates)

5−106 ToolOptions−C++Compiler

C++Compiler:−−no−distinct−template−signatures

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−distinct−template−signaturestotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−distinct−template−signatures

Description Controlwhetherthesignaturesfortemplatefunctionscanmatchthosefornon−templatefunctionswhenthefunctionsappearin differentcompilationunits.Bydefaultanormalfunctioncannotbeusedtosatisfytheneedforatemplateinstance;e.g.,a function"voidf(int)"couldnotbeusedtosatisfytheneedforaninstantiationofatemplate"voidf(T)"withTsettoint. −−no−distinct−template−signaturesprovidestheolderlanguagebehavior,underwhichanon−templatefunctioncanmatcha templatefunction.Alsocontrolswhetherfunctiontemplatesmayhavetemplateparametersthatarenotusedinthefunction signatureofthefunctiontemplate.

Relatedinformation

5−107 MicroBlazeEmbeddedToolsReference

C++Compiler:−−no−double(−F)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−doubletotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−double −F

Description WiththisoptionyoutelltheC++compilertotreatvariablesofthetypedoubleasfloat.Becausethefloattypetakesless space,executionspeedincreasesandcodesizedecreases,bothatthecostoflessprecision.

Example cpmb−−no−doubletest.cc

Thefiletest.cciscompiledwherevariablesofthetypedoublearetreatedasfloat.

Relatedinformation

5−108 ToolOptions−C++Compiler

C++Compiler:−−no−enum−overloading

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−enum−overloadingtotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−enum−overloading

Description Disablesupportforusingoperatorfunctionstooverloadbuilt−inoperationsonenum−typedoperands

Relatedinformation

5−109 MicroBlazeEmbeddedToolsReference

C++Compiler:−−no−explicit

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−explicittotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−explicit Default:theexplicitspecifierisallowed.

Description Disablesupportfortheexplicitspecifieronconstructordeclarations.

Relatedinformation

5−110 ToolOptions−C++Compiler

C++Compiler:−−no−export

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−exporttotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−export Default:exportedtemplates(declaredwiththekeywordexport)areallowed.

Description Disablerecognitionofexportedtemplates.Thisoptionrequiresthatdependentnameprocessingbedone,andcannotbeused withimplicitinclusionoftemplatedefinitions.

Relatedinformation

Section2.6.5,ExportedTemplatesinchapterC++Language.

5−111 MicroBlazeEmbeddedToolsReference

C++Compiler:−−no−extern−inline

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−extern−inlinetotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−extern−inline Default:inlinefunctionsareallowedtohaveexternallinkage.

Description DisablesupportforinlinefunctionswithexternallinkageinC++.Wheninlinefunctionsareallowedtohaveexternallinkage (asrequiredbythestandard),thenexternandinlinearecompatiblespecifiersonanon−memberfunctiondeclaration;the defaultlinkagewheninlineappearsaloneisexternal(thatis,inlinemeansexterninlineonnon−memberfunctions); andaninlinememberfunctiontakesonthelinkageofitsclass(whichisusuallyexternal).However,wheninlinefunctions haveonlyinternallinkage(using−−no−extern−inline),thenexternandinlineareincompatible;thedefaultlinkagewhen inlineappearsaloneisinternal(thatis,inlinemeansstaticinlineonnon−memberfunctions);andinlinemember functionshaveinternallinkagenomatterwhatthelinkageoftheirclass.

Relatedinformation

Section2.8,ExternInlineFunctionsinchapterC++Language.

5−112 ToolOptions−C++Compiler

C++Compiler:−−no−for−init−diff−warning

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−for−init−diff−warningtotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−for−init−diff−warning

Description Disableawarningthatisissuedwhenprogramscompiledwithoutthe−−old−for−initoptionwouldhavehaddifferentbehavior undertheoldrules.

Relatedinformation

C++compileroption−−old−for−init(Useoldforscopingrules)

5−113 MicroBlazeEmbeddedToolsReference

C++Compiler:−−no−implicit−typename

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−implicit−typenametotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−implicit−typename Default:implicittypenamedeterminationisenabled.

Description Disableimplicitdetermination,fromcontext,whetheratemplateparameterdependentnameisatypeornontype.

Relatedinformation

C++compileroption−−no−typename(Disablethetypenamekeyword)

5−114 ToolOptions−C++Compiler

C++Compiler:−−no−inlining

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. DisabletheoptionMinimalinliningoffunctioncalls.

Commandlinesyntax −−no−inlining

Description Disableminimalinliningoffunctioncalls.

Relatedinformation

5−115 MicroBlazeEmbeddedToolsReference

C++Compiler:−−nonconst−ref−anachronism

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−nonconst−ref−anachronismtotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−nonconst−ref−anachronism −−no−nonconst−ref−anachronism(default)

Description Enableordisabletheanachronismofallowingareferencetononconsttobindtoaclassrvalueoftherighttype.This anachronismisalsoenabledbytheoption−−anachronisms.

Relatedinformation

C++compileroption−−anachronisms(EnableC++anachronisms) Section2.3.3,AnachronismsAcceptedinchapterC++Language.

5−116 ToolOptions−C++Compiler

C++Compiler:−−nonstd−qualifier−deduction

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−nonstd−qualifier−deductiontotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−nonstd−qualifier−deduction

Description Controlswhethernon−standardtemplateargumentdeductionshouldbeperformedinthequalifierportionofaqualifiedname. Withthisfeatureenabled,atemplateargumentforthetemplateparameterTcanbededucedincontextslikeA::BorT::B. Thestandarddeductionmechanismtreatstheseasnon−deducedcontextsthatusethevaluesoftemplateparametersthatwere eitherexplicitlyspecifiedordeducedelsewhere.

Relatedinformation

5−117 MicroBlazeEmbeddedToolsReference

C++Compiler:−−nonstd−using−decl

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−nonstd−using−decltotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−nonstd−using−decl Default:non−standardusingdeclarationsarenotallowed

Description Allowanon−memberusingdeclarationthatspecifiesanunqualifiedname.

Relatedinformation

5−118 ToolOptions−C++Compiler

C++Compiler:−−no−parse−templates

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−parse−templatestotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−parse−templates Default:parsingofnonclasstemplatesisenabled.

Description Disabletheparsingofnonclasstemplatesintheirgenericform(i.e.,eveniftheyarenotreallyinstantiated).Itisdonebydefault ifdependentnameprocessingisenabled.

Relatedinformation

C++compileroption−−no−dep−name(Disabledependentnameprocessing)

5−119 MicroBlazeEmbeddedToolsReference

C++Compiler:−−no−pch−messages

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−pch−messagestotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−pch−messages Default:amessageisdisplayedindicatingthataprecompiledheaderfilewascreatedorusedinthecurrentcompilation.For example, "test.cc":creatingprecompiledheaderfile"test.pch"

Description Disablethedisplayofamessageindicatingthataprecompiledheaderfilewascreatedorusedinthecurrentcompilation.

Relatedinformation

C++compileroption−−pch(AutomaticPCHmode) C++compileroption−−use−pch(Useprecompiledheaderfile) C++compileroption−−create−pch(Createprecompiledheaderfile) Section2.11,PrecompiledHeadersinchapterC++Language.

5−120 ToolOptions−C++Compiler

C++Compiler:−−no−preprocessing−only

Menuentry AltiumDesigneralwaysdoesafullcompilation.

Commandlinesyntax −−no−preprocessing−only

Description YoucanusethisoptioninconjunctionwiththeoptionsthatnormallycausetheC++compilertodopreprocessingonly(e.g., −−preprocess,etc.)tospecifythatafullcompilationshouldbedone(notjustpreprocessing).Whenusedwiththeimplicit inclusionoption,thismakesitpossibletogenerateapreprocessedoutputfilethatincludesanyimplicitlyincludedfiles.

Example cpmb−−preprocess−−implicit−include−−no−preprocessing−onlytest.cc

Relatedinformation

C++compileroption−−preprocess(Preprocessingonly) C++compileroption−−implicit−include(Implicitsourcefileinclusion)

5−121 MicroBlazeEmbeddedToolsReference

C++Compiler:−−no−stdinc/−−no−stdstlinc

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−stdincor−−no−stdstlinctotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−stdinc −−no−stdstlinc

Description Withoption−−no−stdincyoutelltheC++compilernottolookinthedefaultincludedirectoryrelativetotheinstallation directory,whensearchingforstandardincludefiles. Withoption−−no−stdstlincyoutelltheC++compilernottolookinthedefaultinclude.stldirectoryrelativetothe installationdirectory,whensearchingforstandardSTLincludefiles. ThiswaytheC++compileronlysearchesintheincludefilesearchpathsyouspecified.

Relatedinformation

Section3.3,HowtheC++CompilerSearchesIncludeFilesinchapterUsingtheC++Compileroftheuser’smanual.

5−122 ToolOptions−C++Compiler

C++Compiler:−−no−typename

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−no−typenametotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−no−typename Default:typenameisrecognizedasakeyword.

Description Disablerecognitionofthetypenamekeyword.

Relatedinformation

C++compileroption−−no−implicit−typename(Disableimplicittypenamedetermination)

5−123 MicroBlazeEmbeddedToolsReference

C++Compiler:−−no−use−before−set−warnings(−j)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectDiagnostics. 3. EnabletheoptionSuppressC++compiler"usedbeforeset"warnings.

Commandlinesyntax −−no−use−before−set−warnings −j

Description Suppresswarningsonlocalautomaticvariablesthatareusedbeforetheirvaluesareset.

Relatedinformation

C++compileroption−−no−warnings(Suppressallwarnings)

5−124 ToolOptions−C++Compiler

C++Compiler:−−no−warnings(−w)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectDiagnostics. 3. EnabletheoptionSuppressallwarnings.

Commandlinesyntax −−no−warnings −w

Description Withthisoptionyousuppressallwarningmessages.Errormessagesarestillissued.

Relatedinformation

C++compileroption−−warnings−as−errors(Treatwarningsaserrors)

5−125 MicroBlazeEmbeddedToolsReference

C++Compiler:−−old−for−init

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−old−for−inittotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−old−for−init

Description Controlthescopeofadeclarationinafor−init−statement.Theold(cfront−compatible)scopingrulesmeanthedeclaration isinthescopetowhichtheforstatementitselfbelongs;thedefault(standard−conforming)rulesineffectwraptheentirefor statementinitsownimplicitlygeneratedscope.

Relatedinformation

C++compileroption−−no−for−init−diff−warning(Disablewarningforoldfor−scoping)

5−126 ToolOptions−C++Compiler

C++Compiler:−−old−line−commands

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−old−line−commandstotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−old−line−commands

Description Whengeneratingsourceoutput,putout#linedirectivesintheform#nnninsteadof#linennn.

Example Todopreprocessingonly,withoutcommentsandwitholdstylelinecontrolinformation,enter: cpmb−−preprocess−−old−line−commandstest.cc

Relatedinformation

C++compileroption−−preprocess(Preprocessingonly)

5−127 MicroBlazeEmbeddedToolsReference

C++Compiler:−−old−specializations

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−old−specializationstotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−old−specializations

Description Enableacceptanceofold−styletemplatespecializations(thatis,specializationsthatdonotusethetemplate<>syntax).

Relatedinformation

5−128 ToolOptions−C++Compiler

C++Compiler:−−option−file(−f)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−option−filetotheAdditionalCcompileroptionsfield. BeawarethattheoptionsintheoptionfileareaddedtotheC++compileroptionsyouhavesetintheotherdialogs.Onlyin extraordinarycasesyoumaywanttousethemincombination.AltiumDesignerautomaticallysavestheoptionswithyour project.

Commandlinesyntax −−option−file=file,... −ffile,...

Description

Thisoptionisprimarilyintendedforcommandlineuse.Insteadoftypingalloptionsonthecommandline,youcancreatean optionfilewhichcontainsalloptionsandflagsyouwanttospecify.WiththisoptionyouspecifytheoptionfiletotheC++ compiler. Useanoptionfilewhenthecommandlinewouldexceedthelimitsoftheoperatingsystem,orjusttostoreoptionsandsave typing. Youcanspecifytheoption−−option−filemultipletimes. Formatofanoptionfile • Multipleargumentsononelineintheoptionfileareallowed. • Toincludewhitespaceinanargument,surroundtheargumentwithsingleordoublequotes. • Ifyouwanttousesinglequotesaspartoftheargument,surroundtheargumentbydoublequotesandviseversa: "Thishasasinglequote’embedded" ’Thishasadoublequote"embedded’ ’Thishasadoublequote"andasinglequote’"’embedded" • Whenatextlinereachesitslengthlimit,usea\tocontinuetheline.Whitespacebetweenquotesispreserved. "Thisisacontinuation\ line"

−>"Thisisacontinuationline" • Itispossibletonestcommandlinefilesupto25levels. Example Supposethefilemyoptionscontainsthefollowinglines: −−embedded−c++ −−define=DEMO=1 test.cc

SpecifytheoptionfiletotheC++compiler: cpmb−−option−file=myoptions

Thisisequivalenttothefollowingcommandline: cpmb−−embedded−c++−−define=DEMO=1test.cc

5−129 MicroBlazeEmbeddedToolsReference

Relatedinformation

5−130 ToolOptions−C++Compiler

C++Compiler:−−output(−o)

Menuentry AltiumDesignernamestheoutputfilealwaysaftertheC++sourcefile. 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−old−specializationstotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−output=file −ofile Default:modulenamewith.icsuffix.

Description WiththisoptionyoucanspecifyanotherfilenamefortheoutputfileoftheC++compiler.Withoutthisoptionthebasenameofthe C++sourcefileisusedwithextension.ic. Youcanalsousethisoptionincombinationwiththeoption−−preprocess(−E)toredirectthepreprocessingoutputtoafile.

Example Tocreatethefileoutput.icinsteadoftest.ic,enter: cpmb−−output=output.ictest.cc

Tousethefilemy.preasthepreprocessingoutputfile,enter: cpmb−−preprocess−−output=my.pretest.cc

Relatedinformation

C++compileroption−−preprocess(Preprocessingonly)

5−131 MicroBlazeEmbeddedToolsReference

C++Compiler:−−pch

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectPrecompiledHeaders. 3. EnabletheoptionAutomaticallyuseand/orcreateaprecompiledheaderfile.

Commandlinesyntax −−pch

Description Automaticallyuseand/orcreateaprecompiledheaderfile.If−−use−pchor−−create−pch(manualPCHmode)appearsonthe commandlinefollowingthisoption,itseffectiserased.

Relatedinformation

C++compileroption−−use−pch(Useprecompiledheaderfile) C++compileroption−−create−pch(Createprecompiledheaderfile) Section2.11,PrecompiledHeadersinchapterC++Language.

5−132 ToolOptions−C++Compiler

C++Compiler:−−pch−dir

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectPrecompiledHeaders. 3. EnterapathinthePrecompiledheaderfiledirectoryfield.

Commandlinesyntax −−pch−dir=directory−name

Description Specifythedirectoryinwhichtosearchforand/orcreateaprecompiledheaderfile.Thisoptionmaybeusedwithautomatic PCHmode(−−pch)ormanualPCHmode(−−create−pchor−−use−pch).

Example Tousethedirectoryc:\usr\include\pchtoautomaticallycreateprecompiledheaderfiles,enter: cpmb−−pch−dir=c:\usr\include\pch−−pchtest.cc

Relatedinformation

C++compileroption−−pch(AutomaticPCHmode) C++compileroption−−use−pch(Useprecompiledheaderfile) C++compileroption−−create−pch(Createprecompiledheaderfile) Section2.11,PrecompiledHeadersinchapterC++Language.

5−133 MicroBlazeEmbeddedToolsReference

C++Compiler:−−pch−verbose

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−pch−verbosetotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−pch−verbose

Description InautomaticPCHmode,foreachprecompiledheaderfilethatcannotbeusedforthecurrentcompilation,amessageis displayedgivingthereasonthatthefilecannotbeused.

Example cpmb−−pch−−pch−verbosetest.cc

Relatedinformation

C++compileroption−−pch(AutomaticPCHmode) Section2.11,PrecompiledHeadersinchapterC++Language.

5−134 ToolOptions−C++Compiler

C++Compiler:−−pending−instantiations

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−pending−instantiationstotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−pending−instantiations=n wherenisthemaximumnumberofinstantiationsofasingletemplate. Default:64

Description Specifiesthemaximumnumberofinstantiationsofagiventemplatethatmaybeinprocessofbeinginstantiatedatagiventime. Thisisusedtodetectrunawayrecursiveinstantiations.Ifniszero,thereisnolimit.

Example Tospecifyamaximumof32pendinginstantiations,enter: cpmb−−pending−instantiations=32test.cc

Relatedinformation

Section2.6,TemplateInstantiationinchapterC++Language.

5−135 MicroBlazeEmbeddedToolsReference

C++Compiler:−−preprocess(−E)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectPreprocessing. 3. EnabletheoptionStoretheC++compilerpreprocessoutput(.pre).

Commandlinesyntax −−preprocess[=flags] −E[flags] Youcansetthefollowingflags(whenyouspecify−Ewithoutflags,thedefaultis−ECMP): +/−comments (c/C) KeepcommentsfromtheCsourceinthepreprocessedoutput +/−make (m/M) Generatedependencylinesthatcanbeusedforthemakefile +/−noline (p/P) Strip#linesourcepositioninfo(linesstartingwith#line)

Description WiththisoptionyoutelltheC++compilertopreprocesstheC++source.UnderAltiumDesignertheC++compilersendsthe preprocessedoutputtothefilename.pre(wherenameisthenameoftheC++sourcefiletocompile).AltiumDesigneralso compilestheC++source. Onthecommandline,theC++compilersendsthepreprocessedfiletostdout.Tocapturetheinformationinafile,specifyan outputfilewiththeoption−−output. With−−preprocess=+commentsyoutellthepreprocessortokeepthecommentsfromtheC++sourcefileinthepreprocessed output. With−−preprocess=+maketheC++compilerwillgeneratedependencylinesthatcanbeusedinaMakefile.Thepreprocessor outputisdiscarded.Thedefaulttargetnameisthebasenameoftheinputfile,withtheextension.obj.Withtheoption −−make−targetyoucanspecifyatargetnamewhichoverrulesthedefaulttargetname. Whenimplicitinclusionoftemplatesisenabled,theoutputmayindicatefalse(butsafe)dependenciesunless −−no−preprocessing−onlyisalsoused. With−−preprocess=+nolineyoutellthepreprocessortostripthe#linesourcepositioninformation(linesstartingwith#line). Theselinesarenormallyprocessedbytheassemblerandnotneededinthepreprocessedoutput.Whenyouleavetheselines out,theoutputiseasiertoread.

Example cpmb−−preprocess=+comments,−make,−nolinetest.cc−−output=test.pre

TheC++compilerpreprocessesthefiletest.ccandsendstheoutputtothefiletest.pre.Commentsareincludedbutno dependenciesaregeneratedandthelinesourcepositioninformationisnotstrippedfromtheoutputfile.

Relatedinformation

C++compileroption−−no−preprocessing−only(Forcefullcompilation) C++compileroption−−make−target(Specifytargetnamefor−Emoutput)

5−136 ToolOptions−C++Compiler

C++Compiler:−−remarks(−r)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectDiagnostics. 3. EnabletheoptionIssueremarksonC++code.

Commandlinesyntax −−remarks −r

Description Issueremarks,whicharediagnosticmessagesevenmilderthanwarnings

Relatedinformation

Section3.4,C++CompilerErrorMessagesinchapterUsingtheC++Compileroftheuser’smanual.

5−137 MicroBlazeEmbeddedToolsReference

C++Compiler:−−remove−unneeded−entities

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−remove−unneeded−entitiestotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−remove−unneeded−entities

Description Enableanoptimizationtoremovetypes,variables,routines,andrelatedconstructsthatarenotreallyneeded.Somethingmay bereferencedbutunneededifitisreferencedonlybysomethingthatisitselfunneeded;certainentities,suchasglobalvariables androutinesdefinedinthetranslationunit,arealwaysconsideredtobeneeded.

Relatedinformation

5−138 ToolOptions−C++Compiler

C++Compiler:−−rtti

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectC++Language. 3. EnabletheoptionSupportforRTTI(run−timetypeinformation).

Commandlinesyntax −−rtti Default:RTTI(run−timetypeinformation)featuresaredisabled.

Description EnablesupportforRTTI(run−timetypeinformation)features:dynamic_cast,typeid. Themacro__RTTIisdefinedwhenRTTIsupportisenabled.

Relatedinformation

5−139 MicroBlazeEmbeddedToolsReference

C++Compiler:−−schar(−s)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−schartotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−schar −s

Description Withthisoptioncharisthesameassignedchar. Whenplaincharissigned,themacro__SIGNED_CHARS__isdefined.

Relatedinformation

C++compileroption−−uchar(Plaincharisunsigned)

5−140 ToolOptions−C++Compiler

C++Compiler:−−signed−bitfields

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−signed−bitfieldstotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−signed−bitfields

Description Forbit−fieldsitdependsontheimplementationwhetheraplainintistreatedassignedintorunsignedint.Bydefault anintbit−fieldistreatedasunsignedint.Thisoffersthebestperformance.WiththisoptionyoutelltheC++compilerto treatintbit−fieldsassignedint.Inthiscase,youcanstilladdthekeywordunsignedtotreataparticularintbit−fieldas unsigned.

Relatedinformation

Ccompileroption−−signed−bitfields

5−141 MicroBlazeEmbeddedToolsReference

C++Compiler:−−special−subscript−cost

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−special−subscript−costtotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−special−subscript−cost

Description Enableaspecialnonstandardweightingoftheconversiontotheintegraloperandofthe[]operatorinoverloadresolution. Thisisacompatibilityfeaturethatmaybeusefulwithsomeexistingcode.Withthisfeatureenabled,thefollowingcodecompiles withouterror: structA{ A(); operatorint*(); intoperator[](unsigned); }; voidmain(){ Aa; a[0];//Ambiguous,butallowedwiththisoption //operator[]ischosen }

Relatedinformation

5−142 ToolOptions−C++Compiler

C++Compiler:−−strict(−A)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectC++Language. 3. DisabletheoptionAllownon−ANSI/ISOC++features.

Commandlinesyntax −−strict −A Default:non−ANSI/ISOC++featuresareenabled.

Description EnablestrictANSI/ISOmode,whichprovidesdiagnosticmessageswhennon−standardfeaturesareused,anddisables featuresthatconflictwithANSI/ISOCorC++.AllANSI/ISOviolationsareissuedaserrors.

Example ToenablestrictANSImode,witherrordiagnosticmessages,enter: cpmb−−stricttest.cc

Relatedinformation

C++compileroption−−strict−warnings(StrictANSI/ISOmodewithwarnings)

5−143 MicroBlazeEmbeddedToolsReference

C++Compiler:−−strict−warnings(−a)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−strict−warningstotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−strict−warnings −a Default:non−ANSI/ISOC++featuresareenabled.

Description Thisoptionissimilartotheoption−−strict,butallviolationsareissuedaswarningsinsteadoferrors.

Example ToenablestrictANSImode,withwarningdiagnosticmessages,enter: cpmb−−strict−warningstest.cc

Relatedinformation

C++compileroption−−strict(StrictANSI/ISOmodewitherrors)

5−144 ToolOptions−C++Compiler

C++Compiler:−−suppress−vtbl

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. IntheVirtualfunctiontablesfield,selectSuppressdefinitionofvirtualfunctiontables.

Commandlinesyntax −−suppress−vtbl

Description SuppressdefinitionofvirtualfunctiontablesincaseswheretheheuristicusedbytheC++compilertodecideondefinitionof virtualfunctiontablesprovidesnoguidance.Thevirtualfunctiontableforaclassisdefinedinacompilationifthecompilation containsadefinitionofthefirstnon−inlinenon−purevirtualfunctionoftheclass.Forclassesthatcontainnosuchfunction,the defaultbehavioristodefinethevirtualfunctiontable(buttodefineitasalocalstaticentity).The−−suppress−vtbloption suppressesthedefinitionofthevirtualfunctiontablesforsuchclasses,andthe−−force−vtbloptionforcesthedefinitionofthe virtualfunctiontableforsuchclasses.−−force−vtbldiffersfromthedefaultbehaviorinthatitdoesnotforcethedefinitiontobe local.

Relatedinformation

C++compileroption−−force−vtbl(Forcedefinitionofvirtualfunctiontables)

5−145 MicroBlazeEmbeddedToolsReference

C++Compiler:−−sys−include

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−sys−includetotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−sys−include=directory,...

Description Changethealgorithmforsearchingsystemincludefileswhosenamesdonothaveanabsolutepathnametolookindirectory.

Example Toaddthedirectoryc:\proj\includetothesystemincludefilesearchpath,enter: cpmb−−sys−include=c:\proj\includetest.cc

Relatedinformation

C++compileroption−−include−directory(Adddirectorytoincludefilesearchpath) Section3.3,HowtheC++CompilerSearchesIncludeFilesinchapterUsingtheC++Compileroftheuser’smanual.

5−146 ToolOptions−C++Compiler

C++Compiler:−−template−directory

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−template−directorytotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−template−directory=directory,...

Description Specifiesadirectorynametobeplacedontheexportedtemplatesearchpath.Thedirectoriesareusedtofindthedefinitionsof exportedtemplates(.etfiles)andaresearchedintheorderinwhichtheyarespecifiedonthecommandline.Thecurrent directoryisalwaysthefirstentryonthesearchpath.

Example Toaddthedirectoryexporttotheexportedtemplatesearchpath,enter: cpmb−−template−directory=exporttest.cc

Relatedinformation

Section2.6.5,ExportedTemplatesinchapterC++Language.

5−147 MicroBlazeEmbeddedToolsReference

C++Compiler:−−timing

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−timingtotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−timing Default:notiminginformationisgenerated.

Description Generatecompilationtiminginformation.ThisoptioncausestheC++compilertodisplaytheamountofCPUtimeandelapsed timeusedbyeachphaseofthecompilationandatotalfortheentirecompilation.

Example cpmb−−timingtest.cc processed180linesat8102lines/min

Relatedinformation

5−148 ToolOptions−C++Compiler

C++Compiler:−−trace−includes

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectDiagnostics. 3. EnabletheoptionListallvisited#includedfiles.

Commandlinesyntax −−trace−includes

Description Outputalistofthenamesoffiles#includedtotheerroroutputfile.Thesourcefileiscompilednormally(i.e.itisnotjust preprocessed)unlessanotheroptionthatcausespreprocessingonlyisspecified.

Example cpmb−−trace−includestest.cc iostream.h string.h

Relatedinformation

5−149 MicroBlazeEmbeddedToolsReference

C++Compiler:−−type−traits−helpers

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−type−traits−helperstotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−type−traits−helpers −−no−type−traits−helpers Default:inC++modetypetraitshelpersareenabledbydefault.InGNUC++mode,typetraitshelpersareneverenabledby default.

Description Enableordisabletypetraitshelpers(like__is_unionand__has_virtual_destructor).Typetraitshelpersaremeantto easetheimplementationofISO/IECTR19768. Themacro__TYPE_TRAITS_ENABLEDisdefinedwhentypetraitspseudo−functionsareenabled.

Relatedinformation

5−150 ToolOptions−C++Compiler

C++Compiler:−−uchar(−u)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−uchartotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−uchar −u

Description Bydefaultcharisthesameasspecifyingsignedchar.Withthisoptioncharisthesameasunsignedchar.

Relatedinformation

C++compileroption−−schar(Plaincharissigned)

5−151 MicroBlazeEmbeddedToolsReference

C++Compiler:−−undefine(−U)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−undefinetotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−undefine=macro_name −Umacro_name

Description Removeanyinitialdefinitionofidentifiernameasin#undef.−−undefineoptionsareprocessedafterall−−defineoptionshave beenprocessed. Youcannotundefineapredefinedmacroasspecifiedinsection2.10,PredefinedMacros,exceptfor: __STDC__ __cplusplus __SIGNED_CHARS__

Example Toundefinethepredefinedmacro__cplusplus: cpmb−−undefine=__cplusplustest.cc

Relatedinformation

C++compileroption−−define(Definepreprocessormacro) Section2.10,PredefinedMacrosinchapterC++Language.

5−152 ToolOptions−C++Compiler

C++Compiler:−−use−pch

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectPrecompiledHeaders. 3. EnterafilenameintheUseprecompiledheaderfilefield.

Commandlinesyntax −−use−pch=filename

Description Useaprecompiledheaderfileofthespecifiednameaspartofthecurrentcompilation.If−−pch(automaticPCHmode)or −−create−pchappearsonthecommandlinefollowingthisoption,itseffectiserased.

Example Tousetheprecompiledheaderfilewiththenametest.pch,enter: cpmb−−use−pch=test.pchtest.cc

Relatedinformation

C++compileroption−−pch(AutomaticPCHmode) C++compileroption−−create−pch(Createprecompiledheaderfile) Section2.11,PrecompiledHeadersinchapterC++Language.

5−153 MicroBlazeEmbeddedToolsReference

C++Compiler:−−using−std

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−using−stdtotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−using−std Default:implicituseofthestdnamespaceisdisabled.

Description Enableimplicituseofthestdnamespacewhenstandardheaderfilesareincluded.Notethatthisdoesnotdotheequivalentof puttinga"usingnamespacestd;"intheprogramtoallowoldprogramstobecompiledwithnewheaderfiles;ithasa specialandlocalizedmeaningrelatedtotheTASKINGversionsofcertainheaderfiles,andisunlikelytobeofmuchuseto end−usersoftheTASKINGC++compiler.

Relatedinformation

C++compileroption−−namespaces(Supportfornamespaces) Section2.5,NamespaceSupportinchapterC++Language.

5−154 ToolOptions−C++Compiler

C++Compiler:−−variadic−macros

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−variadic−macrostotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−variadic−macros Default:macroswithavariablenumberofargumentsarenotallowed.

Description Allowmacroswithavariablenumberofarguments.

Relatedinformation

C++compileroption−−extended−variadic−macros(Allowextendedvariadicmacros)

5−155 MicroBlazeEmbeddedToolsReference

C++Compiler:−−version(−V)

Menuentry Commandlineonly.

Commandlinesyntax −−version −V

Description Displayversioninformation.TheC++compilerignoresallotheroptionsorinputfiles.

Relatedinformation

5−156 ToolOptions−C++Compiler

C++Compiler:−−warnings−as−errors

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectDiagnostics. 3. EnabletheoptionTreatwarningsaserrors.

Commandlinesyntax −−warnings−as−errors

Description IftheC++compilerencountersanerror,itstopscompiling.WiththisoptionyoutelltheC++compilertotreatallwarningsas errors.ThismeansthattheexitstatusoftheC++compilerwillbenon−zeroafteroneormorecompilerwarnings.Asa consequence,theC++compilernowalsostopsafterencounteringawarning.

Relatedinformation

C++compileroption−−no−warnings(Suppressallwarnings)

5−157 MicroBlazeEmbeddedToolsReference

C++Compiler:−−wchar_t−keyword

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectC++Language. 3. EnabletheoptionAllowthe’wchar_t’keyword.

Commandlinesyntax −−wchar_t−keyword Default:wchar_tisnotrecognizedasakeyword.

Description Enablerecognitionofwchar_tasakeyword. Themacro_WCHAR_Tisdefinedwhenwchar_ttisrecognizedasakeyword.

Relatedinformation

5−158 ToolOptions−C++Compiler

C++Compiler:−−xref−file(−X)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheC++CompilerentryandselectMiscellaneous. 3. Addtheoption−−xref−filetotheAdditionalC++compileroptionsfield.

Commandlinesyntax −−xref−file=file −Xfile

Description Generatecross−referenceinformationinafile.Foreachreferencetoanidentifierinthesourceprogram,alineoftheform symbol_idnameXfile−nameline−numbercolumn−number iswritten,whereXis D fordefinition; d fordeclaration(thatis,adeclarationthatisnotadefinition); M formodification; A foraddresstaken; U forused; C forchanged(butactuallymeaningusedandmodifiedinasingleoperation,suchasanincrement); R foranyotherkindofreference,or E foranerrorinwhichthekindofreferenceisindeterminate. symbol−idisauniquedecimalnumberforthesymbol.Thefieldsoftheabovelineareseparatedbytabcharacters.

Relatedinformation

5−159 MicroBlazeEmbeddedToolsReference

5.3 AssemblerOptions

AltiumDesignerusesamakefiletobuildyourentireproject.ThismeansthatinAltiumDesigneryoucannotruntheassembler separately.Ifyouwantassemblyresults,youmustcompileasingleCsourcefilefromwithinAltiumDesigner,thefileisthen alsoassembled.However,youcansetoptionsspecificfortheassembler.

OptionsinAltiumDesignerversusoptionsonthecommandline MostcommandlineoptionshaveanequivalentoptioninAltiumDesignerbutsomeoptionsareonlyavailableonthecommand line(forexampleinaWindowsCommandPrompt).IfthereisnoequivalentoptioninAltiumDesigner,youcanspecifya commandlineoptioninAltiumDesignerasfollows: 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectMiscellaneous. 3. EnteroneormorecommandlineoptionsintheAdditionalassembleroptionsfield.

Invocationsyntaxonthecommandline(WindowsCommandPrompt) Tocalltheassemblerfromthecommandline,usethefollowingsyntax: asmb[[option]...[file]...]...

Theinputfilemustbeanassemblysourcefile(.asmor.src).

Shortandlongoptionnames Optionscanhavebothshortandlongnames.Shortoptionnamesalwaysbeginwithasingleminus(−)character,longoption namesalwaysbeginwithdoubleminus(−−)characters.Youcanabbreviatelongoptionnamesaslongasthenameisunique. Youcanmixshortandlongoptionnamesonthecommandline. Optionscanhaveflagsorsub−options.Toswitchaflag’on’,usealowercaseletterora+longflag.Toswitchaflagoff,usean uppercaseletterora−longflag.Separatelongflagswithcommas.Thefollowingtwoinvocationsareequivalent: asmb−Ogstest.src asmb−−optimize=+generics,+instr−sizetest.src

Whenyoudonotspecifyanoption,adefaultvaluemaybecomeactive.

5−160 ToolOptions−Assembler

Assembler:−−case−insensitive(−c)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectMiscellaneous. 3. DisabletheoptionAssemblecasesensitive.

Commandlinesyntax −−case−insensitive −c

Description Withthisoptionyoutelltheassemblernottodistinguishbetweenupperandlowercasecharacters.Bydefaulttheassembler considersupperandlowercasecharactersasdifferentcharacters.

DisablingtheoptionAssemblecasesensitiveinAltiumDesigneristhesameasspecifyingtheoption −−case−insensitiveonthecommandline. Assemblysourcefilesthataregeneratedbythecompilermustalwaysbeassembledcasesensitive.Whenyouarewritingyour ownassemblycode,youmaywanttospecifythecaseinsensitivemode.

Example Whenassemblingcaseinsensitive,thelabelLabelNameisthesamelabelaslabelname.

Relatedinformation

5−161 MicroBlazeEmbeddedToolsReference

Assembler:−−check

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectMiscellaneous. 3. Addtheoption−−checktotheAdditionalassembleroptionsfield.

Commandlinesyntax −−check

Description Withthisoptionyoucancheckthesourcecodeforsyntaxerrors,withoutgeneratingcode.Thissavestimeindevelopingyour application. Theassemblerreportsanywarningsand/orerrors.

Relatedinformation

Ccompileroption−−check(Checksyntax)

5−162 ToolOptions−Assembler

Assembler:−−debug−info(−g)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectDebugInformation. 3. Selectwhichdebuginformationtoinclude:AutomaticHLLorassemblyleveldebuginformation,Customdebug informationorNodebuginformation. IfyouselectCustomdebuginformation: 4. SelectwhichCustomdebuginformationtoinclude:Assemblersourcelineinformation,PassHLLdebuginformation,or None. 5. EnableordisabletheoptionAssemblerlocalsymbolsinformation.

Commandlinesyntax −−debug−info[=flag] −g[flag] Youcansetthefollowingflags: +/−asm (a/A) Assemblysourcelineinformation +/−hll (h/H) Passhighlevellanguagedebuginformation(HLL) +/−local (l/L) Assemblerlocalsymbolsdebuginformation +/−smart (s/S) Smartdebuginformation

Description Withthisoptionyoutelltheassemblerwhichkindofdebuginformationtoemitintheobjectfile. Ifyoudonotusethisoption,thedefaultis−−debug−info=+hll.Ifyouspecify−−debug−infowithoutanyflags,thedefaultis −−debug−info=+smart. Youcannotspecify−−debug−info=+asm,+hll.Eithertheassemblergeneratesassemblysourcelineinformation,oritpasses HLLdebuginformation. Whenyouspecify−−debug−info=+smart,theassemblerselectswhichflagstouse.Ifhighlevellanguageinformationis availableinthesourcefile,theassemblerpassesthisinformation(sameas−−debug−info=−asm,+hll,−local).Ifnot,the assemblergeneratesassemblysourcelineinformation(sameas−−debug−info=+asm,−hll,+local). With−−debug−info=AHLStheassemblerdoesnotgenerateanydebuginformation.

Relatedinformation

5−163 MicroBlazeEmbeddedToolsReference

Assembler:−−define(−D)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectPreprocessing. 3. ClickonUsermacro,clickonthedownarrowintherightpanetoexpandmacroinput. 4. ClickonanemptyMacrofieldandenteramacroname.(Thenclickoutsidethecelltoconfirm) 5. Optionally,clickintheValuefieldandenteradefinition.(Thenclickoutsidethecelltoconfirm)

Commandlinesyntax

−−define=macro_name[=macro_definition] −Dmacro_name[=macro_definition]

Description Withthisoptionyoucandefineamacroandspecifyittotheassemblerpreprocessor.Ifyouonlyspecifyamacroname(no macrodefinition),themacroexpandsas’1’. Youcanspecifyasmanymacrosasyoulike.Onthecommandlineyoucanusetheoption−−define(−D)multipletimes.Ifthe commandlineexceedsthelimitoftheoperatingsystem,youcandefinethemacrosinanoptionfilewhichyouthenmustspecify totheassemblerwiththeoption−−option−file=file(−f). Definingmacroswiththisoption(insteadofintheassemblysource)is,forexample,usefulincombinationwithconditional assemblyasshownintheexamplebelow.

Thisoptionhasthesameeffectasdefiningsymbolsviathe.DEFINE,.SET,and.EQUdirectives.(similarto#definein theClanguage).Withthe.MACROdirectiveyoucandefinemorecomplexmacros.

Example Considerthefollowingassemblyprogramwithconditionalcodetoassembleademoprogramandarealprogram: .IFDEMO==1 ...;instructionsfordemoapplication .ELSE ...;instructionsfortherealapplication .ENDIF

YoucannowuseamacrodefinitiontosettheDEMOflag: Macro Value DEMO 1(orempty) asmb−−define=DEMOtest.src asmb−−define=DEMO=1test.src

Notethatbothinvocationshavethesameeffect.

Relatedinformation

Assembleroption−−option−file(Readoptionsfromfile)

5−164 ToolOptions−Assembler

Assembler:−−diag

Menuentry 1. FromtheViewmenu,selectWorkspacePanels»System»Messages. TheMessagespanelappears. 2. IntheMessagespanel,right−clickonthemessageyouwantmoreinformationon. Apopupmenuappears. 3. SelectMoreInfo. AMessageInfoboxappearswithadditionalinformation.

Commandlinesyntax

−−diag=[format:]{all|nr,...}

Description Withthisoptionyoucanaskforanextendeddescriptionoferrormessagesintheformatyouchoose.Theoutputisdirectedto stdout(normallyyourscreen)andintheformatyouspecify.Youcanspecifythefollowingformats:html,rtfortext(default). Tocreateafilewiththedescriptions,youmustredirecttheoutput. Withthesuboptionall,thedescriptionsofallerrormessagesaregiven.Ifyouwantthedescriptionofoneormoreselectederror messages,youcanspecifytheerrormessagenumbers,separatedbycommas. Withthisoptiontheassemblerdoesnotassembleanyfiles.

Example Todisplayanexplanationofmessagenumber241,enter: asmb−−diag=241

Thisresultsinthefollowingmessageandexplanation: W241:additionalinputfileswillbeignored Theassemblersupportsonlyasingleinputfile.Allotherinputfilesareignored.

TowriteanexplanationofallerrorsandwarningsinHTMLformattofileaserrors.html,useredirectionandenter: asmb−−diag=html:all>aserrors.html

Relatedinformation

5−165 MicroBlazeEmbeddedToolsReference

Assembler:−−emit−locals

Menuentry Commandlineonly.

Commandlinesyntax

−−emit−locals[=flag,...] Youcansetthefollowingflags(whenyouspecifynoflags,thedefaultisEs):: +/−equs (e/E) emitlocalEQUsymbols +/−symbols (s/S) emitlocalnon−EQUsymbols

Description Withtheoption−−emit−locals=+equstheassembleralsoemitslocalEQUsymbolstotheobjectfile.Normally,onlyglobal symbolsandnon−EQUlocalsymbolsareemitted.Havinglocalsymbolsintheobjectfilecanbeusefulfordebugging.

Relatedinformation

5−166 ToolOptions−Assembler

Assembler:−−error−file

Menuentry Commandlineonly.

Commandlinesyntax

−−error−file[=file]

Description Withthisoptiontheassemblerredirectserrormessagestoafile. Ifyoudonotspecifyafilename,theerrorfilewillbenamedaftertheinputfilewithextension.ers.

Example Towriteerrorstoerrors.errinsteadofstderr,enter: asmb−−error−file=errors.errtest.src

Relatedinformation

5−167 MicroBlazeEmbeddedToolsReference

Assembler:−−error−limit

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectMiscellaneous. 3. Addtheoption−−error−limittotheAdditionalassembleroptionsfield.

Commandlinesyntax −−error−limit=number

Description Withthisoptionyoutelltheassemblertoonlyemitthespecifiedmaximumnumberoferrors.Withoutthisoption(sameas0)the assembleremitsallerrors.

Relatedinformation

5−168 ToolOptions−Assembler

Assembler:−−help(−?)

Menuentry Commandlineonly.

Commandlinesyntax

−−help[=options] −?

Description Displaysanoverviewofallcommandlineoptions.Whenyouspecifytheargumentoptionsyoucanlistdetailedoption descriptions.

Example Thefollowinginvocationsalldisplayalistoftheavailablecommandlineoptions: asmb−? asmb−−help asmb

Toseeadetaileddescriptionoftheavailableoptions,enter: asmb−−help=options

5−169 MicroBlazeEmbeddedToolsReference

Assembler:−−include−directory(−I)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. SelectBuildOptions. 3. AddapathnameintheIncludeFilesPathfield. Ifyouentermultiplepaths,separatethemwithasemicolon(;).

Commandlinesyntax −−include−directory=path,... −Ipath,...

Description Withthisoptionyoucanspecifythepathwhereyourincludefilesarelocated.Arelativepathwillberelativetothecurrent directory. Theorderinwhichtheassemblersearchesforincludefilesis: 1. Thepathnameintheassemblyfileandthedirectoryoftheassemblysource. 2. Thepaththatisspecifiedwiththisoption. 3. ThepaththatisspecifiedintheenvironmentvariableASMBINCwhentheproductwasinstalled. 4. Thedefaultincludedirectoryrelativetotheinstallationdirectory.

Example Supposethatyourassemblysourcefiletest.srccontainsthefollowingline: .INCLUDE’myinc.inc’

Youcancalltheassemblerasfollows: asmb−−include−directory=c:\proj\includetest.src

Firsttheassemblerlooksinthedirectorywheretest.srcislocatedforthefilemyinc.inc.Ifitdoesnotfindthefile,itlooksin thedirectoryc:\proj\includeforthefilemyinc.inc(thisoption).Ifthefileisstillnotfound,theassemblersearchesinthe environmentvariableandtheninthedefaultincludedirectory.

Relatedinformation

Assembleroption−−include−file(−H)(Includefilebeforesource)

5−170 ToolOptions−Assembler

Assembler:−−include−file(−H)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectPreprocessing. 3. EnterthenameofthefileintheIncludethisfilebeforesourcefieldorclick...andselectafile.

Commandlinesyntax −−include−file=file,... −Hfile,...

Description Withthisoption(setatprojectlevel)youincludeoneextrafileatthebeginningoftheassemblysourcefile.Thespecifiedinclude fileisincludedbeforeallotherincludes.Thisisthesameasspecifying.INCLUDE’file’atthebeginningofyourassembly source.

Example asmb−−include−file=myinc.inctest1.src

Thefilemyinc.incisincludedatthebeginningoftest1.srcbeforeitisassembled.

Relatedinformation

Assembleroption−−include−directory(Includefilespath) Section5.4,HowtheAssemblerSearchesIncludeFiles,inchapterUsingtheAssembleroftheuser’smanual.

5−171 MicroBlazeEmbeddedToolsReference

Assembler:−−keep−output−files(−k)

Menuentry AltiumDesigneralwaysremovestheobjectfilewhenerrorsoccurduringassembling.

Commandlinesyntax −−keep−output−files −k

Description Ifanerroroccursduringassembling,theresultingobjectfile(.obj)maybeincompleteorincorrect.Withthisoptionyoukeep thegeneratedobjectfilewhenanerroroccurs. Bydefaulttheassemblerremovesthegeneratedobjectfilewhenanerroroccurs.Thisisusefulwhenyouusethemakeutility.If theerroneousfilesarenotremoved,themakeutilitymayprocesscorruptfilesonasubsequentinvocation. Usethisoptionwhenyoustillwanttousethegeneratedobject.Forexamplewhenyouknowthataparticularerrordoesnot resultinacorruptobjectfile.

Relatedinformation

5−172 ToolOptions−Assembler

Assembler:−−list−file(−l)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectListFile. 3. EnableGeneratelistfile. 4. IntheListfileformatsection,enableordisablethetypesofinformationtobeincluded.

Commandlinesyntax −−list−file[=file] −l[file]

Description Withthisoptionyoutelltheassemblertogeneratealistfile.Alistfileshowsthegeneratedobjectcodeandtherelative addresses.Notethattheassemblergeneratesarelocatableobjectfilewithrelativeaddresses. Withtheoptionalfileyoucanspecifyanalternativenameforthelistfile.Bydefault,thenameofthelistfileisthebasenameof thesourcefilewiththeextension.lst.

Relatedinformation

Onthecommandlineyoucanusetheoption−−list−format(−L)tospecifywhichtypesofinformationshouldbeincluded inthelistfile.

5−173 MicroBlazeEmbeddedToolsReference

Assembler:−−list−format(−L)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectListFile. 3. EnableGeneratelistfile. 4. IntheListfileformatsection,enableordisablethetypesofinformationtobeincluded.

Commandlinesyntax −−list−format=flags −Lflags Youcansetthefollowingflags: 0 Sameas−LDEGILMNPQRSVWXYZ(alloptionsdisabled) 1 Sameas−Ldegilmnpqrsvwxyz(alloptionsenabled) +/−section (d/D) Sectiondirectives(.SECTION) +/−symbol (e/E) Symboldefinitiondirectives +/−generic−expansion (g/G) Genericinstructionexpansion +/−generic (i/I) Genericinstructions +/−line (l/L) Cpreprocessor#linedirectives +/−macro (m/M) Macro/dupdefinitions(e.g..MACRO) +/−empty−line (n/N) Emptysourcelines(newline) +/−conditional (p/P) Conditionalassembly(.IF,.ELSE,.ENDIF) +/−equate (q/Q) Assembler.EQUand.SETdirectives +/−relocations (r/R) Relocationcharacters(’r’) +/−hll (s/S) HLLsymbolicdebuginformation(.SYMB) +/−equate−values (v/V) Assembler.EQUand.SETvalues +/−wrap−lines (w/W) Wrappedsourcelines +/−macro−expansion (x/X) Macroexpansions +/−cycle−count (y/Y) Cyclecounts +/−macro−expansion (z/Z) Defineexpansions

Default:−LdEGilMnPqrsVwXyZ

Description Withthisoptionyouspecifywhichinformationyouwanttoincludeinthelistfile.

Onthecommandlineyoumustusethisoptionincombinationwiththeoption−−list−file(−l).

Relatedinformation

Assembleroption−−list−file(Generatelistfile) Assembleroption−−section−info=+list(Displaysectioninformationinlistfile)

5−174 ToolOptions−Assembler

Assembler:−−nested−sections(−N)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectMiscellaneous. 3. Addtheoption−NtotheAdditionalassembleroptionsfield.

Commandlinesyntax −−nested−sections −N

Description Withthisoptionitisallowedtohavenestedsectionsinyourassemblysourcefile.Whenyouusethisoptionevery.SECTION directivemusthaveacorresponding.ENDSECdirective.

Example .SECTION.text ;code .SECTION.data ;anestedsection .ENDSEC ;code .ENDSEC

Relatedinformation

5−175 MicroBlazeEmbeddedToolsReference

Assembler:−−no−warnings(−w)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectDiagnostics. 3. Enableoneoftheoptions: • Reportallwarnings • Suppressallwarnings • Suppressspecificwarnings IfyouselectSuppressspecificwarnings: 4. Enterthenumbers,separatedbycommas,ofthewarningsyouwanttosuppress.

Commandlinesyntax −−no−warnings[=number,...] −w[number,...]

Description Withthisoptionyoucansuppressesallwarningmessagesorspecificwarningmessages. • Ifyoudonotspecifythisoption,allwarningsarereported. • Ifyouspecifythisoptionbutwithoutnumbers,allwarningsaresuppressed. • Ifyouspecifythisoptionwithanumber,onlythespecifiedwarningissuppressed. Youcanspecifytheoption−−no−warnings=numbermultipletimes. Example Tosuppresswarnings135and136,enter135,136intheSpecificwarningstosuppressfield,orenterthefollowingonthe commandline: asmbtest.src−−no−warnings=135,136

Relatedinformation

Assembleroption−−warnings−as−errors(Treatwarningsaserrors)

5−176 ToolOptions−Assembler

Assembler:−−optimize(−O)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectOptimization. 3. Enableordisabletheoptimizationoptions: • Genericinstructions • Jumpchains • Instructionsize Commandlinesyntax −Oflags −−optimize=flags Youcansetthefollowingflags: +/−generics (g/G) Allowgenericinstructions +/−jumpchains (j/J) Jumpchains +/−instr−size (s/S) Optimizeinstructionsize Default:−−optimize=gJs

Description Allowgenericinstructions Ifyouusegenericinstructionsinyourassemblysource,theassemblercanoptimizethembyreplacingitwiththefastestor shortestpossiblevariantofthatinstruction.Bydefaultthisoptionisenabled.Ifyouturnoffthisoptimization,theassembler generatesanerrorongenericinstructions.Beawarethatthecompileralsogeneratesgenericinstructions! Jumpchains Withthisoptimization,theassemblerreplaceschainedjumpsbyasinglejumpinstruction.Forexample,ajumpfromatob immediatelyfollowedbyajumpfrombtoc,isreplacedbyajumpfromatoc. Optimizeinstructionsize Withthisoptimizationtheassemblertriestofindtheshortestpossibleoperandencodingforinstructions.

Relatedinformation

Section5.5,AssemblerOptimizationsinchapterUsingtheAssembleroftheuser’smanual.

5−177 MicroBlazeEmbeddedToolsReference

Assembler:−−option−file(−f)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectMiscellaneous. 3. Addtheoption−−option−filetotheAdditionalassembleroptionsfield. Beawarethattheoptionsintheoptionfileareaddedtotheassembleroptionsyouhavesetintheotherdialogs.Onlyin extraordinarycasesyoumaywanttousethemincombination.

Commandlinesyntax −−option−file=file,... −ffile,...

Description Thisoptionisprimarilyintendedforcommandlineuse.Insteadoftypingalloptionsonthecommandline,youcancreatean optionfilewhichcontainsalloptionsandflagsyouwanttospecify.Withthisoptionyouspecifytheoptionfiletotheassembler. Useanoptionfilewhenthecommandlinewouldexceedthelimitsoftheoperatingsystem,orjusttostoreoptionsandsave typing. Optionfilescanalsobegeneratedonthefly,forexamplebythemakeutility.Youcanspecifytheoption−−option−filemultiple times. Formatofanoptionfile • Multipleargumentsononelineintheoptionfileareallowed. • Toincludewhitespaceinanargument,surroundtheargumentwithsingleordoublequotes. • Ifyouwanttousesinglequotesaspartoftheargument,surroundtheargumentbydoublequotesandviseversa: "Thishasasinglequote’embedded" ’Thishasadoublequote"embedded’ ’Thishasadoublequote"andasinglequote’"’embedded" • Whenatextlinereachesitslengthlimit,usea’tocontinuetheline.Whitespacebetweenquotesispreserved. "Thisisacontinuation\ line"

−>"Thisisacontinuationline" • Itispossibletonestcommandlinefilesupto25levels. Example Supposethefilemyoptionscontainsthefollowinglines: −gaL test.src

Specifytheoptionfiletotheassembler: asmb−−option−file=myoptions

Thisisequivalenttothefollowingcommandline: asmb−gaLtest.src

Relatedinformation

5−178 ToolOptions−Assembler

Assembler:−−output(−o)

Menuentry AltiumDesignernamestheoutputfilealwaysafterthesourcefile.

Commandlinesyntax

−−output=file −ofile

Description Withthisoptionyoucanspecifyanotherfilenamefortheoutputfileoftheassembler.Withoutthisoption,thebasenameofthe assemblysourcefileisusedwithextension.obj.

Example Tocreatethefilerelobj.objinsteadofasm.obj,enter: asmb−−output=relobj.objasm.src

Relatedinformation

5−179 MicroBlazeEmbeddedToolsReference

Assembler:−−page−length

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectMiscellaneous. 3. Addtheoption−−page−lengthtotheAdditionalassembleroptionsfield.

Commandlinesyntax −−page−length=number Default:72

Description Ifyougeneratealistfilewiththeassembleroption−−list−file,(−l),thisoptionsetsthenumberoflinesinapageinthelistfile. Thedefaultis72,theminimumis10.Asaspecialcase,apagelengthof0turnsoffpagebreaks.

Relatedinformation

Assembleroption−−list−file(Generatelistfile)

5−180 ToolOptions−Assembler

Assembler:−−page−width

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectMiscellaneous. 3. Addtheoption−−page−widthtotheAdditionalassembleroptionsfield.

Commandlinesyntax −−page−width=number Default:132

Description Ifyougeneratealistfilewiththeassembleroption−−list−file,(−l),thisoptionsetsthenumberofcolumnsperlineonapagein thelistfile.Thedefaultis132,theminimumis40.

Relatedinformation

Assembleroption−−list−file(Generatelistfile)

5−181 MicroBlazeEmbeddedToolsReference

Assembler:−−preprocess(−E)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectMiscellaneous. 3. Addtheoption−−preprocesstotheAdditionalassembleroptionsfield.

Commandlinesyntax −−preprocess −E

Description Withthisoptiontheassemblerwillonlypreprocesstheassemblysourcefile.Theassemblersendsthepreprocessedfileto stdout.

Relatedinformation

5−182 ToolOptions−Assembler

Assembler:−−preprocessor−type(−m)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectMiscellaneous. 3. Addtheoption−−preprocessor−typetotheAdditionalassembleroptionsfield.

Commandlinesyntax −−preprocessor−type={none|tasking} −m{n|t} Default:−mt

Description Withthisoptionyouselectthepreprocessorthattheassemblerwilluse.Bydefault,theassemblerusestheTASKING preprocessor. Whentheassemblysourcefiledoesnotcontainanypreprocessorsymbols,youcanspecifytotheassemblernottousea preprocessor.

Relatedinformation

5−183 MicroBlazeEmbeddedToolsReference

Assembler:−−section−info(−t)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectListFile. 3. EnableGeneratelistfile. 4. EnabletheoptionDisplaysectioninformation.

Commandlinesyntax −−section−info[=flags] −t[flags] Youcansetthefollowingflags: +/−console (c/C) Displaysectioninformationonstdout. +/−list (l/L) Writesectioninformationtothelistfile.

Description Withthisoptionyoutelltheassemblertodisplaysectioninformation.Foreachsectionitsmemoryspace,size,totalcyclecounts andnameislistedonstdoutand/orinthelistfile. Thecyclecountconsistsoftwoparts:thetotalaccumulatedcountforthesectionandthetotalaccumulatedcountforall repeatedinstructions.Inthecaseofnestedloopsitispossiblethatthetotalsupersedesthesectiontotal. Withoutargumentsthisoptionisthesameas−−section−info=cl.

With−−section−info=l,theassemblerwritesthesectioninformationtothelistfile.Youmustspecifythisoptionin combinationwiththeoption−−list−file(generatelistfile).

Example asmb−−list−file−−section−info=+console,+listtest.src

Theassemblergeneratesalistfileandwritesthesectioninformationtothisfile.Thesectioninformationisalsodisplayedon stdout.

Relatedinformation

Assembleroption−−list−file(generatelistfile)

5−184 ToolOptions−Assembler

Assembler:−−symbol−scope(−i)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectMiscellaneous. 3. Selectthedefaultlabelmode:LocalorGlobal.

Commandlinesyntax −−symbol−scope={global|local} −i{g|l} (Default: −il)

Description Withthisoptionyoutelltheassemblerhowtotreatsymbolsthatyouhavenotspecifiedexplicitlyasglobalorlocal.Bydefault theassemblertreatsallsymbolsaslocalsymbolsunlessyouhavedefinedthemexplicitlyasglobal.

Relatedinformation

5−185 MicroBlazeEmbeddedToolsReference

Assembler:−−use−hardware

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheProcessorentryandselectProcessorDefinition. 3. Enableoneormoreoftheoptions: • Barrelshifterpresent • Divideunitpresent • Multiplyunitpresent • Floating−pointunitpresent • MSRSETandMSRCLRinstructionspresent • PCMPBF,PCMPEQandPCMPNEinstructionspresent Commandlinesyntax −−use−hardware=flag,... Youcansetthefollowingflags: +/−barrel−shift (b/B) Barrelshifter +/−divide (d/D) Divideunit +/−fpu (f/F) Floating−pointunit +/−multiply (m/M) Multiplyunit +/−pcmp (p/P) Patterncompareinstructions +/−msr (s/S) msrclrandmsrsetinstructions Default:BDFMPS

Description WiththisoptionyoutelltheassemblerwhethertheMicroBlazetargethasahardwarebarrelshifter,divider,floating−point, multiplierand/orhardwaresupportforpatterncompareinstructionsand/orthemsrsetandmsrclrinstructions.Thiswaythe assemblercanusetheoptionalbarrelshift,divide,multiply,patterncompareand/ormsrset,msrclrinstructions.

Relatedinformation

5−186 ToolOptions−Assembler

Assembler:−−version(−V)

Menuentry Commandlineonly.

Commandlinesyntax −−version −V

Description Displaysversioninformationoftheassembler.Theassemblerignoresallotheroptionsorinputfiles.

Relatedinformation

5−187 MicroBlazeEmbeddedToolsReference

Assembler:−−verbose(−v)

Menuentry Commandlineonly.

Commandlinesyntax −−verbose −v

Description Withthisoptionyouputtheassemblerinverbosemode.Theassemblerprintsthefilenamesandtheassemblypasseswhileit processesthefilessoyoucanmonitorthecurrentstatusoftheassembler.

Relatedinformation

5−188 ToolOptions−Assembler

Assembler:−−warnings−as−errors

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheAssemblerentryandselectDiagnostics. 3. EnabletheoptionTreatwarningsaserrors.

Commandlinesyntax −−warnings−as−errors[=number,...]

Description Iftheassemblerencountersanerror,itstopsassembling.Whenyouusethisoptionwithoutarguments,youtelltheassemblerto treatallwarningsaserrors.Thismeansthattheexitstatusoftheassemblerwillbenon−zeroafteroneormorecompiler warnings.Asaconsequence,theassemblernowalsostopsafterencounteringawarning. Youcanalsolimitthisoptiontospecificwarningsbyspecifyingacomma−separatedlistofwarningnumbers.

Relatedinformation

Assembleroption−−no−warnings(Suppresssomeorallwarnings)

5−189 MicroBlazeEmbeddedToolsReference

5.4 LinkerOptions

AltiumDesignerusesamakefiletobuildyourentireproject.Thismeansthatyoucannotrunthelinkerseparately.However,you cansetoptionsspecificforthelinker.

OptionsinAltiumDesignerversusoptionsonthecommandline MostcommandlineoptionshaveanequivalentoptioninAltiumDesignerbutsomeoptionsareonlyavailableonthe commandline(forexampleinaWindowsCommandPrompt).IfthereisnoequivalentoptioninAltiumDesigner,youcan specifyacommandlineoptioninAltiumDesignerasfollows: 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. EnteroneormorecommandlineoptionsintheAdditionalLinkeroptionsfield.

Invocationsyntaxonthecommandline(WindowsCommandPrompt) Theinvocationsyntaxonthecommandlineis: lkmb[[option]...[file]...]...

Whenyouarelinkingmultiplefiles,eitherrelocatableobjectfiles(.objor.o),.outfilesorlibraries(.libor.a),itisimportant tospecifythefilesintherightorder.Fileswithextensionsotherthan.obj,.o,.out,.libor.aarenotrecognizedasinput files.

Shortandlongoptionnames Optionscanhavebothshortandlongnames.Shortoptionnamesalwaysbeginwithasingleminus(−)character,longoption namesalwaysbeginwithdoubleminus(−−)characters.Youcanabbreviatelongoptionnamesaslongasthenameisunique. Youcanmixshortandlongoptionnamesonthecommandline. Optionscanhaveflagsorsub−options.Toswitchaflag’on’,usealowercaseletterora+longflag.Toswitchaflagoff,usean uppercaseletterora−longflag.Separatelongflagswithcommas.Thefollowingtwoinvocationsareequivalent: lkmb−mfktest.obj lkmb−−map−file−format=+files,+linktest.obj

Whenyoudonotspecifyanoption,adefaultvaluemaybecomeactive.

5−190 ToolOptions−Linker

Linker:−−case−insensitive

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. DisabletheoptionLinkcasesensitive.

Commandlinesyntax −−case−insensitive

Description Withthisoptionyoutellthelinkernottodistinguishbetweenupperandlowercasecharactersinsymbols.Bydefaultthelinker considersupperandlowercasecharactersasdifferentcharacters.

DisablingtheoptionLinkcasesensitiveinAltiumDesigneristhesameasspecifyingtheoption−−case−insensitiveon thecommandline. Assemblysourcefilesthataregeneratedbythecompilermustalwaysbeassembledandthuslinkedcasesensitive.Whenyou havewrittenyourownassemblycodeandspecifiedtoassembleitcaseinsensitive,youmustalsolinkthe.objfilecase insensitive.

Relatedinformation

5−191 MicroBlazeEmbeddedToolsReference

Linker:−−chip−output(−c)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectOutputFormat. 3. EnabletheoptionsIntelHEXrecordsand/orMotorolaS−records.

Commandlinesyntax −−chip−output=[basename]:format[:addr_size],... −c[basename]:format[:addr_size],... Youcanspecifythefollowingformats: IHEX IntelHex SREC MotorolaS−records Theaddr_sizespecifiesthesizeoftheaddressesinbytes(recordlength).ForIntelHexyoucanusethevalues1,2or4bytes (default).ForMotorola−Syoucanspecify:2(S1records),3(S2records)or4bytes(S3records,default).InAltiumDesigneryou cannotspecifytheaddresssizebecauseAltiumDesigneralwaysusesthedefaultvalues.

Description WiththisoptionyouspecifytheIntelHexorMotorolaS−recordoutputformatforloadingintoaPROM−programmer.Thelinker generatesafileforeachROMmemorydefinedintheLSLfile,wheresectionsarelocated: memorymemname {type=rom;}

ThenameofthefileisthenameoftheAltiumDesignerprojector,onthecommandline,thenameofthememorydevicethat wasemittedwithextension.hexor.sre.Optionally,youcanspecifyabasenamewhichprependsthegeneratedfilename.

ThelinkeralwaysoutputsadebuggingfileinELF/DWARFformatandoptionallyanabsoluteobjectfileinIntel Hex−formatand/orMotorolaS−recordformat.

Example TogenerateIntelHexoutputfilesforeachdefinedmemory,enterthefollowingonthecommandline: lkmb−−chip−output=myfile:IHEXtest1.obj

Inthiscase,thisgeneratesthefilemyfile_memname.hex

Relatedinformation

Linkeroption−−output(Outputfile) Section7.2,MotorolaS−RecordFormat, Section7.3,IntelHexRecordFormat,inChapterObjectFileFormats.

5−192 ToolOptions−Linker

Linker:−−define(−D)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. ClickonUsermacro,clickonthedownarrowintherightpanetoexpandmacroinput. 4. ClickonanemptyMacrofieldandenteramacroname.(Thenclickoutsidethecelltoconfirm) 5. Optionally,clickintheValuefieldandenteradefinition.(Thenclickoutsidethecelltoconfirm)

Commandlinesyntax

−−define=macro_name[=macro_definition] −Dmacro_name[=macro_definition]

Description WiththisoptionyoucandefineamacroandspecifyittothelinkerLSLfilepreprocessor.Ifyouonlyspecifyamacroname(no macrodefinition),themacroexpandsas’1’. Youcanspecifyasmanymacrosasyoulike;justusetheoption−−definemultipletimes.Ifthecommandlineexceedsthelimit oftheoperatingsystem,youcandefinethemacrosinanoptionfilewhichyouthenmustspecifytothelinkerwiththeoption −−option−file=file(−f). Thedefinitioncanbetestedbythepreprocessorwith#if,#ifdefand#ifndef,forconditionallocating.

Example Todefinethestacksizewhichisusedinthelinkerscriptfilemb.lsl,enter: lkmbtest.obj−otest.abs−dmb.lsl−D__STACK=10k orusingthelongoptionnames: lkmb−otest.abs−lsl−file=mb.lsl−−define=__STACK=10k

Relatedinformation

Linkeroption−−option−file(Readoptionsfromfile)

5−193 MicroBlazeEmbeddedToolsReference

Linker:−−diag

Menuentry 1. FromtheViewmenu,selectWorkspacePanels»System»Messages. TheMessagespanelappears. 2. IntheMessagespanel,right−clickonthemessageyouwantmoreinformationon. Apopupmenuappears. 3. SelectMoreInfo. AMessageInfoboxappearswithadditionalinformation.

Commandlinesyntax

−−diag=[format:]{all|nr,...]

Description Withthisoptionyoucanaskforanextendeddescriptionoferrormessagesintheformatyouchoose.Theoutputisdirectedto stdout(normallyyourscreen)andintheformatyouspecify.Youcanspecifythefollowingformats:html,rtfortext(default). Tocreateafilewiththedescriptions,youmustredirecttheoutput. Withthesuboptionall,thedescriptionsofallerrormessagesaregiven.Ifyouwantthedescriptionofoneormoreselectederror messages,youcanspecifytheerrormessagenumbers,separatedbycommas. Withthisoptionthelinkerdoesnotlink/locateanyfiles.

Example Todisplayanexplanationofmessagenumber106,enter: lkmb−−diag=106

Thisresultsinthefollowingmessageandexplanation: E106:unresolvedexternal: Thelinkercouldnotresolveallexternalsymbols.Thisisanerrorwhentheincremental linkingoptionisdisabled.Theindicatesthesymbolthatisunresolved.

TowriteanexplanationofallerrorsandwarningsinHTMLformattofilelerrors.html,enter: lkmb−−diag=html:all>lerrors.html

Relatedinformation

5−194 ToolOptions−Linker

Linker:−−error−file

Menuentry −

Commandlinesyntax

−−error−file[=file]

Description Withthisoptionthelinkerredirectserrormessagestoafile. Ifyoudonotspecifyafilename,theerrorfileislkmb.elk.

Example Towriteerrorstoerrors.elkinsteadofstderr,enter: lkmb−−error−file=errors.elktest.obj

Relatedinformation

5−195 MicroBlazeEmbeddedToolsReference

Linker:−−error−limit

Menuentry −

Commandlinesyntax

−−error−limit=number

Description Withthisoptionyoutellthelinkertoonlyemitthespecifiedmaximumnumberoferrors.When0(null)isspecified,thelinker emitsallerrors.Withoutthisoptionthemaximumnumberoferrorsis42.

Relatedinformation

5−196 ToolOptions−Linker

Linker:−−extern(−e)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. Addtheoption−−externtotheAdditionallinkeroptionsfield.

Commandlinesyntax −−extern=symbol −esymbol

Description Withthisoptionyouforcethelinkertoconsiderthegivensymbolasanundefinedreference.Thelinkertriestoresolvethis symbol,eitherthesymbolisdefinedinanobjectfileorthelinkerextractsthecorrespondingsymboldefinitionfromalibrary. Thisoptionis,forexample,usefulifthestartupcodeispartofalibrary.Becauseyourownapplicationdoesnotrefertothe startupcode,youcanforcethestartupcodetobeextractedbyspecifyingthesymbol_STARTasanunresolvedexternal.

Example Considerthefollowinginvocation: lkmbmylib.lib

Nothingislinkedandnooutputfilewillbeproduced,becausetherearenounresolvedsymbolswhenthelinkersearches throughmylib.lib. lkmb−−extern=_STARTmylib.lib

Inthiscasethelinkersearchesforthesymbol_STARTinthelibraryand(iffound)extractstheobjectthatcontains_START,the startupcode.Ifthismodulecontainsnewunresolvedsymbols,thelinkerlooksagaininmylib.lib.Thisprocessrepeatsuntil nonewunresolvedsymbolsarefound.

Relatedinformation

Section6.4,LinkingwithLibraries,inchapterUsingtheLinkeroftheuser’smanual.

5−197 MicroBlazeEmbeddedToolsReference

Linker:−−first−libraryfirst

Menuentry −

Commandlinesyntax −−first−library−first

Description Whenthelinkerprocessesalibraryitsearchesforsymbolsthatarereferencedbytheobjectsandlibrariesprocessedsofar.If thelibrarycontainsadefinitionforanunresolvedreferencethelinkerextractstheobjectthatcontainsthedefinitionfromthe library. Bydefaultthelinkerprocessesobjectfilesandlibrariesintheorderinwhichtheyappearonthecommandline.Ifyouspecifythe option−−first−library−firstthelinkeralwaystriestotakethesymboldefinitionfromthelibrarythatappearsfirstonthe commandlinebeforescanningsubsequentlibraries. Thisisforexampleusefulwhenyouareworkingwithanewerversionofalibrarythatpartiallyoverlapstheolderversion. Becausetheydonotcontainexactlythesamefunctions,youhavetolinkthemboth.However,whenafunctionispresentin bothlibraries,youmaywantthelinkertoextractthemostrecentfunction.

Example Considerthefollowingexample: lkmb−−first−library−firsta.libtest.objb.lib

Ifthefiletest.objcallsafunctionwhichisbothpresentina.libandb.lib,normallythefunctioninb.libwouldbe extracted.Withthisoptionthelinkerfirsttriestoextractthesymbolfromthefirstlibrarya.lib. Notethatroutinesinb.libthatcallotherroutinesthatarepresentinbotha.libandb.libarenowalsoresolvedfrom a.lib.

Relatedinformation

Linkeroption−−no−rescan(Rescanlibrariestosolveunresolvedexternals)

5−198 ToolOptions−Linker

Linker:−−global−type−checking

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. Addtheoption−−global−type−checkingtotheAdditionallinkeroptionsfield.

Commandlinesyntax −−global−type−checking

Description Usethisoptionwhenyouwantthelinkertocheckthetypesofvariableandfunctionreferencesagainsttheirdefinitions,using DWARF2orDWARF3debuginformation. ThischeckshouldgivethesameresultastheCcompilerwhenyouuseMILlinking.

Relatedinformation

5−199 MicroBlazeEmbeddedToolsReference

Linker:−−help(−?)

Menuentry −

Commandlinesyntax

−−help[=options] −?

Description Displaysanoverviewofallcommandlineoptions.Whenyouspecifytheargumentoptionsyoucanlistdetailedoption descriptions.

Example Thefollowinginvocationsalldisplayalistoftheavailablecommandlineoptions: lkmb−? lkmb−−help lkmb

Toseeadetaileddescriptionoftheavailableoptions,enter: lkmb−−help=options

5−200 ToolOptions−Linker

Linker:−−hex−format

Menuentry −

Commandlinesyntax

−−hex−format=flag,... Youcansetthefollowingflag: +/−start−address (s/S) Emitstartaddressrecord Default:−−hex−format=s

Description Withthisoptionyoucanspecifytoemitoromitthestartaddressrecordfromthehexfile.

Relatedinformation

Linkeroption−−output(Outputfile)

5−201 MicroBlazeEmbeddedToolsReference

Linker:−−hex−record−size

Menuentry −

Commandlinesyntax

−−hex−record−size=size Default:32

Description Withthisoptionyoucansetthesize(width)oftheIntelHexdatarecords.

Relatedinformation

Linkeroption−−output(Outputfile) Section7.3,IntelHexRecordFormat,inChapterObjectFileFormats.

5−202 ToolOptions−Linker

Linker:−−import−object

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. AddoneormorefilestotheImportthefollowingdataobjectfilesfield.

Commandlinesyntax −−import−object=file,...

Description Withthisoptionthelinkerimportsabinaryfilecontainingrawdataandplacesitinasection.Thesectionnameisderivedfrom thefilename,inwhichdotsarereplacedbyanunderscore.So,whenimportingafilecalledmy.jpg,asectionwiththename my_jpgiscreated.Inyourapplicationyoucanrefertothecreatedsectionbyusinglinkerlabels.

Relatedinformation

Section6.7,ImportingBinaryFiles.

5−203 MicroBlazeEmbeddedToolsReference

Linker:−−include−directory(−I)

Menuentry −

Commandlinesyntax

−−include−directory=path,... −Ipath,...

Description WiththisoptionyoucanspecifythepathwhereyourLSLincludefilesarelocated.Arelativepathwillberelativetothecurrent directory. TheorderinwhichthelinkersearchesforLSLincludefilesis: 1. ThepathnameintheLSLfileandthedirectorywheretheLSLfileislocated (onlyfor#includefilesthatareenclosedin"") 2. Thepaththatisspecifiedwiththisoption. 3. Thedefaultdirectory$(PRODDIR)\include.lsl.

Example Supposethatyourlinkerscriptfilemylsl.lslcontainsthefollowingline: #include"myinc.inc"

Youcancallthelinkerasfollows: lkmb−−include−directory=c:\proj\include−−lsl−file=mylsl.lsltest.obj

Firstthelinkerlooksinthedirectorywheremylsl.lslislocatedforthefilemyinc.inc.Ifitdoesnotfindthefile,itlooksinthe directoryc:\proj\includeforthefilemyinc.inc(thisoption).Finallyitlooksinthedirectory$(PRODDIR)\include.lsl.

Relatedinformation

5−204 ToolOptions−Linker

Linker:−−incremental(−r)

Menuentry −

Commandlinesyntax −−incremental −r

Description Normallythelinkerlinksandlocatesthespecifiedobjectfiles.Withthisoptionyoutellthelinkeronlytolinkthespecifiedfiles. Thelinkercreatesalinkeroutputfile.out.Youthencanlinkthisfileagainwithotherobjectfilesuntilyouhavereachedthefinal linkeroutputfilethatisreadyforlocating. Inthelastpass,youcallthelinkerwithoutthisoptionwiththefinallinkeroutputfile.out.Thelinkerwillnowlocatethefile.

Example Inthisexample,thefilestest1.obj,test2.objandtest3.objareincrementallylinked: 1. lkmb−−incrementaltest1.objtest2.obj−otest.out test1.objandtest2.objarelinked 2. lkmb−−incrementaltest3.objtest.out test3.objandtest.outarelinked,task1.outiscreated 3. lkmbtask1.out task1.outislocated

Relatedinformation

Section6.5,IncrementalLinkinginchapterUsingtheLinkeroftheuser’smanual.

5−205 MicroBlazeEmbeddedToolsReference

Linker:−−keep−output−files(−k)

Menuentry AltiumDesigneralwaysremovestheoutputfileswhenerrorsoccurred.

Commandlinesyntax −−keep−output−files −k

Description Ifanerroroccursduringlinking,theresultingoutputfilemaybeincompleteorincorrect.Withthisoptionyoukeepthegenerated outputfileswhenanerroroccurs. Bydefaultthelinkerremovesthegeneratedoutputfilewhenanerroroccurs.Thisisusefulwhenyouusethemakeutility.Ifthe erroneousfilesarenotremoved,themakeutilitymayprocesscorruptfilesonasubsequentinvocation. Usethisoptionwhenyoustillwanttousethegeneratedfile.Forexamplewhenyouknowthataparticularerrordoesnotresult inacorruptobjectfile,orwhenyouwanttoinspecttheoutputfile,orsendittoAltiumsupport.

Relatedinformation

5−206 ToolOptions−Linker

Linker:−−library(−l)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectLibraries. 3. EnabletheoptionLinkdefaultClibraries.

Commandlinesyntax −−library=name −lname

Description Withthisoptionyoutellthelinkertousesystemlibraryname.lib,wherenameisastring.Thelinkerfirstsearchesfor systemlibrariesinanydirectoriesspecifiedwith−−library−directory,theninthedirectoriesspecifiedwiththeenvironment variableLIBMB,unlessyouusedtheoption−−ignore−default−library−path.

Example Tosearchinthesystemlibrarycmba.lib(Clibrary): lkmbtest.objmylib.lib−−library=cmba

Thelinkerlinksthefiletest.objandfirstlooksinmylib.lib(inthecurrentdirectoryonly),theninthesystemlibrary cmba.libtoresolveunresolvedsymbols.

Relatedinformation

Linkeroption−−library−directory(Additionalsearchpathforsystemlibraries) Section6.4,LinkingwithLibraries,inchapterUsingtheLinkeroftheuser’smanual.

5−207 MicroBlazeEmbeddedToolsReference

Linker:−−library−directory(−L)/−−ignore−default−library−path

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. OpentheBuildOptionspage. 3. AddapathnameintheLibraryfilespathfield. Ifyouentermultiplepaths,separatethemwithasemicolon(;).

Commandlinesyntax −−library−directory=dir −Ldir −−ignore−default−library−path −L

Description Withthisoptionyoucanspecifythepath(s)whereyoursystemlibraries,specifiedwiththe−−libraryoption,arelocated.Ifyou wanttospecifymultiplepaths,usetheoption−−library−directoryforeachseparatepath. Thedefaultpathis$(PRODDIR)\cmb\lib. Ifyouspecifyonly−L(withoutapathname)orthelongoption−−ignore−default−library−path,thelinkerwillnotsearchthe defaultpathandalsonotinthepathsspecifiedintheenvironmentvariableLIBMB.So,thelinkerignoressteps2and3aslisted below. Thepriorityorderinwhichthelinkersearchesforsystemlibrariesspecifiedwiththe−−libraryoptionis: 1. Thepaththatisspecifiedwiththe−−library−directoryoption. 2. ThepaththatisspecifiedintheenvironmentvariableLIBMB. 3. Thedefaultdirectory$(PRODDIR)\cmb\lib(oraprocessorspecificsub−directory).

Example Supposeyoucallthelinkerasfollows: lkmbtest.obj−−library−directory=c:\mylibs−−library=cmba

Firstthelinkerlooksinthedirectoryc:\mylibsforlibrarycmba.lib(thisoption). Ifitdoesnotfindtherequestedlibraries,itlooksinthedirectorythatissetwiththeenvironmentvariableLIBMB. Thenthelinkerlooksinthedefaultdirectory$(PRODDIR)\cmb\libforlibraries.

Relatedinformation

Linkeroption−−library(Linksystemlibrary) Section6.4.1,HowthelinkersearcheslibrariesinchapterUsingtheLinkeroftheuser’smanual.

5−208 ToolOptions−Linker

Linker:−−link−only

Menuentry −

Commandlinesyntax −−link−only

Description Withthisoptionyousuppressthelocatingphase.Thelinkerstopsafterlinkingandinformsyouaboutunresolvedreferences.

Relatedinformation

Controlprogramoption−cl(Stopafterlinking)

5−209 MicroBlazeEmbeddedToolsReference

Linker:−−lsl−check

Menuentry −

Commandlinesyntax −−lsl−check

Description WiththisoptionthelinkerjustchecksthesyntaxoftheLSLfile(s)andexits.Nolinkingorlocatingisperformed.Usetheoption −−lsl−file=filetospecifythenameoftheLinkerScriptFileyouwanttotest.

Relatedinformation

Linkeroption−−lsl−file(Linkerscriptfile) Linkeroption−−lsl−dump(DumpLSLinfo) Section6.9,ControllingtheLinkerwithaScript,inchapterUsingtheLinkeroftheuser’smanual.

5−210 ToolOptions−Linker

Linker:−−lsl−dump

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. EnabletheoptionDumpprocessorandmemoryinfofromLSLfile.

Commandlinesyntax −−lsl−dump[=file]

Description WiththisoptionyoutellthelinkertodumptheLSLpartofthemapfileinaseparatefile,independentoftheoption−−map−file (generatemapfile).Ifyoudonotspecifyafilename,thefilelktarget.ldfisused.

Relatedinformation

Linkeroption−−map−file−format(Mapfileformatting)

5−211 MicroBlazeEmbeddedToolsReference

Linker:−−lsl−file(−d)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. EnabletheoptionUseprojectspecificLSLfile. 4. IntheLSLfilefield,typeanameorclick...andselectanLSLfile.

Commandlinesyntax −−lsl−file=file −dfile

Description Alinkerscriptfilecontainsvitalinformationaboutthecoreforthelocatingphaseofthelinker.AlinkerscriptfileiscodedinLSL andcontainsthefollowingtypesofinformation: • thearchitecturedefinitiondescribesthecore’shardwarearchitecture. • thememorydefinitiondescribesthephysicalmemoryavailableinthesystem. • thesectionlayoutdefinitiondescribeshowtolocatesectionsinmemory. Withthisoptionyouspecifyalinkerscriptfiletothelinker.Ifyoudonotspecifythisoption,thelinkerusesadefaultscriptfile. Youcanspecifytheexistingfilemb.lslorthenameofamanuallywrittenlinkerscriptfile.Youcanusethisoptionmultiple times.ThelinkerprocessestheLSLfilesintheorderinwhichtheyappearonthecommandline.

Relatedinformation

Linkeroption−−lsl−check(CheckLSLfile(s)andexit) Section6.9,ControllingtheLinkerwithaScript,inchapterUsingtheLinkeroftheuser’smanual.

5−212 ToolOptions−Linker

Linker:−−map−file(−M)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMapFile. 3. EnabletheoptionGenerateamemorymapfile(.map). 4. IntheMapfileformatsection,enableordisabletheinformationyouwanttobeincludedinthemapfile.

Commandlinesyntax −−map−file[=file] −M[file]

Description Withthisoptionyoutellthelinkertogeneratealinkermapfile.Ifyoudonotspecifyafilenameandyouspecfiedthe−ooption, thelinkerusesthesamebasenameastheoutputfilewiththeextension.map.Ifyoudidnotspecifythe−ooption,thelinker usesthefiletask1.map.AltiumDesignernamesthe.mapfileaftertheproject. Alinkermapfileisatextfilethatshowshowthelinkerhasmappedthesectionsandsymbolsfromthevariousobjectfiles (.obj)tothelinkedobjectfile.Alocatepartshowstheabsolutepositionofeachsection.Externalsymbolsarelistedperspace withtheirabsoluteaddress,bothsortedonsymbolandsortedonaddress.

Relatedinformation

Withtheoption−−map−file−format(mapfileformatting)youcanspecifywhichpartsyouwanttoplaceinthemapfile. Section6.2,LinkerMapFileFormat,inChapterListFileFormats.

5−213 MicroBlazeEmbeddedToolsReference

Linker:−−map−file−format(−m)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMapFile. 3. EnabletheoptionGenerateamapfile(.map). 4. IntheMapfileformatsection,enableordisabletheinformationyouwanttobeincludedinthemapfile.

Commandlinesyntax −−map−file−format=flags −mflags Youcanspecifythefollowingformats: 0 Sameas−mcDfikLMNoQrSU(linkinformation) 1 Sameas−mCDfiKlMNoQRSU(locateinformation) 2 Sameas−mcdfiklmNoQrSu(mostinformation) +/−callgraph (c/C) Callgraphinformation +/−removed (d/D) Removedsectionsinformation +/−files (f/F) Processedfilesinformation +/−invocation (i/I) Invocationandtoolinformation +/−link (k/K) Linkresultinformation +/−locate (l/L) Locateresultinformation +/−memory (m/M) Memoryusageinformation +/−nonalloc (n/N) Nonallocinformation +/−overlay (o/O) Overlayinformation +/−statics (q/Q) Modulelocalsymbols +/−crossref (r/R) Crossreferencesinformation +/−lsl (s/S) Processorandmemoryinformation +/−rules (u/U) Locaterules

Description Withthisoptionyouspecifywhichinformationyouwanttoincludeinthemapfile.Usethisoptionincombinationwiththeoption −−map−file(−M). Ifyoudonotspecifythisoption,thelinkerusesthedefault:−−map−file−format=2.

Relatedinformation

Linkeroption−−map−file(Generatemapfile)

5−214 ToolOptions−Linker

Linker:−−misra−c−report

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheCCompilerentryandselectMISRA−C. 3. SelectaMISRA−Cconfiguration. 4. EnabletheoptionProduceaMISRA−Creport.

Commandlinesyntax −−misra−c−report[=file]

Description WiththisoptionyoutellthelinkertocreateaMISRA−CQualityAssurancereport.Thisreportliststhevariousmodulesinthe projectwiththerespectiveMISRA−Csettingsatthetimeofcompilation.Ifyoudonotspecifyafilename,thefilename.mcris used.

Relatedinformation

Compileroption−−misrac

5−215 MicroBlazeEmbeddedToolsReference

Linker:−−munch

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. Addtheoption−−munchtotheAdditionallinkeroptionsfield.

Commandlinesyntax

−−munch

Description Withthisoptionyoutellthelinkertoactivatethemuncherinthepre−locatephase.

Relatedinformation

5−216 ToolOptions−Linker

Linker:−−non−romable

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. Addtheoption−−non−romabletotheAdditionallinkeroptionsfield.

Commandlinesyntax −−non−romable

Description WiththisoptionyoutellthelinkerthattheapplicationmustnotbelocatedinROM.ThelinkerwilllocateallROMsections, includingacopytableifpresent,inRAM.Whentheapplicationisstarted,thedatasectionsarere−initializedandtheBSS sectionsareclearedasusual. Thisoptionis,forexample,usefulwhenyouwanttotesttheapplicationinRAMbeforeyouputthefinalapplicationinROM.This savesyouthetimeofflashingtheapplicationinROMoverandoveragain.

Relatedinformation

5−217 MicroBlazeEmbeddedToolsReference

Linker:−−no−rescan

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectLibraries. 3. DisabletheoptionRescanlibrariestosolveunresolvedexternals.

Commandlinesyntax −−no−rescan

Description Whenthelinkerprocessesalibraryitsearchesforsymboldefinitionsthatarereferencedbytheobjectsandlibrariesprocessed sofar.Ifthelibrarycontainsadefinitionforanunresolvedreferencethelinkerextractstheobjectthatcontainsthedefinitionfrom thelibrary.Thelinkerprocessesobjectfilesandlibrariesintheorderinwhichtheyappearonthecommandline. Whenallobjectsandlibrariesareprocessedthelinkerchecksifthereareunresolvedsymbolsleft.Ifso,thedefaultbehaviorof thelinkeristorescanalllibrariesintheordergivenatthecommandline.Thelinkerstopsrescanningthelibrarieswhenall symbolsareresolved,orwhenthelinkercouldnotresolveanysymbol(s)duringtherescanofalllibraries.Noticethatresolving onesymbolmayintroducenewunresolvedsymbols. Withthisoption,youtellthelinkertoscantheobjectfilesandlibrariesonlyonce.Whenthelinkerhasnotresolvedallsymbols afterthefirstscan,itreportswhichsymbolsarestillunresolved.Thisoptionisusefulifyouarebuildingyourownlibraries.The librariesaremostefficientlyorganizedifthelinkerneedsonlyonepasstoresolveallsymbols.

Relatedinformation

Linkeroption−−first−library−first(Scanlibrariesingivenorder)

5−218 ToolOptions−Linker

Linker:−−no−rom−copy(−N)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. Addtheoption−−no−rom−copytotheAdditionallinkeroptionsfield.

Commandlinesyntax −−no−rom−copy −N

Description WiththisoptionthelinkerwillnotgenerateaROMcopyfordatasections.Acopytableisgeneratedandcontainsentriesto clearBSSsection.However,noentriestocopydatasectionsfromROMtoRAMareplacedinthecopytable. Thedatasectionsareinitializedwhentheapplicationisdownloaded.Thedatasectionsarenotre−initializedwhenthe applicationisrestarted.

Relatedinformation

5−219 MicroBlazeEmbeddedToolsReference

Linker:−−no−warnings(−w)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectDiagnostics. 3. SetErrorreportingtooneofthefollowingvalues: • Reportallwarnings • Suppressallwarnings • Suppressspecificwarnings. IfyouselectSuppressspecificwarnings: 4. Enterthenumbers,separatedbycommas,ofthewarningsyouwanttosuppress.

Commandlinesyntax −−no−warnings[=number,...] −w[number,...]

Description Withthisoptionyoucansuppressesallwarningmessagesorspecificwarningmessages. • Ifyoudonotspecifythisoption,allwarningsarereported. • Ifyouspecifythisoptionbutwithoutnumbers,allwarningsaresuppressed. • Ifyouspecifythisoptionwithanumber,onlythespecifiedwarningissuppressed.Youcanspecifytheoption −−no−warnings=numbermultipletimes. Example Tosuppresswarnings135and136,enter135,136intheSpecificwarningstosuppressfield,orenterthefollowingonthe commandline: lkmb−−no−warnings=135,136test.obj

Relatedinformation

Linkeroption−−warnings−as−errors(Treatwarningsaserrors)

5−220 ToolOptions−Linker

Linker:−−optimize(−O)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectOptimization. 3. SelectanoptimizationlevelintheOptimizationlevelbox. IfyouselectCustomOptimization: 4. Enabletheoptimizationsyouwant.

Commandlinesyntax

−−optimize[=flags] −O[flags] Usethefollowingoptionsforpredefinedsetsofflags: −−optimize=0 (−O0) Nooptimization Aliasfor:−OCDLTXYZ −−optimize=1 (−O1) Defaultoptimization Aliasfor:−OcDLtXYZ −−optimize=2 (−O2) Alloptimizations Aliasfor:−Ocdltxyz Youcansetthefollowingflags: +/−delete−unreferenced−sections (c/C) Deleteunreferencedsectionsfromtheoutputfile +/−shrink−dynamic−sections (d/D) Removezero−valuedimmediateprefixes +/−first−fit−decreasing (l/L) Usea’firstfitdecreasing’algorithmtolocate unrestrictedsectionsinmemory. +/−copytable−compression (t/T) Emitsmartrestrictionstoreducecopytablesize +/−delete−duplicate−code (x/X) Deleteduplicatecodesectionsfromtheoutputfile +/−delete−duplicate−data (y/Y) Deleteduplicateconstantdatafromtheoutputfile +/−copytable−item−compression (z/Z) TrytocompressROMsectionsofcopytableitems

Description Withthisoptionyoucancontrolthelevelofoptimizationthelinkerperforms.Ifyoudonotusethisoption,−−optimize=1isthe default.

Relatedinformation

Section6.8,LinkerOptimizations,inchapterUsingtheLinkeroftheuser’smanual.

5−221 MicroBlazeEmbeddedToolsReference

Linker:−−option−file(−f)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. Addtheoption−−option−filetotheAdditionallinkeroptionsfield. Beawarethattheoptionsintheoptionfileareaddedtothelinkeroptionsyouhavesetintheotherdialogs.Onlyin extraordinarycasesyoumaywanttousethemincombination.AltiumDesignerautomaticallysavestheoptionswithyour project.

Commandlinesyntax −−option−file=file −ffile

Description

Thisoptionisprimarilyintendedforcommandlineuse.Insteadoftypingalloptionsonthecommandline,youcancreatean optionfilewhichcontainsalloptionsandflagsyouwanttospecify.Withthisoptionyouspecifytheoptionfiletothelinker. Useanoptionfilewhenthelengthofthecommandlinewouldexceedthelimitsoftheoperatingsystem,orjusttostoreoptions andsavetyping. Youcanspecifytheoption−−option−filemultipletimes. Formatofanoptionfile • Multipleargumentsononelineintheoptionfileareallowed. • Toincludewhitespaceinanargument,surroundtheargumentwithsingleordoublequotes. • Ifyouwanttousesinglequotesaspartoftheargument,surroundtheargumentbydoublequotesandviseversa: "Thishasasinglequote’embedded" ’Thishasadoublequote"embedded’ ’Thishasadoublequote"andasinglequote’"’embedded" • Whenatextlinereachesitslengthlimit,usea\tocontinuetheline.Whitespacebetweenquotesispreserved. "Thisisacontinuation\ line"

−>"Thisisacontinuationline" • Itispossibletonestcommandlinefilesupto25levels. Example Supposethefilemyoptionscontainsthefollowinglines: −Mmymap(generateamapfile) test.obj(inputfile) −Lc:\mylibs(additionalsearchpathforsystemlibraries) Specifytheoptionfiletothelinker: lkmb−−option−file=myoptions

Thisisequivalenttothefollowingcommandline: lkmb−Mmymaptest.obj−Lc:\mylibs

Relatedinformation

5−222 ToolOptions−Linker

Linker:−−output(−o)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectOutputFormat. 3. Enableoneormoreoutputformats

Commandlinesyntax −−output=[filename][:format[:addr_size]]... −o[filename][:format[:addr_size]]... Youcanspecifythefollowingformats: ELF ELF/DWARF IHEX IntelHex SREC MotorolaS−records

Description Bydefault,thelinkergeneratesanoutputfileinELF/DWARFformat,namedafterthefirstinputfilewithextension.abs. Withthisoptionyoucanspecifyanalternativefilename,andanalternativeoutputformat.Thedefaultoutputformatistheformat ofthefirstinputfile. Youcanusethe−−outputoptionmultipletimes.Thisisusefultogeneratemultipleoutputformats.Withthefirstoccurrenceof the−−outputoptionyouspecifythebasename(thefilenamewithoutextension),whichisusedforsubsequent−−output optionswithnofilenamespecified.Ifyoudonotspecifyafilename,oryoudonotspecifythe−−outputoptionatall,thelinker usesthedefaultbasenametaskn.

IHEXandSRECformats IfyouspecifytheIntelHexformatortheMotorolaS−recordsformat,youcanusetheargumentaddr_sizetospecifythesizeof addressesinbytes(recordlength).ForIntelHexyoucanusethevalues:1,2,and4(default).ForMotorolaS−recordsyoucan specify:2(S1records),3(S2records)or4bytes(S3records,default). Thenameoftheoutputfilewillbefilenamewiththeextension.hexor.sreandcontainsthecodeanddataallocatedinthe defaultaddressspace.Iftheyexist,anyotheraddressspacesarealsoemittedwhereastheiroutputfilesarenamed filename_spacename.hex(.sre).

Useoption−−chip−output(−c)tocreateIntelHexorMotorolaS−recordoutputfilesforeachchipdefinedintheLSLfile (suitableforloadingintoaPROM−programmer).

Example Tocreatetheoutputfilemyfile.hexofthedefaultaddressspace: lkmbtest.obj−−output=myfile.hex:IHEX

Iftheyexist,anyotheraddressspacesareemittedaswellandarenamedmyfile_spacename.hex.

Relatedinformation

Linkeroption−−chip−output(Generateanoutputfileforeachchip)

5−223 MicroBlazeEmbeddedToolsReference

Linker:−−print−mangled−symbols(−P)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. Addtheoption−−print−mangled−symbolstotheAdditionallinkeroptionsfield.

Commandlinesyntax −−print−mangled−symbols −P

Description C++compilersgenerateunreadablesymbolnames.ThesesymbolscannoteasilyberelatedtoyourC++sourcefileanymore. ThereforethelinkerwillbydefaultdecodethesesymbolsconformtheIA64ABIwhenprintedtostdout.Withthisoptionyou canoverridethisdefaultsettingandprintthemanglednamesinstead.

Relatedinformation

5−224 ToolOptions−Linker

Linker:−−strip−debug(−S)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. DisabletheoptionIncludesymbolicdebuginformation.

Commandlinesyntax −−strip−debug −S

Description Withthisoptionyouspecifynottoincludesymbolicdebuginformationintheresultingoutputfile.

Relatedinformation

5−225 MicroBlazeEmbeddedToolsReference

Linker:−−user−provided−initialization−code(−i)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. Addtheoption−−user−provided−initialization−codetotheAdditionallinkeroptionsfield.

Commandlinesyntax −−user−provided−initialization−code −i

Description Itispossibletouseyourowninitializationcode,forexample,tosaveROMspace.Withthisoptionyoutellthelinkernotto generateacopytableforinitialize/clearsections.Uselinkerlabelsinyoursourcecodetoaccessthepositionsofthesections whenlocated. IfthelinkerdetectsreferencestotheTASKINGinitializationcode,anerrorisemitted:itiseithertheTASKINGinitialization routineoryourown,notboth. Notethattheoptions−−no−rom−copyand−−non−romable,mayvaryindependently.The’copytable−compression’ optimization(−−optimize=t)isautomaticallydisabledwhenyouenablethisoption.

Relatedinformation

5−226 ToolOptions−Linker

Linker:−−verbose(−v)/−−extra−verbose(−vv)

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectMiscellaneous. 3. Addtheoption−−verboseor−−extra−verbosetotheAdditionallinkeroptionsfield.

Commandlinesyntax −−verbose/−−extra−verbose −v/−vv

Description Withthisoptionyouputthelinkerinverbosemode.Thelinkerprintsthelinkphaseswhileitprocessesthefiles.Intheextra verbosemode,thelinkeralsoprintsthefilenamesanditshowswhichobjectsareextractedfromlibraries.Withthisoptionyou canmonitorthecurrentstatusofthelinker.

Relatedinformation

5−227 MicroBlazeEmbeddedToolsReference

Linker:−−version(−V)

Menuentry −

Commandlinesyntax −−version −V

Description Displayversioninformation.Thelinkerignoresallotheroptionsorinputfiles.

Relatedinformation

5−228 ToolOptions−Linker

Linker:−−warnings−as−errors

Menuentry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. ExpandtheLinkerentryandselectDiagnostics. 3. EnabletheoptionTreatwarningsaserrors.

Commandlinesyntax −−warnings−as−errors[=number,...]

Description Whenthelinkerdetectsanerrororwarning,ittriestocontinuethelinkprocessandreportsothererrorsandwarnings.When youusethisoptionwithoutarguments,youtellthelinkertotreatallwarningsaserrors.Thismeansthattheexitstatusofthe linkerwillbenon−zeroafterthedetectionofoneormorelinkerwarnings.Asaconsequence,thelinkerwillnotproduceany outputfiles. Youcanalsolimitthisoptiontospecificwarningsbyspecifyingacomma−separatedlistofwarningnumbers.

Relatedinformation

Linkeroption−−no−warnings(Suppresssomeorallwarnings)

5−229 MicroBlazeEmbeddedToolsReference

5.5 ControlProgramOptions

Thecontrolprogramisatooltofacilitateuseofthetoolsetfromthecommandline.Thereforeyoucanonlycallthecontrol programfromthecommandline.Theinvocationsyntaxis: ccmb[option]...[file]...

Options Thecontrolprogramprocessescommandlineoptionseitherbyitself,or,whentheoptionisunknowntothecontrolprogram,it lookswhetheritcanpasstheoptiontooneoftheothertools.However,fordirectlypassinganoptiontotheC++compiler,C compiler,assemblerorlinker,itisrecommendedtousethecontrolprogramoptions−−pass−c++,−−pass−c, −−pass−assembler,−−pass−linker.

Shortandlongoptionnames Optionscanhavebothshortandlongnames.Shortoptionnamesalwaysbeginwithasingleminus(−)character,longoption namesalwaysbeginwithdoubleminus(−−)characters.Youcanabbreviatelongoptionnamesaslongasthenameisunique. Youcanmixshortandlongoptionnamesonthecommandline. Optionscanhaveflagsorsub−options.Toswitchaflag’on’,usealowercaseletterora+longflag.Toswitchaflagoff,usean uppercaseletterora−longflag.Separatelongflagswithcommas.Thefollowingtwoinvocationsareequivalent: ccmb−Wc−Oactest.c ccmb−−pass−c=−−optimize=+coalescer,+csetest.c

Whenyoudonotspecifyanoption,adefaultvaluemaybecomeactive.

5−230 ToolOptions−ControlProgram

ControlProgram:−−address−size

Commandlinesyntax −−address−size=addr_size

Description

IfyouspecifyIHEXorSRECwiththecontroloption−−format,youcanadditionallyspecifytherecordlengthtobeemittedinthe outputfiles. Withthisoptionyoucanspecifythesizeofaddressesinbytes(recordlength).ForIntelHexyoucanusethevalues:1,2,and4 (default).ForMotorolaS−recordsyoucanspecify:2(S1records),3(S2records)or4bytes(S3records,default). Ifyoudonotspecifyaddr_size,thedefaultaddresssizeisgenerated.

Example TocreatetheSRECfiletest.srewithS1records,type: ccmb−−format=SREC−−address−size=2test.c

Relatedinformation

Controlprogramoption−−format(Setlinkeroutputformat) Linkeroption−−output(Specifyanoutputobjectfile)

5−231 MicroBlazeEmbeddedToolsReference

ControlProgram:−−check

Commandlinesyntax

−−check

Description Withthisoptionyoucancheckthesourcecodeforsyntaxerrors,withoutgeneratingcode.Thissavestimeindevelopingyour application. Thecompiler/assemblerreportsanywarningsand/orerrors.

Relatedinformation

Ccompileroption−−check(Checksyntax)

Assembleroption−−check(Checksyntax)

5−232 ToolOptions−ControlProgram

ControlProgram:−−create(−cc/−cl/−cm/−co/−cs)

Commandlinesyntax −−create[=stage] −c[stage] Youcanspecifythefollowingstages(ifyouomitthestage,thedefaultis−−create=object): intermediate−c (c) StopafterC++filesarecompiledtointermediateCfiles(.ic) relocatable (l) Stopafterthefilesarelinkedtoalinkerobjectfile(.out) mil (m) StopafterCfilesarecompiledtoMIL(.mil) object (o) Stopafterthefilesareassembledtoobjects(.obj) assembly (s) StopafterCfilesarecompiledtoassembly(.src)

Description Normallythecontrolprogramgeneratesanabsoluteobjectfileofthespecifiedoutputformatfromthefileyousuppliedasinput. Withthisoptionyoutellthecontrolprogramtostopafteracertainnumberofphases.

Relatedinformation

Linkeroption−−link−only(Linkonly,nolocating)

5−233 MicroBlazeEmbeddedToolsReference

ControlProgram:−−debug−info(−g)

Commandlinesyntax −−debug−info −g

Description

Withthisoptionyoutellthecontrolprogramtoincludedebuginformationinthegeneratedobjectfile.

Relatedinformation

5−234 ToolOptions−ControlProgram

ControlProgram:−−define(−D)

Commandlinesyntax −−define=macro_name[=macro_definition] −Dmacro_name[=macro_definition]

Description

Withthisoptionyoucandefineamacroandspecifyittothepreprocessor.Ifyouonlyspecifyamacroname(nomacro definition),themacroexpandsas’1’. Youcanspecifyasmanymacrosasyoulike.Onthecommandline,usetheoption−−definemultipletimes.Ifthecommandline exceedsthelengthlimitoftheoperatingsystem,youcandefinethemacrosinanoptionfilewhichyouthenmustspecifytothe controlprogramwiththeoption−−option−file=file(−f). Definingmacroswiththisoption(insteadofintheCsource)is,forexample,usefultocompileorassembleconditionalsourceas shownintheexamplebelow. Thecontrolprogrampassestheoption−−define(−D)tothecompilerandtheassembler.

Example ConsiderthefollowingCprogramwithconditionalcodetocompileademoprogramandarealprogram: voidmain(void) { #ifDEMO==1 demo_func();/*compileforthedemoprogram*/ #else real_func();/*compilefortherealprogram*/ #endif }

YoucannowuseamacrodefinitiontosettheDEMOflag.Withthecontrolprogramthislooksasfollows: ccmb−−define=DEMOtest.c ccmb−−define=DEMO=1test.c

Notethatbothinvocationshavethesameeffect. Thenextexampleshowshowtodefineamacrowitharguments.Notethatthemacronameanddefinitionareplacedbetween doublequotesbecauseotherwisethespaceswouldindicateanewoption. ccmb−D"MAX(A,B)=((A)>(B)?(A):(B))"test.c

Relatedinformation

ControlProgramoption−−undefine(Undefinepreprocessormacro) ControlProgramoption−−option−file(Readoptionsfromfile)

5−235 MicroBlazeEmbeddedToolsReference

ControlProgram:−−dep−file

Commandlinesyntax −−dep−file[=file]

Description

WiththisoptionyoutellthecompilertogeneratedependencylinesthatcanbeusedinaMakefile.Incontrasttotheoption −−preprocess=+make,thedependencyinformationwillbegeneratedinadditiontothenormaloutputfile. Bydefault,theinformationiswrittentoafilewithextension.d(oneforeveryinputfile).Whenyouspecifyafilename,all dependencieswillbecombinedinthespecifiedfile.

Example ccmb−−dep−file=test.dep−ttest.c

Thecompilercompilesthefiletest.c,whichresultsintheoutputfiletest.src,andgeneratesdependencylinesinthefile test.dep.

Relatedinformation

Controlprogramoption−−preprocess=+make(Generatedependenciesformake)

5−236 ToolOptions−ControlProgram

ControlProgram:−−diag

Commandlinesyntax −−diag=[format:]{all|nr,...]

Description

Withthisoptionyoucanaskforanextendeddescriptionoferrormessagesintheformatyouchoose.Theoutputisdirectedto stdout(normallyyourscreen)andintheformatyouspecify.Youcanspecifythefollowingformats:html,rtfortext(default). Tocreateafilewiththedescriptions,youmustredirecttheoutput. Withthesuboptionall,thedescriptionsofallerrormessagesaregiven.Ifyouwantthedescriptionofoneormoreselectederror messages,youcanspecifytheerrormessagenumbers,separatedbycommas. Withthisoptionthecontrolprogramdoesnotprocessanyfiles.

Example Todisplayanexplanationofmessagenumber103,enter: ccmb−−diag=103

Thisresultsinmessage103withexplanation. TowriteanexplanationofallerrorsandwarningsinHTMLformattofileccerrors.html,enter: ccmb−−diag=html:all>ccerrors.html

Relatedinformation

5−237 MicroBlazeEmbeddedToolsReference

ControlProgram:−−dry−run(−n)

Commandlinesyntax −−dry−run −n

Description

Withthisoptionyouputthecontrolprogramverbosemode.Thecontrolprogramprintstheinvocationsofthetoolsitwoulduse toprocessthefileswithoutactuallyperformingthesteps.

Relatedinformation

ControlProgramoption−−verbose(−v)(Verboseoutput)

5−238 ToolOptions−ControlProgram

ControlProgram:−−error−file

Commandlinesyntax −−error−file

Description

Withthisoptionthecontrolprogramtellsthecompiler,assemblerandlinkertoredirecterrormessagestoafile. Theerrorfilewillbenamedaftertheinputfilewithextension.err(forcompiler)or.ers(forassembler).Forthelinker,the errorfileislkmb.elk.

Example Towriteerrorstoerrorfilesinsteadofstderr,enter: ccmb−−error−file−ttest.c

Relatedinformation

ControlProgramoption−−warnings−as−errors(Treatwarningsaserrors)

5−239 MicroBlazeEmbeddedToolsReference

ControlProgram:−−exceptions

Commandlinesyntax −−exceptions

Description

WiththisoptionyouenablesupportforexceptionhandlingintheC++compiler.

Relatedinformation

5−240 ToolOptions−ControlProgram

ControlProgram:−−force−c

Commandlinesyntax −−force−c

Description

Withthisoptionyoutellthecontrolprogramtotreatall.ccfilesasCfilesinsteadofC++files.Thismeansthatthecontrol programdoesnotcalltheC++compilerandforcesthelinkertolinkClibraries.

Relatedinformation

Controlprogramoption−−force−c++(ForceC++compilationandlinking)

5−241 MicroBlazeEmbeddedToolsReference

ControlProgram:−−force−c++

Commandlinesyntax −−force−c++

Description

Withthisoptionyoutellthecontrolprogramtotreatall.cfilesasC++filesinsteadofCfiles.Thismeansthatthecontrol programcallstheC++compilerpriortotheCcompilerandforcesthelinkertolinkC++libraries.

Relatedinformation

Controlprogramoption−−force−c(TreatC++filesasCfiles)

5−242 ToolOptions−ControlProgram

ControlProgram:−−force−munch

Commandlinesyntax −−force−munch

Description

Withthisoptionyouforcethecontrolprogramtoactivatethemuncherinthepre−locatephase.

Relatedinformation

5−243 MicroBlazeEmbeddedToolsReference

ControlProgram:−−format

Commandlinesyntax −−format=format Youcanspecifythefollowingformats: IEEE IEEE−695 ELF ELF/DWARF IHEX IntelHex SREC MotorolaS−records

Description Withthisoptionyouspecifytheoutputformatfortheresulting(absolute)objectfile.ThedefaultoutputformatisELF/DWARF, whichcandirectlybeusedbythedebugger. IfyouchooseIHEXorSREC,youcanadditionallyspecifytheaddresssizeofthechosenformat(option−−address−size).

Example TogenerateanMotorolaS−recordoutputfile: ccmb−−format=SRECtest1.ctest2.c−−output=test.sre

Relatedinformation

Controlprogramoption−−address−size(SetaddresssizeforlinkerIHEX/SRECfiles) Linkeroption−−output(Specifyanoutputobjectfile) Linkeroption−−chip−output(Generatehexfileforeachchip)

5−244 ToolOptions−ControlProgram

ControlProgram:−−global−type−checking

Commandlinesyntax −−global−type−checking

Description

TheCcompileralreadyperformstypecheckingwithineachmodule.Usethisoptionwhenyouwantthelinkertoperformtype checkingbetweenmodules.

Relatedinformation

Ccompileroption−−global−type−checking(Globaltypechecking)

5−245 MicroBlazeEmbeddedToolsReference

ControlProgram:−−help(−?)

Commandlinesyntax −−help[=options] −?

Description

Displaysanoverviewofallcommandlineoptions.Whenyouspecifytheargumentoptionsyoucanlistdetailedoption descriptions.

Example Thefollowinginvocationsalldisplayalistoftheavailablecommandlineoptions: ccmb−? ccmb−−help ccmb

Toseeadetaileddescriptionoftheavailableoptions,enter: ccmb−−help=options

5−246 ToolOptions−ControlProgram

ControlProgram:−−include−directory(−I)

Commandlinesyntax −−include−directory=path,... −Ipath,...

Description

Withthisoptionyoucanspecifythepathwhereyourincludefilesarelocated.Arelativepathwillberelativetothecurrent directory.

Example SupposethattheCsourcefiletest.ccontainsthefollowinglines: #include #include"myinc.h"

Youcancallthecontrolprogramasfollows: ccmb−−include−directory=myincludetest.c

Firstthecompilerlooksforthefilestdio.hinthedirectorymyincluderelativetothecurrentdirectory.Ifitwasnotfound,the compilersearchesintheenvironmentvariableandtheninthedefaultincludedirectory. Thecompilernowlooksforthefilemyinc.h,inthedirectorywheretest.cislocated.Ifthefileisnottherethecompiler searchesinthedirectorymyinclude.Ifitwasstillnotfound,thecompilersearchesintheenvironmentvariableandtheninthe defaultincludedirectory.

Relatedinformation

Ccompileroption−−include−directory(Adddirectorytoincludefilesearchpath) Ccompileroption−−include−file(Includefileatthestartofacompilation) Section2.4,HowtheCompilerSearchesIncludeFiles,inchapterUsingtheCompileroftheuser’smanual.

5−247 MicroBlazeEmbeddedToolsReference

ControlProgram:−−instantiate

Commandlinesyntax −−instantiate=mode Youcanspecifythefollowingmodes: used(default) all local

Description Controlinstantiationofexternaltemplateentities.Externaltemplateentitiesareexternal(thatis,non−inlineandnon−static) templatefunctionsandtemplatestaticdatamembers.Theinstantiationmodedeterminesthetemplateentitiesforwhichcode shouldbegeneratedbasedonthetemplatedefinition.Normally,whenafileiscompiled,templateentitiesareinstantiated wherevertheyareused(thelinkerwilldiscardduplicatedefinitions).Theoverallinstantiationmodecan,however,bechanged withthisoption.Youcanspecifythefollowingmodes: used Instantiatethosetemplateentitiesthatwereusedinthecompilation.Thiswillincludeallstaticdatamembersfor whichtherearetemplatedefinitions.Thisisthedefault. all Instantiatealltemplateentitiesdeclaredorreferencedinthecompilationunit.Foreachfullyinstantiatedtemplate class,allofitsmemberfunctionsandstaticdatamemberswillbeinstantiatedwhetherornottheywereused. Non−membertemplatefunctionswillbeinstantiatedeveniftheonlyreferencewasadeclaration. local Similarto−−instantiate=usedexceptthatthefunctionsaregiveninternallinkage.Thisisintendedtoprovidea verysimplemechanismforthosegettingstartedwithtemplates.Thecompilerwillinstantiatethefunctionsthatare usedineachcompilationunitaslocalfunctions,andtheprogramwilllinkandruncorrectly(barringproblemsdue tomultiplecopiesoflocalstaticvariables).However,onemayendupwithmanycopiesoftheinstantiated functions,sothisisnotsuitableforproductionuse. Youcannotuse−−instantiate=localinconjunctionwithautomatictemplateinstantiation.

Relatedinformation

Controlprogramoption−−no−auto−instantiation(DisableautomaticC++instantiation) Section2.6,TemplateInstantiationinchapterC++Language.

5−248 ToolOptions−ControlProgram

ControlProgram:−−io−streams

Commandlinesyntax −−io−streams

Description

AsI/Ostreamsrequiresubstantialresourcestheyaredisabledbydefault.UsethisoptiontoenableI/Ostreamssupportinthe C++library. Thisoptionalsoenablesexceptionhandling.

Relatedinformation

5−249 MicroBlazeEmbeddedToolsReference

ControlProgram:−−iso

Commandlinesyntax −−iso={90|99}

Description

WiththisoptionyouspecifytothecontrolprogramagainstwhichISOstandarditshouldcheckyourCsource.C90isalso referredtoasthe"ANSICstandard".C99referstothenewerISO/IEC9899:1999(E)standardandisthedefault.

IndependantofthechosenISOstandard,thecontrolprogramalwayslinkslibrarieswithC99support.

Example Tocompilethefiletest.cconformtheISOC90standard: ccmb−−iso=90test.c

Relatedinformation

Ccompileroption−−iso(ISOCstandard)

5−250 ToolOptions−ControlProgram

ControlProgram:−−keep−output−files(−k)

Commandlinesyntax −−keep−output−files −k

Description

Ifanerroroccursduringthecompilation,assemblingorlinkingprocess,theresultingoutputfilemaybeincompleteorincorrect. Withthisoptionyoukeepthegeneratedoutputfileswhenanerroroccurs. Bydefaultthecontrolprogramremovesgeneratedoutputfileswhenanerroroccurs.Thisisusefulwhenyouusethemake utility.Iftheerroneousfilesarenotremoved,themakeutilitymayprocesscorruptfilesonasubsequentinvocation. Usethisoptionwhenyoustillwanttousethegeneratedfiles.Forexamplewhenyouknowthataparticularerrordoesnotresult inacorruptfile,orwhenyouwanttoinspecttheoutputfile,orsendittoAltiumsupport.

Relatedinformation

5−251 MicroBlazeEmbeddedToolsReference

ControlProgram:−−keep−temporary−files(−t)

MenuEntry 1. FromtheProjectmenu,selectProjectOptions... TheProjectOptionsdialogboxappears. 2. SelectBuildOptions. 3. EnabletheoptionKeeptemporaryfilesthataregeneratedduringacompile.

Commandlinesyntax −−keep−temporary−files −t

Description Bydefault,thecontrolprogramremovesintermediatefileslikethe.srcfile(resultofthecompilerphase)andthe.objfile (resultoftheassemblerphase). Withthisoptionyoutellthecontrolprogramtokeeptemporaryfilesitgeneratesduringthecreationoftheabsoluteobjectfile.

Relatedinformation

5−252 ToolOptions−ControlProgram

ControlProgram:−−library(−l)

Commandlinesyntax −−library=name −lname

Description

Withthisoptionyoutellthelinkerviathecontrolprogramtousesystemlibraryname.lib,wherenameisastring.The linkerfirstsearchesforsystemlibrariesinanydirectoriesspecifiedwith−−library−directory,theninthedirectoriesspecified withtheenvironmentvariableLIBMB,unlessyouusedtheoption−−ignore−default−library−path.

Example Tosearchinthesystemlibrarycmba.lib(Clibrary): ccmbtest.objmylib.lib−−library=cmba

Thelinkerlinksthefiletest.objandfirstlooksinmylib.lib(inthecurrentdirectoryonly),theninthesystemlibrary cmba.libtoresolveunresolvedsymbols.

Relatedinformation

Linkeroption−−library−directory(Additionalsearchpathforsystemlibraries) Section6.4,LinkingwithLibraries,inchapterUsingtheLinkeroftheuser’smanual.

5−253 MicroBlazeEmbeddedToolsReference

ControlProgram:−−library−directory(−L)/−−ignore−default−library−path

Commandlinesyntax −−library−directory=dir −Ldir −−ignore−default−library−path −L

Description Withthisoptionyoucanspecifythepath(s)whereyoursystemlibraries,specifiedwiththe−−libraryoption,arelocated.Ifyou wanttospecifymultiplepaths,usetheoption−−library−directoryforeachseparatepath. Bydefaultpaththisis$(PRODDIR)\cmb\libdirectory. Ifyouspecifyonly−L(withoutapathname)orthelongoption−−ignore−default−library−path,thelinkerwillnotsearchthe defaultpathandalsonotinthepathsspecifiedintheenvironmentvariableLIBMB.So,thelinkerignoressteps2and3aslisted below. Thepriorityorderinwhichthelinkersearchesforsystemlibrariesspecifiedwiththe−−libraryoptionis: 1. Thepaththatisspecifiedwiththe−−library−directoryoption. 2. ThepaththatisspecifiedintheenvironmentvariableLIBMB. 3. Thedefaultdirectory$(PRODDIR)\cmb\lib(oraprocessorspecificsub−directory).

Example Supposeyoucallthecontrolprogramasfollows: ccmbtest.c−−library−directory=c:\mylibs−−library=cmba

Firstthelinkerlooksinthedirectoryc:\mylibsforlibrarycmba.lib(thisoption). Ifitdoesnotfindtherequestedlibraries,itlooksinthedirectorythatissetwiththeenvironmentvariableLIBMB. Thenthelinkerlooksinthedefaultdirectory$(PRODDIR)\cmb\libforlibraries.

Relatedinformation

Linkeroption−−library(Linksystemlibrary)

5−254 ToolOptions−ControlProgram

ControlProgram:−−list−files

Commandlinesyntax −−list−files[=name]

Description

Withthisoptionyoutelltheassemblerviathecontrolprogrammatogeneratealistfileforeachspecifiedinputfile.Alistfile showsthegeneratedobjectcodeandtherelativeaddresses.Notethattheassemblergeneratesarelocatableobjectfilewith relativeaddresses. Withnameyoucanspecifyanameforthelistfile.Thisisonlypossibleifyouspecifyonlyoneinputfiletothecontrol program.Ifyoudonotspecifyname,oryouspecifymorethanoneinputfiles,thecontrolprogramnamesthegeneratedlist file(s)afterthespecifiedinputfile(s)withextension.lst.

Example Thisexamplegeneratesthelistfiles1.lstand2.lstfor1.cand2.c.Ifinthisexamplealsoanamehadbeenspecified,it wouldbeignoredbecausetwoinputfilesarespecified. ccmb1.c2.c−−list−files

Relatedinformation

Assembleroption−−list−file(Generatelistfile) Assembleroption−−list−format(Listfileformattingoptions)

5−255 MicroBlazeEmbeddedToolsReference

ControlProgram:−−lsl−file(−d)

Commandlinesyntax −−lsl−file=file,... −dfile,...

Description

Alinkerscriptfilecontainsvitalinformationaboutthecoreforthelocatingphaseofthelinker.AlinkerscriptfileiscodedinLSL andcontainsthefollowingtypesofinformation: • thearchitectureandderivativedefinitiondescribethecore’shardwarearchitectureanditsinternalmemory. • theboardspecificationdescribesthephysicalmemoryavailableinthesystem. • thesectionlayoutdefinitiondescribeshowtolocatesectionsinmemory. Withthisoptionyouspecifyalinkerscriptfileviathecontrolprogramtothelinker.Ifyoudonotspecifythisoption,thelinker doesnotuseascriptfile.Youcanspecifytheexistingfilemb.lslorthenameofamanuallywrittenlinkerscriptfile.Youcan usethisoptionmultipletimes.ThelinkerprocessestheLSLfilesintheorderinwhichtheyappearonthecommandline.

Relatedinformation

Section6.9,ControllingtheLinkerwithaScript,inchapterUsingtheLinkeroftheuser’smanual.

5−256 ToolOptions−ControlProgram

ControlProgram:−−make−target

Commandlinesyntax −−make−target=name

Description

Withthisoptionyoucanoverrulethedefaulttargetnameinthemakedependenciesgeneratedbytheoptions −−preprocess=+make(−Em)and−−dep−file.Thedefaulttargetnameisthebasenameoftheinputfile,withextension.obj.

Example ccmb−−preprocess=+make−−make−target=../mytarget.objtest.c

Thecompilergeneratesdependencylineswiththedefaulttargetname../mytarget.objinsteadoftest.obj.

Relatedinformation

Controlprogramoption−−preprocess=+make(Generatedependenciesformake) Controlprogramoption−−dep−file(Generatedependenciesinafile)

5−257 MicroBlazeEmbeddedToolsReference

ControlProgram:−−mil−link/−−mil−split

Commandlinesyntax −−mil−link −−mil−split

Description

Withoption−−mil−linktheCcompilerlinkstheoptimizedintermediaterepresentation(MIL)ofallinputfilesandMILlibraries specifiedonthecommandlineinthecompiler.Theresultisonesinglemodulethatisoptimizedanothertime. Option−−mil−splitdoesthesameasoption−−mil−link,butinaddition,theresultingMILrepresentationiswrittentoafilewith thesuffix.milandtheCcompileralsosplitstheMILrepresentationandwritesittoseparatefileswithsuffix.ms.Onefileis writtenforeachinputfileorMILlibraryspecifiedonthecommandline.The.msfilesareonlyupdatedonachange. Withoption−−mil−splityoucanperformapplication−wideoptimizationsduringthefrontendphasebyspecifyingallmodulesat once,andstillinvokethebackendphaseonemoduleatatimetoreducethetotalcompilationtime.

Relatedinformation

Ccompileroption−−mil/−−mil−split

5−258 ToolOptions−ControlProgram

ControlProgram:−−no−auto−instantiation

Commandlinesyntax −−no−auto−instantiation Default:theC++compilerautomaticallyinstantiatestemplates.

Description

Withthisoptionautomaticinstantiationoftemplatesisdisabled.

Relatedinformation

Controlprogramoption−−instantiate(Setinstantiationmode) Section2.6,TemplateInstantiationinchapterC++Language.

5−259 MicroBlazeEmbeddedToolsReference

ControlProgram:−−no−default−libraries

Commandlinesyntax −−no−default−libraries

Description

BydefaultthecontrolprogramspecifiesthestandardClibraries(C99)andrun−timelibrarytothelinker.Withthisoptionyoutell thecontrolprogramnottospecifythestandardClibrariesandrun−timelibrarytothelinker. Inthiscaseyoumustspecifythelibrariesyouwanttolinktothelinkerwiththeoption−llibrary_name.Thecontrolprogram recognizestheoption−lasanoptionforthelinkerandpassesitassuch.

Example ccmb−−no−default−librariestest.c

Thecontrolprogramdoesnotspecifyanylibrariestothelinker.Innormalcasesthiswouldresultinunresovedexternals. Tospecifyyourownlibraries(libmy.a)andavoidunresolvedexternals: ccmb−−no−default−libraries−lmytest.c

Relatedinformation

Linkeroption−−library(−l)(Addlibrary)

5−260 ToolOptions−ControlProgram

ControlProgram:−−no−double(−F)

Commandlinesyntax −−no−double −F

Description

Withthisoptionyoutellthecompilertotreatvariablesofthetypedoubleasfloat.Becausethefloattypetakeslessspace, executionspeedincreasesandcodesizedecreases,bothatthecostoflessprecision.

Relatedinformation

5−261 MicroBlazeEmbeddedToolsReference

ControlProgram:−−no−map−file

Commandlinesyntax −−no−map−file

Description

Bydefaultthecontrolprogramtellsthelinkertogeneratealinkermapfile. Alinkermapfileisatextfilethatshowshowthelinkerhasmappedthesectionsandsymbolsfromthevariousobjectfiles (.obj)tothelinkedobjectfile.Alocatepartshowstheabsolutepositionofeachsection.Externalsymbolsarelistedperspace withtheirabsoluteaddress,bothsortedonsymbolandsortedonaddress. Withthisoptionyoupreventthegenerationofamapfile.

Relatedinformation

5−262 ToolOptions−ControlProgram

ControlProgram:−−no−preprocessing−only

Commandlinesyntax −−no−preprocessing−only

Description

Onthecommandline,thecontrolprogramstopsafterpreprocessing.IfyoualsowanttocompiletheCsourceyoucanspecify theoption−−no−preprocessing−only.Inthiscasethecontrolprogramcallsthecompilertwice,oncewithoption −−preprocessandonceforaregularcompilation.

Relatedinformation

Controlprogramoption−−preprocess/−E

5−263 MicroBlazeEmbeddedToolsReference

ControlProgram:−−no−warnings(−w)

Commandlinesyntax −−no−warnings[=number[−number],...] −w[number[−number],...]

Description

WiththisoptionyoucansuppressallwarningmessagesorspecificCcompilerwarningmessages: • Ifyoudonotspecifythisoption,allwarningsarereported. • Ifyouspecifythisoptionbutwithoutnumbers,allwarningsaresuppressed. • Ifyouspecifythisoptionwithanumberorarange,onlythespecifiedCcompilerwarningissuppressed. Youcanspecifytheoption−−no−warnings=numbermultipletimes. Relatedinformation

5−264 ToolOptions−ControlProgram

ControlProgram:−−option−file(−f)

Commandlinesyntax −−option−file=file −ffile

Description

Insteadoftypingalloptionsonthecommandline,youcancreateanoptionfilewhichcontainsalloptionsandflagsyouwantto specify.Withthisoptionyouspecifytheoptionfiletothecontrolprogram. Useanoptionfilewhenthecommandlinewouldexceedthelimitsoftheoperatingsystem,orjusttostoreoptionsandsave typing. Youcanspecifytheoption−−option−filemultipletimes. Formatofanoptionfile • Multipleargumentsononelineintheoptionfileareallowed. • Toincludewhitespaceinanargument,surroundtheargumentwithsingleordoublequotes. • Ifyouwanttousesinglequotesaspartoftheargument,surroundtheargumentbydoublequotesandviseversa: "Thishasasinglequote’embedded" ’Thishasadoublequote"embedded’ ’Thishasadoublequote"andasinglequote’"’embedded" • Whenatextlinereachesitslengthlimit,usea’tocontinuetheline.Whitespacebetweenquotesispreserved. "Thisisacontinuation\ line"

−>"Thisisacontinuationline" • Itispossibletonestcommandlinefilesupto25levels. Example Supposethefilemyoptionscontainsthefollowinglines: −DDEMO=1 test.c

Specifytheoptionfiletothecontrolprogram: ccmb−−option−file=myoptions

Thisisequivalenttothefollowingcommandline: ccmb−DDEMO=1test.c

Relatedinformation

5−265 MicroBlazeEmbeddedToolsReference

ControlProgram:−−output(−o)

Commandlinesyntax −−output=file −ofile

Description

Default,thecontrolprogramgeneratesafilewiththesamebasenameasthefirstspecifiedinputfile.Withthisoptionyouspecify anothernamefortheresultingabsoluteobjectfile.

Example ccmbtest.cprog.c

ThecontrolprogramgeneratesanELF/DWARFobjectfile(default)withthenametest.abs. Togeneratethefileresult.abs: ccmb−−output=result.abstest.cprog.c

Relatedinformation

5−266 ToolOptions−ControlProgram

ControlProgram:−−pass(−W)

Commandlinesyntax −−pass−assembler=option (−Waoption) Passoptiondirectlytotheassembler −−pass−c=option (−Wcoption) PassoptiondirectlytotheCcompiler −−pass−c++=option (−Wcpoption) PassoptiondirectlytotheC++compiler −−pass−linker=option (−Wloption) Passoptiondirectlytothelinker

Description Withthisoptionyoutellthecontrolprogramtocallatoolwiththespecifiedoption.Thecontrolprogramdoesnotuseorinterpret theoptionitself,butspecifiesitdirectlytothetoolwhichitcalls.

Relatedinformation

5−267 MicroBlazeEmbeddedToolsReference

ControlProgram:−−preprocess(−E)

Commandlinesyntax −−preprocess[=flags] −E[flags] Youcansetthefollowingflags(whenyouspecify−Ewithoutflags,thedefaultis−ECILMP): +/−comments (c/C) KeepcommentsfromtheCsourceinthepreprocessedoutput +/−includes (i/I) Generatealistofincludedsourcefiles +/−list (l/L) Generatealistofmacrodefinitions +/−make (m/M) Generatedependencylinesthatcanbeusedforthemakefile +/−noline (p/P) Strip#linesourcepositioninfo(linesstartingwith#line)

Description WiththisoptionyoutellthecontrolprogramtopreprocesstheCsource. TheCcompilersendsthepreprocessedoutputtothefilename.pre(wherenameisthenameoftheCsourcefilebeing compiled).AltiumDesigneralsocompilestheCsource. Onthecommandline,thecontrolprogramstopsafterpreprocessing.IfyoualsowanttocompiletheCsourceyoucanspecify theoption−−no−preprocessing−only.Inthiscasethecontrolprogramcallsthecompilertwice,oncewithoption −−preprocessandonceforaregularcompilation. With−−preprocess=+commentsyoutellthepreprocessortokeepthecommentsfromtheC++sourcefileinthepreprocessed output. With−−preprocess=+includesthecompilerwillgeneratealistofallincludedsourcefiles.Thepreprocessoroutputis discarded. With−−preprocess=+listthecompilerwillgeneratealistofallmacrodefinitions.Thepreprocessoroutputisdiscarded. With−−preprocess=+makethecompilerwillgeneratedependencylinesthatcanbeusedinaMakefile.Theinformationis writtentoafilewithextension.d.Thepreprocessoroutputisdiscarded.Thedefaulttargetnameisthebasenameoftheinput file,withtheextension.obj.Withtheoption−−make−targetyoucanspecifyatargetnamewhichoverrulesthedefaulttarget name. With−−preprocess=+nolineyoutellthepreprocessortostripthe#linesourcepositioninformation(linesstartingwith#line). Theselinesarenormallyprocessedbytheassemblerandnotneededinthepreprocessedoutput.Whenyouleavetheselines out,theoutputiseasiertoread.

Example ccmb−−preprocess=+comments,−make,−noline−−no−preprocessing−onlytest.c

Thecompilerpreprocessesthefiletest.candsendstheoutputtothefiletest.pre.Commentsareincludedbutno dependenciesaregeneratedandthelinesourcepositioninformationisnotstrippedfromtheoutputfile.Next,thecontrol programcallsthecompiler,assemblerandlinkertocreatethefinalobjectfiletest.abs.

Relatedinformation

Controlprogramoption−−no−preprocessing−only Controlprogramoption−−make−target(Specifytargetnamefor−Emoutput) Controlprogramoption−−dep−file(Generatedependenciesinafile)

5−268 ToolOptions−ControlProgram

ControlProgram:−−profile(−p)

Commandlinesyntax −−profile[=flags] −p[flags] Usethefollowingoptionforapredefinedsetofflags: −−profile=g (−pg) profilingwithcallgraphandfunctiontimers Aliasfor:−pBcFt Youcansetthefollowingflags(whenyouspecify−pwithoutflags,thedefaultis−pBCfST): +/−block (b/B) blockcounters +/−callgraph (c/C) callgraph +/−function (f/F) functioncounters +/−static (s/S) staticprofilegeneration +/−time (t/T) functiontimers

Description Profilingistheprocessofcollectingstatisticaldataaboutarunningapplication.Withthesedatayoucananalyzewhichfunctions arecalled,howoftentheyarecalledandwhattheirexecutiontimeis. Severalmethodsofprofilingexist.Onemethodiscodeinstrumentationwhichaddscodetoyourapplicationthattakescareof theprofilingprocesswhentheapplicationisexecuted.

ForanextensivedescriptionofprofilingrefertoChapter4,Profilingintheuser’smanual. Withthisoption,thecompileraddstheextracodetoyourapplicationthattakescareoftheprofilingprocess.Youcanobtainthe followingprofilingdata(seeflagsabove): Blockcounters(notincombinationwithCallgraphorTime) Thiswillinstrumentthecodetoperformbasicblockcounting.Astheprogramruns,itcountsthenumberofexecutionsof eachbranchinanifstatement,eachiterationofaforloop,andsoon.NotethatthoughyoucancombineBlockcounters withFunctioncounters,thishasnoeffectbecauseFunctioncountersisonlyasubsetofBlockcounters. Callgraph(notincombinationwithBlockcounters) Thiswillinstrumentthecodetoreconstructtherun−timecallgraph.Astheprogramrunsitassociatesthecallerwiththe gatheredprofilingdata. Functioncounters Thiswillinstrumentthecodetoperformfunctioncallcounting.ThisisasubsetofthebasicBlockcounters. Time(notincombinationwithBlockcounters) Thiswillinstrumentthecodetomeasurethetimespentinafunction.Thisincludesthetimespentinallsubfunctions (callees).

Notethatthemoredetailledinformationyourequest,thelargertheoverheadintermsofexecutiontime,codesizeand heapspaceneeded.TheoptionGenerateDebuginformation(−gor−−debug)doesnotaffectprofiling,executiontime orcodesize.

Thecontrolprogramautomaticallyspecifiesthecorrespondingprofilinglibrariestothelinker.

Example

Togenerateblockcountinformationforthemoduletest.cduringexecution,compileasfollows: ccmb−−profile=+blocktest.c

Inthiscasethelibrarypbmba.libislinked.

5−269 MicroBlazeEmbeddedToolsReference

Relatedinformation

Chapter4,Profilingintheuser’smanual.

5−270 ToolOptions−ControlProgram

ControlProgram:−−show−c++−warnings

Commandlinesyntax −−show−c++−warnings

Description

TheC++compilermaygenerateacompiledC++file(.ic)thatcauseswarningsduringcompilationorassembling.Withthis optionyoutellthecontrolprogramtoshowthesewarnings.Bydefault,warningsinC++generatedfilesaresuppressed.

Relatedinformation

5−271 MicroBlazeEmbeddedToolsReference

ControlProgram:−−static

Commandlinesyntax −−static

Description

Thisoptionisdirectlypassedtothecompiler. Withthisoption,thecompilertreatsexternaldefinitionsatfilescope(exceptformain)asiftheyweredeclaredstatic.Asa result,unusedfunctionswillbeeliminated,andthealiascheckingalgorithmassumesthatobjectswithstaticstoragecannotbe referencedfromfunctionsoutsidethecurrentmodule. Thisoptiononlymakessensewhenyouspecifyallmodulesofanapplicationonthecommandline.

Example ccmb−−staticmodule1.cmodule2.cmodule3.c

Relatedinformation

5−272 ToolOptions−ControlProgram

ControlProgram:−−undefine(−U)

Commandlinesyntax −−undefine=macro_name −Umacro_name

Description

Withthisoptionyoucanundefineanearlierdefinedmacroaswith#undef. Thisoptionisforexampleusefultoundefinepredefinedmacros.However,youcannotundefinepredefinedISOCstandard macros. Thecontrolprogrampassestheoption−−undefine(−U)tothecompiler.

Example Toundefinethepredefinedmacro__TASKING__: ccmb−−undefine=__TASKING__test.c

Relatedinformation

ControlPogramoption−−define(Definepreprocessormacro)

5−273 MicroBlazeEmbeddedToolsReference

ControlProgram:−−verbose(−v)

Commandlinesyntax −−verbose −v

Description

Withthisoptionyouputthecontrolprograminverbosemode.Withtheoption−vthecontrolprogramperformsittaskswhileit printsthestepsitperformstostdout.

Relatedinformation

ControlProgramoption−n(−−dry−run)(Verboseoutputandsuppressexecution)

5−274 ToolOptions−ControlProgram

ControlProgram:−−version(−V)

Commandlinesyntax −−version −V

Description

Displayversioninformation.Thecontrolprogramignoresallotheroptionsorinputfiles.

Relatedinformation

5−275 MicroBlazeEmbeddedToolsReference

ControlProgram:−−warnings−as−errors

Commandlinesyntax −−warnings−as−errors[=number[−number],...]

Description

Ifoneofthetoolsencountersanerror,itstopsprocessingthefile(s).Withthisoptionyoutellthetoolstotreatwarningsaserrors ortreatspecificcontrolprogramwarningmessagesaserrors: • Ifyouspecifythisoptionbutwithoutnumbers,allwarningsaretreatedaserrors. • Ifyouspecifythisoptionwithanumber,onlythespecifiedcontrolprogramwarningistreatedasanerror. Youcanspecifytheoption−−warnings−as−errors=numbermultipletimes. Useoneofthe−−pass−tooloptionstopassthisoptiondirectlytoatoolwhenaspecificwarningforthattoolmustbetreated asanerror.Forexample,use−−pass−c=−−warnings−as−errors=numbertotreataspecificCcompilerwarningasanerror.

Relatedinformation

Controlprogramoption−−no−warnings(Suppressallwarnings) Controlprogramoption−−pass(Passoptiontotool)

5−276 ToolOptions−MakeUtility

5.6 MakeUtilityOptions

WhenyoubuildaprojectinAltiumDesigner,AltiumDesignergeneratesamakefileandusesthemakeutilitytmktobuildall yourfiles.However,youcanalsousethemakeutilitydirectlyfromthecommandlinetobuildyourproject. Theinvocationsyntaxis: tmk[option...][target...][macro=def]

Thissectiondescribesalloptionsforthemakeutility.Themakeutilityisacommandlinetoolsotherearenoequivalentoptions inAltiumDesigner.

5−277 MicroBlazeEmbeddedToolsReference

DefiningMacros

Commandlinesyntax macro=definition

Description

Withthisargumentyoucandefineamacroandspecifyittothemakeutility. Amacrodefinitionremainsinexistenceduringtheexecutionofthemakefile,evenwhenthemakefilerecursivelycallsthemake utilityagain.Intherecursivecall,themacroactsasanenvironmentvariable.Thismeansthatitisoverruledbydefinitionsinthe recursivecall.Usetheoption−etopreventthis.

Youcanspecifyasmanymacrosasyoulike.Ifthecommandlineexceedsthelimitoftheoperatingsystem,youcandefinethe macrosinanoptionfilewhichyouthenmustspecifytothemakeutilitywiththeoption−mfile.

Definingmacrosonthecommandlineis,forexample,usefulincombinationwithconditionalprocessingasshowninthe examplebelow.

Example Considerthefollowingmakefilewithconditionalrulestobuildademoprogramandarealprogram: ifdefDEMO#thevalueofDEMOisofnoimportance real.abs:real.objmain.obj lkmbdemo.objmain.obj−dmb.lsl−lcmba−lfpmba−lrtmba else real.abs:real.objmain.obj lkmbreal.objmain.obj−dmb.lsl−lcmba−lfpmba−lrtmba endif

YoucannowuseamacrodefinitiontosettheDEMOflag: tmkreal.absDEMO=1

Inbothcasestheabsoluteobjectfilereal.absiscreatedbutdependingontheDEMOflagitislinkedwithdemo.objorwith real.obj.

Relatedinformation

Makeutilityoption−e(Environmentvariablesoverridemacrodefinitions) Makeutilityoption−m(Nameofinvocationfile)

5−278 ToolOptions−MakeUtility

MakeUtility:−?

Commandlinesyntax

−?

Description Displaysanoverviewofallcommandlineoptions.

Example Thefollowinginvocationdisplaysalistoftheavailablecommandlineoptions: tmk−?

Relatedinformation

5−279 MicroBlazeEmbeddedToolsReference

MakeUtility:−a

Commandlinesyntax

−a

Description Normallythemakeutilityrebuildsonlythosefilesthatareoutofdate.Withthisoptionyoutellthemakeutilitytorebuildallfiles, withoutcheckingwhethertheyareoutofdate.

Example tmk−a

Rebuildsallyourfiles,regardlessofwhethertheyareoutofdateornot.

Relatedinformation

5−280 ToolOptions−MakeUtility

MakeUtility:−c

Commandlinesyntax

−c

Description AltiumDesignerusesthisoptionforthegraphicalversionofthemakeutilitywhenyoucreatesub−projects.Inthiscasethe makeutilitycallsanotherinstanceofthemakeutilityforthesub−project.Withtheoption−c,themakeutilityrunsasachild processofthecurrentmake. Theoption−coverrulestheoption−err.

Example tmk−c

Themakeutilityrunsitscommandsasachildprocesses.

Relatedinformation

5−281 MicroBlazeEmbeddedToolsReference

MakeUtility:−D/−DD

Commandlinesyntax

−D −DD

Description

Withtheoption−Dthemakeutilityprintseverylineofthemakefiletostandardoutputasitisreadbytmk.

Withtheoption−DDnotonlythelinesofthemakefileareprintedbutalsothelinesofthetmk.mkfile(implicitrules).

Example tmk−D

Eachlineofthemakefilethatisreadbythemakeutilityisprintedtostandardoutput(usuallyyourscreen).

Relatedinformation

5−282 ToolOptions−MakeUtility

MakeUtility:−d/−dd

Commandlinesyntax

−d −dd

Description

Withtheoption−dthemakeutilityshowswhichfilesareoutofdateandthusneedtoberebuild.Theoption−ddgivesmore detailthantheoption−d.

Example tmk−d

Showswhichfilesareoutofdateandrebuildsthem.

Relatedinformation

5−283 MicroBlazeEmbeddedToolsReference

MakeUtility:−e

Commandlinesyntax

−e

Description Ifyouusemacrodefinitions,theymayoverrulethesettingsoftheenvironmentvariables.

Withtheoption−e,thesettingsoftheenvironmentvariablesareusedevenifmacrosdefineotherwise.

Example tmk−e

Themakeutilityusesthesettingsoftheenvironmentvariablesregardlessofmacrodefinitions.

Relatedinformation

5−284 ToolOptions−MakeUtility

MakeUtility:−err

Commandlinesyntax

−errfile

Description Withthisoptionthemakeutilityredirectserrormessagesandverbosemessagestoaspecifiedfile. Withtheoption−sthemakeutilityonlydisplayserrormessages.

Example tmk−errerror.txt

Themakeutilitywritesmessagestothefileerror.txt.

Relatedinformation

Makeutilityoption−s(Donotprintcommandsbeforeexecution)

5−285 MicroBlazeEmbeddedToolsReference

MakeUtility:−f

Commandlinesyntax

−fmy_makefile

Description Defaultthemakeutilityusesthefilemakefiletobuildyourfiles.

Withthisoptionyoutellthemakeutilitytousethespecifiedfileinsteadofthefilemakefile.Multiple−foptionsactasifallthe makefileswereconcatenatedinaleft−to−rightorder.

Example tmk−fmymake

Themakeutilityusesthefilemymaketobuildyourfiles.

Relatedinformation

5−286 ToolOptions−MakeUtility

MakeUtility:−G

Commandlinesyntax

−Gpath

Description Normallyyoumustcallthemakeutilitytmkfromthedirectorywhereyourmakefileandotherfilesarestored.

Withtheoption−Gyoucancallthemakeutilityfromwithinanotherdirectory.Thepathisthepathtothedirectorywhereyour makefileandotherfilesarestoredandcanbeabsoluteorrelativetoyourcurrentdirectory.

Example Supposeyourmakefileandotherfilesarestoredinthedirectory..\myfiles.Youcancallthemakeutility,forexample,as follows: tmk−G..\myfiles

Relatedinformation

5−287 MicroBlazeEmbeddedToolsReference

MakeUtility:−i

Commandlinesyntax

−i

Description Whenanerroroccursduringthemakeprocess,themakeutilityexitswithacertainexitcode.

Withtheoption−i,themakeutilityexitswithoutanerrorcode,evenwhenerrorsoccurred.

Example tmk−i

Themakeutilityexitswithoutanerrorcode,evenwhenanerroroccurs.

Relatedinformation

5−288 ToolOptions−MakeUtility

MakeUtility:−K

Commandlinesyntax

−K

Description Withthisoptionthemakeutilitykeepstemporaryfilesitcreatesduringthemakeprocess.Themakeutilitystorestemporaryfiles inthedirectorythatyouhavespecifiedwiththeenvironmentvariableTMPDIRorinthedefault’temp’directoryofyoursystem whentheTMPDIRenvironmentvariableisnotspecified.

Example tmk−K

Themakeutilitypreservesalltemporaryfiles.

Relatedinformation

5−289 MicroBlazeEmbeddedToolsReference

MakeUtility:−k

Commandlinesyntax

−k

Description Whenduringthemakeprocessthemakeutilityencountersanerror,itstopsrebuildingyourfiles.

Withtheoption−k,themakeutilityonlystopsbuildingthetargetthatproducedtheerror.Allothertargetsdefinedinthemakefile arebuilt.

Example tmk−k

Ifthemakeutilityencountersanerror,itstopsbuildingthecurrenttargetbutproceedswiththeothertargetsthataredefinedin themakefile.

Relatedinformation

Makeutilityoption−S(Undotheeffectof−k)

5−290 ToolOptions−MakeUtility

MakeUtility:−m

Commandlinesyntax

−mfile

Description Insteadoftypingalloptionsonthecommandline,youcancreateanoptionfilewhichcontainsalloptionsandflagsyouwantto specify.Withthisoptionyouspecifytheoptionfiletothemakeutility. Useanoptionfilewhenthecommandlinewouldexceedthelimitsoftheoperatingsystem,orjusttostoreoptionsandsave typing. Youcanspecifytheoption−mmultipletimes.

Formatofanoptionfile • Multipleargumentsononelineintheoptionfileareallowed. • Toincludewhitespaceinanargument,surroundtheargumentwithsingleordoublequotes. • Ifyouwanttousesinglequotesaspartoftheargument,surroundtheargumentbydoublequotesandviseversa: "Thishasasinglequote’embedded" ’Thishasadoublequote"embedded’ ’Thishasadoublequote"andasinglequote’"’embedded" • Whenatextlinereachesitslengthlimit,usea’\’tocontinuetheline.Whitespacebetweenquotesispreserved. "Thisisacontinuation\ line" −>"Thisisacontinuationline" • Itispossibletonestcommandlinefilesupto25levels. Example Supposethefilemyoptionscontainsthefollowinglines: −k −errerrors.txt test.abs

Specifytheoptionfiletothemakeutility: tmk−mmyoptions

Thisisequivalenttothefollowingcommandline: tmk−k−errerrors.txttest.abs

Relatedinformation

5−291 MicroBlazeEmbeddedToolsReference

MakeUtility:−n

Commandlinesyntax

−n

Description Withthisoptionyoutellthemakeutilitytoperformadryrun.Themakeutilityshowswhatitwoulddobutdoesnotactually performthesetasks. Thisoptionisforexampleusefultoquicklyinspectwhatwouldhappenifyoucallthemakeutility.

Example tmk−n

Themakeutilitydoesnotperformanytasksbutdisplayswhatitwoulddoifcalledwithouttheoption−n.

Relatedinformation

Makeutilityoption−s(Donotprintcommandsbeforeexecution)

5−292 ToolOptions−MakeUtility

MakeUtility:−p

Commandlinesyntax

−p

Description Normally,ifacommandinatargetruleinamakefilereturnsanerrororwhenthetargetconstructionisinterrupted,themake utilityremovesthattargetfile.Withthisoptionyoutellthemakeutilitytomakealltargetfilesprecious.Thismeansthat dependencyfilesareneverremoved.

Example tmk−p

Themakeutilityneverremovestargetdependencyfiles.

Relatedinformation

5−293 MicroBlazeEmbeddedToolsReference

MakeUtility:−q

Commandlinesyntax

−q

Description Withthisoptionthemakeutilitydoesnotperformanytasksbutonlyreturnsanexitcode.Azerostatusindicatesthatalltarget filesareuptodate,anon−zerostatusindicatesthatsomeoralltargetfilesareoutofdate.

Example tmk−q

Themakeutilityonlyreturnsanexitcodethatindicateswhetheralltargetfilesareuptodateornot.Itdoesnotrebuildanyfiles.

Relatedinformation

5−294 ToolOptions−MakeUtility

MakeUtility:−r

Commandlinesyntax

−r

Description Whenyoucallthemakeutility,itfirstreadstheimplicitrulesfromthefiletmk.mk,thenitreadsthemakefilewiththerulesto buildyourfiles.(Thefiletmk.mkislocatedinthe\etcdirectoryofthetoolset.) Withthisoptionyoutellthemakeutilitynottoreadtmk.mkandtorelyfullyonthemakerulesinthemakefile.

Example tmk−r

Themakeutilitydoesnotreadtheimplicitmakerulesintmk.mk.

Relatedinformation

5−295 MicroBlazeEmbeddedToolsReference

MakeUtility:−S

Commandlinesyntax

−S

Description

Withthisoptionyoucanceltheeffectoftheoption−k.Thisisonlynecessaryinarecursivemakewheretheoption−kmightbe inheritedfromthetop−levelmakeviaMAKEFLAGSorifyousettheoption−kintheenvironmentvariableMAKEFLAGS.

Example tmk−S

Theeffectoftheoption−kiscancelledsothemakeutilitystopswiththemakeprocessafteritencountersanerror.

Theoption−kinthisexamplemayhavebeensetwiththeenvironmentvariableMAKEFLAGSorinarecursivecalltotmkinthe makefile.

Relatedinformation

Makeutilityoption−k(Onerror,abandontheworkforthecurrenttargetonly)

5−296 ToolOptions−MakeUtility

MakeUtility:−s

Commandlinesyntax

−s

Description Withthisoptionyoutellthemakeutilitytoperformitstaskswithoutprintingthecommandsitexecutes.Errormessagesare normallyprinted.

Example tmk−s

Themakeutilityrebuildsyourfilesbutdoesnotprintthecommandsitexecutesduringthemakeprocess.

Relatedinformation

Makeutilityoption−n(Performadryrun)

5−297 MicroBlazeEmbeddedToolsReference

MakeUtility:−t

Commandlinesyntax

−t

Description Withthisoptionyoutellthemakeutilitytotouchthetargetfiles,bringingthemuptodate,ratherthanperformingtherulesto rebuildthem.

Example tmk−t

Themakeutilityupdatesout−of−datefilesbygivingthemanewdateandtimestamp.Thefilesarenotactuallyrebuild.

Relatedinformation

5−298 ToolOptions−MakeUtility

MakeUtility:−time

Commandlinesyntax

−time

Description Withthisoptionyoutellthemakeutilitytodisplaythecurrentdateandtimeonstandardoutput.

Example tmk−time

Themakeutilitydisplaysthecurrentdateandtimeandupdatesout−of−datefiles.

Relatedinformation

5−299 MicroBlazeEmbeddedToolsReference

MakeUtility:−V

Commandlinesyntax

−V

Description Displayversioninformation.Themakeutilityignoresallotheroptionsorinputfiles.

Example tmk−V

Themakeutilitydisplaystheversioninformationbutdoesnotperformanytasks.

Relatedinformation

5−300 ToolOptions−MakeUtility

MakeUtility:−W

Commandlinesyntax

−Wtarget

Description Withthisoptionthemakeutilityconsidersthespecifiedtargetfilealwaysasuptodateandwillnotrebuildit.

Example tmk−Wtest.abs

Themakeutilityrebuildsoutofdatetargetsinthemakefileexceptthefiletest.abswhichisconsiderednowasuptodate.

Relatedinformation

5−301 MicroBlazeEmbeddedToolsReference

MakeUtility:−x

Commandlinesyntax

−x

Description Withthisoptionthemakeutilityshowsextendederrormessages.Extendederrormessagesgivemoredetailedinformation abouttheexitstatusofthemakeutilityaftererrors.AltiumDesignerusesthisoptionforthegraphicalversionofmake.

Example tmk−x

Iferrorsoccur,themakeutilitygivesextendedinformation.

Relatedinformation

5−302 ToolOptions−Librarian

5.7 LibrarianOptions

Thelibrariantlbisatooltobuildlibraryfilesanditoffersthepossibilitytoreplace,extractandremovemodulesfromanexisting library. Youcanonlycallthelibrarianfromthecommandline.Theinvocationsyntaxis: tlbkey_option[sub_option...]library[object_file] Thissectiondescribesalloptionsforthemakeutility.Suboptionscanonlybeusedincombinationwithcertainkeyoptions. Keyoptionsandtheirsuboptionsaretherefordescribedtogether.Themiscellaneousoptionscanalwaysbeusedandarealso describedseparately. ThelibrarianisacommandlinetoolsotherearenoequivalentoptionsinAltiumDesigner.

Description Option Suboption Mainfunctions(keyoptions) Replaceoraddanobjectmodule −r −a−b−c−u−v Extractanobjectmodulefromthelibrary −x −o−v Deleteobjectmodulefromlibrary −d −v Moveobjectmoduletoanotherposition −m −a−b−v Printatableofcontentsofthelibrary −t −s0−s1 Printobjectmoduletostandardoutput −p Suboptions Appendormovenewmodulesafterexistingmodulename −aname Appendormovenewmodulesbeforeexistingmodulename −bname Createlibrarywithoutnotificationiflibrarydoesnotexist −c Preservelast−modifieddatefromthelibrary −o Printsymbolsinlibrarymodules −s{0|1} Replaceonlynewermodules −u Verbose −v Miscellaneous Displayoptions −? Displayversionheader −V Readoptionsfromfile −ffile Suppresswarningsaboveleveln −wn

Table5−1:Overviewoflibrarianoptionsandsuboptions

5−303 MicroBlazeEmbeddedToolsReference

Librarian:−?

Commandlinesyntax

−?

Description Displaysanoverviewofallcommandlineoptions.

Example Thefollowinginvocationsdisplayalistoftheavailablecommandlineoptions: tlb−? tlb

Relatedinformation

5−304 ToolOptions−Librarian

Librarian:−d

Commandlinesyntax −d[−v]

Description

Deletethespecifiedobjectmodulesfromalibrary.Withthesuboption−vthelibrarianshowswhichfilesareremoved.

−v Verbose:thelibrarianshowswhichfilesareremoved.

Example tlb−dmylib.libobj1.objobj2.obj

Thelibrariandeletesobj1.objandobj2.objfromthelibrarymylib.lib. tlb−d−vmylib.libobj1.objobj2.obj

Thelibrariandeletesobj1.objandobj2.objfromthelibrarymylib.libanddisplayswhichfilesareremoved.

Relatedinformation

5−305 MicroBlazeEmbeddedToolsReference

Librarian:−f

Commandlinesyntax −ffile

Description

Insteadoftypingalloptionsonthecommandline,youcancreateanoptionfilewhichcontainsalloptionsandflagsyouwantto specify.Withthisoptionyouspecifytheoptionfiletothelibrariantlb. Useanoptionfilewhenthecommandlinewouldexceedthelimitsoftheoperatingsystem,orjusttostoreoptionsandsave typing. Optionfilescanalsobegeneratedonthefly,forexamplebythemakeutility.Youcanspecifytheoption−fmultipletimes. Formatofanoptionfile • Multipleargumentsononelineintheoptionfileareallowed. • Toincludewhitespaceinanargument,surroundtheargumentwithsingleordoublequotes. • Ifyouwanttousesinglequotesaspartoftheargument,surroundtheargumentbydoublequotesandviseversa: "Thishasasinglequote’embedded" ’Thishasadoublequote"embedded’ ’Thishasadoublequote"andasinglequote’"’embedded" • Whenatextlinereachesitslengthlimit,usea’tocontinuetheline.Whitespacebetweenquotesispreserved. "Thisisacontinuation\ line" −>"Thisisacontinuationline" • Itispossibletonestcommandlinefilesupto25levels. Example Supposethefilemyoptionscontainsthefollowinglines: −xmylib.libobj1.obj −w5

Specifytheoptionfiletothelibrarian: tlb−fmyoptions

Thisisequivalenttothefollowingcommandline: tlb−xmylib.libobj1.obj−w5

5−306 ToolOptions−Librarian

Librarian:−m

Commandlinesyntax

−m[−aposname][−bposname]

Description Movethespecifiedobjectmodulestoanotherpositioninthelibrary. Theorderingofmembersinalibrarycanmakeadifferenceinhowprogramsarelinkedifasymbolisdefinedinmorethanone member.

Default,thespecifiedmembersaremovedtotheendofthearchive.Usethesuboptions−aor−btomovethemtoaspecified placeinstead.

−aposname Movethespecifiedobjectmodule(s)aftertheexistingmoduleposname.

−bposname Movethespecifiedobjectmodule(s)beforetheexistingmoduleposname.

Example

Supposethelibrarymylib.libcontainsthefollowingobjects(seeoption−t): obj1.obj obj2.obj obj3.obj

Tomoveobj1.objtotheendofmylib.lib: tlb−mmylib.libobj1.obj

Tomoveobj3.objjustbeforeobj2.obj: tlb−m−bobj3.objmylib.libobj2.obj

Thelibrarymylib.libafterthesetwoinvocationsnowlookslike: obj3.obj obj2.obj obj1.obj

Relatedinformation

Librarianoption−t(Printlibrarycontents)

5−307 MicroBlazeEmbeddedToolsReference

Librarian:−p

Commandlinesyntax −p

Description

Printthespecifiedobjectmodule(s)inthelibrarytostandardoutput. Thisoptionisonlyusefulwhenyouredirectorpipetheoutputtootherfilesortoolsthatserveyourownpurposes.Normallyyou donotneedthisoption.

Example tlb−pmylib.libobj1.obj>file.obj

Thelibrarianprintsthefileobj1.objtostandardoutputwhereitisredirectedtothefilefile.obj.Theeffectofthisexample isverysimilartoextractingafilefromthelibrarybutinthiscasethe’extracted’filegetsanothername.

Relatedinformation

5−308 ToolOptions−Librarian

Librarian:−r

Commandlinesyntax

−r[−aposname][−bposname][−c][−u][−v]

Description

Youcanusetheoption−rforseveralpurposes: • Addingnewobjectstothelibrary • Replacingobjectsinthelibrarywiththesameobjectofanewerdate • Creatinganewlibrary Theoption−rnormallyaddsanewmoduletothelibrary.However,ifthelibraryalreadycontainsamodulewiththespecified name,theexistingmoduleisreplaced.Ifyouspecifyalibrarythatdoesnotexist,thelibrariancreatesanewlibrarywiththe specifiedname.

Ifyouaddamoduletothelibrarywithoutspecifyingthesuboption−aor−b,thespecifiedmoduleisaddedattheendofthe archive.Usethesuboptions−aor−btoinsertthemtoaspecifiedplaceinstead.

−aposname Addthespecifiedobjectmodule(s)aftertheexistingmoduleposname.

−bposname Addthespecifiedobjectmodule(s)beforetheexistingmoduleposname.

−c Createanewlibrarywithoutcheckingwhetheritalreadyexists.Ifthelibraryalreadyexists,itisoverwritten.

−u Insertthespecifiedobjectmoduleonlyifitisnewerthanthemoduleinthelibrary.

−v Verbose:thelibrarianshowswhichfilesareremoved.

Thesuboptions−aor−bhavenoeffectwhenanobjectisaddedtothelibrary.

Examples

Supposethelibrarymylib.libcontainsthefollowingobjects(seeoption−t): obj1.obj

Toaddobj2.objtotheendofmylib.lib: tlb−rmylib.libobj2.obj

Toinsertobj3.objjustbeforeobj2.obj: tlb−r−bobj2.objmylib.libobj3.obj

Thelibrarymylib.libafterthesetwoinvocationsnowlookslike: obj1.obj obj3.obj obj2.obj

Creatinganewlibrary Tocreateanewlibraryfile,addanobjectfileandspecifyalibrarythatdoesnotyetexist: tlb−robj1.obj.lib

Thelibrariancreatesthelibrarynewlib.libandaddstheobjectobj1.objtoit. Tocreateanewlibraryfileandoverwriteanexistinglibrary,addanobjectfileandspecifyanexistinglibrarywiththesupoption −c: tlb−r−cobj1.objmylib.lib

5−309 MicroBlazeEmbeddedToolsReference

Thelibrarianoverwritesthelibrarymylib.libandaddstheobjectobj1.objtoit.Thenewlibrarymylib.libonlycontains obj1.obj.

Relatedinformation

Librarianoption−t(Printlibrarycontents)

5−310 ToolOptions−Librarian

Librarian:−t

Commandlinesyntax

−t[−s0|−s1]

Description

Printatableofcontentsofthelibrarytostandardout.Withthesuboption−sthelibrariandisplaysallsymbolsperobjectfile.

−s0 Displaysperobjectthelibraryinwhichitresides,thenameoftheobjectitselfandallsymbolsintheobject.

−s1 Displaysonlythesymbolsofallobjectfilesinthelibrary.

Example tlb−tmylib.lib

Thelibrarianprintsalistofallobjectmodulesinthelibarymylib.lib. tlb−t−s0mylib.lib

Thelibrarianprintsperobjectallsymbolsinthelibrary.Thislookslike: prolog.obj symbols: mylib.lib:prolog.obj:___Qabi_callee_save mylib.lib:prolog.obj:___Qabi_callee_restore div16.obj symbols: mylib.lib:div16.obj:___udiv16 mylib.lib:div16.obj:___div16 mylib.lib:div16.obj:___urem16 mylib.lib:div16.obj:___rem16

Relatedinformation

5−311 MicroBlazeEmbeddedToolsReference

Librarian:−V

Commandlinesyntax

−V

Description Displayversioninformation.Thelibrarianignoresallotheroptionsorinputfiles.

Example tlb−V

Thelibrariandisplaysversioninformationbutdoesnotperformanytasks.

Relatedinformation

5−312 ToolOptions−Librarian

Librarian:−w

Commandlinesyntax −wlevel

Description

Withthissuboptionyoutellthelibrariantosuppressallwarningsabovethespecifiedlevel.Thelevelisanumberbetween0−9.

Thelevelofamessageisprintedbetweenparenthesesafterthewarningnumber.Ifyoudonotusethe−woption,thedefault warninglevelis8.

Example Tosuppresseswarningsabovelevel5: tlb−x−w5mylib.libobj1.obj

Relatedinformation

5−313 MicroBlazeEmbeddedToolsReference

Librarian:−x

Commandlinesyntax −x[−o][−v]

Description

Extractanexistingmodulefromthelibrary.

−o Givetheextractedobjectmodulethesamedateasthelast−modifieddatethatwasrecordedinthelibrary.

Withoutthissuboptionitreceivesthelast−modifieddateofthemomentitisextracted.

−v Verbose:thelibrarianshowswhichfilesareextracted.

Examples Toextractthefileobj1.objfromthelibrarymylib.lib: tlb−xmylib.libobj1.obj

Ifyoudonotspecifyanobjectmodule,allobjectmodulesareextracted: tlb−xmylib.lib

Relatedinformation

5−314 6 ListFileFormats

Summary Thischapterdescribestheformatoftheassemblerlistfileandthelinkermapfile.

6.1 AssemblerListFileFormat

Theassemblerlistfileisanadditionaloutputfileoftheassemblerthatcontainsinformationaboutthegeneratedcode. Thelistfileconsistsofapageheaderandasourcelisting.

Pageheader Thepageheaderisrepeatedoneverypage:

TASKINGtargetAssemblervx.yrzBuildnnnSN00000000 TitlePage1

ADDRCODECYCLESLINESOURCELINE

Thefirstlinecontainsversioninformation. Thesecondlinecancontainatitlewhichyoucanspecifywiththeassemblerdirective.TITLEandalwayscontainsapage number.Withtheassemblerdirectives.LIST/.NOLISTand.PAGE,andwiththeassembleroption−Lflag(−−list−format)you canformatthelistfile.

SeeSection4.8.2,AssemblerDirectivesinChapterAssemblyLanguageandSection5.3,AssemblerOptionsinChapter ToolsOptions. Thefourthlinecontainstheheadingsofthecolumnsforthesourcelisting.

Sourcelisting Thefollowingisasamplepartofalisting.Anexplanationofthedifferentcolumnsfollowsbelow.

ADDRCODECYCLESLINESOURCELINE 1;Modulestart . . 0010F86100002912swir3,r1,0 0014B000rrrr31213addikr3,r0,_2_str 3060rrrr 001CB000rrrr21414bralidr15,printf B9FCrrrr . . 000038.ds2 |RESERVED 0001

Themeaningofthedifferentcolumnsis: ADDR Thiscolumncontainsthememoryaddress.Theaddressisahexadecimalnumberthatrepresentsthe offsetfromthebeginningofarelocatablesectionortheabsoluteaddressforanabsolutesection.The addressonlyappearsonlinesthatgenerateobjectcode.

6−1 MicroBlazeEmbeddedToolsReference

CODE Thisistheobjectcodegeneratedbytheassemblerforthissourceline,displayedinhexadecimalformat. Thedisplayedcodeneednotbethesameasthegeneratedcodethatisenteredintheobjectmodule.The codecanalsoberelocatablecode.Inthiscasetheletter’r’isprintedfortherelocatablecodepartinthe listing.Forlinesthatallocatespace,thecodefieldcontainsthetext"RESERVED".Forlinesthatinitializea buffer,thecodefieldlistsonevaluefollowedbytheword"REPEATS". CYCLES Thefirstnumberinthiscolumnisthenumberofinstructioncyclesneededtoexecutetheinstruction(s)as generatedintheCODEfield.Thesecondnumberistheaccumulatedcyclecountofthissection. LINE Thiscolumncontainsthelinenumber.Thisisadecimalnumberindicatingeachinputline,startingfrom1 andincrementingwitheachsourceline. SOURCELINE Thiscolumncontainsthesourcetext.Thisisacopyofthesourcelinefromtheassemblysourcefile.

Forthe.SETand.EQUdirectivestheADDRandCODEcolumnsdonotapply.Thesymbolvalueislistedinstead.

Relatedinformation

Seesection5.6,GeneratingaListFile,inChapterUsingtheAssembleroftheuser’smanualformoreinformationon howtogeneratealistfileandspecifytheamountoflistfileinformation.

6−2 ListFileFormats

6.2 LinkerMapFileFormat

Thelinkermapfileisanadditionaloutputfileofthelinkerthatshowshowthelinkerhasmappedthesectionsandsymbolsfrom thevariousobjectfiles(.obj)tooutputsections.Thelocatepartshowstheabsolutepositionofeachsection.Externalsymbols arelistedperspacewiththeirabsoluteaddress,bothsortedonsymbolandsortedonaddress. Withthelinkeroption−−map−file−format(mapfileformatting)youcanspecifywhichpartsofthemapfileyouwanttosee.

Example(partof)linkermapfile

********************************************************** Tool and Invocation *********************************************************** +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+ | tool | TASKING MicroBlaze object linker vx.yrz Build 033 | | path | \System\Tasking\cmb\bin\lkmb.exe | | arguments | hello.obj −o hello.abs −dmb.lsl −M −mnqs −lcmba −lfpmba −lrtmba | | task | task1 | +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+

************************************************************* Used Resources *************************************************************

* Memory usage in bytes ======+−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+ | Memory | Code | Data | Reserved | Free | Total | |======| | system:xram | 0x0 | 0x0029a | 0x02806 | 0x7d560 | 0x80000 | | system:xrom | 0x01848 | 0x0015b | 0x00104 | 0x0e559 | 0x10000 | |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| | Total | 0x01848 | 0x003f5 | 0x0290a | 0x8bab9 | 0x90000 | +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+

* Space usage in bytes ======+−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+ | Space | Native used Rom | Native used Ram | Foreign used | Reserved | Free Rom | Free Ram | Total | |======| | system:sw:main | 0x019a3 | 0x0029a | 0x0 | 0x0290a | 0x0e559 | 0x7d560 | 0x90000 | |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| | Total | 0x019a3 | 0x0029a | − | − | − | − | − | | Largest gap | − | − | − | − | 0x0e557 | 0x7d560 | − | +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+

Note: When spaces share memory with each other, some space can be consumed by sections located in other spaces. In the table above we call this foreign used space as opposed to native used space.

* Estimated stack usage ======+−−−−−−−−−−−−−−−−−−−−−−−−−+ | Stack Name | Used | |======| | stack 0 | 0x00000128 | |−−−−−−−−−−−−−−−−−−−−−−−−−| | recursive | no | +−−−−−−−−−−−−−−−−−−−−−−−−−+

************************************************************ Processed Files ************************************************************* +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+ | File | From archive | Symbol causing the extraction | |======| | cstart.obj | cmba.lib | _START | | hello.obj | | | | printf.obj | cmba.lib | printf | +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+

6−3 MicroBlazeEmbeddedToolsReference

************************************************************** Link Result *************************************************************** +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+ | [in] File | [in] Section | [in] Size (MAU) | [out] Offset | [out] Section | [out] Size (MAU) | |======| | hello.obj | .text (2) | 0x00000034 | 0x00000000 | .text (2) | 0x00000034 | |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| | cstart.obj | .text.libc (27) | 0x00000034 | 0x00000000 | .text.libc (27) | 0x00000034 | |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| | printf.obj | .text.libc (83) | 0x00000048 | 0x00000000 | .text.libc (83) | 0x00000048 | |+−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+

********************************************************** Module Local Symbols **********************************************************

* Scope "hello.c" ======+−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+ | Name | Space addr | Space | |======| | hello.c | 0x0 | − | |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| | .data | 0x01000010 | system:sw:main | | .sbss | 0x01000004 | | | .sdata | 0x01000000 | | | .text | 0x00000120 | | | .text | 0x00000154 | | +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+

************************************************************ Cross References ************************************************************

+−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+ | Definition file | Definition section | Symbol | Referenced in | |======| | cstart.obj | .text.libc (27) | _START | hello.obj | | hello.obj | .text (2) | main | cstart.obj | +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+

* Undefined symbols ======+−−−−−−−−−−−−−−−−−−−−−−−−+ | Symbol | Referenced in | |======| | _init | hello.obj | +−−−−−−−−−−−−−−−−−−−−−−−−+

*************************************************************** Call Graph *************************************************************** main | +−− printloop | | | +−− printf * | +−− printf * printf | +−− _doprint | +−− _doprint_int.c:_emitchar * | +−− _doprint_int.c:_putnumber | | | +−− _doprint_int.c:_emitchar * | | | +−− _doprint_int.c:_putstring * | | | +−− strlen * | | | +−− _doprint_int.c:_ltoa | +−− _doprint_int.c:_putstring * | +−− _doflt

6−4 ListFileFormats

************************************************************* Locate Result **************************************************************

* Task entry address ======+−−−−−−−−−−−−−−−−−−+ | symbol | _START | +−−−−−−−−−−−−−−−−−−+

* Sections ======

+ Space system:sw:main (MAU = 8bit)

+−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+ | Chip | Group | Section | Size (MAU) | Space addr | Chip addr | |======| | system:xrom | | .text.libc (28) | 0x00000008 | 0x0 | 0x0 | | system:xrom | | [.data] (323) | 0x0000000e | 0x00000008 | 0x00000008 | | system:xrom | | [.data.libc] (324) | 0x000000c8 | 0x00000018 | 0x00000018 | | system:xrom | | [.data.libc] (325) | 0x0000000c | 0x000000e0 | 0x000000e0 | | system:xrom | | .rodata.libc (51) | 0x00000034 | 0x000000ec | 0x000000ec | | system:xrom | | .text (2) | 0x00000034 | 0x00000120 | 0x00000120 | | system:xrom | | table (321) | 0x00000041 | 0x00001a68 | 0x00001a68 | | system:xram | anchor_r13 | .sdata (3) | 0x00000004 | 0x01000000 | 0x0 | | system:xram | anchor_r13 | .sbss (5) | 0x00000001 | 0x01000004 | 0x00000004 | | system:xram | | stack (319) | 0x00002800 | 0x010002a0 | 0x000002a0 | +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+

* Symbols (sorted on name) ======+−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+ | Name | Space addr | Space | |======| | _Exit | 0x000001ac | system:sw:main | | _START | 0x00000448 | | | main | 0x00000120 | | +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+

* Symbols (sorted on address) ======+−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+ | Space addr | Name | Space | |======| | 0x00000120 | main | system:sw:main | | 0x000001ac | _Exit | | | 0x00000448 | _START | | +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+

********************************************************** Processor and Memory **********************************************************

************************************************************** Locate Rules ************************************************************** +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+ | Address space | Type | Properties | Sections | |======| | system:sw:main | absolute | 0x00000000 | .text.libc (28) | | system:sw:main | contiguous | | .sdata (3) | .sbss (5) | .sbss.libc (172) | .sbss.libc (206) | | system:sw:main | clustered | | .data (4) + .data.libc (91) + .data.libc (207) | | system:sw:main | clustered | | .bss.libc (92) + .bss (222) | | system:sw:main | clustered | | [.data] (323) + [.data.libc] (324) + [.data.libc] (325) | | system:sw:main | unrestricted | | .rodata.libc (51) , .text (2) , .text (1) , .text._Exit (263) , .text._cptable_clr (296) | | system:sw:main | unrestricted | | stack (319) | | system:sw:main | unrestricted | | .alignment_protection (326) | +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+

************************************************************ Removed Sections ************************************************************ +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+ | Section | File | Library | Symbol | Reason | |======| | .text.libc (33) | printf_int.obj | cmba.lib | dummy | unreferenced | | .text.libc (103) | fgetc.obj | cmba.lib | fgetc | unreferenced | | .text.libc (117) | ungetc.obj | cmba.lib | ungetc | unreferenced | | .text.libc (124) | _filbuf.obj | cmba.lib | _filbuf | unreferenced | +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+

6−5 MicroBlazeEmbeddedToolsReference

Themeaningofthedifferentpartsis:

ToolandInvocation Thispartofthemapfilecontainsinformationaboutthelinker,itsversionheaderinformation,binarylocationandwhichoptions areusedtocallit.

UsedResources Thispartofthemapfileshowsthememoryusageatmemorylevelandspacelevel.Thelargestfreeblockofmemory(Largest gap)isalsoshown.Thispartalsocontainsanestimationofthestackusage. Memory Thenamesofthememoryasdefinedinthelinkerscriptfile(*.lsl). Code Thesizeofallexecutablesections. Data Thesizeofallnon−executablesections(notincludingstacks,heaps,debugsectionsinnon−alloc space). Reserved Thetotalsizeofreservedmemories,reservedranges,reservedspecialsections,stacks,heaps, alignmentprotections,sectionslocatedinnon−allocspace(debugsections).Infact,thissizeisthe sameasthesizeintheTotalcolumnminusthesizeofallothercolumns. Free Thefreememoryareaaddressablebythiscore.Thisareaisaccessibleforunrestricteditems. Total Thetotalmemoryareaaddressablebythiscore. Space Thenamesoftheaddressspacesasdefinedinthelinkerscriptfile(*.lsl).Thenamesare constructedofthederivativenamefollowedbyacolon’:’,thecorename,anothercolon’:’andthe spacename. Nativeused... Thesizeofsectionslocatedinthisspace. Foreignused Thesizeofallsectionsdestinedfor/locatedinotherspaces,butbecauseofoverlapinspaces consumememoryinthisspace. StackName Thename(s)ofthestack(s)asdefinedinthelinkerscriptfile(*.lsl). Used Anestimationofthestackusage.Thelinkercalculatestherequiredstacksizebyusinginformation (.CALLSdirectives)generatedbythecompiler.Ifforexamplerecursionisdetected,thecalculated stacksizeisinaccurate,thereforethisisanestimationonly.Thecalculatedstacksizeissupposed tobesmallerthantheactualallocatedstacksize.Ifthatisnotthecase,thenawarningisgiven.

ProcessedFiles Thispartofthemapfileshowsallprocessedfiles.Thisalsoincludesobjectfilesthatareextractedfromalibrary,withthe symbolthatledtotheextraction.

LinkResult Thispartofthemapfileshowsperobjectfilehowthelinkphasehasmappedthesectionsfromthevariousobjectfiles(.obj)to outputsections. [in]File Thenameofaninputobjectfile. [in]Section Asectionnameandidfromtheinputobjectfile.Thenumberbetween’()’uniquelyidentifiesthesection. [in]Size Thesizeoftheinputsection. [out]Offset Theoffsetrelativetothestartoftheoutputsection. [out]Section Theresultingoutputsectionnameandid. [out]Size Thesizeoftheoutputsection.

ModuleLocalSymbols Thispartofthemapfileshowsatableforeachlocalscopewithinanobjectfile.Eachtablehasthreecolumns,1thesymbol name,2theaddressofthesymboland3thespacewherethesymbolresidesin.Thetableissortedonsymbolnamewithin eachspace.

6−6 ListFileFormats

Bydefaultthispartisnotshowninthemapfile.Youhavetoturnthispartonmanuallywithlinkeroption −−map−file−format=+statics(modulelocalsymbols).

CrossReferences Thispartofthemapfilelistsallsymbolsdefinedintheobjectmodulesandforeachsymboltheobjectmodulesthatcontaina referencetothesymbolareshown.Also,symbolsthatremainundefinedareshown.

CallGraph

Thispartofthemapfilecontainsaschematicoverviewthatshowshow(library)functionscalleachother.

LocateResult:Sections Thispartofthemapfileshowstheabsolutepositionofeachsectionintheabsoluteobjectfile.Itisorganizedperaddress space,memorychipandgroupandsortedonspaceaddress. +Space Thenamesoftheaddressspacesasdefinedinthelinkerscriptfile(*.lsl).Thenamesareconstructed ofthederivativenamefollowedbyacolon’:’,thecorename,anothercolon’:’andthespacename. Chip Thenamesofthememorychipsasdefinedinthelinkerscriptfile(*.lsl)inthememorydefinitions. Group Sectionscanbeorderedingroups.Thesearethenamesofthegroupsasdefinedinthelinkerscriptfile (*.lsl)withthekeywordgroupinthesection_layoutdefinition.Thenamethatisdisplayedisthe nameofthedeepestnestedgroup. Section Thenameandidofthesection.Thenumberbetween’()’uniquelyidentifiesthesection.Nameswithin squarebrackets[]willbecopiedduringinitializationfromROMtothecorrespondingsectionnamein RAM. Size(MAU) Thesizeofthesectioninminimumaddressableunits. Spaceaddr Theabsoluteaddressofthesectionintheaddressspace. Chipaddr Theabsoluteoffsetofthesectionfromthestartofamemorychip.

LocateResult:Symbols Thispartofthemapfilelistsallexternalsymbolsperaddressspacename,bothsortedonaddressandsortedonsymbolname. Name Thenameofthesymbol. Spaceaddr Theabsoluteaddressofthesectionintheaddressspace. Space Thenamesoftheaddressspacesasdefinedinthelinkerscriptfile(*.lsl).Thenamesareconstructed ofthederivativenamefollowedbyacolon’:’,thecorename,anothercolon’:’andthespacename.

ProcessorandMemory Thispartofthemapfileshowstheprocessorandmemoryinformationofthelinkerscriptfile. Bydefaultthispartisnotshowninthemapfile.Youhavetoturnthispartonmanuallywithlinkeroption −−map−file−format=+lsl(processorandmemoryinfo).Youcanprintthisinformationtoaseparatefilewithlinkeroption −−lsl−dump.

LocateRules Thispartofthemapfileshowstherulesthelinkerusestolocatesections. Addressspace Thenamesoftheaddressspacesasdefinedinthelinkerscriptfile(*.lsl).Thenamesareconstructed ofthederivativenamefollowedbyacolon’:’,thecorename,anothercolon’:’andthespacename. Type Theruletype: ordered/contiguous/clustered/unrestricted Specifieshowsectionsaregrouped.Bydefault,agroupis’unrestricted’whichmeansthatthelinker hastotalfreedomtoplacethesectionsofthegroupintheaddressspace. absolute ThesectionmustbelocatedattheaddressshowninthePropertiescolumn.

6−7 MicroBlazeEmbeddedToolsReference

ranged ThesectionmustbelocatedanywhereintheaddressrangesshowninthePropertiescolumn;end addressesarenotincludedintherange. floating Thesectionsmustbelocatedinsomeaddressrangewithasizenotlargerthanshowninthe Propertiescolumn;thefirstnumberisthepagesize,thesecondpartistheaddressrange restrictionwithinthepage. rangedfloat Boththerangedandthefloatingrestrictionapply.InthePropertiescolumntherangerestrictionis listedfirst,followedbythefloatingrestrictionbetweenparenthesis. ballooned Afterlocatingallsections,thelargestremaininggapinthespaceisusedcompletelyforthestack and/orheap. Properties ThecontentsdependsontheTypecolumn. Sections Thesectionstowhichtheruleapplies; restrictionsbetweensectionsareshowninthiscolumn: < ordered | contiguous + clustered Forcontiguoussections,thelinkerusesthesectionorderasshownhere.Clusteredsectionscanbe locatedinanyrelativeorder.

RemovedSections Thispartofthemapfilecontainsinformationaboutthesectionsthatareremovedfromtheabsoluteobjectfile.Forexample, unreferencedsections.

Relatedinformation

Section6.11,GeneratingaMapFile,inChapterUsingtheLinkeroftheuser’smanual. Linkeroption−−map−file(Generatemapfile)

6−8 7 ObjectFileFormats

Summary Thischapterdescribestheformatsofseveralobjectfiles.

7.1 ELF/DWARFObjectFormat

TheTASKINGMicroBlazetoolsetbydefaultproducesobjectsintheELF/DWARF2format. ForacompletedescriptionoftheELFandDWARFformats,pleaserefertotheToolInterfaceStandard(TIS).

7−1 MicroBlazeEmbeddedToolsReference

7.2 MotorolaS−RecordFormat

Withthelinkeroption−ofilename:SRECoptionthelinkerproducesoutputinMotorolaS−recordformatwiththreetypesof S−records:S0,S3andS7.Withtheoptions−ofilename:SREC:2or−ofilename:SREC:3optionyoucanforceothertypesof S−records.Theyhavethefollowinglayout:

S0−record ’S’’0’<2bytes0> AlinkergeneratedS−recordfilestartswithaS0recordwiththefollowingcontents: length_byte :$07 comment :lkmb checksum :$52 lkmb S00700006C6B6D6252

TheS0recordisacommentrecordanddoesnotcontainrelevantinformationforprogramexecution. Thelength_byterepresentsthenumberofbytesintherecord,notincludingtherecordtypeandlengthbyte. Thechecksumiscalculatedbyfirstaddingthebinaryrepresentationofthebytesfollowingtherecordtype(startingwiththe length_byte)tojustbeforethechecksum.Thentheone’scomplementiscalculatedofthissum.Theleastsignificantbyteofthe resultisthechecksum.Thesumofallbytesfollowingtherecordtypeis0FFH.

S1−record Withthelinkeroption−ofilename:SREC:2,theactualprogramcodeanddataissuppliedwithS1records,withthefollowing layout: ’S’’1’

Thisrecordisusedfor2−byteaddresses. Example: S1130250F03EF04DF0ACE8A408A2A013EDFCDB00E6 ||||_checksum |||_code ||_address |_length

ThelinkerhasanoptionthatcontrolsthelengthoftheoutputbufferforgeneratingS1records.Thedefaultbufferlengthis32 codebytes. ThechecksumcalculationofS1recordsisidenticaltoS0.

S2−record Withthelinkeroption−ofilename:SREC:3,theactualprogramcodeanddataissuppliedwithS2records,withthefollowing layout: ’S’’2’

Thisrecordisusedfor3−byteaddresses. Example: S213FF002000232222754E00754F04AF4FAE4E22BF ||||_checksum |||_code ||_address |_length

ThelinkerhasanoptionthatcontrolsthelengthoftheoutputbufferforgeneratingS2records.Thedefaultbufferlengthis32 codebytes.

7−2 ObjectFileFormats

ThechecksumcalculationofS2recordsisidenticaltoS0.

S3−record Withthelinkeroption−ofilename:SREC:4,whichisthedefault,theactualprogramcodeanddataissuppliedwithS3records, withthefollowinglayout: ’S’’3’

Thelinkergenerates4−byteaddressesbydefault. Example: S3070000FFFE6E6825 ||||_checksum |||_code ||_address |_length

ThelinkerhasanoptionthatcontrolsthelengthoftheoutputbufferforgeneratingS3records. ThechecksumcalculationofS3recordsisidenticaltoS0.

S7−record Withthelinkeroption−ofilename:SREC:4,whichisthedefault,attheendofanS−recordfile,thelinkergeneratesanS7record, whichcontainstheprogramstartaddress.S7isthecorrespondingterminationrecordforS3records. Layout: ’S’’7’

Example: S70500000000FA |||_checksum ||_address |_length

ThechecksumcalculationofS7recordsisidenticaltoS0.

S8−record Withthelinkeroption−ofilename:SREC:3,attheendofanS−recordfile,thelinkergeneratesanS8record,whichcontainsthe programstartaddress. Layout: ’S’’8’

Example: S804FF0003F9 |||_checksum ||_address |_length

ThechecksumcalculationofS8recordsisidenticaltoS0.

S9−record

Withthelinkeroption−ofilename:SREC:2,attheendofanS−recordfile,thelinkergeneratesanS9record,whichcontainsthe programstartaddress.S9isthecorrespondingterminationrecordforS1records. Layout: ’S’’9’

7−3 MicroBlazeEmbeddedToolsReference

Example: S9030210EA |||_checksum ||_address |_length

ThechecksumcalculationofS9recordsisidenticaltoS0.

7−4 ObjectFileFormats

7.3 IntelHexRecordFormat

IntelHexrecordsdescribethehexadecimalobjectfileformatfor8−bit,16−bitand32−bit.Thehexadecimal objectfileisanASCIIrepresentationofanabsolutebinaryobjectfile.Therearesixdifferenttypesofrecords: • DataRecord(8−,16,or32−bitformats) • EndofFileRecord(8−,16,or32−bitformats) • ExtendedSegmentAddressRecord(16,or32−bitformats) • StartSegmentAddressRecord(16,or32−bitformats) • ExtendedLinearAddressRecord(32−bitformatonly) • StartLinearAddressRecord(32−bitformatonly) Bydefaultthelinkergeneratesrecordsinthe32−bitformat(4−byteaddresses).

GeneralRecordFormat

Intheoutputfile,therecordformatis:

ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ

ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ

Á Á Á Á Á

Á : length offset type content checksum

ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ

Á Á Á Á Á Á

ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ Where:ÁÁÁ : istherecordheader. length istherecordlengthwhichspecifiesthenumberofbytesofthecontentfield.Thisvalueoccupiesonebyte(two hexadecimaldigits).Thelinkeroutputsrecordsof255bytes(32hexadecimaldigits)orless;thatis,lengthis nevergreaterthanFFH. offset isthestartingloadoffsetspecifyinganabsoluteaddressinmemorywherethedataistobelocatedwhenloaded byatool.Thisfieldistwobyteslong.ThisfieldisonlyusedforDataRecords.Inotherrecordsthisfieldiscoded asfourASCIIzerocharacters(’0000’). type istherecordtype.Thisvalueoccupiesonebyte(twohexadecimaldigits).Therecordtypesare:

ByteType Recordtype 00 Data 01 EndofFile 02 Extendedsegmentaddress(notused) 03 Startsegmentaddress(notused) 04 Extendedlinearaddress(32−bit) 05 Startlinearaddress(32−bit) content istheinformationcontainedintherecord.Thisdependsontherecordtype. checksum istherecordchecksum.Thelinkercomputesthechecksumbyfirstaddingthebinaryrepresentationofthe previousbytes(fromlengthtocontent).Thelinkerthencomputestheresultofsummodulo256andsubtractsthe remainderfrom256(two’scomplement).Therefore,thesumofallbytesfollowingtheheaderiszero.

ExtendedLinearAddressRecord TheExtendedLinearAddressRecordspecifiesthetwomostsignificantbytes(bits16−31)oftheabsoluteaddressofthefirst

databyteinasubsequentDataRecord:

ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ

ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ

Á Á Á Á Á

Á : 02 0000 04 upper_address checksum

ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ

7−5 MicroBlazeEmbeddedToolsReference

The32−bitabsoluteaddressofabyteinaDataRecordiscalculatedas: (address+offset+index)modulo4G where: address isthebaseaddress,wherethetwomostsignificantbytesaretheupper_addressandthetwoleastsignificant bytesarezero. offset isthe16−bitoffsetfromtheDataRecord. index istheindexofthedatabytewithintheDataRecord(0forthefirstbyte). Example: :0200000400FFFB |||||_checksum ||||_upper_address |||_type ||_offset |_length

DataRecord

TheDataRecordspecifiestheactualprogramcodeanddata.

ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ

: length offset 00 data checksum

ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ

Á Á Á Á Á Á

ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ Thelengthbytespecifiesthenumberofdatabytes.Thelinkerhasanoptionthatcontrolsthelengthoftheoutputbufferfor generatingDatarecords.Thedefaultbufferlengthis32bytes. Theoffsetisthe16−bitstartingloadoffset.TogetherwiththeaddressspecifiedintheExtendedAddressRecorditspecifiesan absoluteaddressinmemorywherethedataistobelocatedwhenloadedbyatool. Example: :0F00200000232222754E00754F04AF4FAE4E22C3 |||||_checksum ||||_data |||_type ||_offset |_length

StartLinearAddressRecord TheStartLinearAddressRecordcontainsthe32−bitprogramexecutionstartaddress.

Layout:

ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ

ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ

Á Á Á Á Á

Á : 04 0000 05 address checksum

ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ

Example: :0400000500FF0003F5 |||||_checksum ||||_address |||_type ||_offset |_length

7−6 ObjectFileFormats

EndofFileRecord Thehexadecimalfilealwaysendswiththefollowingend−of−filerecord: :00000001FF ||||_checksum |||_type ||_offset |_length

7−7 MicroBlazeEmbeddedToolsReference

7−8 8 LinkerScriptLanguage

Summary Thischapterdescribesthesyntaxofthelinkerscriptlanguage(LSL)

8.1 Introduction

Tomakefulluseofthelinker,youcanwriteascriptwithinformationaboutthearchitectureofthetargetprocessorandlocating information.ThelanguageforthescriptiscalledtheLinkerScriptLanguage(LSL).Thischapterfirstdescribesthestructureof anLSLfile.ThenextsectioncontainsasummaryoftheLSLsyntax.Finally,intheremainingsections,thesemanticsofthe LinkerScriptLanguageisexplained. TheTASKINGlinkerisatargetindependentlinker/locatorthatcansimultaneouslylinkandlocateallprogramsforallcores availableonatargetboard.Thetargetboardmaybeofarbitrarycomplexity.Asimpletargetboardmaycontainonestandard processorwithsomeexternalmemorythatexecutesonetask.Acomplextargetboardmaycontainmultiplestandard processorsandDSPscombinedwithconfigurableIP−coresloadedinanFPGA.Eachcoremayexecuteadifferentprogram, andexternalmemorymaybesharedbymultiplecores. LSLservestwopurposes.Firstitenablesyoutospecifythecharacteristics(thatareofinteresttothelinker)ofyourspecific targetboardandofthecoresinstalledontheboard.Seconditenablesyoutospecifyhowsectionsshouldbelocatedin memory.

8.2 StructureofaLinkerScriptFile

Ascriptfileconsistsofseveraldefinitions.Thedefinitionscanappearinanyorder.

Thearchitecturedefinition(required) Inessenceanarchitecturedefinitiondescribeshowthelinkershouldconvertlogicaladdressesintophysicaladdressesfora giventypeofcore.Ifthecoresupportsmultipleaddressspaces,thenforeachspacethelinkermustknowhowtoperformthis conversion.Inthiscontextaphysicaladdressisanoffsetonagiveninternalorexternalbus.Additionallythearchitecture definitioncontainsinformationaboutitemssuchasthe(hardware)stackandthevectortable. ThisspecificationisnormallywrittenbyAltium.ThearchitecturedefinitionoftheLSLfileshouldnotbechangedbyyouunless youalsomodifythecore’shardwarearchitecture.IftheLSLfiledescribesamulti−coresystemanarchitecturedefinitionmustbe availableforeachdifferenttypeofcore.

Seesection8.5,SemanticsoftheArchitectureDefinitionfordetaileddescriptionsofLSLinthearchitecturedefinition.

Thederivativedefinition Thederivativedefinitiondescribestheconfigurationoftheinternal(on−chip)busandmemorysystem.Basicallyittellsthelinker howtoconvertoffsetsonthebusesspecifiedinthearchitecturedefinitionintooffsetsininternalmemory.Aderivativedefinition mustbepresentinanLSLfile.andDSPsoftenhaveinternalmemoryandI/Osub−systemsapartfromoneor morecores.Thedesignofsuchachipiscalledaderivative. WhenyoudesignanFPGAtogetherwithaPCB,thecomponentsontheFPGAbecomepartoftheboarddesignandthereisno needtodistinguishbetweeninternalandexternalmemory.Forthisreasonyouprobablydonotneedtoworkwithderivative definitionsatall.Thereare,however,twosituationswherederivativedefinitionsareuseful: 1. Whenyoure−useanFPGAdesignforseveralboarddesignsitmaybepracticaltowriteaderivativedefinitionfortheFPGA designandincludeitintheprojectLSLfile. 2. Whenyouwanttousemultiplecoresofthesametype,youmustinstantiatethecoresinaderivativedefinition,sincethe linkerautomaticallyinstantiatesonlyasinglecoreforanunusedarchitecture.

8−1 MicroBlazeEmbeddedToolsReference

Seesection8.6,SemanticsoftheDerivativeDefinitionforadetaileddescriptionofLSLinthederivativedefinition.

Theprocessordefinition Theprocessordefinitiondescribesaninstanceofaderivative.Typicallytheprocessordefinitioninstantiatesonederivativeonly (single−coreprocessor).Aprocessorthatcontainsmultiplecoreshavingthesame(homogeneous)ordifferent(heterogeneous) architecturecanalsobedescribedbyinstantiatingmultiplederivativesofthesameordifferenttypesinseparateprocessor definitions. Ifforaderivative’A’noprocessorisdefinedintheLSLfile,thelinkerautomaticallycreatesaprocessornamed’A’ofderivative ’A’.Thisiswhyforsingle−processorapplicationsitisenoughtospecifythederivativeintheLSLfile.

Seesection8.7,SemanticsoftheBoardSpecificationforadetaileddescriptionofLSLintheprocessordefinition.

Thememoryandbusdefinitions(optional) Memoryandbusdefinitionareusedwithinthecontextofaderivativedefinitiontospecifyinternalmemoryandon−chipbuses.In thecontextofaboardspecificationthememoryandbusdefinitionsareusedtodefineexternal(off−chip)memoryandbuses. Giventheabovedefinitionsthelinkercanconvertalogicaladdressintoanoffsetintoanon−chiporoff−chipmemorydevice.

Seesection8.7.3,DefiningExternalMemoryandBuses,formoreinformationonhowtospecifytheexternalphysical memorylayout.Internalmemoryforaprocessorshouldbedefinedinthederivativedefinitionforthatprocessor.

Theboardspecification Theprocessordefinitionandmemoryandbusdefinitionstogetherformaboardspecification.LSLprovideslanguageconstructs toeasilydescribesingle−coreandheterogeneousorhomogeneousmulti−coresystems.Theboardspecificationdescribesall characteristicsofyourtargetboard’ssystembuses,memorydevices,I/Osub−systems,andcoresthatareofinteresttothe linker.Basedontheinformationprovidedintheboardspecificationthelinkercanforeachcore: • convertalogicaladdresstoanoffsetwithinamemorydevice • locatesectionsinphysicalmemory • maintainanoverallviewoftheusedandfreephysicalmemorywithinthewholesystemwhilelocating Thesectionlayoutdefinition(optional) Theoptionalsectionlayoutdefinitionenablesyoutoexactlycontrolwhereinputsectionsarelocated.Featuresareprovided suchas:theabilitytoplacesectionsatagivenload−addressorrun−timeaddress,toplacesectionsinagivenorder,andto overlaycodeand/ordatasections. Whichobjectfiles(sections)constitutethetaskthatwillrunonagivencoreisspecifiedonthecommandlinewhenyouinvoke thelinker.Thelinkerwilllinkandlocateallsectionsofalltaskssimultaneously.Fromthesectionlayoutdefinitionthelinkercan deducewhereagivensectionmaybelocatedinmemory,formtheboardspecificationthelinkercandeducewhichphysical memoryis(still)availablewhilelocatingthesection.

Seesection8.9,SemanticsoftheSectionLayoutDefinition,formoreinformationonhowtolocateasectionataspecific placeinmemory.

SkeletonofaLinkerScriptFile Theskeletonofalinkerscriptfilenowlooksasfollows: architecturearchitecture_name { architecturedefinition } derivativederivative_name { derivativedefinition }

8−2 LinkerScriptLanguage

processorprocessor_name { processordefinition } memorydefinitionsand/orbusdefinitions section_layoutspace_name { sectionplacementstatements }

8.3 SyntaxoftheLinkerScriptLanguage

8.3.1 Preprocessing

WhenthelinkerloadsanLSLfile,thelinkerprocessesitwithaC−styleprepocessor.Assuch,itstripsCandC++comments. YoucanusethestandardISOCpreprocessordirectives,suchas#include,#define,#if/#else/#endif. Forexample: #include"arch.lsl"

Preprocessandincludethefilearch.lslatthispointintheLSLfile.

8.3.2 LexicalSyntax

ThefollowinglexiconisusedtodescribethesyntaxoftheLinkerScriptLanguage: A::=B =AisdefinedasB A::=BC =AisdefinedasBandC;BisfollowedbyC A::=B|C= AisdefinedasBorC 0|1 =zerooroneoccurrenceofB >=0 =zeroofmoreoccurrencesofB >=1 =oneofmoreoccurrencesofB IDENTIFIER=acharactersequencestartingwith’a’−’z’,’A’−’Z’or’_’. Followingcharactersmayalsobedigitsanddots’.’ STRING=sequenceofcharactersnotstartingwith\n,\ror\t DQSTRING="STRING"(doublequotedstring) OCT_NUM=octalnumber,startingwithazero(06,045) DEC_NUM=decimalnumber,notstartingwithazero(14,1024) HEX_NUM=hexadecimalnumber,startingwith’0x’(0x0023,0xFF00) OCT_NUM,DEC_NUMandHEX_NUMcanbefollowedbyak(kilo),M(mega),orG(giga). Charactersinboldarecharactersthatoccurliterally.Wordsinitalicsarehigherordertermsthataredefinedinthesameorin oneoftheothersections. TowritecommentsinLSLfile,youcanusetheCstyle’/**/’orC++style’//’.

8−3 MicroBlazeEmbeddedToolsReference

8.3.3 Identifiers arch_name::=IDENTIFIER bus_name::=IDENTIFIER core_name::=IDENTIFIER derivative_name::=IDENTIFIER file_name::=DQSTRING group_name::=IDENTIFIER mem_name::=IDENTIFIER proc_name::=IDENTIFIER section_name::=DQSTRING space_name::=IDENTIFIER stack_name::=section_name symbol_name::=DQSTRING

8.3.4 Expressions

TheexpressionsandoperatorsinthissectionworkthesameasinISOC. number::=OCT_NUM |DEC_NUM |HEX_NUM expr::=number |symbol_name |unary_opexpr |exprbinary_opexpr |expr?expr:expr |(expr) |function_call unary_op::=!//logicalNOT |~//bitwisecomplement |−//negativevalue binary_op::=^//exclusiveOR |*//multiplication |///division |%//modulus |+//addition |−//subtraction |>>//rightshift |<<//leftshift |==//equalto |!=//notequalto |>//greaterthan |<//lessthan |>=//greaterthanorequalto |<=//lessthanorequalto |&//bitwiseAND ||//bitwiseOR |&&//logicalAND |||//logicalOR

8−4 LinkerScriptLanguage

8.3.5 Built−inFunctions function_call::=absolute(expr) |addressof(addr_id) |exists(section_name) |max(expr,expr) |min(expr,expr) |sizeof(size_id) addr_id::=sect:section_name |group:group_name size_id::=sect:section_name |group:group_name |mem:mem_name • Everyspace,bus,memory,sectionorgroupyourreferto,mustbedefinedintheLSLfile. • Theaddressof()andsizeof()functionswiththegrouporsectargumentcanonlybeusedintherighthandsideofan assignment.Thesizeof()functionwiththememargumentcanbeusedanywhereinsectionlayouts. Youcanusethefollowingbuilt−infunctionsinexpressions.Allfunctionsreturnanumericalvalue.Thisvalueisa64−bitsigned integer. absolute()

intabsolute(expr)

Convertsthevalueofexprtoapositiveinteger. absolute("labelA"−"labelB") addressof()

intaddressof(addr_id)

Returnstheaddressofaddr_id,whichisanamedsectionorgroup.Togettheoffsetofthesectionwiththenameasect: addressof(sect:"asect")

Thisfunctiononlyworksinassignments. exists()

intexists(section_name)

Thefunctionreturns1ifthesectionsection_nameexistsinoneormoreobjectfile,0otherwise.Ifthesectionisnotpresentin inputobjectfiles,butgeneratedfromLSL,theresultofthisfunctionisundefined. Tocheckwhetherthesectionmysectionexistsinoneoftheobjectfilesthatisspecifiedtothelinker: exists("mysection") max()

intmax(expr,expr)

Returnsthevalueoftheexpressionthathasthelargestvalue.Togetthehighestvalueoftwosymbols: max("sym1","sym2")

8−5 MicroBlazeEmbeddedToolsReference min()

intmin(expr,expr)

Returnsthevalueoftheexpressionhathasthesmallestvalue.Togetthelowestvalueoftwosymbols: min("sym1","sym2") sizeof()

intsizeof(size_id)

Returnsthesizeoftheobject(group,sectionormemory)theidentifierrefersto.Togetthesizeofthesection"asection": sizeof(sect:"asection")

Thegroupandsectargumentsonlyworksinassignments.Thememargumentcanbeusedanywhereinsection layouts.

8.3.6 LSLDefinitionsintheLinkerScriptFile description::=>=1 definition::=architecture_definition |derivative_definition |board_spec |section_definition |section_setup • Atleastonearchitecture_definitionmustbepresentintheLSLfile.

8.3.7 MemoryandBusDefinitions mem_def::=memorymem_name{>=0} • Amem_defdefinesamemorywiththemem_nameasauniquename. mem_descr::=type=0|1mem_type |mau=expr |size=expr |speed=number |fill<=fill_values>0|1 |mapping • Amem_defcontainsexactlyonetypestatement. • Amem_defcontainsexactlyonemaustatement(non−zerosize). • Amem_defcontainsexactlyonesizestatement. • Amem_defcontainszerooronespeedstatement(ifabsent,thedefaultspeedvalueis1). • Amem_defcontainszerooronefillstatement. • Amem_defcontainsatleastonemapping. mem_type::=rom//attrs=rx |ram//attrs=rw |nvram//attrs=rwx fill_values::=expr |[expr<,expr>>=0] bus_def::=busbus_name{>=0} • Abus_defstatementdefinesabuswiththegivenbus_nameasauniquenamewithinacorearchitecture.

8−6 LinkerScriptLanguage bus_descr::=mau=expr |width=expr//buswidth,nr |//ofdatabits |mapping//legaldestination //’bus’only • Themauandwidthstatementsappearexactlyonceinabus_descr.Thedefaultvalueforwidthisthemausize. • ThebuswidthmustbeanintegertimesthebusMAUsize. • TheMAUsizemustbenon−zero. • Abuscanonlyhaveamappingonadestinationbus(throughdest=bus:). mapping::=map(map_descr<,map_descr>>=0) map_descr::=dest=destination |dest_dbits=range |dest_offset=expr |size=expr |src_dbits=range |src_offset=expr • Amappingrequiresatleastthesizeanddeststatements. • Eachmap_descrcanoccuronlyonce. • Youcandefinemultiplemappingsfromasinglesource. • Overlapbetweensourcerangesordestinationrangesisnotallowed. • Ifthesrc_dbitsordest_dbitsstatementisnotpresent,itsvaluedefaultstothewidthvalueifthesource/destinationis abus,andtothemausizeotherwise. destination::=space:space_name |bus:0|1bus_name • Aspace_namereferstoadefinedaddressspace. • Aproc_namereferstoadefinedprocessor. • Acore_namereferstoadefinedcore. • Abus_namereferstoadefinedbus. • Thefollowingmappingsareallowed(sourcetodestination) − space=>space − space=>bus − bus=>bus − memory=>bus range::=expr..expr • Withaddressranges,theendaddressisnotpartoftherange.

8.3.8 ArchitectureDefinition architecture_definition ::=architecturearch_name <(parameter_list)>0|1 0|1>0|1 {arch_spec>=0} • Anarchitecture_definitiondefinesacorearchitecturewiththegivenarch_nameasauniquename. • Atleastonespace_defandatleastonebus_defhavetobepresentinanarchitecture_definition. • Anarchitecture_definitionthatusestheextendsconstructdefinesanarchitecturethatinheritsallelementsofthe architecturedefinedbythesecondarch_name.TheparentarchitecturemustbedefinedintheLSLfileaswell. parameter_list::=parameter<,parameter>>=0 parameter::=IDENTIFIER<=expr>0|1

8−7 MicroBlazeEmbeddedToolsReference argument_list::=expr<,expr>>=0 arch_spec::=bus_def |space_def |endianness_def space_def::=spacespace_name{>=0} • Aspace_defdefinesanaddressspacewiththegivenspace_nameasauniquenamewithinanarchitecture. space_descr::=space_property; |section_definition//nospaceref |vector_table_statement |reserved_range space_property::=id=number//asusedinobject |mau=expr |align=expr |page_size=expr<[range]<|[range]>>=0>0|1 |page |direction=direction |stack_def |heap_def |copy_table_def |start_address |mapping • Aspace_defcontainsexactlyoneidandonemaustatement. • Aspace_defcontainsatmostonealignstatement. • Aspace_defcontainsatmostonepage_sizestatement. • Aspace_defcontainsatleastonemapping. stack_def::=stackstack_name(stack_heap_descr <,stack_heap_descr>>=0) • Astack_defdefinesastackwiththestack_nameasauniquename. heap_def::=heapheap_name(stack_heap_descr <,stack_heap_descr>>=0) • Aheap_defdefinesaheapwiththeheap_nameasauniquename. stack_heap_descr::=min_size=expr |grows=direction |align=expr |fixed |id=expr • Themin_sizestatementmustbepresent. • Youcanspecifyatmostonealignstatementandonegrowsstatement. • Eachstackdefinitionhasitsownuniqueid,thenumberspecifiedcorrespondstotheindexinthe.CALLSdirectiveas generatedbythecompiler.Iftheidisomitted,theidis0(zero). direction::=low_to_high |high_to_low • Ifyoudonotspecifythegrowsstatement,thestackandgrowlow−to−high. copy_table_def::=copytable<(copy_table_descr <,copy_table_descr>>=0)>0|1 • Aspace_defcontainsatmostonecopytablestatement. • Ifthearchitecturedefinitioncontainsmorethanoneaddressspace,exactlyonecopytablemustbedefinedinoneofthe spaces.Ifthearchitecturedefinitioncontainsonlyoneaddressspace,acopytabledefinitionisoptional(itwillbegenerated inthespace).

8−8 LinkerScriptLanguage copy_table_descr::=align=expr |copy_unit=expr |dest0|1=space_name |page • Thecopy_unitisdefinedbythesizeinMAUsinwhichthestartupcodemovesdata. • Thedeststatementisonlyrequiredwhenthestartupcodeinitializesmemoryusedbyanotherprocessorthathasno accesstoROM. • Aspace_namereferstoadefinedaddressspace. start_addr::=start_address(start_addr_descr <,start_addr_descr>>=0) start_addr_descr::=run_addr=expr |symbol=symbol_name • Asymbol_namereferstothesectionthatcontainsthestartupcode. vector_table_statement ::=vector_tablesection_name (vecttab_spec<,vecttab_spec>>=0) {>=0} vecttab_spec::=vector_size=expr |size=expr |id_symbol_prefix=symbol_name |run_addr=addr_absolute |template=section_name |template_symbol=symbol_name |vector_prefix=section_name |fill=vector_value |no_inline |copy vector_def::=vector(vector_spec<,vector_spec>>=0) vector_spec::=id=vector_id_spec |fill=vector_value vector_id_spec::=number |[range]<,[range]>>=0 vector_value::=symbol_name |[number<,number>>=0] |loop<[expr]>0|1 reserved_range::=reservedexpr..expr; • Theendaddressisnotpartoftherange. endianness_def::=endianness{>=1} endianness_type::=big |little

8.3.9 DerivativeDefinition derivative_definition ::=derivativederivative_name <(parameter_list)>0|1 0|1>0|1 {>=0} • Aderivative_definitiondefinesaderivativewiththegivenderivative_nameasauniquename.

8−9 MicroBlazeEmbeddedToolsReference derivative_spec::=core_def |bus_def |mem_def |section_definition//noprocessorname |section_setup core_def::=corecore_name{>=0} • Acore_defdefinesacorewiththegivencore_nameasauniquename. • Atleastonecore_defmustbepresentinaderivative_definition. core_descr::=architecture=arch_name <(argument_list)>0|1 |endianness=(endianness_type <,endianness_type>>=0) • Anarch_namereferstoadefinedcorearchitecture. • Exactlyonearchitecturestatementmustbepresentinacore_def.

8.3.10 ProcessorDefinitionandBoardSpecification board_spec::=proc_def |bus_def |mem_def proc_def::=processorproc_name {proc_descr;} proc_descr::=derivative=derivative_name <(argument_list)>0|1 • Aproc_defdefinesaprocessorwiththeproc_nameasauniquename. • IfyoudonotexplicitlydefineaprocessorforaderivativeinanLSLfile,thelinkerdefinesaprocessorwiththesamenameas thatderivative. • Aderivative_namereferstoadefinedderivative. • Aproc_defcontainsexactlyonederivativestatement.

8.3.11 SectionLayoutDefinitionandSectionSetup section_definition::=section_layout0|1 <(locate_direction)>0|1 {>=0} • Asectiondefinitioninsideaspacedefinitiondoesnothaveaspace_ref. • Allglobalsectiondefinitionshaveaspace_ref. space_ref::=0|1:0|1 :space_name • Ifmorethanoneprocessorispresent,theproc_namemustbegivenforaglobalsectionlayout. • Ifthesectionlayoutreferstoaprocessorthathasmorethanonecore,thecore_namemustbegiveninthespace_ref. • Aproc_namereferstoadefinedprocessor. • Acore_namereferstoadefinedcore. • Aspace_namereferstoadefinedaddressspace. locate_direction::=direction=direction direction::=low_to_high |high_to_low • Asectionlayoutcontainsatmostonedirectionstatement. • Ifyoudonotspecifythedirectionstatement,thelocatedirectionofthesectionlayoutislow−to−high. section_statement ::=simple_section_statement; |aggregate_section_statement

8−10 LinkerScriptLanguage simple_section_statement ::=assignment |select_section_statement |special_section_statement assignment::=symbol_nameassign_opexpr assign_op::== |:= select_section_statement ::=select0|10|1 0|1 • Eitherasection_nameoratleastonesection_selectionmustbedefined. section_selections ::=(section_selection <,section_selection>>=0) section_selection ::=attributes=<<+|−>attribute>>0 • +attributemeans:selectallsectionsthathavethisattribute. • −attributemeans:selectallsectionsthatdonothavethisattribute. special_section_statement ::=heapstack_name0|1 |stackstack_name0|1 |copytable |reservedsection_name0|1 • Specialsectionscannotbeselectedinload−timegroups. size_spec::=(size=expr) reserved_specs::=(reserved_spec<,reserved_spec>>=0) reserved_spec::=attributes |fill_spec |size=expr |alloc_allowed=absolute|ranged • Ifareservedsectionhasattributesr,rw,x,rxorrwx,andnofillpatternisdefined,thesectionisfilledwithzeros.Ifno attributesareset,thesectioniscreatedasascratchsection(attributesws,noimage). fill_spec::=fill=fill_values fill_values::=expr |[expr<,expr>>=0] aggregate_section_statement ::={>=0} |group_descr |if_statement |section_creation_statement group_descr::=group0|1<(group_specs)>0|1 section_statement • Foreverygroupwithaname,thelinkerdefinesalabel. • Notwogroupsforaddressspacesofacorecanhavethesamegroup_name. group_specs::=group_spec<,group_spec>>=0

8−11 MicroBlazeEmbeddedToolsReference group_spec::=group_alignment |attributes |copy |nocopy |group_load_address |fill<=fill_values>0|1 |group_page |group_run_address |group_type |allow_cross_references |priority=number • Theallow−cross−referencespropertyisonlyallowedforoverlaygroups. • Subgroupsinheritallpropertiesfromaparentgroup. group_alignment::=align=expr attributes::=attributes=>=1 attribute::=r//readablesections |w//writablesections |x//executablecodesections |i//initializedsections |s//scratchsections |b//blanked(cleared)sections group_load_address ::=load_addr<=load_or_run_addr>0|1 group_page::=page<=expr>0|1 |page_size=expr<[range]<|[range]>>=0>0|1 group_run_address::=run_addr<=load_or_run_addr>0|1 group_type::=clustered |contiguous |ordered |overlay • Fornon−contiguousgroups,youcanonlyspecifygroup_alignmentandattributes. • Theoverlaykeywordalsosetsthecontiguousproperty. • Theclusteredpropertycannotbesettogetherwithcontiguousororderedonasinglegroup. load_or_run_addr::=addr_absolute |addr_range<|addr_range>>=0 addr_absolute::=expr |memory_reference[expr] • Anabsoluteaddresscanonlybesetonorderedgroups. addr_range::=[expr..expr] |memory_reference |memory_reference[expr..expr] • Theparentofagroupwithanaddr_rangeorpagerestrictioncannotbeordered,contiguousorclustered. • Theendaddressisnotpartoftherange. memory_reference::=mem:0|1mem_name • Aproc_namereferstoadefinedprocessor. • Amem_namereferstoadefinedmemory. if_statement::=if(expr)section_statement 0|1

8−12 LinkerScriptLanguage section_creation_statement ::=sectionsection_name(section_specs) {>=0} section_specs::=section_spec<,section_spec>>=0 section_spec::=attributes |fill_spec |size=expr |blocksize=expr |overflow=section_name section_statement2 ::=select_section_statement; |group_descr2 |{>=0} group_descr2::=group0|1 (group_specs2) section_statement2 group_specs2::=group_spec2<,group_spec2>>=0 group_spec2::=group_alignment |attributes |load_addr section_setup::=section_setupspace_ref {>=0} section_setup_item ::=vector_table_statement |reserved_range |stack_def; |heap_def;

8.4 ExpressionEvaluation

Onlyconstantexpressionsareallowed,includingsizes,butnotaddresses,ofsectionsinobjectfiles. Allexpressionsareevaluatedwith64−bitprecisionintegerarithmetic.Theresultofanexpressioncanbeabsoluteor relocatable.Asymbolyouassigniscreatedasanabsolutesymbol.

8−13 MicroBlazeEmbeddedToolsReference

8.5 SemanticsoftheArchitectureDefinition

Keywordsinthearchitecturedefinition architecture extends endiannessbiglittle bus mau width map space id mau align page_size page directionlow_to_highhigh_to_low stack min_size growslow_to_highhigh_to_low align fixed id heap min_size growslow_to_highhigh_to_low align fixed id copytable align copy_unit dest page vector_table vector_size size id_symbol_prefix run_addr template template_symbol vector_prefix fill no_inline copy vector id fillloop reserved start_address run_addr symbol map

8−14 LinkerScriptLanguage

map destbusspace dest_dbits dest_offset size src_dbits src_offset

8.5.1 DefininganArchitecture

Withthekeywordarchitectureyoudefineanarchitectureandassignauniquenametoit.Thenameisusedtorefertoitat otherplacesintheLSLfile: architecturename { definitions }

Ifyouaredefiningmultiplecorearchitecturesthatshowgreatresemblance,youcandefinethecommonfeaturesinaparent corearchitectureandextendthiswithachildcorearchitecturethatcontainsspecificfeatures.Thechildinheritsallfeaturesof theparent.Withthekeywordextendsyoucreateachildcorearchitecture: architecturename_child_archextendsname_parent_arch { definitions }

Acorearchitecturecanhaveanynumberofparameters.Theseareidentifierswhichgetvaluesassignedoninstantiationor extensionofthearchitecture.Youcanusetheminanyexpressionwithinthecorearchitecture.Parameterscanhavedefault values,whichareusedwhenthecorearchitectureisinstantiatedwithlessargumentsthanthereareparametersdefinedforit. Whenyouextendacorearchitectureyoucanpassargumentstotheparentarchitecture.Argumentsareexpressionsthatset thevalueoftheparametersofthesub−architecture. architecturename_child_arch(parm1,parm2=1) extendsname_parent_arch(arguments) { definitions }

8.5.2 DefiningInternalBuses

Withthebuskeywordyoudefineabus(thecombinationofdataandcorrespondingaddressbus).Thebusnameisusedto identifyabusanddoesnotconflictwithotheridentifiers.Busdescriptionsinanarchitecturedefinitionorderivativedefinition defineinternalbuses.Someinternalbusesareusedtocommunicatewiththecomponentsoutsidethecoreorprocessor.Such busesonaprocessorhavephysicalpinsreservedforthenumberofbitsspecifiedwiththewidthstatements. • ThemaufieldspecifiestheMAUsize(MinimumAddressableUnit)ofthedatabus.Thisfieldisrequired. • Thewidthfieldspecifiesthewidth(numberofaddresslines)ofthedatabus.ThedefaultvalueistheMAUsize. • Themapkeywordspecifieshowthisbusmapsontoanotherbus(ifso).Mappingsaredescribedinsection8.5.4,Mappings. busbus_name { mau=8; width=8; map(map_description); }

8.5.3 DefiningAddressSpaces

Withthespacekeywordyoudefinealogicaladdressspace.Thespacenameisusedtoidentifytheaddressspaceanddoes notconflictwithotheridentifiers.

8−15 MicroBlazeEmbeddedToolsReference

• Theidfielddefineshowtheaddressingspaceisidentifiedinobjectfiles.Ingeneral,eachaddressspacehasauniqueID. ThelinkerlocatessectionswithacertainIDintheaddressspacewiththesameID.Thisfieldisrequired.InIEEEthisIDis specifiedexplicitlyforsectionsandsymbols,ELFsectionsmapbydefaulttotheaddressspacewithID1.Sectionswithone ofthespecialnamesdefinedintheABI(ApplicationBinaryInterface)maymaptodifferentaddressspaces. • ThemaufieldspecifiestheMAUsize(MinimumAddressableUnit)ofthespace.Thisfieldisrequired. • Thealignvaluemustbeapoweroftwo.Thelinkerusesthisvaluetocomputethestartaddresseswhensectionsare concatenated.AnalignvalueofnmeansthatobjectsintheaddressspacehavetobealignedonnMAUs. • Thepage_sizefieldsetsthepagealignmentandpagesizeinMAUsfortheaddressspace.Itmustbeapowerof2.The defaultvalueis1.Ifoneormorepagerangesaresuppliedthesuppliedvalueonlysetsthepagealignment.Theranges specifytheavailablespaceineachpage,asoffsetstothepagestart,whichisalignedatthepagealignment. SeealsothepagekeywordinsubsectionLocatingagroupinsection8.9.2,CreatingandLocatingGroupsofSections. • Withtheoptionaldirectionfieldyoucanspecifyhowallsectionsinthisspaceshouldbelocated.Thiscanbeeitherfrom low_to_highaddresses(thisisthedefault)orfromhigh_to_lowaddresses. • Themapkeywordspecifieshowthisaddressspacemapsontoaninternalbusorontoanotheraddressspace.Mappingsare describedinsection8.5.4,Mappings. Stacksandheaps • Thestackkeyworddefinesastackintheaddressspaceandassignsanametoit.Thearchitecturedefinitionmustcontain atleastonestackdefinition.Eachstackofacorearchitecturemusthaveauniquename.Seealsothestackkeywordin section8.9.3,CreatingorModifyingSpecialSections. Thestackisdescribedintermsofaminimumsize(min_size)andthedirectioninwhichthestackgrows(grows).This canbeeitherfromlow_to_highaddresses(stackgrowsupwards,thisisthedefault)orfromhigh_to_lowaddresses (stackgrowsdownwards).Themin_sizeisrequired. Bydefault,thelinkertriestomaximizethesizeofthestacksandheaps.Afterlocatingallsections,thelargestremaininggap inthespaceisusedcompletelyforthestacksandheaps.Ifyouspecifythekeywordfixed,youcandisablethisso−called ’balloonbehavior’.Thesizeisalsofixedifyouusedastackorheapinthesoftwarelayoutdefinitioninarestrictedway.For examplewhenyouoverrideastackwithanothersizeorselectastackinanorderedgroupwithothersections. TheidkeywordmatchesstackinformationgeneratedbythecompilerwithastacknamespecifiedinLSL.Thisvalue assignedtothiskeywordisstronglyrelatedtothecompiler’soutput,sousersarenotsupposedtochangethisconfiguration. Optionallyyoucanspecifyanalignmentforthestackwiththeargumentalign.Thisalignmentmustbeequalorlargerthan thealignmentthatyouspecifyfortheaddressspaceitself. • Theheapkeyworddefinesaheapintheaddressspaceandassignsanametoit.Thedefinitionofaheapissimilartothe definitionofastack.Seealsotheheapkeywordinsection8.9.3,CreatingorModifyingSpecialSections.

Seesection8.9,SemanticsoftheSectionLayoutDefinition,forinformationoncreatingandplacingstacksections.

Copytables • Thecopytablekeyworddefinesacopytableintheaddressspace.Thecontentofthecopytableiscreatedbythelinker andcontainsthestartaddressandsizeofallsectionsthatshouldbeinitializedbythestartupcode.Youmustdefineexactly onecopytableinoneoftheaddressspaces(foracore). Optionallyyoucanspecifyanalignmentforthecopytablewiththeargumentalign.Thisalignmentmustbeequalorlarger thanthealignmentthatyouspecifyfortheaddressspaceitself.Ifsmaller,thealignmentfortheaddressspaceisused. Thecopy_unitargumentspecifiesthesizeinMAUsofinformationchunksthatarecopied.Ifyoudonotspecifythecopy unit,theMAUsizeoftheaddressspaceitselfisused. Thedestargumentspecifiesthedestinationaddressspacethatthecodeusesforthecopytable.Thelinkerusesthis informationtogeneratethecorrectaddressesinthecopytable.Thememoryintowherethesectionsmustbecopiedat run−time,mustbeaccessiblefromthisdestinationspace. Sectionsgeneratedforthecopytablemaygetapagerestrictionwiththeaddressspace’spagesize,byaddingthepage argument.

8−16 LinkerScriptLanguage

Vectortable • Thevector_tablekeyworddefinesavectortablewithnvectorsofsizem(ThisisaninternalLSLobjectsimilartoanLSL group.)Therun_addrargumentspecifiesthelocationofthefirstvector(id=0).Thiscanbeasimpleaddressoranoffsetin memory(seethedescriptionoftherun−timeaddressinsubsectionLocatingagroupinsection8.9.2,CreatingandLocating GroupsofSections).Avectortabledefinessymbols_lc_ub_fooand_lc_ue_foopointingtostartandendofthetable. vector_table"vtable"(vector_size=m,size=n,run_addr=x,...)

Seethefollowingexampleofavectortabledefinition: vector_table"vtable"(vector_size=4,size=256,run_addr=0, template=".text.vector_template", template_symbol="_lc_vector_target", vector_prefix="_vector_", id_symbol_prefix="foo", no_inline, /*default:empty,or*/ fill="foo",/*or*/ fill=[1,2,3,4],/*or*/ fill=loop) { vector(id=0,fill="_START"); vector(id=12,fill=[0xab,0x21,0x32,0x43]); vector(id=[1..11],fill=[0]); vector(id=[18..23],fill=loop); }

Thetemplateargumentdefinesthenameofthesectionthatholdsthecodetojumptoahandlerfunctionfromthevector table.Thistemplatesectiondoesnotgetlocatedandisremovedwhenthelocatephaseiscompleted.Thisargumentis required. Thetemplate_symbolargumentisthesymbolreferenceinthetemplatesectionthatmustbereplacedbytheaddressof thehandlerfunction.Thissymbolnameshouldstartwiththelinkerprefixforthesymboltobeignoredinthelinkphase.This argumentisrequired. Thevector_prefixargumentdefinesthenamesofvectorsections:thesectionforavectorwithidvector_idis $(vector_prefix)$(vector_id).VectorsdefinedinCorassemblysourcefilesthatshouldbeincludedinthevectortablemust havethecorrectsymbolname.ThecompilerusestheprefixthatisdefinedinthedefaultLSLfile(s);ifthisattributeis changed,thevectorsdeclaredinCsourcefilesarenotincludedinthevectortable.Whenavectorsuppliedinanobjectfile hasexactlyonerelocation,thelinkerwillassumeitisabranchtoahandlerfunction,andcanberemovedwhenthehandler isinlinedinthevectortable.Otherwise,noinliningisdone.Thisargumentisrequired. Withtheoptionalno_inlineargumentthevectorshandlersarenotinlinedinthevectortable. WiththeoptionalcopyargumentaROMcopyofthevectortableismadeandthevectortableiscopiedtoRAMatstartup. Withtheoptionalid_symbol_prefixargumentyoucansetaninternalstringrepresentingasymbolnameprefixthatmay befoundonsymbolsinvectorhandlercode.Whenthelinkerdetectssuchasymbolinahandler,thesymbolisassignedthe vectornumber.Ifthesymbolwasalreadyassignedavectornumber,awarningisissued. Thefillargumentsetsthedefaultcontentsofvectors.Ifnothingisspecifiedforavector,thissettingisused.Seebelow. Whennodefaultisprovided,emptyvectorsmaybeusedtolocatelargevectorhandlersandothersections.Onlyonefill argumentisallowed. Thevectorfielddefinesthecontentofvectorwiththenumberspecifiedbyid.Ifarangeisspecifiedforid([p..q,s..t])all vectorsintheranges(inclusive)aredefinedthesameway. Withfill=symbol_name,thevectormustjumptothissymbol.Ifthesectioninwhichthesymbolisdefinedfitsinthevector table(sizemaybe>m),locatethesectionatthelocationofthevector.Otherwise,insertcodetojumptothesymbol’svalue. Atemplatehandlersectionname+symbolnameforthetargetcodemustbesuppliedintheLSLfile. fill=[value(s)],fillsthevectorwiththespecifiedMAUvalues. Withfill=loopthevectorjumpstoitself.Withtheoptional[offset]youcanspecifyanoffsetfromthevectortableentry.

8−17 MicroBlazeEmbeddedToolsReference

Reservedaddressranges • Thereservedkeywordspecifiestoreserveapartofanaddressspaceevenifnotalloftherangeiscoveredbymemory. Seealsothereservedkeywordinsection8.9.3,CreatingorModifyingSpecialSections. Startaddress • Thestart_addresskeywordspecifiesthestartaddressforthepositionwheretheCstartupcodeislocated.Whena processorisreset,itinitializesitsprogramcountertoacertainstartaddress,sometimescalledtheresetvector.Inthe architecturedefinition,youmustspecifythisstartaddressinthecorrectaddressspaceincombinationwiththenameofthe labelintheapplicationcodewhichmustbelocatedhere. Therun_addrargumentspecifiesthestartaddress(resetvector).Ifthecorestartsexecutingusinganentryfromavector table,anddirectlyjumpstothestartlabel,youshouldomitthisargument. Thesymbolargumentspecifiesthenameofthelabelintheapplicationcodethatshouldbelocatedatthespecifiedstart address.Thesymbolargumentisrequired.Thelinkerwillresolvethestartsymbolanduseitsvalueafterlocatingforthe startaddressfieldinIEEE−695filesandIntelHexfiles.Ifyoualsospecifiedtherun_addrargument,thestartsymbol (label)mustpointtoasection.Thelinkerlocatesthissectionsuchthatthestartsymbolendsuponthestartaddress. spacespace_name { id=1; mau=8; align=8; page_size=1; stackname(min_size=1k,grows=low_to_high); reservedstart_address..end_address; start_address(run_addr=0x0000, symbol="start_label") map(map_description); }

8.5.4 Mappings

Youcanuseamappingwhenyoudefineaspace,busormemory.Withthemapfieldyouspecifyhowaddressesfromthe source(space,busormemory)aretranslatedtoaddressesofadestination(space,bus).Thefollowingmappingsarepossible: • space=>space • space=>bus • bus=>bus • memory=>bus Withamappingyouspecifyarangeofsourceaddressesyouwanttomap(specifiedbyasourceoffsetandasize),the destinationtowhichyouwanttomapthem(abusoranotheraddressspace),andtheoffsetaddressinthedestination. • Thedestargumentspecifiesthedestination.Thiscanbeabusoranotheraddressspace(onlyforaspacetospace mapping).Thisargumentisrequired. • Thesrc_offsetargumentspecifiestheoffsetofthesourceaddresses.Incombinationwithsize,thisspecifiestherangeof addressthataremapped.Bydefaultthesourceoffsetis0x0000. • Thesizeargumentspecifiesthenumberofaddressesthataremapped.Thisargumentisrequired. • Thedest_offsetargumentspecifiesthepositioninthedestinationtowhichthespecifiedrangeofaddressesismapped. Bydefaultthedestinationoffsetis0x0000. Ifyouaremappingabustoanotherbus,thenumberofdatalinesofeachbusmaydiffer.Inthiscaseyouhavetospecifya rangeofsourcedatalinesyouwanttomap(src_dbits=begin..end)andtherangeofdestinationdatalinesyouwantto mapthemto(dest_dbits=first..last). • Thesrc_dbitsargumentspecifiesarangeofdatalinesofthesourcebus.Bydefaultalldatalinesaremapped. • Thedest_dbitsargumentspecifiesarangeofdatalinesofthedestinationbus.Bydefault,alldatalinesfromthesource busaremappedonthedatalinesofthedestinationbus(startingwithline0).

8−18 LinkerScriptLanguage

Fromspacetospace Ifyoumapanaddressspacetoanotheraddressspace(nesting),youcandothisbymappingthesubspacetothecontaining largerspace.Inthisexampleasmallspaceof64kismappedonalargespaceof16M. spacesmall { id=2; mau=4; map(src_offset=0,dest_offset=0, dest=space:large,size=64k); }

Fromspacetobus Allspacesthatarenotmappedtoanotherspacemustmaptoabusinthearchitecture: spacelarge { id=1; mau=4; map(src_offset=0,dest_offset=0, dest=bus:bus_name,size=16M); }

Frombustobus Thenextexamplemapsanexternalbuscallede_bustoaninternalbuscalledi_bus.Thisinternalbusresidesonacore calledmycore.Thesourcebushas16datalineswhereasthedestinationbushasonly8datalines.Therefore,thekeywords src_dbitsanddest_dbitsspecifywhichsourcedatalinesaremappedonwhichdestinationdatalines. architecturemycore { busi_bus { mau=4; }

spacei_space { map(dest=bus:i_bus,size=256); } } buse_bus { mau=16; width=16; map(dest=bus:mycore:i_bus,src_dbits=0..7,dest_dbits=0..7) }

Itisnotpossibletomapaninternalbustoanexternalbus.

8−19 MicroBlazeEmbeddedToolsReference

8.6 SemanticsoftheDerivativeDefinition

Keywordsinthederivativedefinition derivative extends core architecture bus mau width map memory typereservedromramnvram mau size speed fill map section_layout section_setup map destbusspace dest_dbits dest_offset size src_dbits src_offset

8.6.1 DefiningaDerivative

Withthekeywordderivativeyoudefineaderivativeandassignauniquenametoit.Thenameisusedtorefertoitatother placesintheLSLfile: derivativename { definitions }

Ifyouaredefiningmultiplederivativesthatshowgreatresemblance,youcandefinethecommonfeaturesinaparentderivative andextendthiswithachildderivativethatcontainsspecificfeatures.Thechildinheritsallfeaturesoftheparent(coresand memories).Withthekeywordextendsyoucreateachildderivative: derivativename_child_derivextendsname_parent_deriv { definitions }

Aswithacorearchitecture,aderivativecanhaveanynumberofparameters.Theseareidentifierswhichgetvaluesassigned oninstantiationorextensionofthederivative.Youcanusetheminanyexpressionwithinthederivativedefinition. derivativename_child_deriv(parm1,parm2=1) extendsname_parent_derivh(arguments) { definitions }

8.6.2 InstantiatingCoreArchitectures

Withthekeywordcoreyouinstantiateacorearchitectureinaderivative.

8−20 LinkerScriptLanguage

• Withthekeywordarchitectureyoutellthelinkerthatthegivencorehasacertainarchitecture.Thearchitecturename referstoanexistingarchitecturedefinitioninthesameLSLfile. Forexample,ifyouhavetwocores(calledmycore_1andmycore_2)thathavethesamearchitecture(called mycorearch),youmustinstantiatebothcoresasfollows: coremycore_1 { architecture=mycorearch; } coremycore_2 { architecture=mycorearch; }

Ifthearchitecturedefinitionhasparametersyoumustspecifytheargumentsthatcorrespondwiththeparameters.For examplemycorearch1expectstwoparameterswhichareusedinthearchitecturedefinition: coremycore { architecture=mycorearch1(1,2); }

8.6.3 DefiningInternalMemoryandBuses

Withthememorykeywordyoudefinephysicalmemorythatispresentonthetargetboard.Thememorynameisusedtoidentify thememoryanddoesnotconflictwithotheridentifiers.Itiscommontodefineinternalmemory(on−chip)inthederivative definition.Externalmemory(off−chipmemory)isusuallydefinedintheboardspecification(Seesection8.7.3,DefiningExternal MemoryandBuses). • Thetypefieldspecifiesamemorytype: − rom: readonlymemory−itcanonlybewrittenatload−time − ram: randomaccessvolatilewritablememory−writingatrun−timeispossible whilewritingatload−timehasnousesincethedataisnotretainedafter apower−down − nvram: nonvolatileram−writingispossiblebothatload−timeandrun−time Theoptionalreservedqualifierbeforethememorytype,tellsthelinkernottolocateanysectioninthememorybydefault. Youcanlocatesectionsinsuchmemoriesusinganabsoluteaddressorrangerestriction(seesubsectionLocatingagroup insection8.9.2,CreatingandLocatingGroupsofSections). • ThemaufieldspecifiestheMAUsize(MinimumAddressableUnit)ofthememory.Thisfieldisrequired. • ThesizefieldspecifiesthesizeinMAUofthememory.Thisfieldisrequired. • Thespeedfieldspecifiesasymbolicspeedforthememory(1..4):1isthefastest,4theslowest.Thelinkerusestherelative speedofthememoriesinsuchaway,thatoptimalspeedisachieved.Thedefaultspeedis1. • Themapfieldspecifieshowthismemorymapsontoan(internal)bus.Mappingsaredescribedinsection8.5.4,Mappings. • Theoptionalfillfieldcontainsabitpatternthatthelinkerwritestoallmemoryaddressesthatremainunoccupiedduring thelocateprocess.Theresultoftheexpression,orlistofexpressions,isusedasvaluestowritetomemory,eachinMAU. memorymem_name { type=rom; mau=8; fill=0xaa; size=64k; speed=2; map(map_description); }

Withthebuskeywordyoudefineabusinaderivativedefinition.Busesaredescribedinsection8.5.2,DefiningInternalBuses.

8−21 MicroBlazeEmbeddedToolsReference

8.7 SemanticsoftheBoardSpecification

Keywordsintheboardspecification processor derivative bus mau width map memory typereservedromramnvram mau size speed fill map map destbusspace dest_dbits dest_offset size src_dbits src_offset

8.7.1 DefiningaProcessor

Ifyouhaveatargetboardwithmultipleprocessorsthathavethesamederivative,youneedtoinstantiateeachindividual processorinaprocessordefinition.Thisinformationtellsthelinkerwhichprocessorhaswhichderivativeandenablesthelinker todistinguishbetweenthepresentprocessors.

Ifyouuseprocessorsthatallhaveauniquederivative,youmayomittheprocessordefinitions.Inthiscasethelinker assumesthatforeachderivativedefinitionintheLSLfilethereisoneprocessor.Thelinkerusesthederivativenamealso fortheprocessor. Withthekeywordprocessoryoudefineaprocessor.Youcanfreelychoosetheprocessorname.Thenameisusedtoreferto itatotherplacesintheLSLfile: processorproc_name { processordefinition }

8.7.2 InstantiatingDerivatives

Withthekeywordderivativeyoutellthelinkerthatthegivenprocessorhasacertainderivative.Thederivativenamerefers toanexistingderivativedefinitioninthesameLSLfile. Forexamples,ifyouhavetwoprocessorsonyourtargetboard(calledmyproc_1andmyproc_2)thathavethesamederivative (calledmyderiv),youmustinstantiatebothprocessorsasfollows: processormyproc_1 { derivative=myderiv; } processormyproc_2 { derivative=myderiv; }

8−22 LinkerScriptLanguage

Ifthederivativedefinitionhasparametersyoumustspecifytheargumentsthatcorrespondwiththeparameters.Forexample myderiv1expectstwoparameterswhichareusedinthederivativedefinition: processormyproc { derivative=myderiv1(2,4); }

8.7.3 DefiningExternalMemoryandBuses

Itiscommontodefineexternalmemory(off−chip)andexternalbusesattheglobalscope(outsideanyenclosingdefinition). Internalmemory(on−chipmemory)isusuallydefinedinthescopeofaderivativedefinition. Withthekeywordmemoryyoudefinephysicalmemorythatispresentonthetargetboard.Thememorynameisusedtoidentify thememoryanddoesnotconflictwithotheridentifiers.IfyoudefinememorypartsintheLSLfile,onlythememorydefinedin thesepartsisusedforplacingsections. IfnoexternalmemoryisdefinedintheLSLfileandifthelinkeroptiontoallocatememoryondemandissetthenthelinkerwill assumethatallvirtualaddressesaremappedonphysicalmemory.Youcanoverridethisbehaviorbyspecifyingoneormore memorydefinitions. memorymem_name { type=rom; mau=8; fill=0xaa; size=64k; speed=2; map(map_description); }

Foradescriptionofthekeywords,seesection8.6.3,DefiningInternalMemoryandBuses. Withthekeywordbusyoudefineabus(thecombinationofdataandcorrespondingaddressbus).Thebusnameisusedto identifyabusanddoesnotconflictwithotheridentifiers.Busdescriptionsattheglobalscope(outsideanydefinition)define externalbuses.Thesearebusesthatarepresentonthetargetboard. busbus_name { mau=8; width=8; map(map_description); }

Foradescriptionofthekeywords,seesection8.5.2,DefiningInternalBuses. Youcanconnectoff−chipmemorytoanyderivative:youneedtomaptheoff−chipmemorytoabusandmapthatbusonthe internalbusofthederivativeyouwanttoconnectitto.

8−23 MicroBlazeEmbeddedToolsReference

8.8 SemanticsoftheSectionSetupDefinition

Keywordsinthesectionsetupdefinition section_setup stack min_size growslow_to_highhigh_to_low align fixed id heap min_size growslow_to_highhigh_to_low align fixed id vector_table vector_size size id_symbol_prefix run_addr template template_symbol vector_prefix fill no_inline copy vector id fillloop reserved

8.8.1 SettingupaSection

Withthekeywordsection_setupyoucandefinestacks,heaps,vectortables,and/orreservedaddressrangesoutsidetheir addressspacedefinition. section_setup::my_space { vectortablestatements reservedaddressrange stackdefinition heapdefinition }

SeethesubsectionsStacksandheaps,VectortableandReservedaddressrangesinsection8.5.3,DefiningAddress Spaces,fordetailsonthekeywordsstack,heap,vector_tableandreserved.

8−24 LinkerScriptLanguage

8.9 SemanticsoftheSectionLayoutDefinition

Keywordsinthesectionlayoutdefinition section_layout directionlow_to_highhigh_to_low group align attributes+−rwxbis copy nocopy fill ordered contiguous clustered overlay allow_cross_references load_addr mem run_addr mem page page_size priority select stack size heap size reserved size attributesrwx fill alloc_allowedabsoluteranged copytable section size blocksize attributesrwx fill overflow if else

8.9.1 DefiningaSectionLayout

Withthekeywordsection_layoutyoudefineasectionlayoutforexactlyoneaddressspace.Inthesectionlayoutyoucan specifyhowinputsectionsareplacedintheaddressspace,relativetoeachother,andwhattheabsoluterunandload addressesofeachsectionwillbe. Youcandefineoneormoresectiondefinitions.Eachsectiondefinitionarrangesthesectionsinoneaddressspace.Youcan precedetheaddressspacenamewithaprocessornameand/orcorename,separatedbycolons.Youcanomittheprocessor nameand/orthecorenameifonlyoneprocessorisdefinedand/oronlyonecoreispresentintheprocessor.Areferencetoa spaceintheonlycoreoftheonlyprocessorinthesystemwouldlooklike"::my_space".Areferencetoaspaceoftheonly coreonaspecificprocessorinthesystemcouldbe"my_chip::my_space".Thenextexampleshowsasectiondefinitionfor sectionsinthemy_spaceaddressspaceoftheprocessorcalledmy_chip:

8−25 MicroBlazeEmbeddedToolsReference

section_layoutmy_chip::my_space(locate_direction) { sectionstatements }

Withtheoptionalkeyworddirectionyouspecifywhetherthelinkerstartslocatingsectionsfromlow_to_high(default)or fromhigh_to_low.Inthesecondcasethelinkerstartslocatingsectionsatthehighestaddressesintheaddressspacebut preservestheorderofsectionswhennecessary(oneprocessorandcoreinthisexample). section_layout::my_space(direction=high_to_low) { sectionstatements }

Ifyoudonotexplicitlytellthelinkerhowtolocateasection,thelinkerdecidesonthebasisofthesectionattributesinthe objectfileandtheinformationinthearchitecturedefinitionandmemorypartswheretolocatethesection.

8.9.2 CreatingandLocatingGroupsofSections

Sectionsarelocatedpergroup.Agroupcancontainoneormore(setsof)inputsectionsaswellasothergroups.Pergroupyou canassignamutualordertothesetsofsectionsandlocatethemintoaspecificmemorypart. group(group_specifications) { section_statements }

Withthesection_statementsyougenerallyselectsetsofsectionstoformthegroup.ThisisdescribedinsubsectionSelecting sectionsforagroup. Insteadofselectingsections,youcanalsomodifyspecialsectionslikestackandheaporcreateareservedsection.Thisis describedinsection8.9.3,CreatingorModifyingSpecialSections. Withthegroup_specificationsyouactuallylocatethesectionsinthegroup.ThisisdescribedinsubsectionLocatingagroup.

Selectingsectionsforagroup Withtheselectkeywordyoucanselectoneormoresectionsforthegroup.Youcanselectasectionbynameorbyattributes. Ifyouselectasectionbyname,youcanuseawildcardpattern: "*" matcheswithallsectionnames "?" matcheswithasinglecharacterinthesectionname "\" takesthenextcharacterliterally "[abc]" matcheswithasingle’a’,’b’or’c’character "[a−z]" matcheswithanysinglecharacterintherange’a’to’z’ group(...) { select"mysection"; select"*"; }

Thefirstselectstatementselectsthesectionwiththename"mysection".Thesecondselectstatementselectsallsections thatwerenotselectedyet. Asectionisselectedbythefirstselectstatementthatmatches,intheunionofallsectionlayoutsfortheaddressspace. GlobalsectionlayoutsareprocessedintheorderinwhichtheyappearintheLSLfile.Internalcorearchitecturesectionlayouts alwaystakeprecedenceoverglobalsectionlayouts. • Theattributesfieldselectsallsectionsthatcarry(ordonotcarry)thegivenattribute.With+attributeyouselectsections thathavethespecifiedattributeset.With−attributeyouselectsectionsthatdonothavethespecifiedattributeset.Youcan specifyoneormoreofthefollowingattributes: − r readablesections − w writablesections

8−26 LinkerScriptLanguage

− x executablesections − i initializedsections − b sectionsthatshouldbeclearedatprogramstartup − s scratchsections(notclearedandnotinitialized) Toselectallread−onlysections: group(...) { select(attributes=+r−w); }

Keepinmindthatallsectionselectionsarerestrictedtotheaddressspaceofthesectionlayoutinwhichthisgroup definitionoccurs.

• Withtheref_treefieldyoucanselectagroupofrelatedsections.Therelationbetweensectionsisoftenexpressedby meansofreferences.Byselectingjustthe’root’oftree,thecompletetreeisselected.Thisisforexampleusefultolocatea groupofrelatedsectionsinspecialmemory(e.g.fastmemory).The(referenced)sectionsmustmeetthefollowing conditionsinordertobeselected: 1. Thesectionsarewithinthesectionlayout’saddressspace 2. Thesectionsmatchthespecifiedattributes 3. Thesectionshavenoabsoluterestriction(asisthecaseforallwildcardselections) Forexample,toselectthecodesectionsreferencedfromfoo1: grouprefgrp(ordered,contiguous,run_addr=mem:ext_c) { selectref_tree"foo1"(attributes=+x); }

Ifsectionfoo1referencesfoo2andfoo2referencesfoo3,thenallthesesectionsareselectedbytheselectionshown above.

Locatingagroup groupgroup_name(group_specifications) { section_statements }

Withthegroup_specificationsyouactuallydefinehowthelinkermustlocatethegroup.Youcanroughlydefinethreethings:1) assignpropertiestothegrouplikealignmentandread/writeattributes,2)definethemutualorderintheaddressspacefor sectionsinthegroupand3)restrictthepossibleaddressesforthesectionsinagroup. Thelinkercreateslabelsthatallowyoutorefertothebeginandendaddressofagroupfromwithintheapplicationsoftware. Labels_lc_gb_group_nameand_lc_ge_group_namemarkthebeginandendofthegrouprespectively,wherethebeginis thelowestaddressusedwithinthisgroupandtheendisthehighestaddressused.Noticethatagroupnotnecessarilyoccupies allmemorybetweenbeginandendaddress.Thegivenlabelreferstowherethesectionislocatedatrun−time(versus load−time). 1. Assignpropertiestothegrouplikealignmentandread/writeattributes. Thesepropertiesareassignedtoallsectionsinthegroup(andsubgroups)andoverridetheattributesoftheinputsections. • Thealignfieldtellsthelinkertoalignallsectionsinthegroupandthegroupasawholeaccordingtothealignvalue.By defaultthelinkerusesthelargestalignmentconstraintofeithertheinputsectionsorthealignmentoftheaddressspace. • Theattributesfieldtellsthelinkertoassignoneormoreattributestoallsectionsinthegroup.Thisoverrulesthe defaultattributes.Bydefaultthelinkerusestheattributesoftheinputsections.Youcansetther,worrwattributesand youcanswitchbetweenthebandsattributes. • Thecopyfieldtellsthelinkertolocatearead−onlysectioninRAMandgenerateaROMcopyandacopyactioninthe copytable.ThispropertymakesthesectionsinthegroupwritablewhichcausesthelinkertogenerateROMcopiesfor thesections.

8−27 MicroBlazeEmbeddedToolsReference

• Theeffectofthenocopyfieldistheoppositeofthecopyfield.ItpreventsthelinkerfromgeneratingROMcopiesofthe selectedsections. 2. Definethemutualorderofthesectionsinthegroup. Bydefault,agroupisunrestrictedwhichmeansthatthelinkerhastotalfreedomtoplacethesectionsofthegroupinthe addressspace. • Theorderedkeywordtellsthelinkertolocatethesectionsinthesameorderintheaddressspaceastheyappearinthe group(butnotnecessarilyadjacent). Supposeyouhaveanorderedgroupthatcontainsthesections’A’,’B’and’C’.Bydefaultthelinkerplacesthesections intheaddressspacelike’A’−’B’−’C’,wheresection’A’getsthelowestpossibleaddress.With direction=high_to_lowinthesection_layoutspaceproperties,thelinkerplacesthesectionsintheaddress spacelike’C’−’B’−’A’,wheresection’A’getsthehighestpossibleaddress. • Thecontiguouskeywordtellsthelinkertolocatethesectionsinthegroupinasingleaddressrange.Withina contiguousgrouptheinputsectionsarelocatedinarbitraryorder,howeverthegroupoccupiesonecontigousrangeof memory.Duetoalignmentofsectionstherecanbe’alignmentgaps’betweenthesections. Whenyoudefineagroupthatisbothorderedandcontiguous,thisiscalledasequentialgroup.Inasequentialgroup thelinkerplacessectionsinthesameorderintheaddressspaceastheyappearinthegroupanditoccupiesa contiguousrangeofmemory. • Theclusteredkeywordtellsthelinkertolocatethesectionsinthegroupinanumberofcontiguousblocks.Ittriesto keepthenumberoftheseblockstoaminimum.Ifenoughmemoryisavailable,thegroupwillbelocatedasifitwas specifiedascontiguous.Otherwise,itgetssplitintotwoormoreblocks. Ifacontiguousorclusteredgroupcontainsalignmentgaps,thelinkercanlocatesectionsthatarenotpartofthegroupin thesegaps.Topreventthis,youcanusethefillkeyword.IfthegroupislocatedinRAM,thegapsaretreatedas reserved(scratch)space.IfthegroupislocatedinROM,thealignmentgapsarefilledwithzerosbydefault.Youcan howeverchangethefillpatternbyspecifyingabitpattern.Theresultoftheexpression,orlistofexpressions,isusedas valuestowritetomemory,eachinMAU. • Theoverlaykeywordtellsthelinkertooverlaythesectionsinthegroup.Thelinkerplacesallsectionsintheaddress spaceusingacontiguousrangeofaddresses.(Thusanoverlaygroupisautomaticallyalsoacontiguousgroup.)To overlaythesections,allsectionsintheoverlaygroupsharethesamerun−timeaddress. Foreachinputsectionwithintheoverlaythelinkerautomaticallydefinestwosymbols.Thesymbol _lc_cb_section_nameisdefinedastheload−timestartaddressofthesection.Thesymbol_lc_ce_section_name isdefinedastheload−timeendaddressofthesection.C(orassembly)codemaybeusedtocopytheoverlaidsections. Ifsectionsintheoverlaygroupcontainreferencesbetweengroups,thelinkerreportsanerror.Thekeyword allow_cross_referencestellsthelinkertoacceptcross−references.Normally,itdoesnotmakesensetohave referencesbetweensectionsthatareoverlaid. groupovl(overlay) { groupa { select"my_ovl_p1"; select"my_ovl_p2"; } groupb { select"my_ovl_q1"; } }

Itmaybepossiblethatoneofthesectionsintheoverlaygroupalreadyhasbeendefinedinanothergroupwhereit receivedaload−timeaddress.Inthiscasethelinkerdoesnotoverrulethisload−timeaddressandexcludesthesection fromtheoverlaygroup.

8−28 LinkerScriptLanguage

3. Restrictthepossibleaddressesforthesectionsinagroup. Theload−timeaddressspecifieswherethegroup’selementsareloadedinmemoryatdownloadtime.Therun−timeaddress specifieswheresectionsarelocatedatrun−time,thatiswhentheprogramisexecuting.Ifyoudonotexplicitlyrestrictthe addressintheLSLfile,thelinkerassignsaddressestothesectionsbasedontherestrictionsrelativetoothersectionsinthe LSLfileandsectionalignments.Theprogramisresponsibleforcopyingoverlaysectionsatappropriatemomentfromits load−timelocationtoitsrun−timelocation(thisistypicallydonebythestartupcode). • Therun_addrkeyworddefinestherun−timeaddress.Iftherun−timelocationofagroupissetexplicitly,thegivenorder betweengroupsspecifywhethertherun−timeaddresspropagatestotheparentgroupornot.Thelocationofthesections agroupcanberestrictedeithertoasingleabsoluteaddress,ortoanumberofaddressranges(notincludingtheend address).Withanexpressionyoucanspecifythatthegroupshouldbelocatedattheabsoluteaddressspecifiedbythe expression: group(run_addr=0xa00f0000)

Youcanusethe’[offset]’varianttolocatethegroupatthegivenabsoluteoffsetinmemory: group(run_addr=mem:A[0x1000])

Arangecanbeanabsolutespaceaddressrange,writtenas[expr..expr],acompletememorydevice,written asmem:mem_name,oramemoryaddressrange, mem:mem_name[expr..expr] group(run_addr=mem:my_dram)

Youcanusethe’|’tospecifyanaddressrangeofmorethanonephysicalmemorydevice: group(run_addr=mem:A|mem:B) • Theload_addrkeywordchangesthemeaningofthesectionselectioninthegroup:thelinkerselectstheload−time ROMcopyofthenamedsection(s)insteadoftheregularsections.Justlikerun_addryoucanspecifyanabsolute addressoranaddressrange. Theload_addrkeyworditself(withoutanassignment)specifiesthatthegroup’spositionintheLSLfiledefinesits load−timeaddress. group(load_addr) select"mydata";//selectROMcopyofmydata:"[mydata]"

Theload−timeandrun−timeaddressesofagroupcannotbesetatthesametime.Iftheload−timepropertyissetfora group,thegroup(only)restrictsthepositioningatload−timeofthegroup’ssections.Itisnotpossibletosettheaddressofa groupthathasanot−unrestrictedparentgroup. Thepropertiesoftheload−timeandrun−timestartaddressare: • Atrun−time,beforeusinganelementinanoverlaygroup,theapplicationcopiesthesectionsfromtheirloadlocationto theirrun−timelocation,butonlyifthesetwoaddressesaredifferent.Fornon−overlaysectionsthishappensatprogram start−up. • Thestartaddressescannotbesettoabsolutevaluesforunrestrictedgroups. • Fornon−overlaygroupsthatdonothaveanoverlayparent,theload−timestartaddressequalstherun−timestart address. • Foranygroup,iftherun−timestartaddressisnotset,thelinkerselectsanappropriateaddress. • Ifanorderedgrouporsequentialgrouphasanabsoluteaddressandcontainssectionsthathaveseparatepage restrictions(notdefinedinLSL),allthosesectionsarelocatedinasinglepage.Inothercases,forexamplewhenan unrestrictedgrouphasanaddressrangeassignedtoit,thepagedsectionsmaybelocatedindifferentpages. Foroverlays,thelinkerreservesmemoryattherun−timestartaddressaslargeasthelargestelementintheoverlaygroup. • Thepagekeywordtellsthelinkertoplacethegroupinonepage.Insteadofspecifyingarun−timeaddress,youcan specifyapageandoptionalapagenumber.Pagenumbersstartfromzero.Ifyouomitthepagenumber,thelinker choosesapage. Thepagekeywordreferstopagesintheaddressspaceasdefinedinthearchitecturedefinition. • Withthepage_sizekeywordyoucanoverridethepagealignmentandsizesetontheaddressspace.Whenyousetthe pagesizetozero,thelinkerremovessimple(autogenerated)pagerestrictionsfromtheselectedsections.Seealsothe page_sizekeywordinsection8.5.3,DefiningAddressSpaces.

8−29 MicroBlazeEmbeddedToolsReference

group(page,...) group(page=3,...) • Withtheprioritykeywordyoucanchangetheorderinwhichsectionsarelocated.Thisisusefulwhensomesections areconsideredimportantforgoodperformanceoftheapplicationandasmallamountoffastmemoryisavailable.The valueisanumberforwhichthedefaultis1,sohigherprioritiesstartat2.Sectionswithahigherpriorityarelocated beforesectionswithalowerpriority,unlesstheirrelativelocatepriorityisalreadydeterminedbyotherrestrictionslike run_addrandpage. group(priority=2) { select"importantcode1"; select"importantcode2"; }

8.9.3 CreatingorModifyingSpecialSections

Insteadofselectingsections,youcanalsocreateareservedsectionoranoutputsectionormodifyspecialsectionslikeastack oraheap.Becauseyoucannotdefinethesesectionsintheinputfiles,youmustusethelinkertocreatethem.

Stack • Thekeywordstacktellsthelinkertoreservememoryforthestack.Thenameforthestacksectionreferstothestackas definedinthearchitecturedefinition.Ifnonamewasspecifiedinthearchitecturedefinition,thedefaultnameisstack. Withthekeywordsizeyoucanspecifythesizeforthestack.Ifthesizeisnotspecified,thelinkerusesthesizegivenby themin_sizeargumentasdefinedforthestackinthearchitecturedefinition.Normallythelinkerautomaticallytriesto maximizethesize,unlessyouspecifiedthekeywordfixed. group(...) { stack"mystack"(size=2k); }

Thelinkercreatestwolabelstomarkthebeginandendofthestack,_lc_ub_stack_nameforthebeginofthestackand _lc_ue_stack_namefortheendofthestack.Thelinkerallocatesspaceforthestackwhenthereisareferencetoeitherof thelabels. Seealsothestackkeywordinsection8.5.3,DefiningAddressSpaces.

Heap • Thekeywordheaptellsthelinkertoreserveadynamicmemoryrangeforthemalloc()function.Optionallyyoucanassign anametotheheapsection.Withthekeywordsizeyoucanchangethesizefortheheap.Ifthesizeisnotspecified,the linkerusesthesizegivenbythemin_sizeargumentasdefinedfortheheapinthearchitecturedefinition.Normallythe linkerautomaticallytriestomaximizethesize,unlessyouspecifiedthekeywordfixed. group(...) { heap"myheap"(size=2k); }

Thelinkercreatestwolabelstomarkthebeginandendoftheheap,_lc_ub_heap_nameforthebeginoftheheapand _lc_ue_heap_namefortheendoftheheap.Thelinkerallocatesspacefortheheapwhenareferencetoeitherofthe sectionlabelsexistsinoneoftheinputobjectfiles.

Reservedsection • Thekeywordreservedtellsthelinkertocreateanareaorsectionofagivensize.Thelinkerwillnotlocateanyother sectionsinthememoryoccupiedbyareservedsection,withsomeexceptions.Optionallyyoucanassignanametoa reservedsection.Withthekeywordsizeyoucanspecifyasizeforagivenreservedareaorsection. group(...) { reserved"myreserved"(size=2k); }

8−30 LinkerScriptLanguage

Theoptionalfillfieldcontainsabitpatternthatthelinkerwritestoallmemoryaddressesthatremainunoccupiedduring thelocateprocess.Theresultoftheexpression,orlistofexpressions,isusedasvaluestowritetomemory,eachinMAU. ThefirstMAUofthefillpatternisalwaysthefirstMAUinthesection. Bydefault,nosectionscanoverlapwithareservedsection.Withalloc_allowed=absolutesectionsthatarelocatedat anabsoluteaddressduetoanabsolutegrouprestrictioncanoverlapareservedsection.Thesameappliesforreserved sectionswithalloc_allowed=rangedset.Sectionsrestrictedtoafixedaddressrangecanalsooverlapareserved section. Withtheattributesfieldyoucansettheaccesstypeofthereservedsection.Thelinkerlocatesthereservedsectioninits spacewiththerestrictionsthatfollowfromtheusedattributes,r,worxoravalidcombinationofthem.Theallowed attributesareshowninthefollowingtable.Avaluebetween<and>inthetablemeansthisvalueissetautomaticallybythe linker.

PropertiessetinLSL Resultingsectionproperties attributes filled access memory content x yes executable r yes r data r no r scratch rx yes r executable rw yes rw data rw no rw scratch rwx yes rw executable

group(...) { reserved"myreserved"(size=2k, attributes=rw,fill=0xaa); }

Ifyoudonotspecifyanyattributes,thelinkerwillreservethegivennumberofmaus,nomatterwhattypeofmemorylies beneath.Ifyoudonotspecifyafillpattern,nosectionisgenerated. Thelinkercreatestwolabelstomarkthebeginandendofthesection,_lc_ub_nameforthestart,and_lc_ue_namefor theendofthereservedsection.

Outputsections • Thekeywordsectiontellsthelinkertoaccumulatesectionsobtainedfromobjectfiles("inputsections")intoanoutput sectionofafixedsizeinthelocatephase.Youcanselecttheinputsectionswithselectstatements.Youcanusegroups insideoutputsections,butyoucanonlysetthealign,attributesandload_addrattributes. Thefillfieldcontainsabitpatternthatthelinkerwritestoallunusedspaceintheoutputsection.Whenallinputsections haveanimage(code/data)youmustspecifyafillpattern.Ifyoudonotspecifyafillpattern,allinputsectionsmustbe scratchsections.Thefillpatternisalignedatthestartoftheoutputsection. Aswithareservedsectionyoucanusetheattributesfieldtosettheaccesstypeoftheoutputsection. group(...) { section"myoutput"(size=4k,attributes=rw,fill=0xaa) { select"myinput1"; select"myinput2"; } }

8−31 MicroBlazeEmbeddedToolsReference

Theavailableroomforinputsectionsisdeterminedbythesize,blocksizeandoverflowfields.Withthekeywordsize youspecifythefixedsizeoftheoutputsection.Inputsectionsareplacedfromoutputsectionstarttowardshigheraddresses (offsets).Whentheendoftheoutputsectionisreachedandoneormoreinputsectionsarenotyetplaced,anerroris emitted.Ifhowever,theoverflowfieldissettoanotheroutputsection,remainingsectionsarelocatedasiftheywere selectedfortheoverflowoutputsection. group(...) { section"tsk1_data"(size=4k,attributes=rw,fill=0, overflow="overflow_data") { select".data.tsk1.*" } section"tsk2_data"(size=4k,attributes=rw,fill=0, overflow="overflow_data") { select".data.tsk2.*" } section"overflow_data"(size=4k,attributes=rx, fill=0) { } }

Withthekeywordblocksize,thesizeoftheoutputsectionwilladapttothesizeofitscontent.Forexample: groupflash_area(run_addr=0x10000) { section"flash_code"(blocksize=4k,attributes=rx, fill=0) { select"*.flash"; } }

Ifthecontentofthesectionis1mau,thesizewillbe4k,ifthecontentis11k,thesectionwillbe12k,etc.Ifyouusesizein combinationwithblocksize,thesizevalueisusedasdefault(minimal)sizeforthissection.Ifitisomitted,thedefault sizewillbeofblocksize.Itisnotallowedtoomitbothsizeandblocksizefromthesectiondefinition. Thelinkercreatestwolabelstomarkthebeginandendofthesection,_lc_ub_nameforthestart,and_lc_ue_namefor theendoftheoutputsection.

Copytable • Thekeywordcopytabletellsthelinkertoselectasectionthatisusedascopytable.Thecontentofthecopytableis createdbythelinker.Itcontainsthestartaddressandlengthofallsectionsthatshouldbeinitializedbythestartupcode. Thelinkercreatestwolabelstomarkthebeginandendofthesection,_lc_ub_tableforthestart,and_lc_ue_table fortheendofthecopytable.Thelinkergeneratesacopytablewhenareferencetoeitherofthesectionlabelsexistsinone oftheinputobjectfiles.

8.9.4 CreatingSymbols

Youcantellthelinkertocreatesymbolsbeforelocatingbyputtingassignmentsinthesectionlayoutdefinition.Symbolnames arerepresentedbydouble−quotedstrings.Anystringisallowed,butobjectfilesmaynotsupportallcharactersforsymbol names.Youcanusetwodifferentassignmentoperators.Withthesimpleassignmentoperator’=’,thesymboliscreated unconditionally.Withthe’:=’operator,thesymbolisonlycreatedifitalreadyexistsasanundefinedreferenceinanobjectfile. Theexpressionthatrepresentsthevaluetoassigntothesymbolmaycontainreferencestoothersymbols.Ifsuchareferred symbolisaspecialsectionsymbol,creationofthesymbolinthelefthandsideoftheassignmentwillcausecreationofthe specialsection.

8−32 LinkerScriptLanguage

section_layout { "_lc_bs":="_lc_ub_stack"; //whenthesymbol_lc_bsoccursasanundefinedreference //inanobjectfile,thelinkerallocatesspaceforthestack }

8.9.5 ConditionalGroupStatements

Withinagroup,youcanconditionallyselectsectionsorcreatespecialsections. • Withtheifkeywordyoucanspecifyacondition.Thesucceedingsectionstatementisexecutediftheconditionevaluatesto TRUE(1). • Theoptionalelsekeywordisfollowedbyasectionstatementwhichisexecutedincasetheif−conditionevaluatestoFALSE (0). group(...) { if(exists("mysection")) select"mysection"; else reserved"myreserved"(size=2k); }

8−33 MicroBlazeEmbeddedToolsReference

8−34 9 CERTCSecureCodingStandard

Summary ThischaptercontainsanoverviewoftheCERTCSecureCodingStandard recommendationsandrulesthataresupportedbytheTASKINGVX−toolset.

TheCERTCSecureCodingStandardprovidesrulesandrecommendationsforsecurecodingintheCprogramminglanguage. Thegoaloftheserulesandrecommendationsistoeliminateinsecurecodingpracticesandundefinedbehaviorsthatcanleadto exploitablevulnerabilities.Theapplicationofthesecurecodingstandardwillleadtohigher−qualitysystemsthatarerobustand moreresistanttoattack.

FordetailsseetheCERTCSecureCodingStandardwebsite.ForgeneralinformationaboutCERTsecurecoding,see www.cert.org/secure−coding.

Identifiers Eachruleandrecommendationisgivenauniqueidentifier.Theseidentifiersconsistofthreeparts: • athree−lettermnemonicrepresentingthesectionofthestandard • atwo−digitnumericvalueintherangeof00−99 • theletter"C"indicatesthatthisisaClanguageguideline Thethree−lettermnemonicisusedtogroupsimilarcodingpracticesandtoindicatetowhichcategoryacodingpracticebelongs. Thenumericvalueisusedtogiveeachcodingpracticeauniqueidentifier.Numericvaluesintherangeof00−29arereserved forrecommendations,whilevaluesintherangeof30−99arereservedforrules.

Ccompilerinvocation WiththeCcompileroption−−certyoucanenableoneormorechecksfortheCERTCSecureCodingStandard recommendations/rules.With−−diag=certyoucanseealistoftheavailablechecks,oryoucanuseathree−lettermnemonicto listonlythechecksinaparticularcategory.Forexample,−−diag=prelistsallsupportedchecksinthepreprocessorcategory.

9.1 Preprocessor(PRE)

PRE01−C Useparentheseswithinmacrosaroundparameternames Parenthesizeallparameternamesinmacrodefinitionstoavoidprecedenceproblems. PRE02−C Macroreplacementlistsshouldbeparenthesized Macroreplacementlistsshouldbeparenthesizedtoprotectanylower−precedenceoperatorsfromthe surroundingexpression.Theexamplebelowissyntacticallycorrect,althoughthe!=operatorwas omitted.Enclosingtheconstant−1inparenthesiswillpreventtheincorrectinterpretationandforcea compilererror: #defineEOF−1//shouldbe(−1) intgetchar(void); voidf(void) { if(getchar()EOF)//!=operatoromitted { /*...*/ } }

9−1 MicroBlazeEmbeddedToolsReference

PRE10−C Wrapmulti−statementmacrosinado−whileloop Whenmultiplestatementsareusedinamacro,enclosetheminado−whilestatement,sothemacro canappearsafelyinsideifclausesorotherplacesthatexpectasinglestatementorastatementblock. Bracesalonewillnotworkinallsituations,asthemacroexpansionistypicallyfollowedbyasemicolon. PRE11−C Donotconcludeasinglestatementmacrodefinitionwithasemicolon Macrodefinitionsconsistingofasinglestatementshouldnotconcludewithasemicolon.Ifrequired,the semicolonshouldbeincludedfollowingthemacroexpansion.Inadvertentlyinsertingasemicoloncan changethecontrolflowoftheprogram.

9.2 DeclarationsandInitialization(DCL)

DCL30−C Declareobjectswithappropriatestoragedurations Thelifetimeofanautomaticobjectendswhenthefunctionreturns,whichmeansthatapointertothe objectbecomesinvalid. DCL31−C Declareidentifiersbeforeusingthem TheISOC90standardallowsimplicittypingofvariablesandfunctions.Becauseimplicitdeclarations leadtolessstringenttypechecking,theycanoftenintroduceunexpectedanderroneousbehavioror evensecurityvulnerabilities.TheISOC99standardrequirestypeidentifiersandforbidsimplicitfunction declarations.Forbackwardscompatibilityreasons,theVX−toolsetCcompilerassumesanimplicit declarationandcontinuestranslationafterissuingawarningmessage(W505orW535). DCL32−C Guaranteethatmutuallyvisibleidentifiersareunique Thecompilerencounteredtwoormoreidentifiersthatareidenticalinthefirst31characters.TheISO C99standardallowsacompilertoignorecharacterspastthefirst31inanidentifier.Twodistinct identifiersthatareidenticalinthefirst31charactersmayleadtoproblemswhenthecodeisportedtoa differentcompiler. DCL35−C Donotinvokeafunctionusingatypethatdoesnotmatchthefunctiondefinition Thiswarningisgeneratedwhenafunctionpointerissettorefertoafunctionofanincompatibletype. Callingthisfunctionthroughthefunctionpointerwillresultinundefinedbehavior.Example: voidmy_function(inta); intmain(void) { int(*new_function)(inta)=my_function; return(*new_function)(10);/*thebehaviorisundefined*/ }

9.3 Expressions(EXP)

EXP01−C Donottakethesizeofapointertodeterminethesizeofthepointed−totype Thesizeoftheobject(s)allocatedbymalloc(),calloc()orrealloc()shouldbeamultipleofthesizeofthe basetypeoftheresultpointer.Therefore,thesizeofexpressionshouldbeappliedtothisbasetype,and nottothepointertype. EXP12−C Donotignorevaluesreturnedbyfunctions Thecompilergivesthiswarningwhentheresultofafunctioncallisignoredatsomeplace,althoughitis notignoredforothercallstothisfunction.Thiswarningwillnotbeissuedwhenthefunctionresultis ignoredforallcalls,orwhentheresultisexplicitlyignoredwitha(void)cast. EXP30−C Donotdependonorderofevaluationbetweensequencepoints Betweentwosequencepoints,anobjectshouldonlybemodifiedonce.Otherwisethebehavioris undefined. EXP32−C Donotaccessavolatileobjectthroughanon−volatilereference Ifanattemptismadetorefertoanobjectdefinedwithavolatile−qualifiedtypethroughuseofanlvalue withnon−volatile−qualifiedtype,thebehaviorisundefined. EXP33−C Donotreferenceuninitializedmemory Uninitializedautomaticvariablesdefaulttowhichevervalueiscurrentlystoredonthestackorinthe registerallocatedforthevariable.Consequently,uninitializedmemorycancauseaprogramtobehavein anunpredictableorunplannedmannerandmayprovideanavenueforattack.

9−2 CERTCSecureCodingStandard

EXP34−C Ensureanullpointerisnotdereferenced Attemptingtodereferenceanullpointerresultsinundefinedbehavior,typicallyabnormalprogram termination. EXP37−C CallfunctionswiththeargumentsintendedbytheAPI Whenafunctionisproperlydeclaredwithfunctionprototypeinformation,anincorrectcallwillbeflagged bythecompiler.Whenthereisnoprototypeinformationavailableatthecall,thecompilercannotcheck thenumberofargumentsandthetypesofthearguments.Thismessageisissuedtowarnaboutthis situation. EXP38−C Donotcalloffsetof()onbit−fieldmembersorinvalidtypes Thebehavioroftheoffsetof()macroisundefinedwhenthememberdesignatorparameterdesignatesa bit−field.

9.4 Integers(INT)

INT30−C Ensurethatunsignedintegeroperationsdonotwrap Aconstantwithanunsignedintegertypeistruncated,resultinginawrap−around. INT34−C Donotshiftanegativenumberofbitsormorebitsthanexistintheoperand Theshiftcountoftheshiftoperationmaybenegativeorgreaterthanorequaltothesizeoftheleft operand.AccordingtotheCstandard,thebehaviorofsuchashiftoperationisundefined.Makesurethe shiftcountisinrangebyaddingappropriaterangechecks. INT35−C Evaluateintegerexpressionsinalargersizebeforecomparingorassigningtothatsize Ifanintegerexpressioniscomparedto,orassignedtoalargerintegersize,thatintegerexpression shouldbeevaluatedinthatlargersizebyexplicitlycastingoneoftheoperands.

9.5 FloatingPoint(FLP)

FLP30−C Donotusefloatingpointvariablesasloopcounters Toavoidproblemswithlimitedprecisionandrounding,floatingpointvariablesshouldnotbeusedas loopcounters. FLP35−C Takegranularityintoaccountwhencomparingfloatingpointvalues FloatingpointarithmeticinCisinexact,sofloatingpointvaluesshouldnotbetestedforexactequalityor inequality. FLP36−C Bewareofprecisionlosswhenconvertingintegraltypestofloatingpoint Conversionfromintegraltypestofloatingpointtypeswithoutsufficientprecisioncanleadtolossof precision.

9.6 Arrays(ARR)

ARR01−C Donotapplythesizeofoperatortoapointerwhentakingthesizeofanarray Afunctionparameterdeclaredasanarray,isconvertedtoapointerbythecompiler.Therefore,the sizeofoperatorappliedtothisparameteryieldsthesizeofapointer,andnotthesizeofanarray. ARR34−C Ensurethatarraytypesinexpressionsarecompatible Usingtwoormoreincompatiblearraysinanexpressionresultsinundefinedbehavior. ARR35−C Donotallowloopstoiteratebeyondtheendofanarray Readingorwritingofdataoutsidetheboundsofanarraymayleadtoincorrectprogrambehavioror executionofarbitrarycode.

9−3 MicroBlazeEmbeddedToolsReference

9.7 CharactersandStrings(STR)

STR30−C Donotattempttomodifystringliterals Writingtoastringliteralhasundefinedbehavior,asidenticalstringsmaybesharedand/orallocatedin read−onlymemory. STR33−C Sizewidecharacterstringscorrectly Widecharacterstringsmaybeimproperlysizedwhentheyaremistakenfornarrowstringsorfor multi−bytecharacterstrings. STR34−C Castcharacterstounsignedtypesbeforeconvertingtolargerintegersizes Asignedcharacterissign−extendedtoalargersignedintegervalue.Useanexplicitcast,orcastthe valuetoanunsignedtypefirst,toavoidunexpectedsign−extension. STR36−C Donotspecifytheboundofacharacterarrayinitializedwithastringliteral Thecompilerissuesthiswarningwhenthecharacterbufferinitializedbyastringliteraldoesnotprovide enoughroomfortheterminatingnullcharacter.

9.8 MemoryManagement(MEM)

MEM00−C Allocateandfreememoryinthesamemodule,atthesamelevelofabstraction Thecompilerissuesthiswarningwhentheresultofthecalltomalloc(),calloc()orrealloc()isdiscarded, andthereforenotfree()d,resultinginamemoryleak. MEM08−C Userealloc()onlytoresizedynamicallyallocatedarrays Onlyuserealloc()toresizeanarray.Donotuseittotransformanobjecttoanobjectofadifferenttype. MEM30−C Donotaccessfreedmemory Whenmemoryisfreed,itscontentsmayremainintactandaccessiblebecauseitisatthememory manager’sdiscretionwhentoreallocateorrecyclethefreedchunk.Thedataatthefreedlocationmay appearvalid.However,thiscanchangeunexpectedly,leadingtounintendedprogrambehavior.Asa result,itisnecessarytoguaranteethatmemoryisnotwrittentoorreadfromonceitisfreed. MEM31−C Freedynamicallyallocatedmemoryexactlyonce Freeingmemorymultipletimeshassimilarconsequencestoaccessingmemoryafteritisfreed.The underlyingdatastructuresthatmanagetheheapcanbecomecorrupted.Toeliminatedouble−free vulnerabilities,itisnecessarytoguaranteethatdynamicmemoryisfreedexactlyonce. MEM32−C Detectandhandlememoryallocationerrors Theresultofrealloc()isassignedtotheoriginalpointer,withoutcheckingforfailure.Asaresult,the originalblockofmemoryislostwhenrealloc()fails. MEM33−C Usethecorrectsyntaxforflexiblearraymembers UsetheISOC99syntaxforflexiblearraymembersinsteadofanarraymemberofsize1. MEM34−C Onlyfreememoryallocateddynamically Freeingmemorythatisnotallocateddynamicallycanleadtocorruptionoftheheapdatastructures. MEM35−C Allocatesufficientmemoryforanobject Thecompilerissuesthiswarningwhenthesizeoftheobject(s)allocatedbymalloc(),calloc()orrealloc() issmallerthanthesizeofanobjectpointedtobytheresultpointer.Thismaybecausedbyasizeof expressionwiththewrongtypeorwithapointertypeinsteadoftheobjecttype.

9.9 Environment(ENV)

ENV32−C Allatexithandlersmustreturnnormally Thecompilerissuesthiswarningwhenanatexit()handleriscallingafunctionthatdoesnotreturn.No atexit()registeredhandlershouldterminateinanywayotherthanbyreturning.

9−4 CERTCSecureCodingStandard

9.10 Signals(SIG)

SIG30−C Callonlyasynchronous−safefunctionswithinsignalhandlers SIG32−C Donotcalllongjmp()frominsideasignalhandler Invokingthelongjmp()functionfromwithinasignalhandlercanleadtoundefinedbehaviorifitresultsin theinvocationofanynon−asynchronous−safefunctions,likelycompromisingtheintegrityofthe program.

9.11 Miscellaneous(MSC)

MSC32−C Ensureyourrandomnumbergeneratorisproperlyseeded Ensurethattherandomnumbergeneratorisproperlyseededbycallingsrand().

9−5 MicroBlazeEmbeddedToolsReference

9−6 10 MISRA−CRules

Summary ThischaptercontainsanoverviewofthesupportedandunsupportedMISRA−C rules.

10.1 MISRA−C:1998

ThissectionlistsallsupportedandunsupportedMISRA−C:1998rules.

Seealsosection2.7.2,CCodeChecking:MISRA−C,inChapterUsingtheCompileroftheUser’sManual.

AnumberofMISRA−Crulesleaveroomforinterpretation.Otherrulescanonlybecheckedinalimitedway.Insuch casestheimplementationdecisionsandpossiblerestrictionsfortheserulesarelisted. xmeansthattheruleisnotsupportedbytheTASKINGCcompiler. (R)isarequiredrule,(A)isanadvisoryrule.

1. (R) ThecodeshallconformtostandardC,withoutlanguageextensions x 2. (A) Otherlanguagesshouldonlybeusedwithaninterfacestandard 3. (A) InlineassemblyisonlyallowedindedicatedCfunctions x 4. (A) Provisionshouldbemadeforappropriaterun−timechecking 5. (R) OnlyusecharactersandescapesequencesdefinedbyISOC x 6. (R) CharactervaluesshallberestrictedtoasubsetofISO106460−1 7. (R) Trigraphsshallnotbeused 8. (R) Multibytecharactersandwidestringliteralsshallnotbeused 9. (R) Commentsshallnotbenested 10. (A) Sectionsofcodeshouldnotbe"commentedout" Ingeneral,itisnotpossibletodecidewhetherapieceofcommentisCcodethatiscommentedout,orjust somepseudocode.Instead,thefollowingheuristicsareusedtodetectpossibleCcodeinsideacomment: −alineendswith’;’,or −alinestartswith’}’,possiblyprecededbywhitespace 11. (R) Identifiersshallnotrelyonsignificanceofmorethan31characters 12. (A) Thesameidentifiershallnotbeusedinmultiplenamespaces 13. (A) Specific−lengthtypedefsshouldbeusedinsteadofthebasictypes 14. (R) Use’unsignedchar’or’signedchar’insteadofplain’char’ x 15. (A) Floating−pointimplementationsshouldcomplywithastandard 16. (R) Thebitrepresentationoffloating−pointnumbersshallnotbeused Aviolationisreportedwhenapointertoafloating−pointtypeisconvertedtoapointertoanintegertype. 17. (R) "typedef"namesshallnotbereused 18. (A) Numericconstantsshouldbesuffixedtoindicatetype Aviolationisreportedwhenthevalueoftheconstantisoutsidetherangeindicatedbythesuffixes,ifany. 19. (R) Octalconstants(otherthanzero)shallnotbeused 20. (R) Allobjectandfunctionidentifiersshallbedeclaredbeforeuse 21. (R) Identifiersshallnothideidentifiersinanouterscope 22. (A) Declarationsshouldbeatfunctionscopewherepossible

10−1 MicroBlazeEmbeddedToolsReference

x 23. (A) Alldeclarationsatfilescopeshouldbestaticwherepossible 24. (R) Identifiersshallnothavebothinternalandexternallinkage x 25. (R) Identifierswithexternallinkageshallhaveexactlyonedefinition 26. (R) Multipledeclarationsforobjectsorfunctionsshallbecompatible x 27. (A) Externalobjectsshouldnotbedeclaredinmorethanonefile 28. (A) The"register"storageclassspecifiershouldnotbeused 29. (R) Theuseofatagshallagreewithitsdeclaration 30. (R) Allautomaticsshallbeinitializedbeforebeingused Thisruleischeckedusingworst−caseassumptions.Thismeansthatviolationsarereportednotonlyfor variablesthatareguaranteedtobeuninitialized,butalsoforvariablesthatareuninitializedonsome executionpaths. 31. (R) Bracesshallbeusedintheinitializationofarraysandstructures 32. (R) Onlythefirst,orallenumerationconstantsmaybeinitialized 33. (R) Therighthandoperandof&&or||shallnotcontainsideeffects 34. (R) Theoperandsofalogical&&or||shallbeprimaryexpressions 35. (R) AssignmentoperatorsshallnotbeusedinBooleanexpressions 36. (A) Logicaloperatorsshouldnotbeconfusedwithbitwiseoperators 37. (R) Bitwiseoperationsshallnotbeperformedonsignedintegers 38. (R) Ashiftcountshallbebetween0andtheoperandwidthminus1 Thisviolationwillonlybecheckedwhentheshiftcountevaluatestoaconstantvalueatcompiletime. 39. (R) Theunaryminusshallnotbeappliedtoanunsignedexpression 40. (A) "sizeof"shouldnotbeusedonexpressionswithsideeffects x 41. (A) Theimplementationofintegerdivisionshouldbedocumented 42. (R) Thecommaoperatorshallonlybeusedina"for"condition 43. (R) Don’tuseimplicitconversionswhichmayresultininformationloss 44. (A) Redundantexplicitcastsshouldnotbeused 45. (R) Typecastingfromanytypetoorfrompointersshallnotbeused 46. (R) Thevalueofanexpressionshallbeevaluationorderindependent Thisruleischeckedusingworst−caseassumptions.Thismeansthataviolationwillbereportedwhena possiblealiasmaycausetheresultofanexpressiontobeevaluationorderdependent. 47. (A) Nodependenceshouldbeplacedonoperatorprecedencerules 48. (A) Mixedarithmeticshoulduseexplicitcasting 49. (A) Testsofa(non−Boolean)valueagainst0shouldbemadeexplicit 50. (R) F.P.variablesshallnotbetestedforexactequalityorinequality 51. (A) Constantunsignedintegerexpressionsshouldnotwrap−around 52. (R) Thereshallbenounreachablecode 53. (R) Allnon−nullstatementsshallhaveaside−effect 54. (R) Anullstatementshallonlyoccuronalinebyitself 55. (A) Labelsshouldnotbeused 56. (R) The"goto"statementshallnotbeused 57. (R) The"continue"statementshallnotbeused 58. (R) The"break"statementshallnotbeused(exceptina"switch") 59. (R) An"if"orloopbodyshallalwaysbeenclosedinbraces 60. (A) All"if","elseif"constructsshouldcontainafinal"else" 61. (R) Everynon−empty"case"clauseshallbeterminatedwitha"break" 62. (R) All"switch"statementsshouldcontainafinal"default"case

10−2 MISRA−CRules

63. (A) A"switch"expressionshouldnotrepresentaBooleancase 64. (R) Every"switch"shallhaveatleastone"case" 65. (R) Floating−pointvariablesshallnotbeusedasloopcounters 66. (A) A"for"shouldonlycontainexpressionsconcerningloopcontrol Aviolationisreportedwhentheloopinitializationorloopupdateexpressionmodifiesanobjectthatisnot referencedinthelooptest. 67. (A) Iteratorvariablesshouldnotbemodifiedina"for"loop 68. (R) Functionsshallalwaysbedeclaredatfilescope 69. (R) Functionswithvariablenumberofargumentsshallnotbeused 70. (R) Functionsshallnotcallthemselves,eitherdirectlyorindirectly Aviolationwillbereportedfordirectorindirectrecursivefunctioncallsinthesourcefilebeingchecked. Recursionviafunctionsinothersourcefiles,orrecursionviafunctionpointersisnotdetected. 71. (R) Functionprototypesshallbevisibleatthedefinitionandcall 72. (R) Thefunctionprototypeofthedeclarationshallmatchthedefinition 73. (R) Identifiersshallbegivenforallprototypeparametersorfornone 74. (R) Parameteridentifiersshallbeidenticalfordeclaration/definition 75. (R) Everyfunctionshallhaveanexplicitreturntype 76. (R) Functionswithnoparametersshallhavea"void"parameterlist 77. (R) Anactualparametertypeshallbecompatiblewiththeprototype 78. (R) Thenumberofactualparametersshallmatchtheprototype 79. (R) Thevaluesreturnedby"void"functionsshallnotbeused 80. (R) Voidexpressionsshallnotbepassedasfunctionparameters 81. (A) "const"shouldbeusedforreferenceparametersnotmodified 82. (A) Afunctionshouldhaveasinglepointofexit 83. (R) Everyexitpointshallhavea"return"ofthedeclaredreturntype 84. (R) For"void"functions,"return"shallnothaveanexpression 85. (A) Functioncallswithnoparametersshouldhaveemptyparentheses 86. (A) Ifafunctionreturnserrorinformation,itshouldbetested Aviolationisreportedwhenthereturnvalueofafunctionisignored. 87. (R) #includeshallonlybeprecededbyotherdirectivesorcomments 88. (R) Non−standardcharactersshallnotoccurin#includedirectives 89. (R) #includeshallbefollowedbyeitheror"filename" 90. (R) Plainmacrosshallonlybeusedforconstants/qualifiers/specifiers 91. (R) Macrosshallnotbe#define’dand#undef’dwithinablock 92. (A) #undefshouldnotbeused 93. (A) Afunctionshouldbeusedinpreferencetoafunction−likemacro 94. (R) Afunction−likemacroshallnotbeusedwithoutallarguments 95. (R) Macroargumentsshallnotcontainpre−preprocessingdirectives Aviolationisreportedwhenthefirsttokenofanactualmacroargumentis’#’. 96. (R) Macrodefinitions/parametersshouldbeenclosedinparentheses 97. (A) Don’tuseundefinedidentifiersinpre−processingdirectives 98. (R) Amacrodefinitionshallcontainatmostone#or##operator 99. (R) Allusesofthe#pragmadirectiveshallbedocumented Thisruleisreallyadocumentationissue.Thecompilerwillflagall#pragmadirectivesasviolations. 100. (R) "defined"shallonlybeusedinoneofthetwostandardforms 101. (A) Pointerarithmeticshouldnotbeused

10−3 MicroBlazeEmbeddedToolsReference

102. (A) Nomorethan2levelsofpointerindirectionshouldbeused Aviolationisreportedwhenapointerwiththreeormorelevelsofindirectionisdeclared. 103. (R) Norelationaloperatorsbetweenpointerstodifferentobjects Ingeneral,checkingwhethertwopointerspointtothesameobjectisimpossible.Thecompilerwillonly reportaviolationforarelationaloperationwithincompatiblepointertypes. 104. (R) Non−constantpointerstofunctionsshallnotbeused 105. (R) Functionsassignedtothesamepointershallbeofidenticaltype 106. (R) Automaticaddressmaynotbeassignedtoalongerlivedobject 107. (R) Thenullpointershallnotbede−referenced AviolationisreportedforeverypointerdereferencethatisnotguardedbyaNULLpointertest. 108. (R) Allstruct/unionmembersshallbefullyspecified 109. (R) Overlappingvariablestorageshallnotbeused Aviolationisreportedforevery’union’declaration. 110. (R) Unionsshallnotbeusedtoaccessthesub−partsoflargertypes Aviolationisreportedfora’union’containinga’struct’member. 111. (R) bit−fieldsshallhavetype"unsignedint"or"signedint" 112. (R) bit−fieldsoftype"signedint"shallbeatleast2bitslong 113. (R) Allstruct/unionmembersshallbenamed 114. (R) Reservedandstandardlibrarynamesshallnotberedefined 115. (R) Standardlibraryfunctionnamesshallnotbereused x 116. (R) ProductionlibrariesshallcomplywiththeMISRA−Crestrictions x 117. (R) Thevalidityoflibraryfunctionparametersshallbechecked 118. (R) Dynamicheapmemoryallocationshallnotbeused 119. (R) Theerrorindicator"errno"shallnotbeused 120. (R) Themacro"offsetof"shallnotbeused 121. (R) andthe"setlocale"functionshallnotbeused 122. (R) The"setjmp"and"longjmp"functionsshallnotbeused 123. (R) Thesignalhandlingfacilitiesofshallnotbeused 124. (R) Thelibraryshallnotbeusedinproductioncode 125. (R) Thefunctionsatof/atoi/atolshallnotbeused 126. (R) Thefunctionsabort/exit/getenv/systemshallnotbeused 127. (R) Thetimehandlingfunctionsoflibraryshallnotbeused

Seealsosection2.7.2,CCodeChecking:MISRA−C,inChapterUsingtheCompileroftheUser’smanual.

10−4 MISRA−CRules

10.2 MISRA−C:2004

ThissectionlistsallsupportedandunsupportedMISRA−C:2004rules.

Seealsosection2.7.2,CCodeChecking:MISRA−C,inChapterUsingtheCompileroftheUser’sManual.

AnumberofMISRA−Crulesleaveroomforinterpretation.Otherrulescanonlybecheckedinalimitedway.Insuch casestheimplementationdecisionsandpossiblerestrictionsfortheserulesarelisted. xmeansthattheruleisnotsupportedbytheTASKINGCcompiler. (R)isarequiredrule,(A)isanadvisoryrule.

Environment

1.1 (R) AllcodeshallconformtoISO9899:1990"Programminglanguages−C",amendedandcorrectedby ISO/IEC9899/COR1:1995,ISO/IEC9899/AMD1:1995,andISO/IEC9899/COR2:1996. 1.2 (R) Norelianceshallbeplacedonundefinedorunspecifiedbehavior. x 1.3 (R) Multiplecompilersand/orlanguagesshallonlybeusedifthereisacommondefinedinterfacestandard forobjectcodetowhichthelanguages/compilers/assemblersconform. x 1.4 (R) Thecompiler/linkershallbecheckedtoensurethat31charactersignificanceandcasesensitivityare supportedforexternalidentifiers. x 1.5 (A) Floating−pointimplementationsshouldcomplywithadefinedfloating−pointstandard.

Languageextensions

2.1 (R) Assemblylanguageshallbeencapsulatedandisolated. 2.2 (R) Sourcecodeshallonlyuse/*...*/stylecomments. 2.3 (R) Thecharactersequence/*shallnotbeusedwithinacomment. 2.4 (A) Sectionsofcodeshouldnotbe"commentedout". Ingeneral,itisnotpossibletodecidewhetherapieceofcommentisCcodethatiscommentedout,or justsomepseudocode.Instead,thefollowingheuristicsareusedtodetectpossibleCcodeinsidea comment: −alineendswith’;’,or −alinestartswith’}’,possiblyprecededbywhitespace

Documentation

x 3.1 (R) Allusageofimplementation−definedbehaviorshallbedocumented. x 3.2 (R) Thecharactersetandthecorrespondingencodingshallbedocumented. x 3.3 (A) Theimplementationofintegerdivisioninthechosencompilershouldbedetermined,documentedand takenintoaccount. 3.4 (R) Allusesofthe#pragmadirectiveshallbedocumentedandexplained. Thisruleisreallyadocumentationissue.Thecompilerwillflagall#pragma directivesasviolations. 3.5 (R) Theimplementation−definedbehaviorandpackingofbit−fieldsshallbedocumentedifbeingreliedupon. x 3.6 (R) Alllibrariesusedinproductioncodeshallbewrittentocomplywiththeprovisionsofthisdocument,and shallhavebeensubjecttoappropriatevalidation.

Charactersets

4.1 (R) OnlythoseescapesequencesthataredefinedintheISOCstandardshallbeused. 4.2 (R) Trigraphsshallnotbeused.

10−5 MicroBlazeEmbeddedToolsReference

Identifiers

5.1 (R) Identifiers(internalandexternal)shallnotrelyonthesignificanceofmorethan31characters. 5.2 (R) Identifiersinaninnerscopeshallnotusethesamenameasanidentifierinanouterscope,andtherefore hidethatidentifier. 5.3 (R) Atypedefnameshallbeauniqueidentifier. 5.4 (R) Atagnameshallbeauniqueidentifier. x 5.5 (A) Noobjectorfunctionidentifierwithstaticstoragedurationshouldbereused. 5.6 (A) Noidentifierinonenamespaceshouldhavethesamespellingasanidentifierinanothernamespace, withtheexceptionofstructureandunionmembernames. x 5.7 (A) Noidentifiernameshouldbereused.

Types

6.1 (R) Theplainchartypeshallbeusedonlyforstorageanduseofcharactervalues. x 6.2 (R) signedandunsignedchartypeshallbeusedonlyforthestorageanduseofnumericvalues. 6.3 (A) typedefsthatindicatesizeandsignednessshouldbeusedinplaceofthebasictypes. 6.4 (R) bit−fieldsshallonlybedefinedtobeoftypeunsignedintorsignedint. 6.5 (R) bit−fieldsoftypesignedintshallbeatleast2bitslong.

Constants

7.1 (R) Octalconstants(otherthanzero)andoctalescapesequencesshallnotbeused.

Declarationsanddefinitions

8.1 (R) Functionsshallhaveprototypedeclarationsandtheprototypeshallbevisibleatboththefunction definitionandcall. 8.2 (R) Wheneveranobjectorfunctionisdeclaredordefined,itstypeshallbeexplicitlystated. 8.3 (R) Foreachfunctionparameterthetypegiveninthedeclarationanddefinitionshallbeidentical,andthe returntypesshallalsobeidentical. 8.4 (R) Ifobjectsorfunctionsaredeclaredmorethanoncetheirtypesshallbecompatible. 8.5 (R) Thereshallbenodefinitionsofobjectsorfunctionsinaheaderfile. 8.6 (R) Functionsshallbedeclaredatfilescope. 8.7 (R) Objectsshallbedefinedatblockscopeiftheyareonlyaccessedfromwithinasinglefunction. x 8.8 (R) Anexternalobjectorfunctionshallbedeclaredinoneandonlyonefile. x 8.9 (R) Anidentifierwithexternallinkageshallhaveexactlyoneexternaldefinition. x 8.10 (R) Alldeclarationsanddefinitionsofobjectsorfunctionsatfilescopeshallhaveinternallinkageunless externallinkageisrequired. 8.11 (R) Thestaticstorageclassspecifiershallbeusedindefinitionsanddeclarationsofobjectsandfunctions thathaveinternallinkage. 8.12 (R) Whenanarrayisdeclaredwithexternallinkage,itssizeshallbestatedexplicitlyordefinedimplicitlyby initialization.

10−6 MISRA−CRules

Initialization

9.1 (R) Allautomaticvariablesshallhavebeenassignedavaluebeforebeingused. Thisruleischeckedusingworst−caseassumptions.Thismeansthatviolationsarereportednotonlyfor variablesthatareguaranteedtobeuninitialized,butalsoforvariablesthatareuninitializedonsome executionpaths. 9.2 (R) Bracesshallbeusedtoindicateandmatchthestructureinthenon−zeroinitializationofarraysand structures. 9.3 (R) Inanenumeratorlist,the"="constructshallnotbeusedtoexplicitlyinitializemembersotherthanthe first,unlessallitemsareexplicitlyinitialized.

Arithmetictypeconversions

10.1 (R) Thevalueofanexpressionofintegertypeshallnotbeimplicitlyconvertedtoadifferentunderlyingtypeif: a)itisnotaconversiontoawiderintegertypeofthesamesignedness,or b)theexpressioniscomplex,or c)theexpressionisnotconstantandisafunctionargument,or d)theexpressionisnotconstantandisareturnexpression. 10.2 (R) Thevalueofanexpressionoffloatingtypeshallnotbeimplicitlyconvertedtoadifferenttypeif: a)itisnotaconversiontoawiderfloatingtype,or b)theexpressioniscomplex,or c)theexpressionisafunctionargument,or d)theexpressionisareturnexpression. 10.3 (R) Thevalueofacomplexexpressionofintegertypemayonlybecasttoatypethatisnarrowerandofthe samesignednessastheunderlyingtypeoftheexpression. 10.4 (R) Thevalueofacomplexexpressionoffloatingtypemayonlybecasttoanarrowerfloatingtype. 10.5 (R) Ifthebitwiseoperators~and<<areappliedtoanoperandofunderlyingtypeunsignedcharor unsignedshort,theresultshallbeimmediatelycasttotheunderlyingtypeoftheoperand. 10.6 (R) A"U"suffixshallbeappliedtoallconstantsofunsignedtype.

Pointertypeconversions

11.1 (R) Conversionsshallnotbeperformedbetweenapointertoafunctionandanytypeotherthananintegral type. 11.2 (R) Conversionsshallnotbeperformedbetweenapointertoobjectandanytypeotherthananintegraltype, anotherpointertoobjecttypeorapointertovoid. 11.3 (A) Acastshouldnotbeperformedbetweenapointertypeandanintegraltype. 11.4 (A) Acastshouldnotbeperformedbetweenapointertoobjecttypeandadifferentpointertoobjecttype. 11.5 (R) Acastshallnotbeperformedthatremovesanyconstorvolatilequalificationfromthetype addressedbyapointer.

Expressions

12.1 (A) LimiteddependenceshouldbeplacedonC’soperatorprecedencerulesinexpressions. 12.2 (R) Thevalueofanexpressionshallbethesameunderanyorderofevaluationthatthestandardpermits. Thisruleischeckedusingworst−caseassumptions.Thismeansthataviolationwillbereportedwhena possiblealiasmaycausetheresultofanexpressiontobeevaluationorderdependent. 12.3 (R) Thesizeofoperatorshallnotbeusedonexpressionsthatcontainsideeffects. 12.4 (R) Theright−handoperandofalogical&&or||operatorshallnotcontainsideeffects. 12.5 (R) Theoperandsofalogical&&or||shallbeprimary−expressions. 12.6 (A) Theoperandsoflogicaloperators(&&,||and!)shouldbeeffectivelyBoolean.Expressionsthatare effectivelyBooleanshouldnotbeusedasoperandstooperatorsotherthan(&&,||and!). 12.7 (R) Bitwiseoperatorsshallnotbeappliedtooperandswhoseunderlyingtypeissigned.

10−7 MicroBlazeEmbeddedToolsReference

12.8 (R) Theright−handoperandofashiftoperatorshallliebetweenzeroandonelessthanthewidthinbitsof theunderlyingtypeoftheleft−handoperand. Thisviolationwillonlybecheckedwhentheshiftcountevaluatestoaconstantvalueatcompile time. 12.9 (R) Theunaryminusoperatorshallnotbeappliedtoanexpressionwhoseunderlyingtypeisunsigned. 12.10 (R) Thecommaoperatorshallnotbeused. 12.11 (A) Evaluationofconstantunsignedintegerexpressionsshouldnotleadtowrap−around. 12.12 (R) Theunderlyingbitrepresentationsoffloating−pointvaluesshallnotbeused. Aviolationisreportedwhenapointertoafloating−pointtypeisconvertedtoapointertoanintegertype. 12.13 (A) Theincrement(++)anddecrement(−−)operatorsshouldnotbemixedwithotheroperatorsinan expression.

Controlstatementexpressions

13.1 (R) AssignmentoperatorsshallnotbeusedinexpressionsthatyieldaBooleanvalue. 13.2 (A) Testsofavalueagainstzeroshouldbemadeexplicit,unlesstheoperandiseffectivelyBoolean. 13.3 (R) Floating−pointexpressionsshallnotbetestedforequalityorinequality. 13.4 (R) Thecontrollingexpressionofaforstatementshallnotcontainanyobjectsoffloatingtype. 13.5 (R) Thethreeexpressionsofaforstatementshallbeconcernedonlywithloopcontrol. Aviolationisreportedwhentheloopinitializationorloopupdateexpressionmodifiesanobjectthatisnot referencedinthelooptest. 13.6 (R) Numericvariablesbeingusedwithinaforloopforiterationcountingshallnotbemodifiedinthebodyof theloop. 13.7 (R) Booleanoperationswhoseresultsareinvariantshallnotbepermitted.

Controlflow

14.1 (R) Thereshallbenounreachablecode. 14.2 (R) Allnon−nullstatementsshalleither: a)haveatleastonesideeffecthoweverexecuted,or b)causecontrolflowtochange. 14.3 (R) Beforepreprocessing,anullstatementshallonlyoccuronalinebyitself;itmaybefollowedbya commentprovidedthatthefirstcharacterfollowingthenullstatementisawhite−spacecharacter. 14.4 (R) Thegotostatementshallnotbeused. 14.5 (R) Thecontinuestatementshallnotbeused. 14.6 (R) Foranyiterationstatementthereshallbeatmostonebreakstatementusedforlooptermination. 14.7 (R) Afunctionshallhaveasinglepointofexitattheendofthefunction. 14.8 (R) Thestatementformingthebodyofaswitch,while,do...whileorforstatementbeacompound statement. 14.9 (R) Anif(expression)constructshallbefollowedbyacompoundstatement.Theelsekeywordshall befollowedbyeitheracompoundstatement,oranotherifstatement. 14.10 (R) Allif...elseifconstructsshallbeterminatedwithanelseclause.

Switchstatements

15.1 (R) Aswitchlabelshallonlybeusedwhenthemostclosely−enclosingcompoundstatementisthebodyofa switchstatement. 15.2 (R) Anunconditionalbreakstatementshallterminateeverynon−emptyswitchclause. 15.3 (R) Thefinalclauseofaswitchstatementshallbethedefaultclause. 15.4 (R) AswitchexpressionshallnotrepresentavaluethatiseffectivelyBoolean. 15.5 (R) Everyswitchstatementshallhaveatleastonecaseclause.

10−8 MISRA−CRules

Functions

16.1 (R) Functionsshallnotbedefinedwithvariablenumbersofarguments. 16.2 (R) Functionsshallnotcallthemselves,eitherdirectlyorindirectly. Aviolationwillbereportedfordirectorindirectrecursivefunctioncallsinthesourcefilebeingchecked. Recursionviafunctionsinothersourcefiles,orrecursionviafunctionpointersisnotdetected. 16.3 (R) Identifiersshallbegivenforalloftheparametersinafunctionprototypedeclaration. 16.4 (R) Theidentifiersusedinthedeclarationanddefinitionofafunctionshallbeidentical. 16.5 (R) Functionswithnoparametersshallbedeclaredwithparametertypevoid. 16.6 (R) Thenumberofargumentspassedtoafunctionshallmatchthenumberofparameters. 16.7 (A) Apointerparameterinafunctionprototypeshouldbedeclaredaspointertoconstifthepointerisnot usedtomodifytheaddressedobject. 16.8 (R) Allexitpathsfromafunctionwithnon−voidreturntypeshallhaveanexplicitreturnstatementwithan expression. 16.9 (R) Afunctionidentifiershallonlybeusedwitheitherapreceding&,orwithaparenthesizedparameterlist, whichmaybeempty. 16.10 (R) Ifafunctionreturnserrorinformation,thenthaterrorinformationshallbetested. Aviolationisreportedwhenthereturnvalueofafunctionisignored.

Pointersandarrays

x 17.1 (R) Pointerarithmeticshallonlybeappliedtopointersthataddressanarrayorarrayelement. x 17.2 (R) Pointersubtractionshallonlybeappliedtopointersthataddresselementsofthesamearray. 17.3 (R) >,>=,<,<=shallnotbeappliedtopointertypesexceptwheretheypointtothesamearray. Ingeneral,checkingwhethertwopointerspointtothesameobjectisimpossible.Thecompilerwillonly reportaviolationforarelationaloperationwithincompatiblepointertypes. 17.4 (R) Arrayindexingshallbetheonlyallowedformofpointerarithmetic. 17.5 (A) Thedeclarationofobjectsshouldcontainnomorethan2levelsofpointerindirection. Aviolationisreportedwhenapointerwiththreeormorelevelsofindirectionisdeclared. 17.6 (R) Theaddressofanobjectwithautomaticstorageshallnotbeassignedtoanotherobjectthatmaypersist afterthefirstobjecthasceasedtoexist.

Structuresandunions

18.1 (R) Allstructureoruniontypesshallbecompleteattheendofatranslationunit. 18.2 (R) Anobjectshallnotbeassignedtoanoverlappingobject. x 18.3 (R) Anareaofmemoryshallnotbereusedforunrelatedpurposes. 18.4 (R) Unionsshallnotbeused.

Preprocessingdirectives

19.1 (A) #includestatementsinafileshouldonlybeprecededbyotherpreprocessordirectivesorcomments. 19.2 (A) Non−standardcharactersshouldnotoccurinheaderfilenamesin#includedirectives. x 19.3 (R) The#includedirectiveshallbefollowedbyeitheraor"filename"sequence. 19.4 (R) Cmacrosshallonlyexpandtoabracedinitializer,aconstant,aparenthesizedexpression,atype qualifier,astorageclassspecifier,orado−while−zeroconstruct. 19.5 (R) Macrosshallnotbe#define’dor#undef’dwithinablock. 19.6 (R) #undefshallnotbeused. 19.7 (A) Afunctionshouldbeusedinpreferencetoafunction−likemacro. 19.8 (R) Afunction−likemacroshallnotbeinvokedwithoutallofitsarguments.

10−9 MicroBlazeEmbeddedToolsReference

19.9 (R) Argumentstoafunction−likemacroshallnotcontaintokensthatlooklikepreprocessingdirectives. Aviolationisreportedwhenthefirsttokenofanactualmacroargumentis’#’. 19.10 (R) Inthedefinitionofafunction−likemacroeachinstanceofaparametershallbeenclosedinparentheses unlessitisusedastheoperandof#or##. 19.11 (R) Allmacroidentifiersinpreprocessordirectivesshallbedefinedbeforeuse,exceptin#ifdefand #ifndefpreprocessordirectivesandthedefined()operator. 19.12 (R) Thereshallbeatmostoneoccurrenceofthe#or##preprocessoroperatorsinasinglemacrodefinition. 19.13 (A) The#and##preprocessoroperatorsshouldnotbeused. 19.14 (R) Thedefinedpreprocessoroperatorshallonlybeusedinoneofthetwostandardforms. 19.15 (R) Precautionsshallbetakeninordertopreventthecontentsofaheaderfilebeingincludedtwice. 19.16 (R) Preprocessingdirectivesshallbesyntacticallymeaningfulevenwhenexcludedbythepreprocessor. 19.17 (R) All#else,#elifand#endifpreprocessordirectivesshallresideinthesamefileasthe#ifor #ifdefdirectivetowhichtheyarerelated.

Standardlibraries

20.1 (R) Reservedidentifiers,macrosandfunctionsinthestandardlibrary,shallnotbedefined,redefinedor undefined. 20.2 (R) Thenamesofstandardlibrarymacros,objectsandfunctionsshallnotbereused. x 20.3 (R) Thevalidityofvaluespassedtolibraryfunctionsshallbechecked. 20.4 (R) Dynamicheapmemoryallocationshallnotbeused. 20.5 (R) Theerrorindicatorerrnoshallnotbeused. 20.6 (R) Themacrooffsetof,inlibrary,shallnotbeused. 20.7 (R) Thesetjmpmacroandthelongjmpfunctionshallnotbeused. 20.8 (R) Thesignalhandlingfacilitiesofshallnotbeused. 20.9 (R) Theinput/outputlibraryshallnotbeusedinproductioncode. 20.10 (R) Thelibraryfunctionsatof,atoiandatolfromlibraryshallnotbeused. 20.11 (R) Thelibraryfunctionsabort,exit,getenvandsystemfromlibraryshallnotbeused. 20.12 (R) Thetimehandlingfunctionsoflibraryshallnotbeused.

Run−timefailures

x 21.1 (R) Minimizationofrun−timefailuresshallbeensuredbytheuseofatleastoneof: a)staticanalysistools/techniques; b)dynamicanalysistools/techniques; c)explicitcodingofcheckstohandlerun−timefaults.

10−10 Index

Index Symbols __SIZE_MIN,2−23 #define,5−68 __STDC__,2−23 #include,systemincludedirectory,5−146 __STDC_VERSION__,2−23 #undef,5−152 __TASKING__,1−12,2−23,4−3 __ABI_CHANGES_FOR_ARRAY_NEW_AND_DELETE, __TIME__,2−23 2−22 __TYPE_TRAITS_ENABLED,2−23 __ABI_CHANGES_FOR_PLACEMENT_DELETE,2−22 __unaligned,1−2 __ABI_CHANGES_FOR_RTTI,2−22 __VAR_HANDLE_TYPE,2−23 __ABI_COMPATIBILITY_VERSION,2−22 __VERSION__,1−12,2−23,4−3 __align(),1−2 __VIRTUAL_FUNCTION_INDEX_TYPE,2−23 __ARRAY_OPERATORS,2−22 __VIRTUAL_FUNCTION_TYPE,2−23 __asm,syntax,1−5 __WCHAR_MAX,2−23 __at(),1−4 __WCHAR_MIN,2−23 __BASE_FILE__,2−22 _BOOL,2−22 __BIG_ENDIAN__,1−12,2−22 _close,3−6 __BUILD__,1−12,2−22,4−3 _Exit,3−18 __CHAR_MAX,2−22 _fss_break,3−5 __CHAR_MIN,2−22 _fss_init,3−5 __CMB__,1−12 _IOFBF,3−13 __cplusplus,2−22 _IOLBF,3−13 __CPMB__,2−22 _IONBF,3−13 __DATE__,2−22 _lseek,3−6 __DELTA_TYPE,2−22 _open,3−6 __DOUBLE_FP__,1−12,2−22 _read,3−6 __embedded_cplusplus,2−22 _STLP_NO_IOSTREAMS,2−23 __EXCEPTIONS,2−22 _tolower,3−3 __FILE__,2−22 _unlink,3−6 __func__,2−22 _WCHAR_T,2−23 __HW_BARRELSHIFT__,1−12 _write,3−6 __HW_DIVIDE__,1−12 __HW_FPU__,1−12 A __HW_MSR__,1−12 abort,3−18 __HW_MULTIPLY__,1−12 abs,3−19 __HW_PCMP__,1−12 AbsoluteAddress,1−4 __IMPLICIT_USING_STD,2−22 access,3−22 __interrupt(),1−18 acosfunctions,3−8 __JMP_BUF_ELEMENT_TYPE,2−22 acoshfunctions,3−8 __JMP_BUF_NUM_ELEMENTS,2−22 Addressspaces,8−15 __LINE__,2−22 alias,1−8 __MB__,4−3 align,4−10 __NAMESPACES,2−22 Alignment,1−2 __NO_LONG_LONG,2−22 compositetypes,5−3 __noinline,1−15 Alignmentgaps,8−28 __NULL_EH_REGION_NUMBER,2−23 AlternativeC++tokens,5−60 __packed__,1−2 Anachronism,2−4 __PLACEMENT_DELETE,2−23 Anachronisms,5−61,5−116 __PRETTY_FUNCTION__,2−23 Architecturedefinition,8−1,8−14 __PTRDIFF_MAX,2−23 arg,4−6 __PTRDIFF_MIN,2−23 arraynewanddelete,5−101 __REGION_NUMBER_TYPE,2−23 asctime,3−21 __REVISION__,1−12,2−23,4−3 asinfunctions,3−7 __RTTI,2−23 asinhfunctions,3−8 __RUNTIME_USES_NAMESPACES,2−23 Assemblerdirectives __SIGNED_CHARS__,2−23 .align,4−10 __SINGLE_FP__,1−12,2−23 .break,4−11 __SIZE_MAX,2−23 .bs,4−12

Index−1 MicroBlazeEmbeddedToolsReference

.bsb,4−12 −−help,5−169 .bsd,4−12 −−include−directory,5−170 .bsh,4−12 −−include−file,5−171 .bsw,4−12 −−list−file,5−173 .calls,4−13 −−list−format,5−174 .db,4−14 −−nested−sections,5−175 .dd,4−15 −−no−warnings,5−176 .define,4−16 −−optimize,5−177 .dh,4−17 −−option−file,5−178 .ds,4−18 −−output,5−179 .dsb,4−18 −−page−length,5−180 .dsd,4−18 −−page−width,5−181 .dsh,4−18 −−preprocess,5−182 .dsw,4−18 −−preprocessor−type,5−183 .dw,4−19 −−section−info,5−184 .end,4−20 −−symbol−scope,5−185 .equ,4−21 −−use−hardware,5−186 .extern,4−22 −−verbose,5−188 .for/.endfor,4−23 −−version,5−187 .global,4−24 −−warnings−as−errors,5−189 .if/.elif/.else/.endif,4−25 −c,5−161 .include,4−26 −D,5−164 .label,4−27 −E,5−182 .list/.nolist,4−28 −f,5−178 .macro/.endm,4−29 −g,5−163 .message,4−31 −H,5−171 .offset,4−32 −I,5−170 .page,4−33 −i,5−185 .repeat/.endrep,4−34 −k,5−172 .resume,4−35 −k(−−keep−output−files),5−172 .section,4−36 −L,5−174 .set,4−38 −l,5−173 .size,4−39 −m,5−183 .source,4−40 −N,5−175 .title,4−41 −O,5−177 .type,4−42 −o,5−179 .undef,4−43 −t,5−184 assemblycontrol(overview),4−9 −V,5−187 conditionalassembly(overview),4−9 −v,5−188 datadefinition(overview),4−9 −w,5−176 detaileddescription,4−10 debuginformation,5−163,5−166 HLL(overview),4−10 diagnostics,5−168,5−176,5−189 listingcontrol(overview),4−10 listfile,5−173,5−174,5−184 macros(overview),4−9 optimization,5−177 overview,4−8 preprocessing,5−164,5−171,5−182,5−183 storageallocation(overview),4−9 Assemblersignificantcharacters,4−2 symboldefinitions(overview),4−9 Assembly,ProgramminginC,1−5 weak,4−44 Assemblyexpressions,4−3 Assembleroptions,5−160 Assemblyfunctions,4−5 −?,5−169 @arg,4−6 −−case−insensitive,5−161 @cast,4−6 −−check,5−162 @cnt,4−6 −−debug−info,5−163 @defined,4−7 −−define,5−164 @lsb,4−7 −−diag,5−165 @lsh,4−7 −−emit−locals,5−166 @lsw,4−7 −−error−file,5−167 @msb,4−7 −−error−limit,5−168 @msh,4−7

Index−2 Index

@msw,4−7 −−iso,5−21 @strcat,4−7 −−keep−output−files,5−22 @strcmp,4−7 −−language,5−23 @strlen,4−8 −−make−target,5−25 @strpos,4−8 −−max−call−depth,5−26 @use_barrel_shift,4−8 −−mil,5−27 detaileddescription,4−6 −−mil−split,5−27 overview,4−6 −−misrac,5−28 Assemblysyntax,4−1 −−misrac−advisory−warnings,5−29 atanfunctions,3−8 −−misrac−required−warnings,5−29 atan2functions,3−8 −−no−double,5−32 atanhfunctions,3−8 −−no−stdinc,5−34 atexit,3−18 −−no−warnings,5−36 atof,3−18 −−noclear,5−31 atoi,3−18 −−noframe,5−33 atol,3−18 −−novector,5−35 atoll,3−18 −−optimize,5−37 −−option−file,5−39 B −−output,5−40 Binarysearchtable,1−13 −−preprocess,5−41 binary_switch,1−11 −−profile,5−42 Boardspecification,8−2,8−22 −−rename−sections,5−44 boolkeyword,5−103 −−romstrings,5−45 break,4−11 −−runtime,5−46 bs,4−12 −−sdata,5−47 bsb,4−12 −−signed−bitfields,5−48 bsd,4−12 −−source,5−49 bsearch,3−19 −−static,5−50 bsh,4−12 −−stdout,5−51 bsw,4−12 −−tradeoff,5−52 btowc,3−23 −−uchar,5−53 BUFSIZ,3−12 −−undefine,5−54 Buildoptions,5−208 −−use−hardware,5−55 includefilespath,5−16,5−34,5−86,5−170,5−204 −−vector−offset,5−56 Busdefinition,8−2 −−version,5−57 Buses,8−15 −−warnings−as−errors,5−58 −A,5−23 C −c,5−21 −D,5−8 Ccompileroptions,5−1 −E,5−41 −?,5−15 −F,5−32 −−align−composites,5−3 −f,5−39 −−cert,5−4 −g,5−7 −−check,5−5 −H,5−17 −−compact−max−size,5−6 −I,5−16 −−debug−info,5−7 −k,5−22 −−define,5−8 −n,5−51 −−dep−file,5−10 −O,5−37 −−diag,5−11 −o,5−40 −−errorfile,5−12 −p,5−42 −−extern−sdata,5−13 −R,5−44 −−global−type−checking,5−14 −r,5−46 −−help,5−15 −S,5−45 −−include−directory,5−16 −s,5−49 −−include−file,5−17 −t,5−52 −−inline,5−18 −U,5−54 −−inline−max−incr,5−19 −u,5−53 −−inline−max−size,5−19 −V,5−57 −−integer−enumeration,5−20

Index−3 MicroBlazeEmbeddedToolsReference

−w,5−36 −−no−double,5−108 codegeneration,5−33,5−35,5−45,5−56 −−no−enum−overloading,5−109 debuginformation,5−7 −−no−explicit,5−110 diagnostics,5−36,5−58 −−no−export,5−111 language,5−20,5−21,5−23,5−48,5−53 −−no−extern−inline,5−112 MISRA−C,5−28 −−no−for−init−diff−warning,5−113 optimization,5−37,5−52 −−no−implicit−typename,5−114 preprocessing,5−8,5−17,5−41,5−54 −−no−inlining,5−115 C++,languageextensions,2−1 −−no−nonconst−ref−anachronism,5−116 C++compileroptions,5−59 −−no−parse−templates,5−119 −?,5−82 −−no−pch−messages,5−120 −−alternative−tokens,5−60 −−no−preprocessing−only,5−121 −−anachronisms,5−61 −−no−stdinc,5−122 −−base−assign−op−is−default,5−62 −−no−stdstlinc,5−122 −−building−runtime,5−63 −−no−type−traits−helpers,5−150 −−c++0x,5−64 −−no−typename,5−123 −−check,5−65 −−no−use−before−set−warnings,5−124 −−context−limit,5−66 −−no−warnings,5−125 −−create−pch,5−67 −−nonconst−ref−anachronism,5−116 −−define,5−68 −−nonstd−qualifier−deduction,5−117 −−dep−file,5−69 −−nonstd−using−decl,5−118 −−dollar,5−70 −−old−for−init,5−126 −−embedded−c++,5−71 −−old−line−commands,5−127 −−error−file,5−72 −−old−specializations,5−128 −−error−limit,5−73 −−option−file,5−129 −−exceptions,5−74 −−output,5−131 −−exported−template−file,5−75 −−pch,5−132 −−extended−variadic−macros,5−76 −−pch−dir,5−133 −−force−vtbl,5−77 −−pch−verbose,5−134 −−friend−injection,5−78 −−pending−instantiations,5−135 −−g++,5−79 −−preprocess,5−136 −−gnu−version,5−80 −−remarks,5−137 −−guiding−decls,5−81 −−remove−unneeded−entities,5−138 −−help,5−82 −−rtti,5−139 −−implicit−extern−c−type−conversion,5−83 −−schar,5−140 −−implicit−include,5−84 −−signed−bitfields,5−141 −−incl−suffixes,5−85 −−special−subscript−cost,5−142 −−include−directory,5−86 −−strict,5−143 −−include−file,5−87 −−strict−warnings,5−144 −−include−macros−file,5−88 −−suppress−vtbl,5−145 −−init−priority,5−89 −−sys−include,5−146 −−instantiate,5−90 −−template−directory,5−147 −−io−streams,5−91 −−timing,5−148 −−late−tiebreaker,5−92 −−trace−includes,5−149 −−list−file,5−93 −−type−traits−helpers,5−150 −−long−lifetime−temps,5−95 −−uchar,5−151 −−long−long,5−96 −−undefine,5−152 −−make−target,5−97 −−use−pch,5−153 −−multibyte−chars,5−98 −−using−std,5−154 −−namespaces,5−99 −−variadic−macros,5−155 −−no−arg−dep−lookup,5−100 −−version,5−156 −−no−array−new−and−delete,5−101 −−warnings−as−errors,5−157 −−no−auto−instantiation,5−102 −−wchar_t−keyword,5−158 −−no−bool,5−103 −−xref−file,5−159 −−no−class−name−injection,5−104 −A,5−143 −−no−const−string−literals,5−105 −a,5−144 −−no−dep−name,5−106 −D,5−68 −−no−distinct−template−signatures,5−107 −E,5−136

Index−4 Index

−e,5−73 Contextlimit,5−66 −F,5−108 Controlprogram,passingoptions,5−267 −f,5−129 Controlprogramoptions,5−230 −H,5−87 −?,5−246 −I,5−86 −−adress−size,5−231 −j,5−124 −−check,5−232 −L,5−93 −−create,5−233 −o,5−131 −−debug−info,5−234 −r,5−137 −−define,5−235 −s,5−140 −−dep−file,5−236 −t,5−90 −−diag,5−237 −U,5−152 −−dry−run,5−238 −u,5−151,5−156 −−errorfile,5−239 −V,5−156 −−exceptions,5−240 −w,5−125 −−force−c,5−241 −X,5−159 −−force−c++,5−242 −x,5−74 −−force−munch,5−243 diagnostics,5−157 −−format,5−244 preprocessing,5−68,5−87,5−136 −−global−type−checking,5−245 C++dialect,2−1 −−help,5−246 accepted,2−1 −−ignore−default−library−path,5−254 anachronismsaccepted,2−4 −−include−directory,5−247 C++0xlanguagefeaturesaccepted,2−3 −−instantiate,5−248 normalC++modeextensions,2−4 −−io−streams,5−249 standardlanguagefeaturesaccepted,2−1 −−iso,5−250 C++languagefeatures −−keep−output−files,5−251 accepted,2−1 −−keep−temporary−files,5−252 C++0x,2−3 −−library,5−253 C++stylecomments,5−23 −−library−directory,5−254 C++workingpaper,5−64 −−lsl−file,5−256 Callgraph,4−13 −−make−target,5−257 calloc,3−7,3−18 −−mil−link,5−258 calls,4−13 −−mil−split,5−258 cast,4−6 −−no−auto−instantiation,5−259 cbrtfunctions,3−9 −−no−default−libraries,5−260 ceilfunctions,3−9 −−no−double,5−261 CERTC,9−1 −−no−map−file,5−262 CERTCsecurecoding,5−4 −−no−preprocessing−only,5−263 chdir,3−22 −−no−warnings,5−264 Checksourcecode,5−5,5−65,5−162,5−232 −−optionfile,5−265 Classnameinjection,5−104 −−output,5−266 clear/noclear,1−8 −−pass,5−267 clearerr,3−17 −−preprocess,5−268 clock,3−21 −−profile,5−269 clock_t,3−21 −−show−c++−warnings,5−271 CLOCKS_PER_SEC,3−21 −−static,5−272 close,3−22 −−undefine,5−273 cnt,4−6 −−verbose,5−274 Codechecking,CERTC,9−1 −−version,5−275 Codecompaction,5−18,5−26 −−warnings−as−errors,5−276 Commandfile,5−291 −c,5−233 Comment,4−1 −D,5−235 Comments,8−3 −d,5−256 compactmaxmatch,1−8 −E,5−268 compileroptions,−−misrac−version,5−30 −F,5−261 Conditionalassembly,4−48 −f,5−265 Conditionalmakerules,5−278 −g,5−234 const,stringliterals,5−105 −I,5−247

Index−5 MicroBlazeEmbeddedToolsReference

−k,5−251 erffunctions,3−10 −L,5−254 erfcfunctions,3−10 −l,5−253 errno,3−4 −l(−−library),5−255 Errorlimit,5−73 −n,5−238 Erroroutputfile,5−72 −o,5−266 Exceptionhandling,5−74 −p,5−269 exit,3−18 −t,5−252 EXIT_FAILURE,3−17 −U,5−273 EXIT_SUCCES,3−17 −V,5−275 expfunctions,3−8 −v,5−274 exp2functions,3−8 −W,5−267 explicitspecifier,5−110 −w,5−264 expm1functions,3−8 preprocessing,5−235 exportkeyword,2−18,5−111 Copyassignmentoperator,5−62 Exportedtemplates,2−18 Copytable,8−16,8−32 Expressions,4−3 copysignfunctions,3−9 absolute,4−3 cosfunctions,3−7 relative,4−3 coshfunctions,3−8 relocatable,4−3 Cross−referencefile,5−159 extensionisuffix,1−8 ctime,3−21 ExtensionstoC++,2−1 extern,1−8,4−22 D externC,5−83 Datatypes,1−2 externC++,5−83 db,4−14 externinline,5−112 dd,4−15 Externinlinefunctions,2−20 Debuginfo,5−234 extern_sdata,1−9 Debuginformation,5−166 define,4−16 F defined,4−7 fabsfunctions,3−9 Definingamacro,4−45 fclose,3−13 Dependentnameprocessing,5−106 fdimfunctions,3−10 Derivativedefinition,8−1,8−20 FE_ALL_EXCEPT,3−5 dh,4−17 FE_DIVBYZERO,3−5 difftime,3−21 FE_INEXACT,3−5 Digraph,5−60 FE_INVALID,3−5 Directives,4−1 FE_OVERFLOW,3−5 div,3−19 FE_UNDERFLOW,3−5 Dollarsigns,5−70 feclearexcept,3−5 Doubleasfloat,5−261 fegetenv,3−5 ds,4−18 fegetexceptflag,3−5 dsb,4−18 feholdexept,3−5 dsd,4−18 feof,3−17 dsh,4−18 feraiseexcept,3−5 dsw,4−18 ferror,3−17 dw,4−19 fesetenv,3−5 fesetexceptflag,3−5 E fetestexcept,3−5 ELF/DWARFobjectformat,7−1 feupdateenv,3−5 EmbeddedC++,5−71 fflush,3−13 end,4−20 fgetc,3−16 endextern_sdata,1−9 fgetpos,3−17 endprofile,1−10 fgets,3−16 endprotect,1−10 fgetwc,3−16 Entities,removeunneeded,5−138 fgetws,3−16 enumoverloading,5−109 FILENAME_MAX,3−12 EOF,3−12 Floating−point,singleprecision,5−108 equ,4−21 floorfunctions,3−9

Index−6 Index fmafunctions,3−9 fenv.h,3−5 fmaxfunctions,3−10 float.h,3−5 fminfunctions,3−10 fss.h,3−5 fmodfunctions,3−9 inttypes.h,3−6 fopen,3−13 io.h,3−6 FOPEN_MAX,3−12 iso646.h,3−6 for−initstatement,5−113,5−126 limits.h,3−7 for/endfor,4−23 locale.h,3−7 fpclassify,3−10 malloc.h,3−7 fprintf,3−15 math.h,3−7 fputc,3−16 setjmp.h,3−11 fputs,3−16 signal.h,3−11 fputwc,3−16 stdarg.h,3−11 fputws,3−16 stdbool.h,3−11 fread,3−16 stddef.h,3−12 free,3−7,3−18 stdint.h,3−6 freopen,3−13 stdio.h,3−12 frexpfunctions,3−8 stdlib.h,3−17 Friendinjection,5−78 string.h,3−19 fscanf,3−15 tgmath.h,3−7 fseek,3−16 time.h,3−21 fsetpos,3−17 unistd.h,3−22 fstat,3−23 wchar.h,3−12,3−19,3−21,3−23 ftell,3−17 wctype.h,3−3,3−24 Function,syntax,4−5 Headerstop,2−24,2−26 Functioninlining,1−15 Heap,8−16 Functionnames,unqualified,5−100 hypotfunctions,3−9 Functionqualifiers __frame(),1−19 I __interrupt(),1−18 I/Ostreams,5−91 fwprintf,3−15 if/elif/else/endif,4−25 fwrite,3−16 ilogbfunctions,3−8 fwscanf,3−15 imaxabs,3−6 imaxdiv,3−6 G Implicitinclusion,2−17 Genericinstructions,4−1,4−50 include,4−26 getc,3−16 Includedirectory,5−16,5−34,5−86,5−170,5−204,5−247 getchar,3−16 Includefile,5−17,5−87,5−171 getcwd,3−22 macros,5−88 getenv,3−19 Includefiles,suffix,5−85 gets,3−16 Inlineassembly,__asm,1−5 getwc,3−16 Inlinefunction,5−112 getwchar,3−16 Inlinefunctions,1−15 global,4−24 inline/noinline/smartinline,1−9 Globaltypechecking,5−14,5−199 Inlining,5−18,5−115 gmtime,3−21 InliningfunctionsinC++,2−20 GNUextensions,2−5,5−79 Inputspecification,4−1 compilerversion,5−80 Instantiation,2−14 Guidingdeclarations,5−81 pending,5−135 template,5−90 H Instantiationmode,2−15 Headerfiles,3−3 Instantiationpragmas,2−16 alert.h,3−3 Instructions,4−1 complex.h,3−3 generic,4−1,4−50 ctype.h,3−3 Intelhex,recordtype,7−5 errno.h,3−4 IntelHexrecordformat,7−5 fcntl.h,3−4 Interrupt,5−33

Index−7 MicroBlazeEmbeddedToolsReference

Interruptframe,1−19 L Interruptfunctions,1−18 L_tmpnam,3−12 __frame(),1−19 Label,4−2 __interrupt(),1−18 label,4−27 Interruptserviceroutine,1−18 Labels,4−1 defining,1−18 labs,3−19 Interruptvector,5−35,5−56 ldexpfunctions,3−8 Intrinsicfunctions,1−16 ldiv,3−19 isalnum,3−3 lgammafunctions,3−10 isalpha,3−3 Librarianoptions isblank,3−3 −?,5−304 iscntrl,3−3 −d,5−305 isdigit,3−3 −f,5−306 isfinite,3−10 −m,5−307 isgraph,3−3 −p,5−308 isgreater,3−10 −r,5−309 isgreaterequal,3−10 −t,5−311 isinf,3−10 −V,5−312 isless,3−10 −w,5−313 islessequal,3−10 −x,5−314 islessgreater,3−10 addmodule,5−309 islower,3−3 createlibrary,5−309 isnan,3−10 deletemodule,5−305 isnormal,3−10 extractmodule,5−314 ISOCstandard,selecting,5−21,5−250 movemodule,5−307 isprint,3−3 printlistofobjects,5−311 ispunct,3−3 printlistofsymbols,5−311 isspace,3−3 printmodule,5−308 isunordered,3−10 replacemodule,5−309 isupper,3−3 warninglevel,5−313 iswalnum,3−3,3−24 Libraries,linking,5−198,5−218 iswalpha,3−3,3−24 Library,specifying,5−207,5−208,5−253,5−254,5−255 iswblank,3−3 Lifetime,5−95 iswcntrl,3−3,3−24 linear_switch,1−11 iswctype,3−24 Linkermacro,5−193 iswdigit,3−3,3−24 Linkeroptions,5−190 iswgraph,3−3,3−24 −?,5−200 iswlower,3−3,3−24 −−case−insensitive,5−191 iswprint,3−3,3−24 −−chip−output,5−192 iswpunct,3−3,3−24 −−define,5−193 iswspace,3−3,3−24 −−diag,5−194 iswupper,3−3,3−24 −−error−file,5−195 iswxdigit,3−3 −−error−limit,5−196 iswxditig,3−24 −−extern,5−197 isxdigit,3−3 −−extra−verbose,5−227 −−first−library−first,5−198 J −−global−type−checking,5−199 Jumpchain,1−13 −−help,5−200 Jumptable,1−13 −−hex−format,5−201 jump_switch,1−11 −−hex−record−size,5−202 −−ignore−default−library−path,5−208 K −−import−object,5−203 Keyword −−include−directory,5−204 bool,5−103 −−incremental,5−205 explicit,5−110 −−keep−output−files,5−206 export,2−18,5−111 −−library,5−207 typename,5−123 −−library−directory,5−208 wchar_t,5−158 −−link−only,5−209

Index−8 Index

−−lsl−check,5−210 structure,8−1 −−lsl−dump,5−211 Listfile,5−173,5−174 −−lsl−file,5−212 C++,5−93 −−map−file,5−213 list/nolist,4−28 −−map−file−format,5−214 llabs,3−19 −−misra−c−report,5−215 lldiv,3−19 −−munch,5−216 llrintfunctions,3−9 −−no−rescan,5−218 llroundfunctions,3−9 −−no−rom−copy,5−219 Locallabeloverrideoperator,4−48 −−no−warnings,5−220 localeconv,3−7 −−non−romable,5−217 localtime,3−21 −−optimize,5−221 logfunctions,3−8 −−option−file,5−222 log10functions,3−8 −−output,5−223 log1pfunctions,3−8 −−print−mangled−symbols,5−224 log2functions,3−8 −−strip−debug,5−225 logbfunctions,3−8 −−user−provided−initialization−code,5−226 longjmp,3−11 −−verbose,5−227 Lookupofnamesusedintemplates,5−106 −−version,5−228 Lookupofunqualifiedfunctionnames,5−100 −−warnings−as−errors,5−229 lrintfunctions,3−9 −c,5−192 lroundfunctions,3−9 −D,5−193 lsb,4−7 −d,5−212 lseek,3−23 −e,5−197 lsh,4−7 −f,5−222 LSLexpressionevaluation,8−13 −I,5−204 LSLfunctions −i,5−226 absolute(),8−5 −k,5−206 addressof(),8−5 −L,5−208 exists(),8−5 −l,5−207 max(),8−5 −M,5−213 min(),8−6 −m,5−214 sizeof(),8−6 −N,5−219 LSLkeywords −O,5−221 align,8−16,8−27 −o,5−223 alloc_allowed,8−31 −P,5−224 allow_cross_references,8−28 −r,5−205 architecture,8−15,8−20 −S,5−225 attributes,8−26,8−27 −V,5−228 blocksize,8−32 −v,5−227 bus,8−15,8−18,8−23 −vv,5−227 clustered,8−28 −w,5−220 contiguous,8−28 diagnostics,5−220,5−229 copy,8−17,8−27 libraries,5−207,5−218 copy_unit,8−16 MapFile,5−213 copytable,8−16,8−32 miscellaneous,5−191,5−193,5−197,5−203,5−211,5−212 core,8−20 optimization,5−221 derivative,8−20,8−22 outputformat,5−192 dest,8−16,8−18 Linkerscriptfile,5−210,5−211 dest_dbits,8−18 architecturedefinition,8−1 dest_offset,8−18 boardspecification,8−2 direction,8−26,8−28 busdefinition,8−2 else,8−33 derivativedefinition,8−1 extends,8−15,8−20 memorydefinition,8−2 fill,8−17,8−21,8−28,8−31 preprocessing,8−3 fixed,8−16,8−30 processordefinition,8−2 group,8−26,8−27 sectionlayoutdefinition,8−2 grows,8−16 specifying,5−212,5−256 heap,8−16,8−30

Index−9 MicroBlazeEmbeddedToolsReference

high_to_low,8−16,8−26 M id,8−15,8−16 macro/nomacro,1−9 id_symbol_prefix,8−17 Macroargumentstring,4−47 if,8−33 Macrocall,4−1 load_addr,8−29 Macrodefinition,5−8,5−68,5−164,5−235 low_to_high,8−16,8−26 Macrooperations,4−45 map,8−15,8−16,8−18,8−21 macro/endm,4−29 mau,8−15,8−16,8−21,8−23 Macros,4−45 mem,8−29 .fordirective,4−48 memory,8−21,8−23 .repeatdirective,4−48 min_size,8−16,8−30 argumentconcatenation,4−46 no_inline,8−17 argumentoperator,4−46 nocopy,8−28 argumentstring,4−47 nvram,8−21 calling,4−45 ordered,8−28 conditionalassembly,4−48 overflow,8−32 defining,4−45 overlay,8−28 locallabeloverride,4−48 page,8−16,8−29 makeutility,5−278 page_size,8−16,8−29 predefined,2−22 priority,8−30 returndecimalvalueoperator,4−47 processor,8−22 returnhexvalueoperator,4−47 ram,8−21 variableargumentslist,5−76,5−155 ref_tree,8−27 Macros(preprocessor),1−12,4−3 reserved,8−18,8−21,8−30 Makeutilityoptions rom,8−21 −?,5−279 run_addr,8−17,8−18,8−29 −a,5−280 section,8−31 −c,5−281 section_layout,8−25 −D,5−282 section_setup,8−24 −d,5−283 select,8−26 −DD,5−282 size,8−17,8−18,8−21,8−23,8−30,8−32 −dd,5−283 space,8−15,8−18 −e,5−284 speed,8−21,8−23 −err,5−285 src_dbits,8−18 −f,5−286 src_offset,8−18 −G,5−287 stack,8−16,8−30 −i,5−288 start_address,8−18 −K,5−289 symbol,8−18 −k,5−290 template,8−17 −m,5−291,5−296 template_symbol,8−17 −n,5−292 type,8−21,8−23 −p,5−293 vector,8−17 −q,5−294 vector_prefix,8−17 −r,5−295 vector_size,8−17 −s,5−297 vector_table,8−17 −t,5−298 width,8−15 −time,5−299 LSLsyntax,8−3 −V,5−300 architecturedefinition,8−7 −W,5−301 boardspecification,8−10 −x,5−302 busdefinition,8−6 definingamacro,5−278 derivativedefinition,8−9 malloc,3−7,3−18 memorydefinition,8−6 Mapfilegeneration,5−213 processordefinition,8−10 Mappings,8−18 sectionlayoutdefinition,8−10 maxcalldepth,1−9 lstat,3−23 MB_CUR_MAX,3−17,3−23 lsw,4−7 MB_LEN_MAX,3−23

Index−10 Index mblen,3−19 Options,saving/restoring,5−39,5−129,5−222 mbrlen,3−23 Outputfile,5−131 mbrtowc,3−23 mbsinit,3−23 P mbsrtowcs,3−23 page,4−33 mbstate_t,3−23 Parameterpassing,1−14 mbstowcs,3−19 Passingoptions,5−267 mbtowc,3−19 PCHmode memchr,3−20 automatic,2−24,5−132 memcmp,3−20 manual,2−26,5−67,5−153 memcpy,3−19 perror,3−17 memmove,3−19 powfunctions,3−9 Memorydefinition,8−2 Pragma Memoryqualifiers,1−3 can_instantiate,2−16 memset,3−20 do_not_instantiate,2−16 Mergingsourcecode,5−49 hdrstop,2−24,2−26 message,1−9,4−31 instantiate,2−16 MISRA−C,5−28,5−29 no_pch,2−26 MISRA−Creport,5−215 Pragmas,1−8 supportedrules1998,10−1 inC++,2−21 supportedrules2004,10−5 Precompiledheader,2−24 version,5−30 automatic,2−24,5−132 mktime,3−21 create,2−26,5−67 modffunctions,3−8 directory,2−26,5−133 MotorolaS−recordformat,7−2 filecannotbeused,5−134 msb,4−7 manual,2−26 msh,4−7 messages,5−120 msw,4−7 performance,2−26 Multibytecharacters,5−98 pragmas,2−26 prefix,2−25 N use,2−26,5−153 Namespace,2−13,5−99 Predefinedmacros,2−22 std,5−154 Predefinedpreprocessormacros,1−12,4−3 nanfunctions,3−9 Predefinedpreprocessorsymbols,4−3 nearbyintfunctions,3−9 Preprocessing,5−164,5−182,5−263,5−268,8−3 nextafterfunctions,3−9 storingoutput,5−41,5−136 nexttowardfunctions,3−9 printf,3−13,3−15 no_pch,2−26 conversioncharacters,3−14 Functions,1−14,1−19 printfversions,1−20 intrinsic,1−16 Priorityforglobalinitializationfunctions,5−89 parameterpassing,1−14 Processordefinition,8−2,8−22 returntypes,1−14 profile,1−10 novector,1−11 Profiling,5−42,5−269 NULL,3−12 profiling,1−10 protect,1−10 O ptrdiff_t,3−12 offset,4−32 putc,3−16 offsetof,3−12 putchar,3−16 open,3−4 puts,3−16 Operands,4−2 putwc,3−16 Operatorkeywords,5−60 putwchar,3−16 Optimization,5−37,5−177,5−221 codecompaction,5−18,5−26 Q inlining,5−19 qsort,3−19 optimizeforspeed/size,5−52 Qualifierdeduction,5−117 reverseinlining,5−26 optimize/endoptimize,1−10 R Optionfile,5−39,5−129,5−222,5−265,5−291 raise,3−11

Index−11 MicroBlazeEmbeddedToolsReference ramstring,1−10 setvbuf,3−13 rand,3−18 SIGABRT,3−11 RAND_MAX,3−17 SIGFPE,3−11 read,3−23 SIGILL,3−11 realloc,3−7,3−18 SIGINT,3−11 Registerusage,1−14 signal,3−11 remainderfunctions,3−9 signbit,3−10 Remarks,5−137 SIGSEGV,3−11 remove,3−17 SIGTERM,3−11 remquofunctions,3−9 sinfunctions,3−7 rename,3−17 sinhfunctions,3−8 Renamingsections,5−44 size,4−39 repeat/endrep,4−34 size_t,3−12 Reservedaddressranges,8−18 smart_switch,1−11 Resetvector,8−18 smartinline,1−9 resume,4−35 snprintf,3−15 Returndecimalvalueoperator,4−47 Softwarebreak,1−19 Returnhexvalueoperator,4−47 source,4−40 Reverseinlining,5−26 source/nosource,1−11 rewind,3−17 sprintf,3−15 rintfunctions,3−9 sqrtfunctions,3−9 romstring,1−10 srand,3−18 roundfunctions,3−9 sscanf,3−15 Run−timeC++library,5−63 Stack,2−14,8−16 Run−timechecks,5−46 Startaddress,8−18 Run−timetypeinformation,5−139 stat,3−23 runtime,1−10 Statement,4−1 stderr,3−12 S stdin,3−12 scalblnfunctions,3−8 stdinc,1−11 scalbnfunctions,3−8 stdout,3−12 scanf,3−14,3−15 strcat,3−20,4−7 conversioncharacters,3−15 strchr,3−20 scanfversions,1−20 strcmp,3−20,4−7 sdata,1−10 strcoll,3−20 Secondarytranslationunit,2−19 strcpy,3−19 Section,4−36 strcspn,3−20 section/endsection,1−10 strerror,3−20 Sectionattributes,4−36 strftime,3−21 Sectioninformation,5−184 Stringliterals,const,5−105 Sectionlayoutdefinition,8−2,8−25 Strings Sectionrenaming,5−44 C,1−13 Sectionsetupdefinition,8−24 substring,4−4 section_code_init,1−11 strlen,4−8 section_const_init,1−11 strncat,3−20 section_no_code_init,1−11 strncmp,3−20 section_no_const_init,1−11 strncpy,3−19 Sections,4−36 strpbrk,3−20 grouping,8−26 strpos,4−8 nested,5−175 strrchr,3−20 SEEK_CUR,3−12,3−16 strspn,3−20 SEEK_END,3−12,3−16 strstr,3−20 SEEK_SET,3−12,3−16 strtod,3−18 Servicerequest,1−18 strtof,3−18 set,4−38 strtoimax,3−6 setbuf,3−13 strtok,3−20 setjmp,3−11 strtol,3−18 setlocale,3−7 strtold,3−18

Index−12 Index strtoll,3−18 ungetc,3−16 strtoul,3−18 ungetwc,3−16 strtoull,3−18 unlink,3−23 strtoumax,3−6 use_barrel_shift,4−8 strxfrm,3−20 UsingassemblyinCsource,1−5 Substring,4−4 usingdeclaration,allowunqualifiedname,5−118 Switchmethod,1−11 switchstatement,1−13 V swprintf,3−15 va_arg,3−11 swscanf,3−15 va_copy,3−11 Symbolnames,4−2 va_end,3−11 Syntaxerrorchecking,5−5,5−65,5−162,5−232 va_start,3−11 Syntaxofanexpression,4−4 Vectortable,8−17 system,3−19 vector_offset,1−11 Systemincludedirectory,5−146 Versioninformation,5−300,5−312 vfprintf,3−15 T vfscanf,3−15 tanfunctions,3−7 vfwprintf,3−15 tanhfunctions,3−8 vfwscanf,3−15 Template,2−14 Virtualfunctiontable distinctsignatures,5−107 force,5−77 guidingdeclarations,5−81 suppress,5−145 specialization,5−128 vprintf,3−15 Templatedirectory,5−147 vscanf,3−15 Templateinstantiation,2−14 vsprintf,3−15 #pragmadirectives,2−16 vsscanf,3−15 automatic,2−14,5−102 vswprintf,3−15 exportedtemplates,2−18 vswscanf,3−15 implicitinclusion,2−17,5−84 vwprintf,3−15 instantiationmodes,2−15,5−90 vwscanf,3−15 pending,5−135 Templates,5−119 W tgammafunctions,3−10 warning,1−12 Tie−breakers,5−92 Warnings time,3−21 suppressing,5−36,5−176,5−220,5−264 time_t,3−21 treataserrors,5−189 Timinginformation,5−148 wchar_t,3−12 title,4−41 wchar_tkeyword,5−158 tm(struct),3−21 wcrtomb,3−23 TMP_MAX,3−12 wcscat,3−20 tmpfile,3−17 wcschr,3−20 tmpnam,3−17 wcscmp,3−20 tolower,3−3 wcscoll,3−20 toupper,3−3 wcscpy,3−19 towctrans,3−24 wcscspn,3−20 towlower,3−3,3−24 wcsncat,3−20 towupper,3−3,3−24 wcsncmp,3−20 tradeoff,1−11 wcsncpy,3−19 Transferringparametersbetweenfunctions,1−14 wcspbrk,3−20 truncfunctions,3−9 wcsrchr,3−20 type,4−42 wcsrtombs,3−23 Typechecking,5−14,5−199 wcsspn,3−20 Typequalifier,__unaligned,1−2 wcsstr,3−20 Typetraitshelpers,5−150 wcstod,3−18 typenamekeyword,5−123 wcstof,3−18 wcstoimax,3−6 U wcstok,3−20 undef,4−43 wcstol,3−18

Index−13 MicroBlazeEmbeddedToolsReference wcstold,3−18 weak,1−12,4−44 wcstoll,3−18 WEOF,3−12 wcstombs,3−19 wmemchr,3−20 wcstoul,3−18 wmemcmp,3−20 wcstoull,3−18 wmemcpy,3−19 wcstoumax,3−6 wmemmove,3−19 wcsxfrm,3−20 wmemset,3−20 wctob,3−23 wprintf,3−15 wctomb,3−19 write,3−23 wctrans,3−24 wscanf,3−15 wctype,3−24 wstrftime,3−21

Index−14