background image

TMS320C54x

Assembly Language Tools

User’s Guide

Literature Number: SPRU102C

October1998

Printed on Recycled Paper

Summary of Contents for TMS320C54x

Page 1: ...TMS320C54x Assembly Language Tools User s Guide Literature Number SPRU102C October1998 Printed on Recycled Paper ...

Page 2: ...NED INTENDED AUTHORIZED OR WARRANTED TO BE SUITABLE FOR USE IN LIFE SUPPORT APPLICATIONS DEVICES OR SYSTEMS OR OTHER CRITICAL APPLICATIONS Inclusion of TI products in such applications is understood to be fully at the risk of the customer Use of TI products in such applications requires the written approval of an appropriate TI officer Questions concerning potential risk applications should be dir...

Page 3: ...file format COFF which helps you to use the TMS320C54x tools more efficiently Read Chapter 2 Introduction to Common Object File Format before using the assembler and linker Assembler description contains detailed information about using the assembler This section explains how to invoke the assembler and discusses source statement format valid constants and expressions assembler output and assemble...

Page 4: ...ext In syntax descriptions the instruction command or directive is in a bold typeface font and parameters are in an italictypeface Portions of a syntax that are in bold should be entered as shown portions of a syntax that are in italics describe the type of information that should be entered Here is an example of command line syntax abs500 filename abs500 is a command The command invokes the absol...

Page 5: ...d if used must be separated by commas Some directives can have a varying number of parameters For example the byte directive can have up to 100 parameters The syntax for this directive is byte value1 valuen This syntax shows that byte must have at least one value parameter but you have the option of supplying additional value parameters separated by commas Following are other symbols and abbreviat...

Page 6: ...al processor mnemonic instructions individually Also includes a summary of instruction set classes and cycles TMS320C54x DSP Reference Set Volume 3 Algebraic Instruction Set literature number SPRU179 describes the TMS320C54x digital signal processor algebraic instructions individually Also includes a summary of instruction set classes and cycles TMS320C54x DSP Reference Set Volume 4 Applications G...

Page 7: ... that serve the family of TMS320 digital signal processors A myriad of products and applications are offered software and hardware development tools speech recognition image processing noise cancellation modems etc Digital Signal Processing Applications with the TMS320 Family Volumes 1 2 and 3 literature numbers SPRA012 SPRA016 SPRA017 Volumes 1 and 2 cover applications using the C10 and C20 famil...

Page 8: ... Factory Repair 33 4 93 22 25 40 Europe Customer Training Helpline Fax 49 81 61 80 40 10 Asia Pacific Literature Response Center 852 2 956 7288 Fax 852 2 956 2200 Hong Kong DSP Hotline 852 2 956 7268 Fax 852 2 956 1002 Korea DSP Hotline 82 2 551 2804 Fax 82 2 551 2828 Korea DSP Modem BBS 82 2 551 2914 Singapore DSP Hotline Fax 65 390 7179 Taiwan DSP Hotline 886 2 377 1450 Fax 886 2 377 2718 Taiwan...

Page 9: ... Sections 2 4 2 3 2 Initialized Sections 2 6 2 3 3 Named Sections 2 7 2 3 4 Subsections 2 8 2 3 5 Section Program Counters 2 8 2 3 6 An Example That Uses Sections Directives 2 9 2 4 How the Linker Handles Sections 2 12 2 4 1 Default Memory Allocation 2 13 2 4 2 Placing Sections in the Memory Map 2 14 2 5 Relocation 2 15 2 6 Runtime Relocation 2 17 2 7 Loading a Program 2 18 2 8 Symbols in a COFF F...

Page 10: ...c Constants 3 18 3 8 3 Defining Symbolic Constants d Option 3 19 3 8 4 Predefined Symbolic Constants 3 19 3 8 5 Substitution Symbols 3 20 3 8 6 Local Labels 3 21 3 9 Expressions 3 24 3 9 1 Operators 3 25 3 9 2 Expression Overflow and Underflow 3 25 3 9 3 Well Defined Expressions 3 26 3 9 4 Conditional Expressions 3 27 3 9 5 Relocatable Symbols and Legal Expressions 3 27 3 10 Built in Functions 3 2...

Page 11: ...essing Individual Characters of Subscripted Substitution Symbols 5 12 5 3 7 Substitution Symbols as Local Variables in Macros 5 13 5 4 Macro Libraries 5 14 5 5 Using Conditional Assembly in Macros 5 15 5 6 Using Labels in Macros 5 17 5 7 Producing Messages in Macros 5 19 5 8 Formatting the Output Listing 5 21 5 9 Using Recursive and Nested Macros 5 22 5 10 Macro Directives Summary 5 25 6 Archiver ...

Page 12: ...oduce an Unresolved Symbol u symbol Option 7 18 7 4 18 Specify a COFF Format v Option 7 19 7 4 19 Display a Message for Output Section Information w Option 7 19 7 4 20 Exhaustively Read Libraries x Option 7 20 7 5 Linker Command Files 7 21 7 5 1 Reserved Names in Linker Command Files 7 24 7 5 2 Constants in Command Files 7 24 7 6 Object Libraries 7 25 7 7 The MEMORY Directive 7 27 7 7 1 Default Me...

Page 13: ... the Size of the Stack and Heap Sections 7 68 7 17 4 Autoinitialization ROM and RAM Models 7 68 7 17 5 The c and cr Linker Options 7 70 7 18 Linker Example 7 71 8 Absolute Lister Description 8 1 Explains how to invoke the absolute lister to obtain a listing of the absolute addresses of an object file 8 1 Producing an Absolute Listing 8 2 8 2 Invoking the Absolute Lister 8 3 8 3 Absolute Lister Exa...

Page 14: ...ge Mode 10 27 10 9 Building a Table for an On Chip Boot Loader 10 28 10 9 1 Description of the Boot Table 10 28 10 9 2 The Boot Table Format 10 28 10 9 3 How to Build the Boot Table 10 29 10 9 4 Booting From a Device Peripheral 10 31 10 9 5 Setting the Entry Point for the Boot Table 10 32 10 9 6 Using the C54x Boot Loader 10 32 10 10 Controlling the ROM Device Address 10 34 10 10 1 Controlling the...

Page 15: ...s 11 9 11 5 3 Defining Labels When Invoking A Macro 11 10 A Common Object File Format A 1 Contains supplemental technical data about the internal format and structure of COFF object files A 1 COFF File Structure A 2 A 1 1 Overall Object File Structure A 2 A 1 2 Typical Object File Structure A 3 A 1 3 Impact of Switching Operating Systems A 4 A 2 File Header Structure A 5 A 3 Optional File Header F...

Page 16: ...mand File for Two 8 Bit EPROMs C 3 C 3 Example 2 Avoiding Holes With Multiple Sections C 8 C 4 Example 3 Generating a Boot Table C 10 C 5 Example 4 Generating a Boot Table for LP Core Devices C 17 D Error Messages D 1 Lists the error messages that the assembler and linker issue and gives a description of the condition s that caused each error E Glossary E 1 Defines terms and acronyms used in this ...

Page 17: ...n of Example 7 6 7 44 7 5 Memory Allocation Shown in Example 7 7 and Example 7 8 7 46 7 6 Overlay Pages Defined by Example 7 10 and Example 7 11 7 49 7 7 RAM Model of Autoinitialization 7 69 7 8 ROM Model of Autoinitialization 7 69 8 1 Absolute Lister Development Flow 8 2 8 2 module1 lst 8 9 8 3 module2 lst 8 9 9 1 Cross Reference Lister Development Flow 9 2 10 1 Hex Conversion Utility Development...

Page 18: ...ls 11 10 11 5 Rewritten Source Code 11 10 A 1 COFF File Structure A 2 A 2 COFF Object File A 3 A 3 Section Header Pointers for the text Section A 9 A 4 Line Number Blocks A 12 A 5 Line Number Entries A 13 A 6 Symbol Table Contents A 14 A 7 Symbols for Blocks A 17 A 8 Symbols for Functions A 17 A 9 String Table A 18 C 1 A Two 8 Bit EPROM System C 3 C 2 Data From Output File C 6 C 3 EPROM System for...

Page 19: ...tions 10 29 10 3 Options for Specifying Hex Conversion Formats 10 38 A 1 File Header Contents A 5 A 2 File Header Flags Bytes 18 and 19 A 5 A 3 Optional File Header Contents A 6 A 4 Section Header Contents for COFF1 Files A 7 A 5 Section Header Contents for COFF2 Files A 7 A 6 Section Header Flags A 8 A 7 Relocation Entry Contents A 10 A 8 Relocation Types Bytes 8 and 9 A 11 A 9 Line Number Entry ...

Page 20: ...liary Table Entries A 25 A 23 Function Format for Auxiliary Table Entries A 25 A 24 Array Format for Auxiliary Table Entries A 26 A 25 End of Blocks Functions Format for Auxiliary Table Entries A 26 A 26 Beginning of Blocks Functions Format for Auxiliary Table Entries A 27 A 27 Structure Union and Enumeration Names Format for Auxiliary Table Entries A 27 ...

Page 21: ...5 9 Using Subscripted Substitution Symbols to Find Substrings 5 13 5 10 The loop break endloop Directives 5 16 5 11 Nested Conditional Assembly Directives 5 16 5 12 Built In Substitution Symbol Functions Used in a Conditional Assembly Code Block 5 16 5 13 Unique Labels in a Macro 5 17 5 14 Producing Messages in a Macro 5 20 5 15 Using Nested Macros 5 22 5 16 Using Recursive Macros 5 23 7 1 Linker ...

Page 22: ...od One for Avoiding Holes C 8 C 6 Method Two for Avoiding Holes C 9 C 7 C Code for Example 3 C 10 C 8 Linker Command File to Form a Single Boot Section C 12 C 9 Section Allocation Portion of Map File Resulting From the Command File C 13 C 10 Hex Command File for Converting a COFF File C 15 C 11 Map File Resulting From the Command File in Example C 10 C 16 C 12 Hex Conversion Utility Output File Re...

Page 23: ...guage tools For detailed information on the compiler and debugger and for complete descriptions of the TMS320C54x devices refer to the books listed in Related Documentation From Texas Instruments on page vi The assembly language tools create and use object files in common object file format COFF to facilitate modular programming Object files contain separate blocks called sections of code and data...

Page 24: ... portions are optional Figure 1 1 TMS320C54x Software Development Flow Assembler Linker Macro library Library of object files Hex conversion utility EPROM programmer Assembler source COFF object files Archiver Macro source files Archiver C source files C54x Executable COFF file C compiler Library build utility Cross reference lister Absolute lister Debugging tools Runtime support library Assembly ...

Page 25: ...er run Linker directives allow you to combine ob ject file sections bind sections or symbols to addresses or within memory ranges and define or redefine global symbols The archiver collects a group of files into a single archive file For exam ple you can collect several macros into a macro library The assembler searches the library and uses the members that are called as macros by the source file ...

Page 26: ...object files to produce a cross reference listing showing symbols their definitions and their references in the linked source files The purpose of this development process is to produce a module that can be executed in a C54x target system You can use one of several debugging tools to refine and correct your code Available products include An instruction accurate software simulator An extended dev...

Page 27: ...te an assembly language program These blocks are known as sections Both the assembler and the linker provide directives that allow you to create and manipulate sections This chapter provides an overview of COFF sections For additional information see Appendix A Common Object File Format which explains the COFF structure Topic Page 2 1 COFF File Types 2 2 2 2 Sections 2 2 2 3 How the Assembler Hand...

Page 28: ...data that will ultimately occupy contiguous space in the memory map Each section of an object file is separate and distinct COFF object files always con tain three default sections text section usually contains executable code data section usually contains initialized data bss section usually reserves space for uninitialized variables In addition the assembler and linker allow you to create name a...

Page 29: ...location Because most systems contain several types of memory using sections can help you use target memory more efficiently All sections are independently relocatable you can place any section into any allocated block of target memory For example you can define a section that contains an initialization routine and then allocate the routine into a portion of the memory map that contains ROM Figure...

Page 30: ...e 2 8 for more information Note Default Section Directive If you don t use any of the sections directives the assembler assembles everything into the text section 2 3 1 Uninitialized Sections Uninitialized sections reserve space in processor memory they are usually allocated into RAM These sections have no actual contents in the object file they simply reserve memory A program can use this space a...

Page 31: ...ot cross a page boundary unless size is greater than a page in which case the object will start on a page boundary alignment flag is an optional parameter If you specify a value greater than 0 for this parameter the section is aligned to a long word boundary section name tells the assembler which named section to reserve space in For more information about named sections see subsection 2 3 3 Named...

Page 32: ...r sect directive The value if present specifies the starting value of the section program counter The starting value of the section program counter can be specified only once it must be done the first time the directive for that section is encountered By default the SPC starts at 0 Sections are built through an iterative process For example when the assem bler first encounters a data directive the...

Page 33: ... used like the bss section These sections reserve space in RAM for variables The sect directive creates sections like the default text and data sections that can contain code or data The sect directive creates named sections with relocatable addresses The syntax for these directives is shown below symbol usect section name size in words blocking flag alignment flag sect section name The section na...

Page 34: ...ve See subsection 2 3 2 Initialized Sections on page 2 6 Uninitialized subsections are created using the usect directive See subsection 2 3 1 Uninitialized Sections on page 2 4 Subsections are allocated in the same manner as sections See Section 7 8 The SECTIONS Directive on page 7 32 for more information 2 3 5 Section Program Counters The assembler maintains a separate program counter for each se...

Page 35: ...ing into a section for the first time or to continue assembling into a section that already contains code In the latter case the assembler simply appends the new code to the code that is already in the section The format in Example 2 1 is a listing file Example 2 1 shows how the SPCs are modified during assembly A line in a listing file has four fields Field 1 contains the source code line counter...

Page 36: ...00 100f add LD 0Fh A 20 000001 f010 aloop SUB 1 A 000002 0001 21 000003 f842 BC aloop AGEQ 000004 0001 22 23 Another initialized table into data 24 25 000004 data 26 000004 00aa ivals word 0AAh 0BBh 0CCh 000005 00bb 000006 00cc 27 28 Define another section for more variables 29 30 000000 var2 usect newvars 1 31 000001 inbuf usect newvars 7 32 33 Assemble more code into text 34 35 000005 text 36 00...

Page 37: ...the sect directive it contains two words of initialized data bss reserves 10 words in memory newvars is a named section created with the usect directive it reserves eight words in memory The second column shows the object code that is assembled into these sections the first column shows the line numbers of the source statements that generated the object code Figure 2 2 Object Code Generated by the...

Page 38: ......

Page 39: ......

Page 40: ......

Page 41: ......

Page 42: ......

Page 43: ......

Page 44: ......

Page 45: ......

Page 46: ......

Page 47: ......

Page 48: ......

Page 49: ......

Page 50: ......

Page 51: ......

Page 52: ......

Page 53: ......

Page 54: ......

Page 55: ......

Page 56: ......

Page 57: ......

Page 58: ......

Page 59: ......

Page 60: ......

Page 61: ......

Page 62: ......

Page 63: ...ned for each directive that requires a character string Characters are represented internally as 8 bit ASCII characters These are examples of valid character strings sample program defines the 14 character string sample program PLAN C defines the 8 character string PLAN C Character strings are used for the following Filenames as in copy filename Section names as in sect section name Data initializ...

Page 64: ... file must be unique Mnemonic opcodes and assembler directive names without the prefix are valid label names Labels can also be used as the operands of global ref def or bss directives for example global label1 label2 NOP ADD label1 B B label2 3 8 2 Symbolic Constants Symbols can be set to constant values By using constants you can equate meaningful names with constant values The set and struct ta...

Page 65: ...wing direc tives Type of Test Directive Usage Existence if isdefed name Nonexistence if isdefed name 0 Equal to value if name value Not equal to value if name value Note that the argument to the isdefed built in function must be enclosed in quotes The quotes cause the argument to be interpreted literally rather than as a substitution symbol 3 8 4 Predefined Symbolic Constants The assembler has sev...

Page 66: ...ion symbol anywhere within a program for example asg errct AR2 register 2 asg INC indirect auto increment asg DEC indirect auto decrement When you are using macros substitution symbols are important because macro parameters are actually substitution symbols that are assigned a macro argument The following code shows how substitution symbols are used in macros add2 macro ADDRA ADDRB add2 macro defi...

Page 67: ...n be undefined and defined again or automatically generated Local labels cannot be defined by directives A local label can be undefined or reset in one of four ways By using the newblock directive By changing sections using a sect text or data directive By entering an include file specifying the include or copy directive By leaving an include file specifying the include or copy directive Example 3...

Page 68: ...a normal label and is called more than once the assembler issues a multiple definition error If you use a local label and newblock within a macro however the local label is used and reset each time the macro is expanded Up to ten local labels can be in effect at one time After you undefine a local label you can define it and use it again Local labels do not appear in the object code symbol table T...

Page 69: ...ion of mylab in macro macros use different namespace to avoid conflicts mymac macro mylab nop b mylab endm Macro invocation mymac Reference to third definition of mylab note that definition is not reset by macro invocation nor conflicts with same name defined in macro b mylab Changing section allowing fifth definition of mylab sect Secto_One nop mylab word 0 nop nop b mylab newblock directive allo...

Page 70: ...stitute braces or brackets for parentheses Precedence groups The C54x assembler uses the same order of pre cedence as the C language does as summarized in Table 3 1 This differs from the order of prece dence of other TMS320 assemblers When paren theses do not determine the order of expression evaluation the highest precedence operation is evaluated first 8 4 2 10 4 2 is evaluated first Left to rig...

Page 71: ...lus minus 1s complement Right to left Multiplication division modulo Left to right Addition subtraction Left to right Left shift right shift Left to right Less than LT or equal greater than GT or equal Left to right Not equal to equal to Left to right Bitwise AND Left to right Bitwise exclusive OR Left to right Bitwise OR Left to right Note Unary and have higher precedence than the binary forms 3 ...

Page 72: ...3 set label1 labels including the current SPC are considered to be well defined goodsym4 set label2 label1 Although label1 and label2 are not absolute symbols because they are local labels defined in the same section their difference can be computed by the assembler The difference is absolute so the expression is well defined b Invalid well defined expressions global Y badsym1 set Y Because Y is e...

Page 73: ...l symbol An expression cannot contain unresolved symbols that are relocatable to other sections Symbols or registers that have been defined as global with the global directive can also be used in expressions in Table 3 2 these symbols and registers are referred to as external Relocatable registers can be used in expressions the addresses of these registers are relocatable with respect to the regis...

Page 74: ... illegal The first statement in the following example is valid the statements that follow it are invalid LD extern_1 10 B Legal LD 10 extern_1 B Can t negate reloc symbol LD intern_1 B Can t negate reloc symbol LD extern_1 10 B isn t additive operator LD intern_1 extern_1 B Multiple relocatables Example 3 The first statement below is legal although intern_1 and intern_2 are relocatable their diffe...

Page 75: ...s the smallest integer that is not less than the expression cosh expr returns the hyperbolic cosine of expr as a floating point value cos expr returns the cosine of expr as a floating point value cvf expr converts expr to floating point value cvi expr converts expr to integer value exp expr returns the result of raising e to the expr power fabs expr returns absolute value of expr as a floating poi...

Page 76: ...expr as a floating point value trunc expr returns the result of expr rounded toward zero 3 11 Extended Addressing Support The assembler accepts a pseudo op LDX for loading the value of a label function etc that resides or may reside in extended program memory LDX is used to load the upper 8 bits of a 24 bit address For example if a function F1 is in extended program memory which is 24 bits instead...

Page 77: ...h additional word Each additional line is listed immediately following the source statement line Field 1 Source Statement Number Line Number The source statement number is a decimal The assembler numbers source lines as it encounters them in the source file some state ments increment the line counter but are not listed For example title statements and statements following a nolist are not listed T...

Page 78: ...ters to the end of the field undefined external reference text relocatable data relocatable sect relocatable bss usect relocatable Field 4 Source Statement Field This field contains the characters of the source statement as they were scanned by the assembler The assembler accepts a maximum line length of 200 characters Spacing in this field is determined by the spacing in the source statement Exam...

Page 79: ...rupt vectors 16 17 000000 sect reset 18 000000 F073 RESET B init 000001 0008 19 000002 F073 INT0 B ISR0 000003 0000 20 000004 F073 INT1 B ISR1 000005 0000 21 000006 F073 INT2 B ISR2 000007 0000 22 23 24 000000 sect ints 25 000000 F073 TINT B time 000001 0000 26 000002 F073 RINT B rcv 000003 0000 27 000004 F073 XINT B xmt 000005 0000 28 000006 F073 USER B proc 000007 0000 29 30 Initialize processor...

Page 80: ... 000000 sect reset 18 000000 F073 RESET goto init 000001 0008 19 000002 F073 INT0 goto ISR0 000003 0000 20 000004 F073 INT1 goto ISR1 000005 0000 21 000006 F073 INT2 goto ISR2 000007 0000 22 23 24 000000 sect ints 25 000000 F073 TINT goto time 000001 0000 26 000002 F073 RINT goto rcv 000003 0000 27 000004 F073 XINT goto xmt 000005 0000 28 000006 F073 USER goto proc 000007 0000 29 30 Initialize pro...

Page 81: ...ined or referenced during the assembly Value column contains a hexadecimal number which is the value assigned to the symbol or a name that describes the symbol s attributes A value may also be followed by a character that describes the symbol s attributes Table 3 4 lists these char acters and names Definition DEFN column contains the statement number that defines the symbol This column is blank fo...

Page 82: ...It does this by assigning a letter reference A B C etc for each include file The letters are assigned in the order in which the include directives are encountered in the assembly source file For example the following source files a incl0 asm global ABC nop nop b incl1 asm global ABC ld ABC A c incl2 asm global ABC stl A ABC d xref asm start include incl0 asm include incl1 asm add 10 A include incl...

Page 83: ...global start 12 13 000000 bss ABC 2 xref asm PAGE 2 LABEL VALUE DEFN REF TMS320C540 000001 0 TMS320C541 000000 0 TMS320C542 000000 0 TMS320C543 000000 0 TMS320C544 000000 0 TMS320C545 000000 0 TMS320C545LP 000000 0 TMS320C546 000000 0 TMS320C546LP 000000 0 TMS320C548 000000 0 start 000000 1 ABC 000000 12 A 1 B 1 B 2 C 1 C 2 __far_mode 000000 0 __lflags 000000 0 start REF 9 11 The A in the cross re...

Page 84: ...ter is divided into two parts the first part Sections 4 1 through 4 10 describes the directives according to function and the second part Section 4 11 is an alphabetical reference Topic Page 4 1 Directives Summary 4 2 4 2 Compatibility With the TMS320C1x C2x C2xx C5x Assembler Directives 4 7 4 3 Directives That Define Sections 4 8 4 4 Directives That Initialize Constants 4 11 4 5 Directives That A...

Page 85: ...ot discussed in this chapter Note Labels and Comments in Syntax Any source statement that contains a directive may also contain a label and a comment Labels begin in the first column they are the only elements ex cept comments that can appear in the first column and comments must be preceded by a semicolon or an asterisk if the comment is the only statement on the line To improve readability label...

Page 86: ...s 4 58 long value1 valuen Initialize one or more 32 bit integers 4 63 pstring string1 stringn Initialize one or more text strings packed 4 83 space size in bits Reserve size bits in the current section note that a label points to the beginning of the reserved space 4 80 string string1 stringn Initialize one or more text strings 4 83 ubyte value1 valuen uchar value1 valuen Initialize one or more su...

Page 87: ...rective lines 4 41 fclist Allow false conditional code block listing default 4 46 fcnolist Suppress false conditional code block listing 4 46 length page length Set the page length of the source listing 4 60 list Restart the source listing 4 61 mlist Allow macro listings and loop blocks default 4 69 mnolist Suppress macro listings and loop blocks 4 69 nolist Stop the source listing 4 61 option B L...

Page 88: ...c ro definition You must place macro in the opcode field 4 66 mlib filename Define macro library 4 67 mexit Go to endm This directive is useful when error test ing confirms that macro expansion will fail 5 3 endm End macro code block 4 44 var Define a local macro substitution symbol 4 96 g Directives that control conditional assembly Mnemonic and Syntax Description Page break well defined expressi...

Page 89: ...e attributes to a label 4 84 union Begin union definition 4 90 i Miscellaneous directives Mnemonic and Syntax Description Page algebraic Signifies that the file contains algebraic assembly source 4 26 c_mode Signifies that calls and branches are within the normal 16 bit address range 4 35 emsg string Send user defined error messages to the output device 4 42 end End program 4 44 far_mode Signifies...

Page 90: ...ective for the C54x packs fields into words starting at the most significant bit of the word The C1x C2x C2xx C5x assembler field direc tive places fields into words starting at the least significant bit of the word The field directive for the C54x handles values of 1 to 32 bits contrasted with the C1x C2x C2xx C5x assembler which handles values of 1 to 16 bits With the C54x assembler objects that...

Page 91: ...utput of the linker if there are no references found to any symbol in the section data identifies portions of code in the data section The data section usually contains initialized data sect defines initialized named sections and associates subsequent code or data with that section A section defined with sect can contain code or data text identifies portions of code in the text section The text se...

Page 92: ...tion after other code is assembled the section s SPC resumes counting as if there had been no intervening code The directives in Example 4 1 perform the following tasks text initializes words with the values 1 2 3 4 5 6 7 and 8 data initializes words with the values 9 10 11 12 13 14 15 and 16 var_defs initializes words with the values 17 and 18 bss reserves 19 words xy reserves 20 words The bss an...

Page 93: ...C 14 15 16 Start assembling into a named 17 initialized section var_defs 18 19 000000 sect var_defs 20 000000 0011 word 17 18 000001 0012 21 22 23 Resume assembling into the data section 24 25 000004 data 26 000004 000D word 13 14 000005 000E 27 000000 bss sym 19 Reserve space in bss 28 000006 000F word 15 16 Still in data 000007 0010 29 30 31 Resume assembling into the text section 32 33 000004 t...

Page 94: ... contains reserved bits J When you use a label with bes it points to the last word that contains reserved bits Figure 4 1 shows the space and bes directives Assume the following code has been assembled for this example 1 2 space and bes directives 3 4 000000 0100 word 100h 200h 000001 0200 5 000002 Res_1 space 17 6 000004 000f word 15 7 000006 Res_2 bes 20 8 000007 00ba byte 0BAh 9 reserve 3 words...

Page 95: ...ields are packed into a word For this example assume the following code has been assembled notice that the SPC doesn t change for the first three fields the fields are packed into the same word 4 000000 6000 field 3 3 5 000000 6400 field 8 6 6 000000 6440 field 16 5 7 000001 0123 field 01234h 20 000002 4000 8 000003 0000 field 01234h 32 000004 1234 Figure 4 2 The field Directive 0 1 1 0 0 1 0 0 0 ...

Page 96: ...nsecutive words in the current section The most significant word is stored first The long directive automatically aligns to a long word boundary and the xlong directive does not string and pstring place 8 bit characters from one or more character strings into the current section The string directive is similar to byte plac ing an 8 bit character in each consecutive word of the current section The ...

Page 97: ...00000a ffac 7 00000c 3fff float 1 99999 00000d ffac 8 00000e 0068 string help 00000f 0065 000010 006c 000011 0070 Figure 4 3 Initialization Directives Word 0 C C C D D D D E E E E F F F F 0 0 6 8 0 0 6 5 Code byte OAAh OBBh word OCCCh int DDDDh long EEEEFFFFh string help float 1 99999 15 0 15 0 h e 3 F F F F F A C 0 E E E E F F F xlong 0EEEEFFFh xfloat 1 99999 3 F F F F F A C 0 0 6 C 0 0 7 0 l p 1...

Page 98: ...word boundary 2 aligns SPC to long word even boundary 128 aligns SPC to page boundary The align directive with no operands defaults to a page boundary The even directive aligns the SPC so that it points to the next word boundary It is equivalent to specifying the align directive with an operand of 1 Using even with an operand of 2 aligns the SPC to the next long word boundary Any unused bits in th...

Page 99: ... Figure 4 4 The align Directive 00h 80h a Current SPC b New SPC 80h after assembling a align directive 128 words 00h 02h a Current SPC 00h b New SPC 02h after assembling a align 2 directive 2 words a Result of align 2 b Result of align without an argument ...

Page 100: ...s directive to adjust listings for various output devices The list and nolist directives turn the output listing on and off You can use the nolist directive to stop the assembler from printing selected source statements in the listing file Use the list directive to turn the listing on again The source code contains a listing of macro expansions and loop blocks The mlist and mnolist directives turn...

Page 101: ... These directives are useful for debugging the expansion of substitution symbols The tab directive defines tab size The title directive supplies a title that the assembler prints at the top of each page The width directive controls the page width of the listing file You can use this directive to adjust listings for various output devices ...

Page 102: ...ntifies a symbol that is defined in the current module and that can be used by another module The assembler includes the symbol in the symbol table The global directive declares a symbol external so that it is available to other modules at link time For more information about global symbols see subsection 2 8 1 External Symbols on page 2 19 The global directive does double duty acting as a def for...

Page 103: ...the if condition is false and elseif is true else marks a block of code to be assembled if the if condition is false endif marks the end of a conditional block and termi nates the block The loop break endloop directives tell the assembler to repeatedly assemble a block of code according to the evaluation of an expression loop expression marks the beginning a repeatable block of code break expressi...

Page 104: ...within the current section This is useful when a section loads at one address but runs at a different address For example you may want to load a block of performance critical code into slower off chip memory to save space and move the code to high speed on chip memory to run The set and equ directives set a constant value to a symbol The symbol is stored in the symbol table and cannot be refined F...

Page 105: ...ions of size and type that may be temporarily stored in the same memory space The tag directive assigns a label to the union and is associated with the beginning of the union A union can be defined and given a tag and later it can be declared as a member of a structure by using the tag directive A union may also be declared without a tag in which case all of its members will be entered in the symb...

Page 106: ...a list of memory mapped registers The newblock directive resets local labels Local labels are symbols of the form n or name They are defined when they appear in the label field Local labels are temporary labels that can be used as operands for jump instructions The newblock directive limits the scope of local labels by re setting them after they are used For more information about local labels see...

Page 107: ... object file The mmsg directive sends assembly time messages to the standard output device The mmsg directive functions in the same manner as the emsg and wmsg directives but does not set the error count or the warning count It does not affect the creation of the object file The wmsg directive sends warning messages to the standard output device The wmsg directive functions in the same manner as t...

Page 108: ... 67 mlist 4 69 mmregs 4 70 mmsg 4 42 copy 4 36 data 4 39 def 4 51 double 4 40 drlist 4 41 mnolist 4 69 newblock 4 73 nolist 4 61 option 4 74 page 4 76 drnolist 4 41 else 4 56 elseif 4 56 emsg 4 42 end 4 44 endif 4 56 endloop 4 65 pstring 4 83 ref 4 51 sblock 4 77 sect 4 78 set 4 79 short ushort 4 54 space 4 80 endm 4 44 endstruct 4 84 endunion 4 90 equ 4 79 eval 4 28 even 4 27 sslist 4 81 ssnolist...

Page 109: ...be the first line in the file if the mg option is not used Note Mixing Algebraic and Mnemonic Assembly Code Algebraic and mnemonic assembly code cannot be mixed within the same source file The algebraic directive does not provide a method for mixing algebraic and mnemonic statements within the same source file It provides a means of selecting algebraic assembly without specifying the mg assembler ...

Page 110: ...y The even directive aligns the SPC on a long word even boundary This direc tive is equivalent to the align directive with an operand of 2 Using the align directive has two effects The assembler aligns the SPC on a boundary within the current section The assembler sets a flag that forces the linker to align the section so that individual alignments remain intact when a section is loaded into memor...

Page 111: ...is read and assigned to the substitution symbol The substitution symbol must be a valid symbol name The substitution symbol may be 32 characters long and must begin with a letter Remaining characters of the symbol can be a combination of alphanumeric charac ters the underscore _ and the dollar sign The eval directive performs arithmetic on substitution symbols which are stored in the substitution ...

Page 112: ...AR0 FP 7 8 000000 f000 ADD 100 A 000001 0064 9 000002 6d90 MAR FP MAR AR0 10 000003 6d90 MAR AR0 11 12 asg 0 x 13 loop 5 14 eval x 1 x 15 word x 16 endloop 1 eval x 1 x eval 0 1 x 1 000004 0001 word x word 1 1 eval x 1 x eval 1 1 x 1 000005 0002 word x word 2 1 eval x 1 x eval 2 1 x 1 000006 0003 word x word 3 1 eval x 1 x eval 3 1 x 1 000007 0004 word x word 4 1 eval x 1 x eval 4 1 x 1 000008 000...

Page 113: ...his flag causes the assem bler to allocate size on long word boundaries Note Specifying an Alignment Flag Only To specify an alignment flag without a blocking flag you must insert two commas before the alignment flag as shown in the syntax The assembler follows two rules when it allocates space in the bss section Rule 1 Whenever a hole is left in memory as shown in Figure 4 5 the bss directive att...

Page 114: ... 5 shows the second block is allocated on the next page Figure 4 5 Allocating bss Blocks Within a Page Memory Memory allocated by first bss direc tive 64 words left in the first page Hole in memory left because second bss directive required more than 64 words Memory allocated by second bss di rective 58 words left in the second page Unused memory 127 a b 256 0 Page boundary Section directives for ...

Page 115: ... be referenced in the same manner as other symbols and can also be declared external 1 2 Assemble into the text section 3 4 000000 text 5 000000 e800 LD 0 A 6 7 Allocate 4 words in bss for TEMP 8 9 000000 Var_1 bss TEMP 4 10 11 12 Still in text 13 14 000001 f000 ADD 56h A 000002 0056 15 000003 f066 MPY 73h A 000004 0073 16 17 18 Allocate 100 words in bss for the 19 symbol named ARRAY this part of ...

Page 116: ... signifi cant bits of a full 16 bit word The assembler truncates values greater than 8 bits You can use up to 100 value parameters but the total line length cannot exceed 200 characters If you use a label it points to the location where the assembler places the first byte Note that when you use these directives in a struct endstruct sequence they defines a member s size they do not initialize memo...

Page 117: ...INK flag tells the linker to leave the section out of the final COFF output of the linker if there are no references found to any symbol in the sec tion A section in which the entry point of a C program is defined cannot be marked as a conditionally linked section Example In this example the Vars and Counts sections are set for conditional linking 1 000000 sect Vars 2 Vars section is conditionally...

Page 118: ... with the mf assembler option or the far_mode directive to facilitate linking a program that uses extended ad dressing If your program uses extended addressing but your assembly code was not generated by the C compiler you should add the c_mode directive to your as sembly files Note Do not mix extended addressing code with regular code If you want to use extended addressing your entire application...

Page 119: ...rameter that names a source file It may be en closed in double quotes and must follow operating system conventions You can specify a full pathname for example c dsp file1 asm If you do not speci fy a full pathname the assembler searches for the file in 1 The directory that contains the current source file 2 Any directories named with the i assembler option 3 Any directories specified by the enviro...

Page 120: ...o word asm to continue copying and assembling Then the assembler returns to its place in byte asm to continue copying and assembling After completing assembly of byte asm the assembler returns to copy asm to assemble its re maining statement copy asm source file byte asm first copy file word asm second copy file space 29 copy byte asm Back in original file pstring done In byte asm byte 32 1 A copy...

Page 121: ...opy directive except that state ments are not printed in the listing file include asm source file byte2 asm first include file word2 asm second include file space 29 include byte2 asm Back in original file string done In byte2 asm byte 32 1 A include word2 asm Back in byte2 asm byte 67h 3q In word2 asm Listing file 1 000000 space 29 2 include byte2 asm 3 4 Back in original file 5 000007 0064 strin...

Page 122: ...e a section control directive For more information about COFF sections see Chapter 2 Introduction to Common Object File Format Example In this example code is assembled into the data and text sections 1 2 Reserve space in data 3 4 000000 data 5 000000 space 0CCh 6 7 8 Assemble into text 9 10 000000 text 11 0000 INDEX set 0 12 000000 e800 LD INDEX A 13 14 15 Assemble into data 16 17 00000c Table da...

Page 123: ...t format Floating point constants are aligned on a word boundary The value consists of three fields Field Meaning s A 1 bit sign field e An 8 bit biased exponent f A 23 bit fraction The value is stored most significant word first least significant word second in the following format s e f 31 30 23 22 0 When you use double or ldouble in a struct endstruct sequence the direc tives define a member s ...

Page 124: ...ng of the following directives to the listing file asg fcnolist sslist break length ssnolist emsg mlist var eval mmsg width fclist mnolist wmsg By default the assembler acts as if the drlist directive had been specified Example This example shows how drnolist inhibits the listing of the specified directives Source file asg 0 x loop 2 eval x 1 x endloop drnolist asg 1 x loop 3 eval x 1 x endloop Li...

Page 125: ...e sends assembly time messages to the standard output device in the same manner as the emsg and wmsg directives but it does not set the error or warning counts and it does not prevent the assembler from producing an object file The wmsg directive sends warning messages to the standard output device in the same manner as the emsg directive but it increments the warning count rather than the error c...

Page 126: ...ARAM A 1 endif 11 12 000001 MSG_EX 1 if symlen parm1 0 1 emsg ERROR MISSING PARAMETER USER ERROR ERROR MISSING PARAMETER 1 else 1 add parm1 A 1 endif 1 Error No Warnings In addition the following messages are sent to standard output by the assem bler TMS320C54x COFF Assembler Version x xx Copyright c 1998 Texas Instruments Incorporated PASS 1 PASS 2 emsg asm ERROR at line 12 USER ERROR ERROR MISSI...

Page 127: ... and would like to stop assembling at a specific point in your code Note Ending a Macro Use endm to end a macro Example This example shows how the end directive terminates assembly If any source statements follow the end directive the assembler ignores them Source File START space 300 TEMP set 15 bss LOC1 48h ABS A ADD TEMP A STL A LOC1 end byte 4 word CCCh Listing file 1 000000 START space 300 2 ...

Page 128: ...er that the assembly file uses ex tended addressing calls and branches extend beyond the normal 16 bit range This directive has the same effect as using the mf assembler option If your program uses extended addressing and your assembly code was not generated by the C compiler you should add the c_mode directive to your as sembly files ...

Page 129: ... that are actually assembled appears in the listing The if elseif else and endif directives do not appear By default all conditional blocks are listed the assembler acts as if the fclist directive had been used Example This example shows the assembly language and listing files for code with and without the conditional blocks listed Source File AAA set 1 BBB set 0 fclist if AAA ADD 1024 A else ADD ...

Page 130: ...le field 3 1 causes the assembler to truncate the value 3 to 1 the assembler also prints the message warning value truncated Successive field directives pack values into the specified number of bits start ing at the current word Fields are packed starting at the most significant part of the word moving toward the least significant part as more fields are added If the assembler encounters a field s...

Page 131: ...nitialize a 14 bit field 3 4 000000 2AF0 field 0ABCh 14 5 6 7 Initialize a 5 bit field 8 in a new word 9 10 000001 5000 L_F field 0Ah 5 11 12 13 Initialize a 4 bit field 14 in the same word 15 16 000001 5600 x field 0Ch 4 17 18 19 16 bit relocatable field 20 in the next word 21 22 000002 0001 field x 23 24 25 Initialize a 32 bit field 26 27 000003 0000 field 04321h 32 000004 4321 ...

Page 132: ... 0 1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 0 0 0 0 1 0 1 0 0 1 0 1 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 14 bit field 5 bit field 4 bit field 15 0 Word Code a 0 b 0 1 c 1 d 1 2 field 0ABCh 14 field 00Ah 5 field 000Ch 4 field x 0 0 0 0 1 1 0 0 1 0 0 1 0 1 0 0 e 3 4 field 04321 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 ...

Page 133: ... used The xfloat directive performs the same function as the float directive but does not align the result on the long word boundary The 32 bit value consists of three fields Field Meaning s A 1 bit sign field e An 8 bit biased exponent f A 23 bit fraction The value is stored most significant word first least significant word second in the following format s e f 31 30 23 22 0 When you use float in...

Page 134: ...only if the module actually uses the symbol A symbol may be declared global for two reasons If the symbol is not defined in the current module including macro copy and include files the global or ref directive tells the assembler that the symbol is defined in an external module This prevents the assembler from issuing an unresolved reference error At link time the linker looks for the symbol s def...

Page 135: ...2 0000 word X 8 9 10 11 end file2 lst 1 Global symbols defined in this file 2 global X Y Z 3 Global symbol defined in file1 lst 4 global INIT 5 0001 X set 1 6 0002 Y set 2 7 0003 Z set 3 8 000000 0000 word INIT 9 10 11 12 end file3 lst 1 Global symbol defined in this file 2 def INIT 3 Global symbols defined in file4 lst 4 ref X Y Z 5 000000 INIT 6 000000 F000 ADD 56h A 000001 0056 7 000002 0000 wo...

Page 136: ...bal def ref 4 53 Assembler Directives file4 lst 1 Global symbols defined in this file 2 def X Y Z 3 Global symbol defined in file3 lst 4 ref INIT 5 0001 X set 1 6 0002 Y set 2 7 0003 Z set 3 8 000000 0000 word INIT 9 10 11 12 end ...

Page 137: ...elocatable expressions If an expression is relocatable the assembler generates a relocation entry that refers to the ap propriate symbol the linker can then correctly patch relocate the reference This allows you to initialize memory with pointers to variables or labels The assembler truncates values greated than 16 bites You can use as many values as fit on a single line but the total line length ...

Page 138: ...to memory short is used to place 16 bit values 8 3 def and b into memory The label STRN has the value 106h which is the location of the first initialized word 1 000000 space 100h 16 2 3 000100 000A half 10 1 abc a 000101 FFFF 000102 0061 000103 0062 000104 0063 000105 0061 4 000106 0008 STRN short 8 3 def b 000107 FFFD 000108 0064 000109 0065 00010a 0066 00010b 0062 5 ...

Page 139: ...on is false the assembler continues to the next elseif if pres ent else if present or endif if no elseif or else is present The elseif di rective is optional in the conditional blocks and more than one elseif can be used If an expression is false and there is no elseif statement the assembler continues with the code that follows a else if present or a endif The else directive identifies a block of...

Page 140: ...00000 0004 byte SYM4 Equal values 8 else 9 byte SYM2 SYM2 Unequal values 10 endif 11 12 If_5 if SYM1 10 13 000001 000a byte 10 Less than equal 14 else 15 byte SYM1 Greater than 16 endif 17 18 If_6 if SYM3 SYM2 SYM4 SYM2 19 byte SYM3 SYM2 Unequal value 20 else 21 000002 0008 byte SYM4 SYM4 Equal values 22 endif 23 24 If_7 if SYM1 2 25 byte SYM1 26 elseif SYM2 SYM3 5 27 000003 0005 byte SYM2 SYM3 28...

Page 141: ...elocate the reference This allows you to initialize memory with pointers to variables or labels You can use as many values as fit on a single line 200 characters If you use a label it points to the first word that is initialized When you use these directives in a struct endstruct sequence they define a member s size they do not initialize memory For more information about struct endstruct see Sect...

Page 142: ...to high speed on chip memory to run it Such a section is assigned two addresses at link time a load address and a run address All labels defined in the section are relocated to refer to the run time address so that references to the section such as branches are correct when the code runs The label directive creates a special label that refers to the loadtime address This function is useful primari...

Page 143: ...ollowing you can reset the page width with another width directive Default width 80 characters Minimum width 80 characters Maximum width 200 characters The width refers to a full line in a listing file the line counter value SPC value and object code are counted as part of the width of a line Comments and other portions of a source statement that extend beyond the page width are trun cated in the ...

Page 144: ...r You can nest the list nolist directives each nolist needs a matching list to restore the listing By default the source listing is printed to the listing file the assembler acts as if the list directive had been specified However if you don t request a listing file when you invoke the assembler the assembler ignores the list directive Example This example shows how the copy directive inserts sour...

Page 145: ...le NOP nolist copy copy2 asm list Back in original file string Done Listing file 1 copy copy2 asm A 1 In copy2 asm copy file A 2 000000 0020 word 32 1 A 000001 0042 2 Back in original file 3 000002 F495 NOP 7 Back in original file 8 000005 0044 string Done 000006 006F 000007 006E 000008 0065 ...

Page 146: ...quotes Each character in a string represents a separate value The value operand can be either an absolute or relocatable expression If an expression is relocatable the assembler generates a relocation entry that re fers to the appropriate symbol the linker can then correctly patch relocate the reference This allows you to initialize memory with pointers to variables or with labels You can use up t...

Page 147: ...s how the long and xlong directives initialize double words 1 000000 0000 DAT1 long 0ABCDh A 100h g o 000001 ABCD 000002 0000 000003 0141 000004 0000 000005 0067 000006 0000 000007 006F 2 000008 0000 xlong DAT1 0AABBCCDDh 000009 0000 00000a AABB 00000b CCDD 3 00000c DAT2 ...

Page 148: ...the expres sion is false 0 the loop continues When the expression is true nonzero or omitted the assembler breaks the loop and assembles the code after the endloop directive The endloop directive terminates a repeatable block of code it executes when the break directive is true nonzero or when number of loops performed equals the loop count given by loop Example This example illustrates how these ...

Page 149: ...ibrary macname names the macro You must place the name in the source statement s label field macro identifies the source statement as the first line of a macro definition You must place macro in the op code field parameters are optional substitution symbols that appear as operands for the macro directive model statements are instructions or assembler directives that are ex ecuted each time the mac...

Page 150: ...mbler searches for the file in 1 The directory that contains the current source file 2 Any directories named with the i assembler option 3 Any directories specified by the environment variable A_DIR For more information about the i option and the environment variable see Section 3 4 Naming Alternate Directories for Assembler Input on page 3 7 When the assembler encounters a mlib directive it opens...

Page 151: ...ting incr macro ADD 1 A ADD 1 B endm Macro for zero accumulators decr macro SUB A A SUB B B endm Use the archiver to create a macro library ar500 a mac incr asm decr asm Now you can use the mlib directive to reference the macro library and define the incr and decr macros 1 mlib mac lib 2 000000 decr Macro call 1 000000 F420 SUB A A 1 000001 F720 SUB B B 3 000002 incr Macro call 1 000002 F000 ADD 1...

Page 152: ...s a macro named STR_3 The second time the macro is called the macro expansion is not listed because a mnolist directive was assembled The third time the macro is called the macro expansion is listed because a mlist directive was assembled 1 STR_3 macro P1 P2 P3 2 string p1 p2 p3 3 endm 4 5 000000 STR_3 as I am 1 000000 003A string p1 p2 p3 000001 0070 000002 0031 000003 003A 000004 003A 000005 007...

Page 153: ...gister 2 5 Reserved ST0 0006 Status 0 register ST1 0007 Status 1 register AL 0008 A accumulator low A 15 0 AH 0009 A accumulator high A 31 16 AG 000A A accumulator guard A 39 32 BL 000B B accumulator low B 15 0 BH 000C B accumulator high B 31 16 BG 000D B accumulator guard B 39 32 T 000E Temporary register TRN 000F Transition register BK 0019 Circular size register BRC 001A Block repeat counter RS...

Page 154: ...CE 0023 BSP control extension register BSPCE0 0023 BSP control extension register SPCE 0023 BSP control extension register TIM 0024 Timer register PRD 0025 Period register TCR 0026 Timer control register PDWSR 0028 Program data S W wait state register SWWSR 0028 Program data S W wait state register IOWSR 0029 Bank switching control register BSCR 0029 Bank switching control register HPIC 002C HPI c...

Page 155: ... register BKX0 0039 ABU transmit buffer size register ARR 003A ABU receive address register ARR0 003A ABU receive address register BKR 003B ABU receive buffer size register AXR1 003C ABU transmit address register BKX1 003D ABU transmit buffer size register ARR1 003E ABU receive address register BKR1 003F ABU receive buffer size register BDRR1 0040 BSP data receive register BDXR1 0041 Data transmit...

Page 156: ... a local label has been defined and perhaps used you should use the newblock directive to reset it The text data and named sections also reset local labels Local labels that are defined within an include file are not valid out side of the local file Example This example shows how the local label 1 is declared reset and then declared again 1 ref ADDRA ADDRB ADDRC 2 0076 B set 76h 3 4 000000 1000 LA...

Page 157: ...lid options B limits the listing of byte directives to one line L limits the listing of long directives to one line M turns off macro expansions in the listing R resets the B M T and W options T limits the listing of string directives to one line W limits the listing of word directives to one line X produces a symbol cross reference listing You can also obtain a cross reference listing by invoking...

Page 158: ... A 9 000008 15AA word 5546 78h 10 00000a 0045 string Extended Registers 11 12 13 Reset the listing options 14 15 option R 16 00001c 00BD byte C 0B0h 5 00001d 00B0 00001e 0005 17 000020 AABB long 0AABBCCDDh 536 A 000021 CCDD 000022 0000 000023 0259 18 000024 15AA word 5546 78h 000025 0078 19 000026 0045 string Extended Registers 000027 0078 000028 0074 000029 0065 00002a 006E 00002b 0064 00002c 006...

Page 159: ...he source listing into logical divisions improves program readability Example This example shows how the page directive causes the assembler to begin a new page of the source listing Source file title Page Directive Example page Listing file TMS320C54x COFF Assembler Version x xx Copyright c 1998 Texas Instruments Incorporated Page Directive Example PAGE 1 2 3 4 TMS320C54x COFF Assembler Version x...

Page 160: ...uaranteed to not cross a page boundary 128 words if it is smaller than a page or to start on a page boundary if it is larger than a page This direc tive allows specification of blocking for initialized sections only not uninitialized sections declared with usect or the bss directives The section names may optionally be enclosed in quotes Example This example designates the text and data sections f...

Page 161: ...ctions see Chapter 2 Introduction to Common Object File Format Example This example defines a special purpose section named Vars and assembles code into it 1 2 Begin assembling into text section 3 4 000000 text 5 000000 E878 LD 78h A Assembled into text 6 000001 F000 ADD 36h A Assembled into text 000002 0036 7 8 Begin assembling into Vars section 9 10 000000 sect Vars 11 0010 WORD_LEN set 16 12 00...

Page 162: ...xpression appears in the object field of the listing This value is not part of the actual object code and is not written to the output file Symbols defined with set or equ can be made externally visible with the def or global directive In this way you can define global absolute constants Example This example shows how symbols can be assigned with set and equ 1 2 Equate symbol AUX_R1 to register AR...

Page 163: ... 4 000000 text 5 6 7 Reserve 0F0 bits 15 words in the 8 text section 9 10 000000 space 0F0h 11 00000f 0100 word 100h 200h 000010 0200 12 13 Begin assembling into data section 14 15 000000 data 16 000000 0049 string In data 000001 006E 000002 0020 000003 002E 000004 0064 000005 0061 000006 0074 000007 0061 17 18 Reserve 100 bits in the data section 19 RES_1 points to the first word that 20 contains...

Page 164: ... substitution symbols Example This example shows code that by default suppresses the listing of substitu tion symbol expansion and it shows the sslist directive assembled instructing the assembler to list substitution symbol code expansion a Mnemonic example 1 000000 bss ADDRX 1 2 000001 bss ADDRY 1 3 000002 bss ADDRA 1 4 000003 bss ADDRB 1 5 ADD2 macro ADDRA ADDRB 6 LD ADDRA A 7 ADD ADDRB A 8 STL...

Page 165: ...B 1 5 ADD2 macro ADDRA ADDRB 6 A ADDRA 7 A A ADDRB 8 ADDRB A 9 endm 10 11 0000008094 AR4 A 12 000001 ADD2 ADDRX ADDRY 1 0000011000 A ADDRX 1 0000020001 A A ADDRY 1 0000038001 ADDRY A 13 14 sslist 15 16 000004 8094 AR4 A 17 000005 8090 AR0 A 18 19 000006 ADD2 ADDRX ADDRY 1 0000061000 A ADDRA A ADDRX 1 0000070001 A A ADDRB A A ADDRY 1 0000088001 ADDRB A ADDRY A ...

Page 166: ...yte of the word Any unused space is padded with null bytes The assembler truncates any values that are greater than 8 bits You may have up to 100 operands but they must fit on a single source statement line If you use a label it points to the location of the first word that is initialized Note that when you use string in a struct endstruct sequence string defines a member s size it does not initia...

Page 167: ...olic template that can be used repeatedly The endstruct directives terminates the structure definition The tag directive gives structure characteristics to a label simplifying the symbolic representation and providing the ability to define structures that con tain other structures The tag directive does not allocate memory The struc ture tag stag of a tag directive must have been previously define...

Page 168: ...its tag Following a struct directive these directives describe the element s size They do not allocate memory exprn is an optional expression for the number of elements described This value defaults to 1 A string element is considered to be one word in size and a field element is one bit size is an optional label for the total size of the structure Note Directives That Can Appear in a struct endst...

Page 169: ... 000002 bss COMPLEX CPLX_LEN 18 19 000001 0002 ADD COMPLEX REALI A access structure 20 000002 8002 STL A COMPLEX REALI 21 22 000003 0104 ADD COMPLEX IMAGI B allocate space Example 3 1 struct no stag puts mems into 2 global symbol table 3 0000 X int create 3 dim templates 4 0001 Y int 5 0002 Z int 6 0003 endstruct Example 4 1 BIT_REC struct stag 2 0000 STREAM string 64 3 0040 BIT7 field 7 bits1 64 ...

Page 170: ... tab size is eight spaces Example Each of the following lines consists of a single tab character followed by an NOP instruction Source file default tab size NOP NOP NOP tab 4 NOP NOP NOP tab 16 NOP NOP NOP Listing file 1 default tab size 2 000000 F495 NOP 3 000001 F495 NOP 4 000002 F495 NOP 5 7 000003 F495 NOP 8 000004 F495 NOP 9 000005 F495 NOP 10 12 000006 F495 NOP 13 000007 F495 NOP 14 000008 F...

Page 171: ... For more information about COFF sections see Chapter 2 Introduction to Common Object File Format Example This example assembles code into the text and data sections The data sec tion contains integer constants and the text section contains executable code 1 2 Begin assembling into data section 3 4 000000 data 5 000000 000a byte 0Ah 0Bh 000001 000b 6 7 8 Begin assembling into text section 9 10 000...

Page 172: ...n the page that follows the directive and on sub sequent pages until another title directive is processed If you want a title on the first page the first source statement must contain a title directive Example In this example one title is printed on the first page and a different title on succeeding pages Source file title Fast Fourier Transforms title Floating Point Routines page Listing file TMS...

Page 173: ...ment offset This is similar to a C union The union directive does not allocate any memory it merely creates a symbolic template that can be used repeatedly A struct definition may contain a union definition and structs and unions may be nested The endunion directive terminates the union definition The tag directive gives structure or union characteristics to a label simplifying the symbolic repres...

Page 174: ...ield float half int long short string ubyte uchar uhalt uint ulong ushort uword and word An element can also be a com plete declaration of a nested structure or union or a structure or union declared by its tag Following a union directive these directives describe the element s size They do not allocate memory exprn is an optional expression for the number of elements described This value defaults...

Page 175: ...0000 sval string member3 string 6 0002 real_len endunion real_len 2 7 8 000000 bss employid real_len allocate memory 9 10 employid tag xample name an instance 11 000000 0000 ADD employid fval A access union element Example 2 1 2 union utag 3 0000 x long member1 long 4 0000 y float member2 float 5 0000 z word member3 word 6 0002 size_u endunion real_len 2 7 ...

Page 176: ...ocking flag is an optional parameter If specified and nonzero the flag means that this section will be blocked Blocking is an ad dress mechanism similar to alignment but weaker It means a section is guaranteed to not cross a page bound ary 128 words if it is smaller than a page and to start on a page boundary if it is larger than a page This blocking applies to the section not to the object declar...

Page 177: ... word reserved in the var2 section Figure 4 7 on page 4 95 shows how this example reserves space in two unini tialized sections var1 and var2 1 2 Assemble into text section 3 4 000000 text 5 000000 E803 LD 03h A 6 7 8 Reserve 1 word in var1 9 10 000000 ptr usect var1 1 11 12 13 Reserve 100 words in var1 14 15 000001 array usect var1 100 16 17 000001 F000 ADD 037h A Still in text 000002 0037 18 19 ...

Page 178: ...initialized Space usect 4 95 Assembler Directives Figure 4 7 The usect Directive 1 word 100 words 50 words ptr array dflag 151 words reserved in var1 section var1 section var2 100 words 100 words reserved in var2 ...

Page 179: ... variables within a macro With this directive you can define up to 32 local macro sub stitution symbols including parameters per macro The var directive creates temporary substitution symbols with the initial value of the null string These symbols are not passed in as parameters and they are lost after expansion For more information on macros see Chapter 5 ...

Page 180: ...ce version 4 97 Assembler Directives Syntax version value Description The version directive determines for which processor instructions are built Use one of the following for value 541 542 543 545 545LP 546LP 548 549 ...

Page 181: ...cess macro libraries created with the archiver Define conditional and repeatable blocks within a macro Manipulate strings within a macro Control expansion listing Topic Page 5 1 Using Macros 5 2 5 2 Defining Macros 5 3 5 3 Macro Parameters Substitution Symbols 5 6 5 4 Macro Libraries 5 14 5 5 Using Conditional Assembly in Macros 5 15 5 6 Using Labels in Macros 5 17 5 7 Producing Messages in Macros...

Page 182: ...mation Macros can be defined in a macro library A macro library is a collection of files in archive format created by the archiver Each member of the archive file macro library contains one macro definition corresponding to the member name You can access a macro library by using the mlib directive See Section 5 4 Macro Libraries on page 5 14 for more information Step 2 Call the macro After definin...

Page 183: ...mat macname macro parameter1 parametern model statements or macro directives mexit endm macname names the macro You must place the name in the source statement s label field Only the first 32 characters of a macro name are significant The assembler places the macro name in the internal opcode table replacing any instruction or previous macro definition with the same name macro identifies the sourc...

Page 184: ... the macro ex pansion use an asterisk or semicolon For more in formation about macro comments see Section 5 7 Producing Messages in Macros on page 5 19 Example 5 1 shows the definition call and expansion of a macro Example 5 1 Macro Definition Call and Expansion a Mnemonic example 1 2 3 add3 4 5 ADDRP P1 P2 P3 6 7 add3 macro P1 P2 P3 ADDRP 8 9 LD P1 A 10 ADD P2 A 11 ADD P3 A 12 STL A ADDRP 13 endm...

Page 185: ... 2 3 add3 4 5 ADDRP P1 P2 P3 6 7 add3 macro P1 P2 P3 ADDRP 8 9 A P1 10 A A P2 11 A A P3 12 ADDRP A 13 endm 14 15 16 global abc def ghi adr 17 18 000000 add3 abc def ghi adr 1 1 000000 1000 A abc 1 000001 0000 A A def 1 000002 0000 A A ghi 1 000003 8000 adr A ...

Page 186: ...ocal substitution symbols including substitution symbols defined with the var directive per macro For more information about the var directive see subsection 5 3 7 Substitution Symbols as Local Variables in Macros on page 5 13 During macro expansion the assembler passes arguments by variable to the macro parameters The character string equivalent of each argument is assigned to the corresponding p...

Page 187: ...acro With Varying Numbers of Arguments Macro definition Parms macro a b c a a b b c c endm Calling the macro Parms 100 label Parms 100 label x y a 100 a 100 b label b label c c x y Parms 100 x Parms 100 200 300 x y a 100 a 100 200 300 b b x c x c y Parms string x y a string b x c y ...

Page 188: ... strings being assigned to substitution symbols Example 5 3 The asg Directive asg AR0 FP frame pointer asg AR1 Ind indirect addressing asg AR1 0b Rc_Prop reverse carry propagation asg string strng string asg a b c parms parameters The eval directive performs arithmetic on numeric substitution symbols The syntax of the eval directive is eval well defined expression substitution symbol The eval dire...

Page 189: ...bstitution symbols or character string constants The term string refers to the string value of the parameter Table 5 1 Functions and Return Values Function Return Value symlen a length of string a symcmp a b 0 if a b 0 if a b 0 if a b firstch a ch index of the first occurrence of character constant ch in string a lastch a ch index of the last occurrence of character constant ch in string a isdefed...

Page 190: ...orresponding character string If that string is also a substitution symbol the assembler performs substitution again The assembler continues doing this until it encounters a token that is not a substitution symbol or until it encounters a substitution symbol that it has already encountered during this evaluation In Example 5 6 the x is substituted for z z is substituted for y and y is substituted ...

Page 191: ...symbol The syntax for the forced substitution operator is symbol The assembler expands substitution symbols enclosed in colons before it expands other substitution symbols You can use the forced substitution operator only inside macros and you cannot nest a forced substitution operator within another forced substitution operator Example 5 7 shows how the forced substitution operator is used Exampl...

Page 192: ...od expression1 represents the substring s starting position and expression2 represents the substring s length You can specify exactly where to begin subscripting and the exact length of the resulting character string The index of substring characters begins with 1 not 0 Example 5 8 and Example 5 9 show built in substitution symbol functions used with subscripted substitution symbols Example 5 8 Us...

Page 193: ...he subscripted substitution symbol is used to find a substring strg1 beginning at position start in the string strg2 The position of the substring strg1 is assigned to the substitution symbol pos 5 3 7 Substitution Symbols as Local Variables in Macros If you want to use substitution symbols as local variables within a macro you can use the var directive to define up to 32 local macro substitution ...

Page 194: ...e library into the opcode tables as library entries this redefines any existing opcodes or macros that have the same name If one of these macros is called the assembler extracts the entry from the library and loads it into the macro table The assembler expands the library entry in the same way it expands other macros You can control the listing of library entry expansions with the mlist directive ...

Page 195: ...ck repeatedly The format of a repeatable block is loop well defined expression break well defined expression endloop The loop directive s optional expression evaluates to the loop count the number of loops to be performed If the expression is omitted the loop count defaults to 1024 unless the assembler encounters a break directive with an expression that is true nonzero For more information on the...

Page 196: ...dif eval x 1 x endloop Example 5 12 Built In Substitution Symbol Functions Used in a Conditional Assembly Code Block ref OPZ fcnolist Double Add or Subtract DBL macro ABC ADDR src add or subtract double if symcmp ABC 0 dadd ADDR src add double elseif symcmp ABC 0 dsub ADDR src subtract double else emsg Incorrect Operator Parameter endif endm Macro Call DBL OPZ A For more information about conditio...

Page 197: ... label as global The maximum label length is shortened to allow for the unique suffix If the macro is expanded fewer than 10 times the maximum label length is 126 characters If the macro is expanded from 10 to 99 times the maximum label length is 125 The label with its unique suffix is shown in the cross listing file The syntax for a unique label is label Example 5 13 shows unique label generation...

Page 198: ...AR BVAR find minimum 3 4 A AVAR 5 A A BVAR 6 if ALT goto M1 7 A BVAR 8 goto M2 9 M1 A AVAR 10 M2 11 endm 12 13 call macro 14 000000 MIN 50 100 1 1 000000 1032 A 50 1 000001 F010 A A 100 000002 0064 1 000003 F843 if ALT goto M1 000004 0008 1 000005 E864 A 100 1 000006 F073 goto M2 000007 0009 1 000008 1032 M1 A 50 1 000009 M2 ...

Page 199: ...r from producing an object file mmsg sends assembly time messages to the listing file The mmsg directive functions in the same manner as the emsg directive but does not set the error count or prevent the creation of an object file wmsg sends warning messages to the listing file The wmsg directive functions in the same manner as the emsg directive but it increments the warning count and does not pr...

Page 200: ...it 9 else 10 LD y A 11 LD x B 12 ADD A B 13 endif 14 endm 15 16 000000 testparam 1 2 1 1 if symlen x 0 1 emsg ERROR Missing Parameter 1 mexit 1 elseif symlen y 0 1 emsg ERROR Missing Parameter 1 mexit 1 else 1 000000 1002 LD 2 A 1 000001 1101 LD 1 B 1 000002 F500 ADD A B 1 endif 17 18 000003 testparam 1 1 if symlen x 0 1 emsg ERROR Missing Parameter USER ERROR ERROR Missing Parameter 1 mexit 1 Err...

Page 201: ...e all conditional blocks that do not generate code false condi tional blocks Conditional blocks appear in the listing exactly as they appear in the source code fcnolist suppresses the listing of false conditional blocks Only the code in conditional blocks that actually assemble appears in the listing The if elseif else and endif directives do not appear in the listing For false conditional block l...

Page 202: ...guments that you pass to macro parameters because the assembler uses dynamic scoping for parameters This means that the called macro uses the environment of the macro from which it was called Example 5 15 shows nested macros Note that the y in the in_block macro hides the y in the out_block macro The x and z from the out_block macro however are accessible to the in_block macro Example 5 15 Using N...

Page 203: ...lling fact1 which calls itself recursively Example 5 16 Using Recursive Macros a Mnemonic example fact macro N loc n is an integer constant loc memory address n if N 2 0 1 1 ST 1 loc else ST N loc n 2 so store n at loc decrement n and do the eval N 1 N factorial of n 1 fact1 call fact with current environment endif endm fact1 macro if N 1 LD loc T multiply present factorial MPY N A by present posi...

Page 204: ...nstant loc memory address n if N 2 0 1 1 AR0 1 else AR0 N n 2 so store n at loc decrement n and do the eval N 1 N factorial of n 1 fact1 call fact1 with current environment endif endm fact1 macro if N 1 T AR0 multiply present factorial A T N by present position AR0 A save result eval N 1 N decrement position fact1 recursive call endif endm ...

Page 205: ...tring to substitution symbol eval well defined expression substitution symbol Perform arithmetic on numeric substitution symbols var substitution symbol1 substitution symboln Define local macro symbols Table 5 4 Conditional Assembly Mnemonic and Syntax Description if well defined expression Begin conditional assembly elseif well defined expression Optional conditional assembly block else Optional ...

Page 206: ...arning or assembly time message to standard output Table 5 6 Formatting the Listing Mnemonic and Syntax Description fclist Allow false conditional code block listing default fcnolist Inhibit false conditional code block listing mlist Allow macro listings default mnolist Inhibit macro listings sslist Allow expanded substitution symbol listing ssnolist Inhibit expanded substitution symbol listing de...

Page 207: ...ll search the library and use the members that are called as macros by the source file You can also use the archiver to collect a group of object files into an object library The linker will include in the library the mem bers that resolve external references during the link Topic Page 6 1 Archiver Overview 6 2 6 2 Archiver Development Flow 6 3 6 3 Invoking the Archiver 6 4 6 4 Archiver Examples 6...

Page 208: ...e archiver is building libraries of object modules For example you can write several arithmetic routines assemble them and use the archiver to collect the object files into a single logical group You can then specify the object library as linker input The linker will search the library and include members that resolve external references You can also use the archiver to build macro libraries You c...

Page 209: ...raries as input Figure 6 1 Archiver Development Flow Assembler Linker Macro library Library of object files Hex conversion utility EPROM programmer Assembler source COFF object files Archiver Macro source files Archiver C source files C54x Executable COFF file C compiler Library build utility Cross reference lister Absolute lister Debugging tools Runtime support library Translator utility Assemble...

Page 210: ... new members to the end of the archive d deletes the specified members from the library r replaces the specified members in the library If you don t specify filenames the archiver replaces the library mem bers with files of the same name in the current directory If the specified file is not found in the library the archiver adds it instead of replacing it t prints a table of contents of the librar...

Page 211: ...ld library and its constituent members libname names an archive library If you don t specify an extension for libname the archiver uses the default extension lib filename names individual member files that are associated with the library You must specify a complete filename including an extension if applicable It is possible but not desirable for a library to contain several members with the same ...

Page 212: ...nction atan obj TMS320C54x Archiver Version x xx Copyright c 1998 Texas Instruments Incorporated symbol defined symbol_name symbol defined symbol_name building archive function lib Because this example doesn t specify an extension for the libname the archiver adds the files to the library called function lib If function lib didn t exist the archiver would create it The s option tells the archiver ...

Page 213: ...king the Linker 7 4 7 4 Linker Options 7 6 7 5 Linker Command Files 7 21 7 6 Object Libraries 7 25 7 7 The MEMORY Directive 7 27 7 8 The SECTIONS Directive 7 32 7 9 Specifying a Section s Runtime Address 7 41 7 10 Using UNION and GROUP Statements 7 45 7 11 Overlay Pages 7 48 7 12 Default Allocation Algorithm 7 53 7 13 Special Section Types DSECT COPY and NOLOAD 7 56 7 14 Assigning Symbols at Link ...

Page 214: ...s to assign them to final addresses Resolves undefined external references between input files The linker command language controls memory configuration output section definition and address binding The language supports expression assign ment and evaluation You configure system memory by defining and creating a memory model that you design Two powerful directives MEMORY and SECTIONS allow you to ...

Page 215: ...ecutable COFF object module that can be downloaded to one of several development tools or executed by a TMS320C54x device Figure 7 1 Linker Development Flow Assembler Linker Macro library Library of object files Hex conversion utility EPROM programmer Assembler source COFF object files Archiver Macro source files Archiver C source files C54x Executable COFF file C compiler Library build utility Cr...

Page 216: ...o files file1 obj and file2 obj and creates an output module named link out lnk500 file1 obj file2 obj o link out Enter the lnk500 command with no filenames and no options the linker prompts for them Command files Object files obj Output file a out Options J For command files enter one or more command filenames J For object files enter one or more object filenames The default exten sion is obj Sep...

Page 217: ...mmand filename as an input file lnk500 linker cmd When you use a command file you can also specify other options and files on the command line For example you could enter lnk500 m link map linker cmd file3 obj The linker reads and processes a command file as soon as it encounters the filename on the command line so it links the files in this order file1 obj file2 obj and file3 obj This example cre...

Page 218: ...C54x C compiler e global_symbol Define a global_symbol that specifies the primary entry point for the output module f fill_value Set the default fill value for holes within output sec tions fill_value is a 16 bit constant g global_symbol Make a global_symbol static overrides h h Make all global symbols static help Display a listing of all available linker command line options heap size Set heap si...

Page 219: ...r r Produce a relocatable output module s Strip symbol table information and line number entries from the output module stack size Set C system stack size to size words and define a global symbol that specifies the stack size The default size is 1K words u symbol Place an unresolved external symbol into the output module s symbol table vn Specify the output COFF format where n is 0 1 or 2 The defa...

Page 220: ...the a option without the r option the linker produces an absolute executable output module Absolute files contain no relocation information Executable files contain the following J Special symbols defined by the linker subsection 7 14 4 Symbols Defined by the Linker on page 7 60 describes these symbols J An optional header that describes information such as the program entry point J No unresolved ...

Page 221: ...led partial linking For more information see Section 7 18 Linker Example on page 7 71 Producing an Executable Relocatable Output Module ar If you invoke the linker with both the a and r options the linker produces an executable relocatable object module The output file contains the special linker symbols an optional header and all resolved symbol references however the relocation information is re...

Page 222: ...l output file only one set of these entries is necessary The linker eliminates the duplicate entries automatically Use the b option if you want the linker to keep such duplicate entries Using the b option has the effect of the linker running faster and using less machine memory 7 4 3 C Language Options c and cr Options The c and cr options cause the linker to use linking conventions that are requi...

Page 223: ...s an external symbol in one of the input files The value of symbol _c_int00 if present _c_int00 must be the entry point if you are linking code produced by the C compiler The value of symbol _main if present Zero default value This example links file1 obj and file2 obj The symbol begin is the entry point begin must be defined as external in file1 or file2 lnk500 e begin file1 obj file2 obj 7 4 5 S...

Page 224: ...2 obj and b3 obj are related and reference a global variable GLOB Also assume that d1 obj d2 obj and d3 obj are related and reference a separate global variable GLOB By using the h option and partial linking you can link the related files without conflict lnk500 h r b1 obj b2 obj b3 obj o bpart out lnk500 h r d1 obj d2 obj d3 obj o dpart out The h option guarantees that bpart out and dpart out do ...

Page 225: ...ssume that this library defines symbols that are referenced in the file file1 obj This is how you link the files lnk500 file1 obj object lib If you want to use a library that is not in the current directory use the l lowercase L linker option The syntax for this option is l filename The filename is the name of an archive library the space between l and the filename is optional You can augment the ...

Page 226: ...es only one directory but you can use several i options per invocation When you use the i option to name an alternate directory it must precede the l option on the command line or in a command file For example assume that there are two archive libraries called r lib and lib2 lib The table below shows the directories that r lib and lib2 lib reside in how to set environment variable and how to use b...

Page 227: ...ide in ld and ld2 directories The table below shows the directories that r lib and lib2 lib reside in how to set the environment variable and how to use both libraries during a link Select the row for your operating system Operating System Pathname Invocation Command DOS ld and ld2 set C_DIR ld ld2 lnk500 f1 obj f2 obj l r lib l lib2 lib UNIX ld and ld2 setenv C_DIR ld ld2 lnk500 f1 obj f2 obj l r...

Page 228: ...7 4 11 Ignore Alignment Flags k Option The k option forces the linker to ignore any SECTIONS directive alignment specifications For more information on the SECTIONS directive see Section 7 8 The SECTIONS Directive 7 4 12 Create a Map File m filename Option The m option creates a linker map listing and puts it in filename The syntax for the m option is m filename The linker map describes Memory con...

Page 229: ... file2 obj and creates an output module named run out lnk500 o run out file1 obj file2 obj 7 4 14 Specify a Quiet Run q Option The q option suppresses the linker s banner when q is the first option on the command line or in a command file This option is useful for batch operation 7 4 15 Strip Symbolic Information s Option The s option creates a smaller output module by omitting symbol table inform...

Page 230: ...ck size is 1K words 7 4 17 Introduce an Unresolved Symbol u symbol Option The u option introduces an unresolved symbol into the linker s symbol table This forces the linker to search a library and include the member that defines the symbol The linker must encounter the u option before it links in the member that defines the symbol For example suppose a library named rts lib contains a member that ...

Page 231: ...r if the linker encounters one or more input sections that do not have a corre sponding output section defined in the SECTIONS directive the linker combines the input sections that have the same name into an output section with that name By default the linker does not display a message to tell you when this has occurred If this situation occurs and you use the w option the linker displays a messag...

Page 232: ...y read archive library the reference will not be resolved With the x option you can force the linker to reread all libraries The linker rereads libraries until no more references can be resolved Linking using the x option may be slower so you should use it only as needed For example if a lib contains a reference to a symbol defined in b lib and b lib contains a reference to a symbol defined in a l...

Page 233: ...statement in the calling command file The linker does not return from called command files Linker options which can be used in the command file in the same manner that they are used on the command line The MEMORY and SECTIONS linker directives The MEMORY directive defines the target memory configuration The SECTIONS directive controls how sections are built and allocated Assignment statements whic...

Page 234: ... with this command file enter lnk500 link cmd You can place other parameters on the command line when you use a command file lnk500 r link cmd c obj d obj The linker processes the command file as soon as it encounters it so a obj and b obj are linked into the output module before c obj and d obj You can specify multiple command files If for example you have a file called names lst that contains fi...

Page 235: ...mand file Example 7 2 shows a sample command file that contains linker directives Linker directive formats are discussed in later sections Example 7 2 Command File With Linker Directives a obj b obj c obj Input filenames o prog out m prog map Options MEMORY MEMORY directive RAM origin 100h length 0100h ROM origin 01000h length 0100h SECTIONS SECTIONS directive text ROM data RAM bss RAM ...

Page 236: ...ck LENGTH range BLOCK load run COPY LOAD RUN DSECT MEMORY SECTIONS f NOLOAD spare fill o type FILL org TYPE group UNION 7 5 2 Constants in Command Files Constants can be specified with either of two syntax schemes the scheme used for specifying decimal octal or hexadecimal constants used in the assembler see Section 3 6 Constants on page 3 14 or the scheme used for integer constants in C syntax Ex...

Page 237: ... undefined when the library is searched The same library can be specified as often as neces sary it is searched each time it is included Alternatively the x option can be used A library has a table that lists all external symbols defined in the library the linker searches through the table until it determines that it cannot use the library to resolve any more references The following examples link...

Page 238: ...The next example creates an undefined symbol rout1 in the linker s global symbol table lnk500 u rout1 libc lib If any member of libc lib define rout1 the linker includes those members It is not possible to control the allocation of individual library members members are allocated according to the SECTIONS directive default allocation algorithm Subsection 7 4 9 Alter the Library Search Algorithm i ...

Page 239: ... device The assembler inserts a field in the output file s header identifying the device The linker reads this information from the object file s header If you do not use the MEMORY directive the linker uses a default memory model specific to the named device For more information about the default memory model see subsection 7 12 1 Allocation Algorithm on page 7 53 7 7 2 MEMORY Directive Syntax Th...

Page 240: ...MORY directive statement The MEMORY directive is specified in a command file by the word MEMORY uppercase followed by a list of memory range specifications enclosed in braces The MEMORY directive in Example 7 3 defines a system that has 4K words of ROM at address C00h in program memory 32 words of RAM at address 60h in data memory and 4K words at address 80h in data memory Example 7 3 The MEMORY D...

Page 241: ...e not retained in the output file or in the symbol table Memory ranges on separate pages can have the same name with in a page however all memory ranges must have unique names and must not overlap attr Specifies one to four attributes associated with the named range Attributes are optional when used they must be enclosed in parentheses Attributes restrict the allocation of output sections into cer...

Page 242: ... memory range even with 0s causes raw data to be generated for all unallocated blocks of memory in the range The following example specifies a memory range with the R and W attributes and a fill constant of 0FFFFh MEMORY RFILE RW o 02h l 0FEh f 0FFFFh You normally use the MEMORY directive in conjunction with the SECTIONS directive to control allocation of output sections After you use the MEMORY d...

Page 243: ...e 7 3 ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ Data Memory on chip RAM SCRATCH 00000h 0005Fh 00060h 0007Fh 00080h 0107Fh 01080h 0FFFFh Program Memory ROM on chip ROM 00000h 00C00h 01C00h 0FFFFh ONCHIP ...

Page 244: ...s Refer to subsection 2 3 4 Subsections on page 2 8 for information on defining subsections subsections allow you to manipulate sections with greater precision 7 8 1 Default Configuration If you do not specify a SECTIONS directive the linker uses a default algorithm for combining and allocating the sections Section 7 12 Default Allocation Algorithm on page 7 53 describes this algorithm in detail 7...

Page 245: ... in memory the section is to be run Syntax run allocation or run allocation Input sections which define the input sections that constitute the output section Syntax input_sections Section type which defines flags for special section types Syntax type COPY or type DSECT or type NOLOAD For more information on section types see Section 7 13 Special Section Types DSECT COPY and NOLOAD on page 7 56 Fil...

Page 246: ... at 0FF80h allocated in ROM const allocated in ROM bss allocated in RAM data aligned on 16 word boundary 00h The text section combines the text sections from file1 obj and file2 obj The linker combines all sec tions named text into this section The application must relocate the section to run at 0800h The const section combines the const sections from file1 obj and file2 obj The bss section combin...

Page 247: ... within a SECTIONS directive and providing instructions on how to allocate it You control allocation by specifying one or more allocation parameters Each parameter consists of a keyword an optional equal sign or greater than sign and a value optionally enclosed in parentheses If load and run allocation is separate all parameters following the keyword LOAD apply to load allocation and those followi...

Page 248: ... you prefer use parentheses for readability text load ROM align 16 page 2 7 8 3 1 Binding You can supply a specific starting address for an output section by following the section name with an address text 0x1000 This example specifies that the text section must begin at word location 1000h The binding address must be a 16 bit constant Output sections can be bound anywhere in configured memory ass...

Page 249: ...closed in parentheses instead of a memory name Using the same MEMORY directive declaration you can specify SECTIONS text X text executable memory data RI data read or init memory bss RW bss read or write memory In this example the text output section can be linked into either the ROM or RAM area because both areas have the X attribute The data section can also go into either ROM or RAM because bot...

Page 250: ...locking cannot be used together 7 8 3 4 Specifying input sections An input section specification identifies the sections from input files that are combined to form an output section The linker combines input sections by concatenating them in the order in which they are specified The size of an output section is the sum of the sizes of the input sections that comprise it Example 7 5 shows the most ...

Page 251: ...ut section but are not explicitly specified by the SECTIONS directive they are automatically linked in at the end of the output section For example if the linker found more text sections in the preceding example and these text sections were not specified anywhere in the SECTIONS directive the linker would concatenate these extra sections after f4 obj sec2 The specifications in Example 7 5 are actu...

Page 252: ...bj which is followed by all the text input sections The data section contains all the data input sections followed by a named section table from the file fil obj This method includes all the unallocated sections For example if one of the text input sections was already included in another output section when the linker encountered text the linker could not include that first text input section in ...

Page 253: ...lication must copy the section from its load address to its run address this does not happen automatically when you specify a separate run address If you provide only one allocation either load or run for a section the section is allocated only once and will load and run at the same address If you provide both allocations the section is allocated as if it were two sections of the same size This me...

Page 254: ...ies load and run addresses for an uninitialized section bss load 0x1000 run RAM A warning is issued load is ignored and space is allocated in RAM All of the following examples have the same effect The bss section is allocated in RAM bss load RAM bss run RAM bss RAM 7 9 3 Referring to the Load Address by Using the label Directive Normally any reference to a symbol in a section refers to its runtime...

Page 255: ...r_end load address of section end copy fir section from ROM into RAM text STM fir_src AR1 get load address RPT fir_end fir_src 1 MVDP AR1 fir copy address to program memory jump to section now in RAM CALL fir Linker Command File PARTIAL LINKER COMMAND FILE FOR FIR EXAMPLE MEMORY PAGE 0 ONCHIP origin 0800h length 02400h PAGE 0 PROG origin 02C00h length 0D200h PAGE 1 DATA origin 0800h length 0F800h ...

Page 256: ...e Address 7 44 Figure 7 4 illustrates the runtime execution of this example Figure 7 4 Runtime Execution of Example 7 6 ONCHIP fir relocated to run here PROG text DATA fir loads here Program Memory Data Memory 800h 2C00h FE00h 800h ...

Page 257: ...directive provides a way to allocate several sections at the same runtime address In Example 7 7 the bss sections from file1 obj and file2 obj are allocated at the same address in RAM In the memory map the union occupies as much space as its largest component The components of a union remain independent sections they are simply allocated together as a unit Example 7 7 The UNION Statement SECTIONS ...

Page 258: ...ace anywhere it fits in configured memory Uninitialized sections are not loaded and do not require load addresses The UNION statement applies only to allocation of run addresses so it is redundant to specify a load address for the union itself For purposes of allocation the union is treated as an uninitialized section any one allocation specified is considered a run address and if both are specifi...

Page 259: ... bss Normal output section GROUP 1000h Specify a group of sections data First section in the group term_rec Allocated immediately after data You can use binding alignment or named memory to allocate a GROUP in the same manner as a single output section In the preceding example the GROUP is bound to word address 1000h This means that data is allocated at word 1000h and term_rec follows it in memory...

Page 260: ...emory comprising the full 24 bit range of addressable locations This allows you to link two or more sections at the same or overlapping addresses if they are on different pages Pages are numbered sequentially beginning with 0 If you do not use the PAGE option the linker allocates initialized sections into PAGE 0 program memory and uninitialized sections into PAGE 1 data memory For example assume t...

Page 261: ...er the same address range This is possible because each range is on a different page and therefore represents a different memory space Figure 7 6 shows overlay pages defined by the MEMORY directive in Example 7 10 and the SECTIONS directive in Example 7 11 Figure 7 6 Overlay Pages Defined by Example 7 10 and Example 7 11 Run address for f1 f2 f3 f4 ONCHIP PROG text 800h FC00h 2C00h Program Memory ...

Page 262: ...2_start text load PROG PAGE 0 data load PROG PAGE 0 bss load DATA PAGE 1 The four modules of code are f1 f2 f3 and f4 The modules f1 and f2 are combined into output section S1 and f3 and f4 are combined into output section S2 The PAGE specifications for S1 and S2 tell the linker to link these sections into the corresponding pages As a result they are both linked to load address A00h but in differe...

Page 263: ...o specify OVR_MEM for the section 7 11 3 Page Definition Syntax To specify overlay pages as illustrated in Example 7 10 and Example 7 11 use the following syntax for the MEMORY directive MEMORY PAGE 0 name 1 attr origin constant length constant PAGE n name n attr origin constant length constant Each page is introduced by the keyword PAGE and a page number followed by a colon and a list of memory r...

Page 264: ... and RAM are all on PAGE 0 since no page is specified XROM and XRAM are on PAGE 1 Note that XROM on PAGE 1 overlays ROM on PAGE 0 and XRAM on PAGE 1 overlays RAM on PAGE 0 In the output link map obtained with the m linker option the listing of the memory model is keyed by pages This provides an easy method of verifying that you specified the memory model correctly Also the listing of output sectio...

Page 265: ...init PAGE 0 cflag option only bss PAGE 1 All text input sections are concatenated to form a text output section in the executable output file and all data input sections are combined to form a data output section The text and data sections are allocated into configured memory on PAGE 0 which is the program memory space All bss sections are combined to form a bss output section The bss section is a...

Page 266: ...d that the SECTIONS directive does not define an output section for them The linker combines the two Vectors sections from the input files into a single output section named Vectors allocates it into memory and includes it in the output file After the linker determines the composition of all output sections it must allo cate them into configured memory The MEMORY directive specifies which portions...

Page 267: ... encountered Each output section is placed into the first available memory space considering alignment where necessary Note The PAGE Option If you do not use the PAGE option to explicitly specify a memory space for an output section the linker allocates the section into PAGE 0 This occurs even if PAGE 0 has no room and other pages do To use a page other than PAGE 0 you must specify the page with t...

Page 268: ... same value they would have if the DSECT had actually been loaded These sym bols can be referenced by other input sections J Undefined external symbols found in a DSECT cause specified archive libraries to be searched J The section s contents relocation information and line number information are not placed in the output module In the preceding example none of the sections from f1 obj are allocate...

Page 269: ...d externally If it is not the linker defines a new symbol and enters it into the symbol table The expression must follow the rules defined in subsection 7 14 3 Assignment Expressions Assignment statements must terminate with a semicolon The linker processes assignment statements after it allocates all the output sections Therefore if an expression contains a symbol the address used for that symbol...

Page 270: ...on Dstart is assigned before data is allocated The linker will relocate all references to Dstart A special type of assignment assigns a value to the symbol This adjusts the SPC within an output section and creates a hole between two input sec tions Any value assigned to to create a hole is relative to the beginning of the section not to the address actually represented by Assignments to and holes ...

Page 271: ...n Table 7 1 the linker also has an align operator that allows a symbol to be aligned on an n word boundary within an output sec tion n is a power of 2 For example the expression align 16 aligns the SPC within the current section on the next 16 word boundary Because the align operator is a function of the current SPC it can be used only in the same context as that is within a SECTIONS directive Tab...

Page 272: ...xt is assigned the first address following the text output section It marks the end of executable code data is assigned the first address of the data output section It marks the beginning of initialized data tables edata is assigned the first address following the data output section It marks the end of initialized data tables bss is assigned the first address of the bss output section It marks th...

Page 273: ... no raw data they are uninitialized They occupy space in the memory map but have no actual contents Uninitialized sections typically reserve space in RAM for variables In the object file an uninitialized section has a normal sec tion header and may have symbols defined in it however no memory image is stored in the section 7 15 2 Creating Holes You can create a hole in an initialized output sectio...

Page 274: ...ndles assignments to the symbol as if the section started at address 0 even if you have specified a binding address Consider the statement align 16 in the example This statement effectively aligns file3 obj text to start on a 16 word boundary within outsect If outsect is ultimately allocated to start on an address that is not aligned file3 obj text will not be aligned either Note that the symbol r...

Page 275: ...text file1 obj bss This becomes a hole Because the text section has raw data all of outsect must also contain raw data rule 1 Therefore the uninitialized bss section becomes a hole Uninitialized sections become holes only when they are combined with initialized sections If several uninitialized sections are linked together the resulting output section is also uninitialized 7 15 3 Filling Holes Whe...

Page 276: ......

Page 277: ......

Page 278: ......

Page 279: ......

Page 280: ......

Page 281: ......

Page 282: ......

Page 283: ......

Page 284: ......

Page 285: ......

Page 286: ......

Page 287: ......

Page 288: ......

Page 289: ......

Page 290: ......

Page 291: ......

Page 292: ......

Page 293: ......

Page 294: ......

Page 295: ......

Page 296: ......

Page 297: ......

Page 298: ......

Page 299: ......

Page 300: ......

Page 301: ......

Page 302: ......

Page 303: ...ou can use the hex conversion utility ROMS and SECTIONS directives in a command file To invoke the hex conversion utility enter hex500 options filename hex500 is the command that invokes the hex conversion utility options supplies additional information that controls the hex conversion process You can use options on the command line or in a com mand file All options are preceded by a dash and are ...

Page 304: ... options 10 7 b Image options The image options create a continuous image of a range of target memory Option Description Page fill value Fill holes with value 10 27 image Specify image mode 10 26 zero Reset the address origin to zero 10 35 c Memory options The memory options configure the memory widths for your output files Option Description Page memwidth value Define the system memory word width...

Page 305: ...ices The boot loader options for all C54x devices control how the hex conversion utility builds the boot table Option Description Page boot Convert all sections into bootable form use instead of a SECTIONS directive 10 29 bootorg PARALLEL Specify the source of the boot loader table as the parallel port 10 29 bootorg SERIAL Specify the source of the boot loader table as the serial port 10 29 bootor...

Page 306: ...munications port 10 29 spc value Set the serial port control register value 10 29 spce value Set the serial port control extension register value 10 29 arr value Set the ABU receive address register value 10 29 bkr value Set the ABU transmit buffer size register value 10 29 tcsr value Set the TDM serial port channel select register value 10 29 trta value Set the TDM serial port receive transmit ad...

Page 307: ...ction 10 6 The SECTIONS Directive on page 10 22 You can also use this directive to identify specific sections that will be initialized by an on chip boot loader For more information on the on chip boot loader see Section 10 9 3 Building a Table for an On Chip Boot Loader on page 10 29 Comments You can add comments to your command file by using the and delimiters For example This is a comment To in...

Page 308: ...ering hex500 firmware cmd This example converts a file called appl out into four hex files in Intel format Each output file is one byte wide and 16K bytes long The text section is converted to boot loader format appl out input file i Intel format map appl mxp map file ROMS ROW1 origin 01000h len 04000h romwidth 8 files appl u0 appl u1 ROW2 origin 05000h len 04000h romwidth 8 files app1 u2 appl u3 ...

Page 309: ...rates the three separate and distinct phases of the hex conversion utility s process flow Figure 10 2 Hex Conversion Utility Process Flow Raw data in COFF files is repre sented in target width sized words For C54x this is 16 bits The target width is fixed and cannot be changed Phase III Phase II Phase I Output file s i e Intel Tektronix etc according to the specified format and are written to a fi...

Page 310: ...s like the C54x the memory width can be narrower than the target width The hex conversion utility defaults memory width to the target width in this case 16 bits You can change the memory width by Using the memwidth option This changes the memory width value for the entire file Setting the memwidth parameter of the ROMS directive This changes the memory width value for the address range specified i...

Page 311: ...dth in bits of each ROM device and corre sponding output file usually one byte or eight bits The ROM width deter mines how the hex conversion utility partitions the data into output files After the target words are mapped to the memory words the memory words are bro ken into one or more output files The number of output files is determined by the following formula where memory width wROM width num...

Page 312: ... ROM width except for TI Tagged by Using the romwidth option This changes the ROM width value for the entire COFF file Setting the romwidth parameter of the ROMS directive This changes the ROM width value for a specific ROM address range and overrides the romwidth option for that range See Section 10 5 The ROMS Directive on page 10 16 For both methods use a value that is a power of 2 greater than ...

Page 313: ...fixed Source file word 0AABBCDDh word 01122344h 01122h Data after phase I of hex500 Data after phase II of hex500 Data after phase III of hex500 memwidth 16 memwidth 8 AABB 11 22 AA BB 1122 Memory widths variable Output files romwidth 16 romwidth 8 romwidth 8 o file wrd AABB1122 o file b0 o file b1 AA 11 BB 22 o file byt BBAA2211 ...

Page 314: ...rower than target words memory width 16 tar get words are split into multiple consecutive memory words There are two ways to split a wide word into consecutive memory locations in the same hex conversion utility output file order MS specifies big endian ordering in which the most significant part of the wide word occupies the first of the consecutive locations order LS specifies little endian orde...

Page 315: ...t significant file but there is no ordering over the set When you list filenames for a set of files you always list the least significant first regard less of the order option Figure 10 6 demonstrates how order affects the conversion process This figure and the previous figure Figure 10 4 explain the condition of the data in the hex conversion utility output files Figure 10 6 Varying the Word Orde...

Page 316: ...name origin value length value romwidth value memwidth value fill value files filename1 filename2 romname origin value length value romwidth value memwidth value fill value files filename1 filename2 ROMS begins the directive definition PAGE identifies a memory space for targets that use program and data address spaces If your program has been linked nor mally PAGE 0 specifies program memory and PA...

Page 317: ...n bits see subsection 10 4 4 ROM Width on page 10 11 Any value you specify here overrides the romwidth option The value must be a decimal octal or hexadecimal constant that is a power of 2 greater than or equal to 8 memwidth specifies the memory width of the range in bits see subsection 10 4 3 Memory Width on page 10 10 Any value you specify here overrides the memwidth option The value must be a d...

Page 318: ...to Program large amounts of data into fixed size ROMs When you spe cify memory ranges corresponding to the length of your ROMs the utility automatically breaks the output into blocks that fit into the ROMs Restrict output to certain segments You can also use the ROMS direc tive to restrict the conversion to a certain segment or segments of the tar get address space The utility does not convert the...

Page 319: ...FFh The range contains the following sections This section Has this range text 4000h through 487Fh data 5B80H through 5FFFh The rest of the range is filled with 0h the default fill value The data from this range is converted into two output files rom4000 b0 contains bits 0 through 7 rom4000 b1 contains bits 8 through 15 EPROM2 defines the address range from 6000h through 7FFFh The range contains t...

Page 320: ...iles ÉÉÉÉ ÉÉÉÉ rom4000 b0 rom6000 b0 rom4000 b1 rom6000 b1 04000h org 06000h text data table text text data data table data 0FFh infile out memwidth 16 bits ÉÉÉÉ ÉÉÉÉ ÉÉÉÉ 0h ÉÉÉÉ ÉÉÉÉ ÉÉÉÉ 0h 04000h 0487Fh 05B80h 0633Fh 06700h 07C7Fh 04880h 05B80h 06340h 06700h 07C80h 07FFFh EPROM1 05FFFh ÉÉÉÉ ÉÉÉÉ 0FFh Output Files COFF File width 8 bits len 2000h 8K ÉÉÉÉ ÉÉÉÉ table data 0FFh ÉÉÉÉ ÉÉÉÉ 0FFh EPRO...

Page 321: ...roken down by address Following is a segment of the map file resulting from the example in Example 10 1 Example 10 2 Map File Output From Example 10 1 Showing Memory Ranges 00004000 00005fff Page 0 Width 8 EPROM1 OUTPUT FILES rom4000 b0 b0 b7 rom4000 b1 b8 b15 CONTENTS 00004000 0000487f text 00004880 00005b7f FILL 00000000 00005b80 00005fff data 00006000 00007fff Page 0 Width 8 EPROM2 OUTPUT FILES...

Page 322: ...don t use a SECTIONS directive the utility converts all initialized sections that fall within the configured memory The TMS320C54x compiler generated initialized sections include text const cinit and switch Uninitialized sections are never converted whether or not you specify them in a SECTIONS directive Note Sections Generated by the C Compiler The TMS320C54x C compiler automatically generates th...

Page 323: ...l address determined both by the target processor type and by the various boot loader specific command line options The commas separating section names are optional For more similarity with the linker s SECTIONS directive you can use colons after the section names in place of the equal sign on the boot keyboard For example the following statements are equivalent SECTIONS text data boot SECTIONS te...

Page 324: ...iles files on that range the utility takes the filename from the list For example assume that the target data is 16 bit words being converted to two files each eight bits wide To name the output files using the ROMS directive you could specify ROMS RANGE1 romwidth 8 files xyz b0 xyz b1 The utility creates the output files by writing the least significant bits LSBs to xyz b0 and the most significan...

Page 325: ...tive Ranges are numbered starting with 0 If there is no ROMS directive or only one range the utility omits this character c The file number in the set of files for the range starting with 0 for the least significant file For example assume coff out is for a 16 bit target processor and you are creating Intel format output With no output filenames specified the utility produces two output files name...

Page 326: ...es in the output file addresses Some EPROM programmers do not support address disconti nuities In image mode there are no discontinuities Each output file contains a contin uous stream of data that corresponds exactly to an address range in target memory Any gaps before between or after sections are filled with a fill value that you supply An output file converted by using image mode still has add...

Page 327: ...don t specify a value with the fill option The fill option is valid only when you use image otherwise it is ignored 10 8 3 Steps to Follow in Image Mode Step 1 Define the ranges of target memory with a ROMS directive See Section 10 5 The ROMS Directive on page 10 16 for details Step 2 Invoke the hex conversion utility with the image option To number the bytes sequentially use the byte option to re...

Page 328: ...ocation and the values for any control registers The hex conversion utility identifies the target device type from the COFF file builds a complete image of the table according to the format required by that device and converts it into hexadecimal in the output files Then you can burn the table into ROM or load it by other means The boot loader supports loading from memory that is narrower than the...

Page 329: ...e boot loader table e value Specify the entry point for the boot loader table b Options for C54xLP devices only Option Description bootorg WARM or warm Specify the source of the boot loader table as the table cur rently in memory bootorg COMM Specify the source of the boot loader table as the commu nications port spc value Set the serial port control register value spce value Set the serial port c...

Page 330: ...oading Or you can use a SECTIONS directive to select specific sections to be configured see Section 10 6 The SECTIONS Directive on page 10 22 Note that if you use a SECTIONS directive the boot option is ignored Step 3 Set the ROM address of the boot table Use the bootorg option to set the source address of the complete table For example if you are using the C54x and booting from memory location 80...

Page 331: ...d with the bootorg option Your selection of a keyword depends on the target device and the channel you want to use For example to boot a C54x from its serial port specify bootorg SERIAL on the command line or in a command file To boot a C54x from one of its parallel ports specify bootorg PARALLEL Note On Chip Boot Loader Concerns Possible memory conflicts When you boot from a device peripheral the...

Page 332: ...he specified address Your blocks follow this dummy block Since the dummy block is loaded first the dummy value of 0 is over written by the subsequent blocks Then the boot loader jumps to the e option address after the boot load is completed When using the bootorg WARM option the e option sets the address of where the boot table is loaded in ROM 10 9 6 Using the C54x Boot Loader This subsection exp...

Page 333: ...lity automatically builds the table in the correct format To boot from a serial port specify bootorg SERIAL when invoking the utility Use either memwidth 8 or memwidth 16 To load from a parallel I O port invoke the utility by specifying bootorg PARALLEL Use either memwidth 8 or memwidth 16 To boot from external memory EPROM specify the source address of the boot memory by using the bootorg option ...

Page 334: ... output file is a function of the load address as given in the linker command file and the hex conversion utility parameter values The rela tionship is summarized as follows out_file_addr load_addr data_width mem_width out_file_addr is the address of the output file load_addr is the linker assigned load address data_width is specified as 16 bits for the TMS320C54x devices See subsection 10 4 2 Dat...

Page 335: ...addresses of the data You must use the zero option in conjunction with the image option to force the starting address in each output file to be zero If you specify the zero option without the image option the utility issues a warning and ignores the zero option Boot Loader Mode When the boot loader is used the hex conversion utility places the different COFF sections that are in the boot table int...

Page 336: ...ogrammers may require the output file address field to contain a byte count rather than a word count If you use the byte option the output file address increments once for each byte For example if the starting address is 0h the first line contains eight words and you use no byte option the second line would start at address 8 8h If the starting address is 0h the first line contains eight words and...

Page 337: ...r will burn the data starting at location 0x0200 instead of 0x0100 To solve this you can Use the paddr parameter of the SECTIONS directive This forces a sec tion to start at the specified value Figure 10 9 shows a command file that can be used to avoid the hole at the beginning of sec1 Figure 10 9 Hex Command File for Avoiding a Hole at the Beginning of a Section i a out map a map ROMS ROM org 0x0...

Page 338: ...Conversion Formats Option Format Address Bits Default Width a ASCII Hex 16 8 i Intel 32 8 m1 Motorola S1 16 8 m2 or m Motorola S2 24 8 m3 Motorola S3 32 8 t TI Tagged 16 16 x Tektronix 32 8 Address bits determine how many bits of the address information the format supports Formats with 16 bit addresses support addresses up to 64K only The utility truncates target addresses to fit in the number of ...

Page 339: ...XX XX XX C Nonprintable start code Nonprintable end code Address Data byte The file begins with an ASCII STX character ctrl B 02h and ends with an ASCII ETX character ctrl C 03h Address records are indicated with AXXXX in which XXXX is a 4 digit 16 bit hexadecimal address The address records are present only in the following situations When discontinuities occur When the byte stream does not begin...

Page 340: ...receding bytes in the record including byte count address and data bytes Record type 01 the end of file record also begins with a colon followed by the byte count the address the record type 01 and the checksum Record type 04 the extended linear address record specifies the upper 16 address bits It begins with a colon followed by the byte count a dummy address of 0h the record type 04 the most sig...

Page 341: ... record for 32 bit addresses S3 format S8 Termination record for 24 bit addresses S2 format S9 Termination record for 16 bit addresses S1 format The byte count is the character pair count in the record excluding the type and byte count itself The checksum is the least significant byte of the 1s complement of the sum of the values represented by the pairs of characters making up the byte count addr...

Page 342: ...e 10 13 illustrates the tag characters and fields in TI Tagged object format Figure 10 13 TI Tagged Object Format K000COFFTOTI90000BFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFF7EF3DF BFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFF7EE37F BFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFF7F245F Tag characters Program identifier Load address Data words Checksum Data records End of f...

Page 343: ... the record minus the Block type 1 6 data record 8 termination record Checksum 2 A 2 digit hex sum modulo 256 of all values in the record except the and the checksum itself The load address in the data record specifies where the object code will be located The first digit specifies the address length this is always 8 The remaining characters of the data record contain the object code two charac te...

Page 344: ... the hex conversion utility when memory width is less than data width See Section 10 4 Understanding Memory Widths on page 10 9 and Section 10 10 Controlling the ROM Device Address on page 10 34 unconfigured memory error Description This error could have one of two causes J The COFF file contains a section whose load address falls outside the memory range defined in the ROMS directive J The boot l...

Page 345: ...onverts assembly code written in the mnemonic instruction set to code written in the algebraic instruction set Topic Page 11 1 Translator Overview 11 2 11 2 Translator Development Flow 11 3 11 3 Invoking the Translator 11 4 11 4 Translation Modes 11 5 11 5 How the Translator Works With Macros 11 8 Chapter 11 ...

Page 346: ...nslator accomplishes the following Replaces a mnemonic with an algebraic representation of what the instruction does as defined by the language specifications The algebraic representation might consist of more than one line of code Reformats mnemonic instruction operands into algebraic syntax as de scribed in the language specifications This reformatting includes the following J Data memory addres...

Page 347: ...r algebraic syntax Figure 11 1 Translator Development Flow Assembler Linker Macro library Library of object files Hex conversion utility EPROM programmer Assembler source COFF object files Archiver Macro source files Archiver C source files C54x Executable COFF file C compiler Library build utility Cross reference lister Absolute lister Debugging tools Runtime support library Mnemonic to algebraic...

Page 348: ...e command that invokes the translator option specifies the translator mode see Section 11 4 Translation Modes on page 11 5 The options are t Literal mode which is the default if no option is specified e Expansion mode inputfile names the assembly source file you want to translate If you do not specify an extension asm is assumed ...

Page 349: ...bols When the translator does not recognize a macro invocation or instruction it prints a message to standard output and does not translate the code The translator creates a file with the same name as the assembler source file and an extension of cnv Figure 11 2 Literal Mode Process menm2alg filename asm Command Translator Converted file filename cnv Translation 11 4 2 About Symbol Names in Litera...

Page 350: ...xecutable version must be 1 11 or above If the assembler encounters errors during pre processing the translator aborts and no output is produced Figure 11 3 Expansion Mode Process menm2alg e filename asm Command Translator Converted file filename cnv Translation Assembly with switch Assembler filename exp Intermediate file The following example demonstrates how expansion mode works In the intermed...

Page 351: ... parm2 ADD sym 5 parm2 B endm mymac sym A b Intermediate code file exp after preprocessing before translation asg AR0 sym mymac macro parm1 parm2 LD parm1 parm2 ADD sym 5 parm2 B endm mymac sym A LD AR0 A ADD AR0 5 A B c Converted code file cnv after translation asg AR0 sym mymac macro parm1 parm2 LD parm1 parm2 ADD sym 5 parm2 B endm mymac sym A A AR0 B A AR0 5 ...

Page 352: ...es in Macros When macro invocations are expanded directives in macro definitions are not copied to the intermediate file Instead the macro is inlined and the code is no longer in a macro environment The following source code preprocesses to the intermediate code as shown Example 11 3 Directives in Macros a Source code mymac macro parm1 var temp eval parm1 temp word temp endm mymac 5 b Intermediate...

Page 353: ...e preprocesses to the intermediate code as shown Example 11 4 Macro Local Variables a Source code mymac macro parm1 lab word parm1 endm mymac 4 mymac 40 mymac 400 b Intermediate code mymac macro parm1 lab word parm1 endm mymac 4 lab 1 word 4 mymac 40 lab 2 word 40 mymac 400 lab 3 word 400 The local label name is appended with n where n is the number of the macro invocation Insure that there are no...

Page 354: ...owing source code preprocesses to the intermediate code as shown Figure 11 4 Defining Labels a Source code mymac macro word F403 endm LABEL mymac b Intermediate code mymac macro word F403 endm LABEL mymac word F403 LABEL is not defined when the code is assembled Insure that label definitions do not appear on the same line as the macro invocations Rewrite the source code in the example above as fol...

Page 355: ...n to Common Object File Format discusses COFF sections in de tail If you understand section operation you will be able to use the assembly language tools more efficiently This appendix contains technical details about COFF object file structure Much of this information pertains to the symbolic debugging information that is produced by the C compiler The purpose of this appendix is to provide sup p...

Page 356: ...ct File Structure The assembler and linker produce object files with the same COFF structure however a program that is linked for the final time does not usually contain relocation entries Figure A 1 illustrates the overall object file structure Figure A 1 COFF File Structure file header optional file header section 1 header section n header section 1 raw data section n raw data section 1 relocati...

Page 357: ...ers notice that they have no raw data relocation information or line number entries This is because the bss and usect directives simply reserve space for uninitialized data uninitialized sections contain no actual code Figure A 2 COFF Object File file header text section header data section header bss section header named section section header text raw data data raw data named section raw data te...

Page 358: ...wapped The raw data in the COFF files does not need any changes The C54x development tools can detect the difference in the file headers and automatically compensate for it This is true if using only C54x development tools To tell the difference between COFF files you can look at the magic number in the optional file header Bytes 0 and 1 contain the magic number For the SunOStor HP UXtoperating sy...

Page 359: ...if it is 0 then there is no optional file header 18 19 Unsigned short integer Flags see Table A 2 20 21 Unsigned short integer Target id magic number indicates the file can be executed in a TMS320C54x system Table A 2 lists the flags that can appear in bytes 18 and 19 of the file header Any number and combination of these flags can be set at the same time for example if bytes 18 and 19 are set to ...

Page 360: ...e A 3 Optional File Header Contents Byte Number Type Description 0 1 Short integer Magic number for SunOS or HP UX it is 108h for DOS it is 801h 2 3 Short integer Version stamp 4 7 Long integer Size in words of executable code 8 11 Long integer Size in words of initialized words 12 15 Long integer Size in words of uninitialized data 16 19 Long integer Entry point 20 23 Long integer Beginning addre...

Page 361: ...a 24 27 Long integer File pointer to relocation entries 28 31 Long integer File pointer to line number entries 32 33 Unsigned short integer Number of relocation entries 34 35 Unsigned short integer Number of line number entries 36 37 Unsigned short integer Flags see Table A 6 38 Character Reserved 39 Character Memory page number Table A 5 Section Header Contents for COFF2 Files Byte Type Descripti...

Page 362: ...d STYP_GROUP 0004h Grouped section formed from several input sections STYP_PAD 0008h Padding section loaded not allocated not relocated STYP_COPY 0010h Copy section relocated loaded but not allocated relo cation and line number entries are processed normally STYP_TEXT 0020h Section that contains executable code STYP_DATA 0040h Section that contains initialized data STYP_BSS 0080h Section that cont...

Page 363: ... 28 31 32 33 34 35 36 37 38 39 As Figure A 2 on page A 3 shows uninitialized sections created with the bss and usect directives vary from this format Although uninitialized sections have section headers they have no raw data relocation information or line number information They occupy no actual space in the object file Therefore the number of relocation entries the number of line number en tries ...

Page 364: ...rrent section before relo cation it specifies where a relocation must occur This is the address of the field in the object code that must be patched Following is an example of code that generates a relocation entry 0002 global X 0003 0000 FF80 B X 0001 0000 In this example the virtual address of the relocatable field is 0001 The symbol table index is the index of the referenced symbol In the prece...

Page 365: ...sing mode that was used to generate the relocatable reference In the preceding example the actual address of the referenced symbol X will be placed in a 16 bit field in the object code This is a 16 bit direct relocation so the relocation type is R_RELWORD Table A 8 lists the relocation types Table A 8 Relocation Types Bytes 8 and 9 Mnemonic Flag Relocation Type R_ABS 0000h No relocation R_RELBYTE ...

Page 366: ...ries it points to a symbol entry in the symbol table 2 If it is not the first entry in a block it is the physical ad dress of the line indicated by bytes 4 5 4 5 Unsigned short integer This entry may have one of two values 1 If this field is 0 this is the first line of a function entry 2 If this field is not 0 this is the line number of a line in C source code Figure A 4 shows how line number entr...

Page 367: ... The first portion on XYZ s block of line number entries points to the function name in the symbol table Assume that the original function in the C source contained three lines of code The first line of code produces 4 words of assembly lan guage code the second line produces 3 words and the third line produces 10 words Figure A 5 Line Number Entries 0 1 2 3 0 4 7 XYZ line number entries symbol ta...

Page 368: ... function 1 function 2 local symbols for function 2 filename 2 function 1 local symbols for function 1 static variables defined global symbols undefined global symbols Static variables refer to symbols defined in C that have storage class static out side any function If you have several modules that use symbols with the same name making them static confines the scope of each symbol to the module t...

Page 369: ... A 10 Each symbol may also have an 18 byte auxiliary entry the special symbols listed in Table A 11 on page A 16 always have an auxiliary entry Some symbols may not have all the characteristics listed above if a par ticular field is not set it is set to null Table A 10 Symbol Table Entry Contents Byte Number Type Description 0 7 Character This field contains one of the following 1 An 8 character s...

Page 370: ...y a function nfake Dummy tag name for a structure union or enumeration eos End of a structure union or enumeration etext Next available address after the end of the text output section edata Next available address after the end of the data output section end Next available address after the end of the bss output section Several of these symbols appear in pairs bb eb indicate the beginning and end ...

Page 371: ... in the symbol table Figure A 7 Symbols for Blocks bb symbols for block 1 eb bb symbols for block 2 eb Symbol Table Block 1 Block 2 A 7 1 2 Symbols and Functions The symbol definitions for a function appear in the symbol table as a group delineated by bf ef special symbols The symbol table entry for the function name precedes the bf special symbol FigureA 8 shows the format of symbol table entries...

Page 372: ...ymbol names that are longer than eight characters are stored in the string table The field in the symbol table entry that would normally contain the sym bol s name contains instead a pointer to the symbol s name in the string table Names are stored contiguously in the string table delimited by a null byte The first four bytes of the string table contain the size of the string table in bytes thus o...

Page 373: ...numeration tag C_REG 4 Register variable C_MOE 16 Member of an enumeration C_EXTDEF 5 External definition C_REGPARM 17 Register parameter C_LABEL 6 Label C_FIELD 18 Bit field C_ULABEL 7 Undefined label C_BLOCK 100 Beginning or end of a block used only for the bb and eb special symbols C_MOS 8 Member of a structure C_FCN 101 Beginning or end of a func tion used only for the bf and ef special symbol...

Page 374: ...O Stack offset in bits C_UNTAG 0 C_EXT Relocatable address C_TPDEF 0 C_STAT Relocatable address C_ENTAG 0 C_REG Register number C_MOE Enumeration value C_LABEL Relocatable address C_REGPARM Register number C_MOS Offset in bits C_FIELD Bit displacement C_ARG Stack offset in bits C_BLOCK Relocatable address C_STRTAG 0 C_FCN Relocatable address C_MOU Offset in bits C_FILE 0 If a symbol s storage clas...

Page 375: ... the numbering of named sections would begin with 1 If a symbol has a section number of 0 1 or 2 it is not defined in a section A section number of 2 indicates a symbolic debugging symbol which includes structure union and enumeration tag names type definitions and the filename A section number of 1 indicates that the symbol has a value but is not relocatable A section number of 0 indicates a relo...

Page 376: ...eration T_UCHAR 12 Unsigned character T_USHORT 13 Unsigned short integer Bits 4 15 of the type field are arranged as six 2 bit fields that can indicate one to six derived types Table A 17 lists the possible derived types Table A 17 Derived Types Mnemonic Value Type DT_NON 0 No derived type DT_PTR 1 Pointer DT_FCN 2 Function DT_ARY 3 Array An example of a symbol with several derived types would be ...

Page 377: ... T_NULL End of structure see Table A 22 fcname C_EXT C_STAT DT_FCN See note 1 Function see Table A 23 arrname See note 2 DT_ARY See note 1 Array see Table A 24 bb eb C_BLOCK DT_NON T_VOID Beginning and end of a block see Table A 25 and Table A 26 bf ef C_FCN DT_NON T_VOID Beginning and end of a function see Table A 25 and Table A 26 Name related to a structure union or enumeration See note 2 DT_PT...

Page 378: ...at for Auxiliary Table Entries Byte Number Type Description 0 3 Long integer Section length 4 6 Unsigned short integer Number of relocation entries 7 8 Unsigned short integer Number of line number entries 9 17 Not used zero filled A 7 8 3 Tag Names Table A 21 illustrates the format of auxiliary table entries for tag names Table A 21 Tag Name Format for Auxiliary Table Entries Byte Number Type Desc...

Page 379: ...ex 4 5 Unused zero filled 6 7 Unsigned short integer Size of structure union or enumeration 8 17 Unused zero filled A 7 8 5 Functions Table A 23 illustrates the format of auxiliary table entries for functions Table A 23 Function Format for Auxiliary Table Entries Byte Number Type Description 0 3 Long integer Tag index 4 7 Long integer Size of function in bits 8 11 Long integer File pointer to line...

Page 380: ...9 Unsigned short integer First dimension 10 11 Unsigned short integer Second dimension 12 13 Unsigned short integer Third dimension 14 15 Unsigned short integer Fourth dimension 16 17 Unused zero filled A 7 8 7 End of Blocks and Functions Table A 25 illustrates the format of auxiliary table entries for the ends of blocks and functions Table A 25 End of Blocks Functions Format for Auxiliary Table E...

Page 381: ...ce line number 6 11 Unused zero filled 12 15 Long integer Index of next entry past this block 16 17 Unused zero filled A 7 8 9 Names Related to Structures Unions and Enumerations Table A 27 illustrates the format of auxiliary table entries for the names of structures unions and enumerations Table A 27 Structure Union and Enumeration Names Format for Auxiliary Table Entries Byte Number Type Descrip...

Page 382: ...nu meration or union definition The func and endfunc directives specify the beginning and ending lines of a C function The block and endblock directives specify the bounds of C blocks The file directive defines a symbol in the symbol table that identifies the current source file name The line directive identifies the line number of a C source statement These symbolic debugging directives are not u...

Page 383: ...the location in the source file where the block is defined Block definitions can be nested The assembler will detect improper block nesting Example Following is an example of C source that defines a block and the resulting assembly language code C source Beginning of a block int a b a b End of a block Resulting assembly language code block 8 sym _a 2 4 1 16 sym _b 3 4 1 16 line 9 LD SP 3 A cycle 3...

Page 384: ... source file The filename is the name of the file that contains the original C source program The first 14 characters of the filename are significant You can also use the file directive in assembly code to provide a name in the file and improve program readability Example In the following example the filename text c contained the C source that pro duced this directive file text c ...

Page 385: ... a C func tion The line numbers are optional they specify the location in the source file where the function is defined Function definitions cannot be nested Example Following is an example of C source that defines a function and the resulting assembly language code C source power x n Beginning of a function int x n int i p p 1 for i 1 i n i p p x return p End of function ...

Page 386: ...01 28 line 6 29 000005 7601 ST 1 SP 1 000006 0001 30 000007 f7b8 SSBX SXM 31 000008 f495 nop 32 000009 1004 LD SP 4 A 33 00000a 0801 SUB SP 1 A 34 00000b f843 BC L3 ALT 00000c 0018 35 branch occurs 36 00000d L2 37 line 7 38 00000d 4400 LD SP 0 16 A 39 00000e 3102 MPYA SP 2 40 00000f 8102 STL B SP 2 41 line 6 42 000010 6b01 ADDM 1 SP 1 000011 0001 43 000012 f7b8 SSBX SXM 44 000013 f495 nop 45 00001...

Page 387: ...e Example The line directive is followed by the assembly language source statements that are generated by the indicated line of C source For example assume that the lines of C source below are line 4 and 5 in the original C source line 5 produces the assembly language source statements that are shown below C source for i 1 i n i p p x Resulting assembly language code 31 line 7 32 00000d 4400 LD SP...

Page 388: ...is the number of bits of memory required to contain this member Tag is the name of the type if any or structure of which this member is a type This name must have been previously declared by a stag etag or utag directive Dims may be one to four expressions separated by commas This allows up to four dimensions to be specified for the member The order of parameters is significant The name and value ...

Page 389: ... union occupies in memory This is an optional parameter if omitted the size is unspeci fied The stag etag or utag directive should be followed by a number of member directives which define members in the structure The member directive is the only directive that can appear inside a structure enumeration or union definition The assembler does not allow nested structures enumerations or unions The C ...

Page 390: ... char valc valu Resulting assembly language code utag _u_tag 32 member _val1 0 4 11 16 member _val2 0 6 11 32 member _valc 0 2 11 16 eos Example 3 Following is an example of an enumeration definition C Source enum o_ty reg_1 reg_2 result optypes Resulting assembly language code etag _o_ty 16 member _reg_1 0 4 16 16 member _reg_2 1 4 16 16 member _result 2 4 16 16 eos ...

Page 391: ...ge classes Size is the number of bits of memory required to contain this variable Tag is the name of the type if any or structure of which this variable is a type This name must have been previously declared by a stag etag or utag directive Dims may be up to four expressions separated by commas This allows up to four dimensions to be specified for the variable The order of parameters is significan...

Page 392: ...tives Resulting assembly language code global _array bss _array 50 0 0 sym _array _array 244 2 800 5 10 global _ptr bss _ptr 1 0 0 sym _ptr _ptr 21 2 16 global _str bss _str 2 0 0 sym _str _str 8 2 32 _s global _ext bss _ext 1 0 0 sym _ext _ext 4 2 16 ...

Page 393: ...configure the EPROM system and the requirements of the EPROM programmer you will find that converting a file for a specific application is easy Topic Page C 1 Base Code for the Examples C 2 C 2 Example 1 Building a Hex Command File for Two 8 Bit EPROMs C 3 C 3 Example 2 Avoiding Holes With Multiple Sections C 8 C 4 Example 3 Generating a Boot Table C 10 C 5 Example 4 Generating a Boot Table for LP...

Page 394: ... for multiple EPROM memory systems avoid holes and generate a boot table The first two examples use the assembly code shown in Example C 1 Example C 1 Assembly Code for Hex Conversion Utility Examples Assemble two words into section sec1 sect sec1 word 1234h word 5678h Assemble two words into section sec2 sect sec2 word 0aabbh word 0ccddh end ...

Page 395: ...e at physical EPROM address 0x0010 rather than the address specified by the linker 0x1400 The circuitry of the target board handles the translation of this address space The paddr parameter allo cates a section and burns the code at EPROM address 0x0010 The paddr parameter is specified within the SECTIONS directive see Section 10 6 The SECTIONS Directive on page 10 22 for details If you use the pa...

Page 396: ... the following system require ments EPROM system memory width must be 16 bits ROM1 contains the upper 8 bits of a word ROM0 contains the lower 8 bits of a word The hex conversion utility must locate code starting at EPROM address 0x0010 Intel format must be used Byte increment must be selected for addresses in the hex conversion utility output file memory width is the default Use the following opt...

Page 397: ...he selected options Example C 3 A Hex Command File for Two 8 Bit EPROMs test out COFF object input file map example1 mxp Set parameters for EPROM programmer i Select Intel format byte Select byte increment for addresses Set options required to describe EPROM memory system memwidth 16 Set EPROM system memory width romwidth 8 Set physical width of ROM device ROMS PAGE 0 EPROM origin 0x00 length 0x10...

Page 398: ... Bits Data from converted output file 040010003478BBDDA8 00000001FF Corresponding map in EPROM ROM0 See Example C 1 on page C 2 0x0010 DD BB 78 34 b upp8 bit Upper Bits Data from converted output file 040010001256AACC0E 00000001FF Corresponding map in EPROM ROM1 See Example C 1 on page C 2 0x0010 CC AA 56 12 ...

Page 399: ... shown in Example C 4 Example C 4 Map File Resulting From Hex Command File in Example C 3 on page C 5 TMS320C54x COFF Hex Converter Version x xx Fri Oct 11 15 10 53 1998 INPUT FILE NAME test out OUTPUT FORMAT Intel PHYSICAL MEMORY PARAMETERS Default data width 16 Default memory width 16 Default output width 8 OUTPUT TRANSLATION MAP 00000000 0000ffff Page 0 Memory Width 16 ROM Width 8 EPROM OUTPUT ...

Page 400: ...the output file address field You must ensure that the section addresses do not overlap Example C 5 a shows a linker command file for this method The linker should be executed with this command file then the hex conversion utility should be executed with the set of commands shown in Example C 5 b Link the sections together into one output section for conversion Example C 6 a shows a linker command...

Page 401: ...NS sec1 paddr 0x0000 sec2 paddr 0x0004 Example C 6 Method Two for Avoiding Holes a Linker command file SPECIFY THE SYSTEM MEMORY MAP MEMORY PAGE 0 DARAM org 0x0080 length 0x1370 EXT org 0x1400 length 0xEB80 SECTIONS outsec sec1 sec2 EXT PAGE 0 b Hex command file i test out map example mxp ROMS PAGE 0 ROM org 0x0100 length 0x0800 romwidth 8 memwidth 8 files examp2_2 hex SECTIONS outsec paddr 0x100 ...

Page 402: ...ee Section C 5 Example 4 Generating a Boot Table for LP Core Devices on page C 17 Example C 7 C Code for Example 3 int array 1 2 3 4 main array 0 5 Figure C 3 shows the EPROM memory system for which the output file will be generated In this application the single C54x device is booted from a 128K 8 bit EPROM The requirement of the system is that the boot table must reside at EPROM memory address 0...

Page 403: ...outine c_int00 defined in boot asm to load and run initializing the C environment and branching to the main function in the applications code The text and cinit sections must be linked together as a single section in the linker command file The cinit section contains the initialization data and tables for all global or static C symbols that were declared with an initial value i e int x 5 Note that...

Page 404: ... 01000h SECTIONS boot_sec text Set start address for C init table cinit Include all cinit sections cinit Reserve a single space for the zero word to mark end of C init 1 fill 0x0000 Make sure fill value is 0 load PROG PAGE 0 data DATA PAGE 1 bss DATA PAGE 1 const DATA PAGE 1 sysmem DATA PAGE 1 stack DATA PAGE 1 Example C 9 shows a portion of the map file generated when the linker is executed with ...

Page 405: ...exit obj data 00000080 00000000 boot obj data bss 1 00000080 00000025 UNINITIALIZED 00000080 00000004 boot obj bss 00000084 00000000 rts lib boot obj bss 00000084 00000021 exit obj bss const 1 00000080 00000000 UNINITIALIZED sysmem 1 00000080 00000000 UNINITIALIZED stack 1 000000a5 00000400 UNINITIALIZED 000000a5 00000000 rts lib boot obj stack GLOBAL SYMBOLS address name address name 00000080 bss...

Page 406: ...ex conversion utility has options that describe the requirements for the EPROM programmer and options that describe the EPROM memory system For Example 3 assume that the EPROM programmer has only one require ment that the hex file be in Intel format In the EPROM memory system illustrated in Figure C 3 on page C 10 the EPROM system memory width is 8 bits and the physical ROM width is 8 bits You mus...

Page 407: ...ical ROM width boot Make all sections bootable bootorg 0x0000 Place boot table in EPROM starting at address 0x0000 ROMS PAGE 0 ROM origin 0x0000 length 0x20000 In Example 3 memory width and ROM width are the same therefore the hex conversion utility creates a single output file The number of output files is determined by the ratio of memwidth to romwidth Example C 11 shows the map file boot2 map r...

Page 408: ... file boot hex resulting from the command file in Example C 10 is shown in Example C 12 Example C 12 Hex Conversion Utility Output File Resulting From the Command File in Example C 10 200000001400007976F800800005FC00771800A66BF8001803FF68F80018FFFEF7B8F7BED9 20002000F4A0F6B7F6B5F6B6F020146DF1000001F84D142BF07314257EF80012F00000010C 2000400047F800117E9200F80011F00000017EF80011F00000016C89141AF07414...

Page 409: ...sed in this section is shown in Example C 1 on page C 2 Note This example is for C54xLP devices only For non LP C54x devices see Section C 4 Example 3 Generating a Boot Table on page C 10 Example C 13 C Code for a C54xLP int array 1 2 3 4 main array 0 5 Figure C 4 shows the EPROM memory system for which the output file will be generated In this application the single C54xLP device is booted from a...

Page 410: ...l or static C symbols that were declared with an initial value i e int x 5 Note that the linker handles the cinit section differently than the other sections When the linker encounters a cinit section specified as an output section in the link it automatically Sets the symbol cinit to point to the start of the included cinit section Appends a single word to the end of the section This last word co...

Page 411: ...GE 1 stack DATA PAGE 1 Example C 15 shows the map file generated when the linker is executed with the command file in Example C 14 Linking with this command file creates a COFF file you use as input to the hex conversion utility to build the desired boot table Example C 15 Section Allocation Portion of Map File Resulting From the Command File in Example C 14 OUTPUT FILE NAME c54xlp out ENTRY POINT...

Page 412: ...ED 00000080 00000004 c54xlp obj bss 00000084 00000000 rts lib boot obj bss 00000084 00000022 exit obj bss const 1 00000080 00000000 UNINITIALIZED sysmem 1 00000080 00000000 UNINITIALIZED stack 1 000000a6 00000400 UNINITIALIZED 000000a6 00000000 rts lib boot obj stack GLOBAL SYMBOLS address name address name 00000080 bss 00000001 __lflags 00000080 data 00000080 _array 00001400 text 00000080 data 00...

Page 413: ...emory system illustrated in Figure C 4 on page C 17 the EPROM system memory width is 8 bits and the physical ROM width is 8 bits The following options are selected to reflect the requirements of the system Option Description i Create Intel format memwidth 8 Set EPROM system memory width to 8 romwidth 8 Set physical ROM width to 8 Because the application requires the building of a boot table for pa...

Page 414: ... Set physical ROM width boot Make all sections bootable bootorg 0x0000 Place boot table in EPROM starting at address 0x0000 ROMS PAGE 0 ROM origin 0x0000 length 0x20000 In Example 4 memory width and ROM width are the same therefore the hex conversion utility creates a single output file The number of output files is determined by the ratio of memwidth to romwidth Example C 17 shows the map file c5...

Page 415: ...00002 The hex conversion utility output file c54xlp hex resulting from the command file in Example C 16 is shown in Example C 18 Example C 18 Hex Conversion Utility Output File Resulting From the Command File in Example C 16 2000000008AA7FFFF800FFFFFFFF006C0000140076F800800005FC00771800A66BF800189D 2000200003FF68F80018FFFEF7B8F7BEF4A0F6B7F6B5F6B6F020146DF1000001F84D142B46 20004000F07314257EF80012F...

Page 416: ...rom the description to inspect and correct your code the Action is omitted When the assembler completes its second pass it reports any errors that it encountered during the assembly It also prints these errors in the listing file if one is created an error is printed following the source line that incurred it Most assembler errors are fatal errors If an error is not fatal or if it is a macro error...

Page 417: ...ratory Illegal specification of tag identifier Invalid specification of attribute value Left parenthesis expected Left parenthesis is missing Location description block required Matching right parenthesis is missing Missing comma Missing left parenthesis Missing opening brace Missing right bracket for block specification Missing right parenthesis Missing right parenthesis for value specification M...

Page 418: ...cro or directive specified was not recognized Action Check the directive or instruction used Invalid instruction for specified processor version Description The indicated instruction is not allowed for the processor ver sion specified with the version directive Action Check the instruction and version directive E0003 Cluttered character operand encountered Cluttered string constant operand encount...

Page 419: ...ant specified Invalid Operand 2 Invalid operand x Invalid shift value Make sure that the label name is not a reserved keyword Must add AR0 to destination Must subtract AR0 from destination Operand must be the A accumulator Operand must be the B accumulator Section is not defined Shift value must be 16 Shift value out of range Syntax error Operand nnn The accumulator arguments must be the same The ...

Page 420: ...ing constant operand specified Illegal structure reference Incorrect bit symbol for specified status register Invalid data size for relocation Invalid float constant specified Invalid identifier sym specified Invalid macro parameter specified Invalid operand char Must add to the destination operand No parameters available for macro arguments Not expecting direct operand op Not expecting indirect o...

Page 421: ...bout missing operands a required oper and is not supplied Action Correct the source so that all required operands are declared E0006 break must occur within a loop Conditional assembly mismatch Matching endloop missing Matching macro missing No matching if specified No matching endif specified No matching endloop specified No matching loop specified Open block s inside macro Unmatched endloop dire...

Page 422: ...nce a directive was encountered that requires a matching directive but the assembler could not find the matching directive Action Check the source for mismatched structure definition direc tives and correct E0009 Cannot apply bitwise NOT to floats Illegal struct union reference dot operator Missing structure union member or tag Section name is not an initialized section Structure or union tag symb...

Page 423: ...rors about invalid labels The given directive does not permit a label but one is specified Description Remove the invalid label E0102 Local label number defined differently in each pass Local label number is multiply defined Local label number is not defined in this section Local labels can t be used with directives The accumulator operands must be different Description These are errors about the ...

Page 424: ...rors about general expressions An illegal oper and combination was used or an arithmetic type is required but not present Action Correct the source per the error message text E0201 Absolute operands required for FP operations Cannot apply bitwise NOT to floats Floating point divide by zero Floating point overflow Floating point underflow Floating point expression required Illegal floating point ex...

Page 425: ...ref and def Structure union member sym not found The following symbols are undefined Union member previously defined Union tag can t be global Description These are errors about general symbols An attempt was made to redefine a symbol or to define a symbol illegally Action Correct the source per the error message text E0301 Cannot redefine local substitution symbol Substitution Stack Overflow Subs...

Page 426: ...iables declared in macro Description These are errors about general macros A macro definition was probably corrupted Action Correct the source per the error message text E0501 Macro definition not terminated with endm Matching endm missing Matching macro missing mexit directive outside macro definition No active macro definition Description These are errors about macro definition directives A macr...

Page 427: ...that the macro name and member name are the same and the extension of the file is asm E0700 Illegal structure union member No structure union currently open sym not allowed inside structure union Description These are errors about the illegal use of symbolic debugging directives a symbolic debugging directive is not used in an appropriate place Action Correct the source per the error message text ...

Page 428: ...after 1st instruction Cannot change parsing mode after 1st instruction Can t include a file inside a loop or macro Illegal structure member Illegal structure definition contents Illegal union member Illegal union definition contents Invalid load time label Invalid structure union contents setsect only valid if absolute listing produced use a option setsym only valid if absolute listing produced us...

Page 429: ... arguments are limited to 32 parameter Macro nesting is limited to 32 levels Action Check the source to determine how limits have been exceeded W0000 Ambiguous assignment Invalid page number specified ignored No operands expected Operands ignored Trailing operands ignored Unrecognized operand ignored ARn addressing is for write only Description These are warnings about operands The assembler encou...

Page 430: ...nstruction opcode or the required number of bits Action Check the source to make sure the result will be acceptable or change the source if an error has occurred W0002 Address expression will wrap around Expression will overflow value truncated Description These are warnings about arithmetic expressions The assembler has done a calculation that will produce the indicated result which may or may no...

Page 431: ...at in hexadecimal all powers of 2 consist of the integers 1 2 4 or 8 followed by a series of zero or more 0s alignment for redefined Description More than one alignment is supplied for a section attempt to decrement DOT Description A statement such as value is supplied this is illegal Assignments to dot can be used only to create holes B bad fill value Description The fill value must be a 16 bit c...

Page 432: ...this requirement blocking for must be a power of 2 Description Section blocking is not a power of 2 Action Make sure that in hexadecimal all powers of 2 consist of the integers 1 2 4 or 8 followed by a series of zero or more 0s blocking for redefined Description More than one blocking value is supplied for a section C c requires fill value of 0 in cinit overridden Description The cinit tables must...

Page 433: ...ng only can t align a section within GROUP not aligned Description A section in a group was specified for individual alignment The entire group is treated as one unit so the group may be aligned or bound to an address but the sections making up the group cannot be handled individually can t align within UNION section not aligned Description A section in a union was specified for individual alignme...

Page 434: ...Action Check spelling pathname environment variables etc The filename must conform to operating system conventions can t open filename Description The specified file does not exist Action Check spelling pathname environment variables etc The filename must conform to operating system conventions can t read Description The file may be corrupt Action If the input file is corrupt try reassembling it c...

Page 435: ...at _c_int00 is the one and only entry point entry point symbol undefined Description The symbol used with the e option is not defined errors in input not built Description Previous errors prevent the creation of an output file F fail to copy Description The file may be corrupt Action If the input file is corrupt try reassembling it fail to read Description The file may be corrupt Action If the inp...

Page 436: ...s of unknown type magic number Description The binary input file is not a COFF file fill value for redefined Description More than one fill value is supplied for an output section Indi vidual holes can be filled with different values with the section definition I i path too long Description The maximum number of characters in an i path is 256 illegal input character Description There is a control ...

Page 437: ...e archive file is corrupt invalid path specified with i flag Description The operand of the i option flag is not a valid file or path name invalid value for f flag Description The value for f option flag is not a 2 byte constant invalid value for heap flag Description The value for heap option flag is not a 2 byte constant invalid value for stack flag Description The value for stack option flag is...

Page 438: ...tion ignored Description A load address is supplied for an uninitialized section Unini tialized sections have no load addresses only run address es load address for UNION ignored Description UNION refers only to the section s run address load allocation required for initialized UNION member Description A load address is supplied for an initialized section in a union UNIONs refer to runtime allocat...

Page 439: ...le check that MEMORY and SECTIONS directives allow enough room to ensure that no sections are being placed in unconfigured memory missing filename on l use l filename Description No filename operand is supplied for the l lowercase L option misuse of DOT symbol in assignment instruction Description The symbol is used in an assignment statement that is out side the SECTIONS directive N no allocation...

Page 440: ... run address Description No load address is supplied for an initialized section If an ini tialized section has a run address only the section is allo cated to run and load at the same address no run allocation allowed for union member Description A UNION defines the run address for all of its members there fore individual run allocations are illegal no string table in file filename Description The...

Page 441: ...tput file has no bss section Description This is a warning The bss section is usually present in a COFF file There is no requirement for it to be present output file has no data section Description This is a warning The data section is usually present in a COFF file There is no requirement for it to be present output file has no text section Description This is a warning The text section is usuall...

Page 442: ...he input file is corrupt try reassembling it relocation symbol not found index section file Description The input file may be corrupt Action If the input file is corrupt try reassembling it S section at overlays at address Description Two sections overlap and cannot be allocated Action If you are using a linker command file check that MEMORY and SECTIONS directives allow enough room to ensure that...

Page 443: ...ons are being placed in unconfigured memory seek to failed Description The input file may be corrupt Action If the input file is corrupt try reassembling it semicolon required after assignment Description There is a syntax error in the command file statement ignored Description There is a syntax error in an expression symbol referencing errors not built Description Symbol references could not be r...

Page 444: ...s not allowed for GROUP or UNION Description A type is specified for a section in a group or union Special section types apply to individual sections only U u does not specify a legal symbol name Description The u option did not specify a legal symbol name that exists in one of the files that you are linking unexpected EOF end of file Description There is a syntax error in the linker command file ...

Page 445: ...escription An assignment statement contains an undefined symbol unrecognized option Action Check the list of valid options Z zero or missing length for memory area Description A memory range defined with the MEMORY directive did not have a nonzero length ...

Page 446: ...rocess in which the linker calculates the final memory addresses of output sections archive library A collection of individual files that have been grouped into a single file archiver A software program that allows you to collect several individual files into a single file called an archive library The archiver also allows you to delete extract or replace members of the archive library as well as ...

Page 447: ...urce statements into assembly language source statements COFF Common object file format A binary object file format that promotes modular programming by supporting the concept of sections command file A file that contains options filenames directives or com ments for the linker or hex conversion utility comment A source statement or portion of a source statement that is used to document or improve...

Page 448: ... of constants and symbols separated by arithmetic operators external symbol A symbol that is used in the current program module but is defined in a different program module F field For the TMS320C54x a software configurable data type whose length can be programmed to be any value in the range of 1 16 bits file header A portion of a COFF object file that contains general information about the objec...

Page 449: ...ed together initialized section A COFF section that contains executable code or initial ized data An initialized section can be built up with the data text or sect directive input section A section from an object file that will be linked into an executable module L label A symbol that begins in column 1 of a source statement and corre sponds to the address of that statement line number entry An en...

Page 450: ...4x map file An output file created by the linker that shows the memory configuration section composition and section allocation as well as symbols and the addresses at which they were defined member The elements or variables of a structure union archive or enu meration memory map A map of target system memory space which is partitioned into functional blocks mnemonic An instruction name that the a...

Page 451: ... section of memory A hardware switch deter mines which range is active P partial linking The linking of a file that will be linked again Q quiet run Suppresses the normal banner and the progress information R RAM model An autoinitialization model used by the linker when linking C code The linker uses this model when you invoke the linker with the cr option The RAM model allows variables to be init...

Page 452: ...s sign bit simulator A software development system that simulates TMS320C54x operation source file A file that contains C code or assembly language code that will be compiled or assembled to form an object file SPC Section Program counter An element of the assembler that keeps track of the current location within a section each section has its own SPC static A kind of variable whose scope is confi...

Page 453: ... The text section is an initialized section that contains executable code You can use the text directive to assemble code into the text section U unconfigured memory Memory that is not defined as part of the memory map and cannot be loaded with code or data uninitialized section A COFF section that reserves space in the memory map but that has no actual contents These sections are built up with th...

Page 454: ...cing 8 2 absolute output module producing 7 8 relocatable 7 9 algebraic defined E 1 source file 3 5 translation from mnemonic 11 1 to 11 10 algebraic directive 4 23 4 26 align directive 4 15 4 27 compatibility with C1x C2x C2xx C5x 4 7 alignment 4 15 to 4 16 4 27 defined E 1 linker 7 38 allocation 4 30 alignment 4 27 7 38 binding 7 36 to 7 74 blocking 7 38 default algorithm 7 53 to 7 55 defined E ...

Page 455: ...described 2 15 to 2 16 during linking 7 8 sections directives 2 4 to 2 11 source listings 3 31 to 3 34 symbols 3 18 3 20 assembler directives 4 1 to 4 98 absolute lister setsect 8 8 setsym 8 8 aligning the section program counter SPC 4 15 to 4 16 align 4 15 4 27 even 4 15 4 27 compatibility with C1x C2x C2xx C5x 4 7 default directive 2 4 defining assembly time symbols 4 21 to 4 22 asg 4 21 4 28 en...

Page 456: ...19 4 51 include 4 19 4 36 ref 4 19 4 51 summary table 4 2 to 4 6 assembly time constants 4 79 defined E 1 described 3 16 assignment statement defined E 2 expressions 7 58 to 7 59 attr MEMORY specification 7 29 attributes 3 35 7 29 autoinitialization defined E 2 described 7 68 to 7 69 specifying type 7 10 auxiliary entry defined E 2 described A 23 to A 28 B b linker option 7 10 bes directive 4 11 4...

Page 457: ...ve 4 23 4 35 C54X_A_DIR environment variable 3 9 char directive 4 12 4 33 character constant 3 15 string 3 17 cinit section 7 68 to 7 69 tables 7 68 cinit symbol 7 68 to 7 69 clink directive 4 8 4 34 COFF auxiliary entries A 23 to A 28 conversion to hexadecimal format 10 1 to 10 44 See also hex conversion utility default allocation 7 53 defined E 2 file structure A 2 to A 4 file types 2 2 headers ...

Page 458: ... 3 7 4 36 hc assembler option 3 5 i option 3 5 3 7 COPY section 7 56 cr linker option 7 10 7 60 cross reference lister creating the cross reference listing 9 2 example 9 4 in the development flow 9 2 invoking 9 3 options 9 3 symbol attributes 9 6 cross reference listing assembler option 3 6 defined E 2 described 3 35 producing with the option directive 4 17 4 74 producing with the cross reference ...

Page 459: ...IR 3 9 eos symbolic debugging directive B 9 equ directive 4 21 4 79 error messages displayed by tools D 1 to D 30 generating 4 24 4 42 hex conversion utility 10 44 producing in macros 5 19 etag symbolic debugging directive B 9 etext linker symbol 7 60 eval directive 4 21 4 28 listing control 4 17 4 41 use in macros 5 8 evaluation of expressions 3 24 even directive 4 15 4 27 executable module defin...

Page 460: ...ROUP defined E 3 linker directive 7 47 H h assembler option 3 5 linker option 7 12 half directive 4 13 4 54 hc assembler option 3 5 heap linker option sysmem section 7 68 described 7 12 help assembler option 3 5 linker option 7 6 hex conversion utility command file 10 7 to 10 8 controlling the ROM device address 10 34 to 10 37 data width 10 10 defined E 4 described 1 3 development flow 10 2 error ...

Page 461: ...13 4 58 Intel object format 10 40 J j linker option 7 16 K k linker option 7 16 keywords allocation parameters 7 35 load 2 17 7 35 7 41 run 2 17 7 35 7 41 to 7 43 L l assembler option 3 5 3 31 cross reference lister option 9 3 linker 7 13 label case sensitivity 3 4 cross reference list 3 35 defined E 4 field 3 11 in assembly language source 3 11 local 3 21 4 73 symbols used as 3 18 syntax 3 11 usi...

Page 462: ...s 4 81 suppressing 4 61 tab size 4 87 title 4 89 little endian ordering 10 14 lnk500 command 7 4 load address of a section described 7 41 referring to with a label 7 42 to 7 44 load linker keyword 2 17 7 41 to 7 43 loader defined E 4 loading a program 2 18 local labels 3 21 logical operators 3 25 long directive 4 13 4 63 compatibility with C1x C2x C2xx C5x 4 7 limiting listing with option directiv...

Page 463: ...e in macros 5 21 mmregs directive 4 23 4 70 mmsg directive 4 24 4 42 5 19 listing control 4 17 4 41 mnem2alg command 11 4 mnemonic defined E 5 field 3 11 translation to algebraic 11 1 to 11 10 mnemonic to algebraic translator utility See translator mnolist directive 4 17 4 69 listing control 4 17 4 41 use in macros 5 21 model statement defined E 5 Motorola S object format 10 41 N name MEMORY speci...

Page 464: ...utility option 10 15 ordering memory words 10 14 to 10 15 origin MEMORY specification 7 29 ROMS specification 10 17 output executable 7 8 to 7 9 hex conversion utility 10 24 linker 7 3 7 17 7 71 module defined E 6 name 7 17 section allocation 7 35 to 7 40 defined E 6 displaying a message 7 19 rules 7 54 output listing 4 17 to 4 18 overflow in an expression 3 25 overlay page defined E 6 described 7...

Page 465: ... labels 4 73 ROM device address 10 34 to 10 37 model autoinitialization 7 69 defined E 6 width defined E 7 described 10 11 to 10 13 romname ROMS specification 10 16 ROMS hex conversion utility directive 10 16 to 10 21 romwidth ROMS specification 10 17 rts lib 7 67 7 70 run address defined E 7 of a section 7 41 to 7 43 run linker keyword 2 17 7 41 to 7 43 runtime initialization and support 7 67 S s...

Page 466: ... listings 3 31 to 3 34 specifying algebraic instructions 3 5 source statement field 3 32 format 3 11 to 3 13 number in source listing 3 31 syntax 3 10 space directive 4 11 4 80 SPC aligning by creating a hole 7 61 to word boundaries 4 15 to 4 16 4 27 assembler symbol 3 11 assembler s effect on 2 9 to 2 11 assigning a label to 3 11 defined E 7 described 2 8 linker symbol 7 58 7 61 maximum number of...

Page 467: ...E 8 disable merge for linker 7 10 enumeration definitions B 9 file identification B 4 function definitions B 5 symbolic debugging continued line number entries B 7 member definitions B 8 producing error messages in macros 5 19 s assembler option 3 6 stripping symbolic information 7 17 structure definitions B 9 symbols B 11 table structure and content A 14 to A 28 union definitions B 9 symbols asse...

Page 468: ...s 2 5 4 30 usect 2 5 4 93 defined E 8 described 7 61 initialization of 7 64 specifying a run address 7 42 UNION defined E 8 linker directive 7 45 to 7 47 union tag 4 22 4 90 defined E 8 symbolic debugging directives B 9 union directive 4 22 4 90 unsigned defined E 8 usect directive 2 4 4 8 4 93 compatibility with C1x C2x C2xx C5x 4 7 usect section 4 8 ushort directive 4 13 4 54 utag symbolic debug...

Page 469: ... 16 X x archiver command 6 4 assembler option 3 6 3 35 hex conversion utility option 10 43 linker option 7 20 X MEMORY attribute 7 29 xfloat directive 4 13 4 50 xlong directive 4 13 4 63 xref500 command 9 3 ...

Reviews: