Home
ARM Assembly Language Tools v4.7 User's Guide (Rev. J)
Contents
1. KK BRK IKK The CRC generator used by the linker is based on concepts from the document A Painless Guide to CRC Error Detection Algorithms Author Ross Williams ross guest adelaide edu au Date 3 June 1993 Status Public domain C code Description For more information on the Rocksoft tm Model CRC Algorithm see the document titled A Painless Guide to CRC Error Detection Algorithms by Ross Williams ross guest adelaide edu au This document is likely to be in ftp adelaide edu au pub rocksoft or at http www ross net crc download crc v3 txt Note Rocksoft is a trademark of Rocksoft Pty Ltd Adelaide Australia xf 57 Pi Xf 57 a 50 527 wi 517 244 Linker Description www oF Mecony TI SPNU118J August 2011 Submit Documentation Feedback 1 TEXAS INSTRUMENTS www ti com Linker Generated CRC Tables Example 7 29 The CRC Table Header crc_tbl h continued J k k e e e e k k k k k k k k k kk k k k k k k k
2. 28 o Resume assembling into Vars section 0 29 30 00000000 Sect Vars 31 00000000 000D0000 field 13 WORD LEN 32 00000000 0 field OAh BYTE LEN SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Directives Reference 33 00000004 00000008 field 106 DWORD_LEN SPNU118J August 2011 Assembler Directives 123 Submit Documentation Feedback Se oF T www BD EIC conr TI Directives Reference set equ Syntax Description Example 124 Assembler Directives I TEXAS INSTRUMENTS www ti com Define Assembly Time Constant symbol set value symbol equ value The set and equ directives equate a constant value to a symbol The symbol can then be used in place of a value in assembly source This allows you to equate meaningful names with constants and other values The set and equ directives are identical and can be used interchangeably The symbolis a label that must appear in the label field The value must be a well defined expression that i
3. 4 00000000 data 5 00000000 Space 0CCh 6 T 8 Assemble into text 9 0 00000000 text Constant into data 1 00000000 INDEX set 0 2 000000006 0 MOV RO INDEX 3 4 k ko ko ko kk 5 ae Assemble into data 6 7 000000cc Table data 8 000000cc FFFFFFFF word 1 Assemble 32 bit 9 constant into data 20 21 000000d0 FF byte OFFh Assemble 8 bit 22 constant into data 23 24 25 Assemble into text 26
4. 9 Set symbol index to an integer expression XX 0 and use it as an immediate operand 1 ko ko ko 2 00000035 INDEX equ 100 2 3 3 00000004 E2810035 ADD RO AUX R1 INDEX 4 5 ko 6 Set symbol SYMTAB to a relocatable expression 7 xw and use it as a relocatable operand ax 8 9 00000008 0000000A LABEL word 10 20 00000009 SYMTAB set LABEL 1 21 22 ko ko ko ko ko 23 xx Set symbol NSYMS equal to the symbol INDEX 24 nd INDEX and use it as you would INDEX Xm 25
5. 25 KE Assemble more code into text EE 26 27 00000006 MOV PC LR 28 29 ck ko ko 30 KE Declare external bss symbols EF 31 32 global ARRAY TEMP 33 end Assembler Directives 81 Submit Documentation Feedback Se oF T www BD EIC conr TI Directives Reference byte char Syntax Description Examp 82 le Assembler Directives 1 TEXAS INSTRUMENTS www ti com Initialize Byte byte value value char value value The byte and char directives place one or more values into consecutive bytes of the current section A value can be one of the following e An expression that the assembler evaluates and treats as an 8 bit signed number Acharacter string enclosed in double quotes Each character in a string represents a separate value and values are stored in consecut
6. TMS470 COFF Hex Converter Version x xx ck ck ck ck Tue Sep 19 07 41 28 5 INPUT FILE NAME OUTPUT FORMAT lt a out gt Intel PHYSICAL MEMORY PARAMETERS Default data width 8 Default memory width 32 Default output width 16 OUTPUT TRANSLATION MAP 00000000 0001ffff Page 0 ROM Width 16 Memory Width 32 EPROM OUTPUT FILES lowerl6 bit b0 b15 upperl6 bit b16 b31 CONTENTS 00000020 00000021 Data Width 1 secA 00000028 00000029 Data Width 1 secB The contents of the output files lower16 bit and upper16 bit are shown in Figure C 6 and Figure C 7 respectively The low order 16 bits of the 32 bit output word are stored in the lower16 bit file while the upper 16 bits are stored in the upper16 bit file SPNU118J August 2011 Submit Documentation Feedback Hex Conversion Utility Examples www oF Eeconzy TI 329 I TEXAS INSTRUMENTS Scenario 3 Building a Hex Conversion Command File for Two 8 Bit EPROMs www ti com Figure C 6 Contents of Hex Output File lower16 bit Start character Ariese Data 0400200056781234C8 040028004321DCBADA 00000001FF Checksum T c L End offile record Record type
7. ko ko ko gt 27 4 text 28 00000004 000000CC con field Table 32 29 00000008 06 LDR R1 con 30 0000000c E5912000 LDR R2 R1 31 00000010 E0802002 ADD R2 RO 2 32 33 Resume assembling into the data section 34 at address OFh 35 36 000000d1 data SPNU118J August 2011 Assembler Directives 93 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Directives Heference www ti com double Initialize Double Precision Floating Point Value Syntax double value value Description The double directive places the IEEE double precision floating point representation of one or more floating point values into the current section Each value must be a floating point constant or a symbol that has been equated to a floating point constant Each constant is converted to a floating point value in IEEE double precision 64 bit format Double precision floating point constants are aligned to a double word boundary
8. text word 5 6 usym usect xy 20 Reserve space in xy word 7 8 Still in text SPNU118J August 2011 Submit Documentation Feedback Se oF T www BD FEe cenr TI Assembler Directives 67 I TEXAS INSTRUMENTS Directives That Change the Instruction Type www ti com 4 3 4 4 68 Directives That Change the Instruction Type By default the assembler begins assembling all instructions in a file as 32 bit instructions You can change the default action by using the code_state 16 assembler see Section 3 3 option which causes the assembler to begin assembling all instructions in a file as 16 bit instructions You can also use four directives that change how the assembler assembles instructions starting at the point where the directives occur The arm directive tells the assembler to begin assembling ARM UAL syntax 32 bit instructions starting at the location of the directive The arm directive performs an implicit word alignment before any instructions are written to the section to ensure that all 32 bit instructions are word aligned The arm directive also resets any local labels defined The arm directive is equivalent to the state32 directive The state16 directive causes the assembler to begin assembling non UAL 16 bit instructions starting at the location of the directive The state16 directive performs an implicit halfword al
9. ko ko KK 0 00000000 28814000 LF field OAh 5 1 2 ko ko 3 xk Write out the word E 4 ko ko ko ko KKK 5 align 4 6 7 8 xx Initialize a 4 bit field lt lt 9 This fields starts a new word 20 21 00000004 C0000000 x field OCh 4 22 23 24 us 32 bit relocatable field iid 25 5 in the next word ae 26 KKK KKK ko ko ko 27 00000008 00000004 field x 28 29 30 ae Initialize a 32 bit field EE SPNU118J August 2011 Se oF T Submit Docum
10. Reserve 100 bytes in the varl section aK array usect varl 100 ADD RO R1 037 Still in text X Reserve 50 bytes in the varl section xk dflag usect varl 50 ADD R2 R1 dflag array Still in text xk Reserve 100 bytes in the var2 section xk
11. Sect secB word 087654321h word 04321dcbah Before you use this appendix read Chapter 11 to understand how to use the hex conversion utility Topic Page C 1 Scenario 1 Building a Hex Conversion Command File for a Single 8 Bit EPROM 320 C 2 Scenario 2 Building a Hex Conversion Command File for 16 BIS Code 324 C 3 Scenario 3 Building a Hex Conversion Command File for Two 8 Bit EPROMs 327 SPNU 118J August 2011 Hex Conversion Utility Examples 319 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Scenario 1 Building a Hex Conversion Command File for a Single 8 Bit EPROM www ti com C 1 Scenario 1 Building a Hex Conversion Command File for a Single 8 Bit EPROM Scenario 1 shows how to build the hex conversion command file for converting an object file for the memory system shown in Figure C 1 In this system there is one external 128K x 8 bit EPROM interfacing with a TMS470 target processor Figure C 1 EPROM Memory System for Scenario 1 4 ARM CPU 128K 8 ROMO Width 32 bits V ROM width 8 bits longus md EPROM system memory width 8 bits A object file consists of blocks of memory sections with assigned memory locations Typically all sections are not adjacent there are holes between sections in the address space for which there is no data Scenario 1 shows how you can use the hex conve
12. vec usect var2 100 ADD R4 R2 RO Still in text 55 Declare a usect symbol to be external id global array Figure 4 8 The usect Directive Section var1 2 bytes 100 bytes 50 bytes Section var2 ptr 100 bytes 100 bytes reserved in var2 152 bytes reserved in var1 SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com unasg undefine Syntax Description Var Syntax Description SPNU118J August 2011 Directives Reference Turn Off Substitution Symbol unasg symbol undefine symbol The unasg and undefine directives remove the definition of a substitution symbol created using asg or define The named symbol will removed from the substitution symbol table from the point of the undefine or unasg to the end of the assembly file These directives can be used to remove from the assembly environment any C C macros that may cause a prob
13. 6 option R 7 0000003e BD byte 0 0BOh 5 00000035 0 00000040 5 8 00000041 BC char D 0COh 6 00000042 CO 00000043 06 9 00000044 0000000A int 10 35 at abc 00000048 00000084 0000004c 00000061 00000050 00000062 00000054 00000063 20 00000058 AABBCCDD long OAABBCCDDh 536 A 0000005c 00000259 21 00000060 000015AA word 5546 78h 00000064 00000078 22 00000068 45 String Extended Registers 00000069 78 SPNU118J August 2011 E oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com page Eject Page in Listing 0000006a 00000065 0000006c 0000006d 0000006e 0000006 f 00000070 00000071 00000072 00000073 00000074 00000075 00000076 00000077 00000078 00000079 74 65 6E 64 65 64 20 52 65 67 69 73 74 65 72 73 Directives Reference Syntax page Description The page directive produces a page eject in the listing file The page directive is not printed in the source listing but the assembler increments the line counter when it encounters the page directive Using the page directive to divide the 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 Source file title page Listing file TMS470R1x Copyright Page
14. 94 4 6 The field 101 4 7 Single Precision Floating Point Format enne hn nn enne nen 102 4 8 The usect Directive 140 6 1 The Archiver in the ARM Software Development Flow eeeseeeee HII 163 7 1 The Linker in the ARM Software Development FloOW III mnn 171 7 2 Section Allocation Defined 0 5 199 753 R n lime Executloniof sse 000 ER RREBEU RUD EUER EREE 213 7 4 Memory Allocation Shown il ahd sdds a ru IR leni Ec Exe RA eee ER ERR UE CERA NEUE 214 75 ee wayean a r E O 233 7 6 Handler Table smi 234 7 7 66 TABLE Conceptual Model reru rnnt S De ded ETE 244 7 8 X Autoinitialization at Run Time ee 249 759 nitializationcat Load oso enar our nnnm tmu ar ura a mex RR X EUER REDE NEU 250 8 1 Absolute Lister Development FIOW os 256 9 1 The Cross Reference Lister Development FIOW et 262 11 1 The Hex Conversion Utility in the ARM Software Development Flow eene 274 11 2 Hex Conversion Utility P
15. ko ko ko ko ko KK 6 Switch to 32 bit instructions to use the XE 7 32 bit state long multiply instruction 8 ck ck ko ko ko ko 9 00000010 state32 20 21 00000010 E0845190 UMULL rB r4 20 1 22 000000134 1 ADD lr pc 1 23 00000018 EI2FFFIE BX Tr 24 25 Continue assembling 16 bit instructions KR 26 277 Statel6 28 29 0000001c 1A2D SUB Eb 5 0 30 00000016 0 BCS 1 31 00000020 1 SUB r4 1 32 00000022 1 33 00000024 00000000 globl a word globl 34 00000028 00000000 glob2 a word glob2 Assembler Directives 127 Submit Documentation Feedback Se oF T www BD FEe cenr TI Directives Reference state32 arm Syntax Description Example 128 Assembler Directives 1 TEXAS INSTRUMENTS www ti com Assemble 32 Bit Instructions State32 arm By default the assembler begins assemblin
16. k ko 0 0 sect Sym Defs 1 00000000 3400002 float 0 05 Assembled into Sym Defs 2 00000004 000000AA X word OAAh Assembled into Sym_Defs 3 00000008 E2833028 ADD R3 R3 28h Assembled into Sym Defs 4 5 EK Begin assembling into Vars section EE 6 7 00000000 Sect Vars 8 00000010 WORD LEN Set 16 9 00000020 DWORD LEN Set WORD LEN 2 20 00000008 BYTE LEN set WORD LEN 2 21 ko ko ko ko ko 22 Resume assembling into text section 23 24 00000008 text 25 00000008 E2802042 ADD R2 RO 42h Assembled into text 26 0000000c 03 byte 3 4 Assembled into text 00000008 04 27
17. kc k m example3 map SPECIFY THE SYSTEM MEMORY MAP MEMORY 1 I MEM org 0 len 0x00000020 INTERRUPTS ur D MEM org 0 len 0x00010000 DATA MEMORY RAM P MEM org 0 len 0x00100000 PROGRAM MEMORY ROM SPECIFY THE SECTIONS ALLOCATION INTO MEMORY SECTIONS secA load 0x20 secB load D_MEM You must create a hex conversion command file to generate a hex output with the correct addresses and format for the EPROM programmer The EPROM programmer in this scenario has the following system requirements Inthe memory system outlined in Figure C 5 the EPROM system memory width is 32 bits because each of the physical ROMs provides 16 bits of a 32 bit word Because the EPROM system memory width is 32 bits the memwidth value must be set to 32 Because the width of each of the physical ROMs is 16 bits the romwidth value must be set to 16 Intel format must be used With a memwidth of 32 and a romwidth of 16 two output files are generated by the hex conversion utility the number of files is determined by the ratio of memwidth to romwidth In previous scenarios the output filename was specified with the o option Another way to specify the output filename is to use the files keyword within a ROMS directive When you use o or the files keyword the first output filename always contains the low order bytes of the word
18. ko ko ko ko ko 9 8 Switch to 16 bit instructions to use xE 0 less code space 1 2 00000008 statel6 3 00000008 2200 MOV r2 0 4 0000000a 2300 MOV r3 40 5 0000000c 4COB LDR r4 globs a 6 0000000e 2500 MOV r5 40 7 00000010 2600 MOV r6 0 8 00000012 2700 MOV r7 0 9 00000014 4690 MOV r8 r2 20 00000016 4691 MOV r9 ra 21 00000018 4692 MOV PLO 2 22 0000001a 4693 MOV fll r2 23 0000001c 4694 MOV ri2 r2 24 0000001e 4695 MOV r13 r2 25 00000020 4778 BX pc 26 00000022 46CO NOP 27 28 Continue assembling 32 bit instructions 29 30 00000024 State32 31 00000023 4 LDR r0 r4 4 32 00000028 E5941000 LDR rl r4 33 00000020 BL filter 34 00000030 E1500001 CMP r ri 35 00000034 30804005 ADDCC r4 r0 r5 36 00000038 20464001 SUBCS ri r6 ri 37 0000003c 00000000 globs a word globs www sok Eeconzy TI
19. 26 00000035 NSYMS Set INDEX 27 0000000c 00000035 word NSYMS SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Directives Reference Space bes Reserve Space Syntax abe space size in bytes label bes size in bytes Description The space and bes directives reserve the number of bytes given by size in bytes in the current section and fill them with Os The section program counter is incremented to point to the word following the reserved space When you use 3 label with the space directive it points to the first byte reserved When you use a label with the bes directive it points to the ast byte reserved Example This example shows how memory is reserved with the space and bes directives 1 2 Begin assembling into the text section 3 4 00000000 text 5 6 ck ck ck ck ck ck ko ko ko 7 ae Reserve
20. 4 13 Directives That Create or Effect Macros 4 14 Directives That Control 1302081168 0 IH 4 15 Directives That Perform Assembly Source Debug eese 4 16 Directives That Are Used by the Absolute Lister pp 4 17 Directives That Perform Miscellaneous Functions et 5 1 Substitution Symbol Functions and Return Values suesusues 5 2 Creating MACOS dises ieie ET 5 3 Manipulating Substitution Symbols pp 5 4 Gonditional Assembly en exces uei EX vous oe DESEE 5 5 Producing Assembly Time Messages eee HH 5 6 Formatting the Listing sm ii siinid nanninannan 7 1 Basic Options SuUrmimahy pri dd ups nuu iniaa nan uaaa 7 2 Command File Preprocessing Options Summary ce 7 3 Diagnostic Options Summary pe 7 4 File Search Path Options Summary pp 7 5 Linker Output Options Summary pp 7 6 Symbol Management Options Summary esee 7 7 Run Time Environment Options Summary cesse 7 8 Link Time Optimization Options Summary cese 7 9 Miscellaneous Options Summary pp 7 10 Groups of Operators Used in Expressions Precedence 9 1 Symbol Attributes in Cross Reference
21. i How the Linker Handles Sections 2 3 2 3 1 Default Memory Allocation 27 2 3 2 Placing Sections in the Memory Map isses cog Eee ee 28 2 4 sr stdcinatielastatawatedsatdaloaga vadaauawedla stoned paltatiadawawlastdalvanialaltattadal 28 29 7 7 7 2 5 2 6 1862301136 Progra etm 29 27 Symbols in an io ee a a a a 30 2 4 External 1 1 1 1 1 1 1 1 000 30 2 8 Object File Format Specifications 25 en Kan KUR uk Ananaia 30 3 Assembler Description wa 31 3 1 Assembler OVelvieW aL P 32 3 2 The Assembler s Role in the Software Development Flow cene 33 3 3 Invoking the Assembler cceceeee eee e teen nee e tee ee eee eee nhe nnn nnn nnne nnn 34 3 4 Naming Alternate Directories for Assembler Input et 35 3 4 1 Using the include path Assembler Option pet 36 3 4 2 Using the TMS470 A DIR Environment Variable pp 36 3 5 Source Statement Format ee ee e E a EEE a TE ENE 38 25 1 kapel Feld E T T 38 3 5 2 Mnemonic Field ss 39 3 5 3 Operand Field sev i 39 3 5 4 C mment Field ss IIleiiellerep cel aa Kaeaea KEEA aE 02 3 6 05 sa a T E A N 42 42 tio Re re aer
22. sect Counts clink XCount word 0AAh YCount word 0AAh ZCount word QAAh text is unconditionally linked by default www BAYFIconr TI SPNU118J August 2011 Submit Documentation Feedback 1 TEXAS INSTRUMENTS www ti com Directives Reference 20 00000000 text 21 00000000 E59F0004 LDR RO X addr 22 00000004 E5900000 LDR RO RO 23 00000008 E0800001 ADD RO RO 1 24 25 00000006 000000004 X addr field X 32 26 27 The reference to symbol X causes the Vars 28 section to be linked into the COFF output 29 SPNU118J August 2011 Assembler Directives 87 Submit Documentation Feedback Se oF T www BD EIC conr TI Directives Reference copy inc
23. ke ke kk ke ke ke ke ke ke e x filel obj file2 0bj Input files Xy output file prog out Options SECTIONS text load EXT MEM run 0 const load FAST MEM bss load SLOW MEM Vectors load 0x00000000 1 tl obj intvecl t2 0bj intvec2 endvec 198 Linker Description SPNU118J August 2011 oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Example 7 5 The SECTIONS Directive continued Linker Command Files data alpha data beta align 16 align 16 Figure 7 2 shows the six output sections defined by the SECTIONS directive in Example 7 5 vectors text const bss data alpha and data beta and shows how these sections are allocated in memory using the MEMORY directive given in Example 7 3 Figure 7 2 Section Allocation Defined by Example 7 5 0x00000000 FAST MEM Vectors const SLOW MEM I jJ Bound at 0x00000000 Allocated in FAST MEM 0x00001000 Allocated in SLOW MEM Aligned on 16 byte boundary data alpha Aligned on 16 byte The vectors section is composed of the intvec1 section from t1 obj and the intvec2 section from t2 obj The const section combines the const sections from file1 obj and file2 obj The bss section combines the bss sections from file1 obj and file2 obj The data alpha subsection combines the data al pha subsections from file1 o
24. ES DN CO CO CO CO CO PO PO 9 Po PO Po Po 001 OW array gt dflag ptr 00000000 00000000 E3A01003 00000000 00000001 00000004 E281001F 00000065 00000008 E2812064 00000000 0000000c E0824000 poe Assemble into the text section id text MOV R1 03h ck Reserve 1 byte in the varl section xk ptr usect varl 1
25. kk Ck kk kk Copy Table Data Structure ke ek ke kk Kk A Ck KKK kk RK typedef struct copy table unsigned short rec_size unsigned short num_recs COPY RECORD recs 1 COPY TABLE S EE K k k k kk k kk Ck ke kk Ck kk kk Ck kk Ck Ck Kk Ck kk LE Prototype for general purpose copy routine EE K k k k k k k k k k k k k k kk k k k k Lh extern void copy in COPY TABLE tp ifdef _ cplusplus extern C namespace std ifndef _CPP_STYLE_HEADER using std COPY RECORD using std COPY TABLE using std copy in endif CPP STYLE HEADER endif _ cplusplus endif CPY TBL 236 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI TEXAS INSTRUMENTS www ti com Linker Generated Copy Tables For each object component that is marked for a copy the linker creates a COPY_RECORD object for it Each COPY_RECORD contains at least the following information for the obje
26. SPNU 118J August 2011 Linker Description 201 Submit Documentation Feedback I I men BADE gt 9115 1 Linker Command Files I TEXAS INSTRUMENTS www ti com Example 7 6 Linker Allocation With the HIGH Specifier continued Sysmem 0 00000470 00000470 Stack 0 000008c0 000008c0 00000120 00000004 00000140 00000002 UNINITIALIZED rtsxxx lib UNINITIALIZED rtsxxx lib memory obj sysmem boot obj stack As shown in Example 7 6 the bss and sysmem sections are allocated at the lower addresses of RAM 0x0200 0x0590 and the stack section is allocated at address 0800 0 even though lower addresses are available Without using the HIGH specifier the linker allocation would result in the code shown in Example 7 7 The HIGH specifier is ignored if it is used with specific address binding or automatic section splitting lt lt operator Example 7 7 Linker Allocation Without HIGH Specifier bss 0 00000200 00000200 0000031a 000003a2 0000041a 00000460 00000468 0000046c 0000046e 00000470 00000470 Stack 0 00000550 00000550 sysmem 0 00000270 0000011a 00000088 00000078 00000046 00000008 00000004 00000002 00000002 00000140 00000002 00000120 00000004 UNINITIALIZED rtsxxx lib hello obj bs UNINITIALIZED rtsxxx lib UNINITIALIZED rtsxxx lib defs obj bss trgorwv obj D89 lowlev obj bss exit ob
27. The table operator now accepts a compression parameter The syntax is table name compressionz compression kind The compression kind can be one of the following types off Don t compress the data rle Compress data using Run Length Encoding 255 Compress data using Lempel Ziv Storer and Symanski compression A table operator without the compression keyword uses the compression kind specified using the command line option copy compression When you choose compression it is not guaranteed that the linker will compress the load data The linker compresses load data only when such compression reduces the overall size of the load space In some cases even if the compression results in smaller load section size the linker does not compress the data if the decompression routine offsets for the savings For example assume RLE compression reduces the size of section1 by 30 bytes Also assume the RLE decompression routine takes up 40 bytes in load space By choosing to compress section1 the load space is increased by 10 bytes Therefore the linker will not compress section1 On the other hand if there is another section say section2 that can benefit by more than 10 bytes from applying the same compression then both sections can be compressed and the overall load space is reduced In such cases the linker compresses both the sections You cannot force the linker to compress the data when doing so does not result in savings
28. Topic Page 1 1 Software Development Tools Overview ppp 16 2 17 SPNU118J August 2011 Introduction to the Software Development Tools 15 Submit Documentation Feedback I I men YP COMT I I TEXAS INSTRUMENTS Software Development Tools Overview www ti com 1 4 Software Development Tools Overview Figure 1 1 shows the ARM device software development flow The shaded portion highlights the most common development path the other portions are optional The other portions are peripheral functions that enhance the development process Figure 1 1 ARM Device Software Development Flow C C source files C C compiler C C name Assembler source Archiver Macro library Archiver demangling utility Assembler Library build Debugging process Object Run time support library Library of li object files Executable object file Hex conversion utility EPROM Absolute lister Cross reference Object file programmer lister utilities 16 Introduction to the Software Development Tools SPNU118J August 2011 d 3 T Submit Documentation Feedback www BD EIC conr TI www ti com 1 2 TEXAS INSTRUMENTS Tools Descriptions Tools Descriptions The following list describes the tools that are shown in Figure 1 1 The C C compiler accepts C C source code and produces ARM assembly language source code A shell pro
29. IP W1 F1 F1 r1 F1 r1 r1 F1 K0000COFFTOTI90000BFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFF7EF3DF BFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFF7EE37F Data al dd ad wl dd ro ed duda Ge 4 d zi records End of file Data record words Checksum If any data fields appear before the first address the first field is assigned address 0000h Address fields may be expressed but not required for any data byte The checksum field preceded by the tag character 7 is the 25 complement of the sum of the 8 bit ASCII values of characters beginning with the first tag character and ending with the checksum tag character 7 or 8 The end of file record is a colon SPNU 118J August 2011 Hex Conversion Utility Description 295 Submit Documentation Feedback I I men BADE 4 69115 1 I TEXAS INSTRUMENTS Description of the Object Formats www ti com 11 12 6 TI TXT Hex Format ti txt Option The TI TXT hex format supports 16 bit hexadecimal data It consists of section start addresses data byte and an end of file character These restrictions apply The number of sections is unlimited Each hexadecimal start address must be even Each line must have 16 data bytes except the last line of a section Data bytes are separated by a single space The end of file termination tag q is mandatory The data record contains the following inf
30. Name text identifier of the algorithm used by the programmer in the link command file D the numeric identifier of the algorithm stored by the linker in the crc alg ID member of each table entry Orrder the number of bits used by the CRC calculation Polynomial used by the CRC computation engine Initial Value the initial value given to the CRC computation engine Example 7 29 The CRC Table Header crc tbl h Ck ck ck ck ck ck ok ok ko k kc k ck ck ck ck I Ck ck ck ck ck ck ck ck ck KC kk kk KC J EOECECKCKCKCKCkCk crc tbl h Specification of CRC table data structures which can be automatically generated by the linker using the crc table operator in the linker command file 2 y 2 EY J FCKCKCKCkCk k e k e e k k k k e k k k k k k k kk k k kk kkk kkk kkk kkk f ke ke
31. kk Ck kk Ck CkCk kk kk kk Ck RRR KK typedef struct crc record uint64 t crc value uint32 t crc alg ID CRC algorithm ID uint32 t addr Starting address uint32 t size size of data in bytes uint32 t padding explicit padding so layout is the same for COFF and ELF CRC RECORD In the 06 TABLE struct the array recs 1 is dynamically sized by the linker to accommodate the number of records contained in the table num recs A user supplied routine to verify CRC values should take a table name and check the CRC values for all entries in the table An outline of such a routine is shown in Example 7 30 Example 7 30 General Purpose CRC Check Routine E E K k k k k kk Ck ko kk ke kk Ck Ck kk Ck kk Ck Ck Kk Ck kk Ck Ck kk kk Kk Ck kk ko ko k ke ke ke ke kk f General purpose CRC check routine Given the address of a linker generated CRC TABLE data structure verify the CRC of all object components that are designated with the corresponding LCF crc table operator A BRR KK KKK kk kk kk Ck Ck kk k ke kk kk I ke kk Ck kk ko ke k ke ke include crc tbl h BR kCkCk I KK Ck
32. 7 8 8 1 Compressed Copy Table Format The copy table format is the same irrespective of the compression The size field of the copy record is overloaded to support compression Figure 7 5 illustrates the compressed copy table layout Figure 7 5 Compressed Copy Table Load address Size 0 if load data is compressed In Figure 7 5 if the size in the copy record is non zero it represents the size of the data to be copied and also means that the size of the load data is the same as the run data When the size is 0 it means that the load data is compressed 7 8 8 2 Compressed Section Representation in the Object File When the load data is not compressed the object file can have only one section with a different load and run address Consider the following table operation in the linker command file SECTIONS task1 load ROM run RAM table _taskl_table The output object file has one output section named task1 which has a different load and run addresses This is possible because the load space and run space have identical data when the section is not compressed SPNU118J August 2011 Linker Description 233 Submit Documentation Feedback Se oF T www BDE conr TI I TEXAS INSTRUMENTS Linker Generated Copy Tables www ti com Alternatively consider the following SECTIONS task1 load ROM run RAM table _taskl_table compression rle If the linker compresses the task1 section then the load sp
33. Subsections allow you to manipulate sections with greater precision You can specify subsections with the linker s SECTIONS directive If you do not specify a subsection explicitly then the subsection is combined with the other sections with the same base section name It is not always necessary to use linker directives If you do not use them the linker uses the target processor s default allocation algorithm described in Section 7 7 When you do use linker directives you must specify them in a linker command file Refer to the following sections for more information about linker command files and linker directives Section 7 5 Linker Command Files Section 7 5 3 The MEMORY Directive Section 7 5 4 The SECTIONS Directive Section 7 7 Default Allocation Algorithm Default Memory Allocation Figure 2 4 illustrates the process of linking two files together Figure 2 4 Combining Input Sections to Form an Executable Object Module file1 obj Executable bs object module Memory map Space for variables bss Init LL named section Initialized data data file2 obj Executable code text bss Tables Tables Tables named section SPNU118J August 2011 Introduction to Object Modules 27 Submit Documentation Feedback I I men gt 1 1 TEXAS INSTRUMENTS Helocation www ti com 2 3 2 2 4 In Figure
34. The linker normally reads input files including archive libraries only once when they are encountered on the command line or in the command file When an archive is read any members that resolve references to undefined symbols are included in the link If an input file later references a symbol defined in a previously read archive library the reference is not resolved With the reread libs option you can force the linker to reread all libraries The linker rereads libraries until no more references can be resolved Linking using reread libs 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 lib you can resolve the mutual dependencies by listing one of the libraries twice as in 01470 run linker library a lib library b lib library a lib or you can force the linker to do it for you The priority option provides an alternate search mechanism for libraries Using priority causes each unresolved reference to be satisfied by the first library that contains a definition for that symbol For example objfile references A 11 defines B lib2 defines A B obj defining A references B 01470 run linker objfile 1101 2 Under the existing model objfile resolves its reference to A in lib2 pulling in a reference to B which resolves to the B in lib2 Under priority objfile resolves its reference
35. name text name load address 0x20 1load address run address 0x20 run address lt size gt 0xb240 lt size gt lt contents gt object component ref idref oc 34 object component ref idref oc 108 object component ref idref oc e2 lt contents gt lt logical_group gt overlay id lg b lt name gt UNION_1 lt name gt lt run_address gt 0xb600 lt run_address gt lt size gt 0xc0 lt size gt lt contents gt object component ref idref oc 45 logical group ref idref 1g 8 lt contents gt lt overlay gt split section id l1g 12 name task scn name lt size gt 0x120 lt size gt lt contents gt logical group ref idref lg 10 gt logical group ref idref lg 11 lt contents gt lt logical_group_list gt 314 XML Link Information File Description www BRD EKireconr TI SPNU118J August 2011 Submit Documentation Feedback 1 TEXAS INSTRUMENTS www ti com Document Elements B 2 5 Placement Map The lt placement_map gt element describes the memory placement details of all named memory areas in the application including unused spaces between logical groups that have been placed in a particular memory area The lt memory_area gt is a description of the placement details within a named memory area container The description consists of these items The lt name gt names the memory area string The lt page_id gt g
36. 00000000 00000001 00000002 00000004 00000008 0000000c 00000010 00000014 00000015 00000016 00000017 AA BB CC 00000DDD EEEEFFFF 0000DDDD 3FFFFFAC 68 65 66 70 byte char word long sint float Stxudng OAAh OBBh OCCh ODDDh OEEEEFFFFh ODDDDh 1 99999 help Figure 4 2 Initialization Directives Contents Code 0 0 A B byte OABh word OCDEFh long 089ABCDEFh string help 4 5 Directives That Perform Alignment and Reserve Space 70 These directives align the section program counter SPC or reserve space in a section The align directive aligns the SPC at a 1 byte to 32K byte boundary This ensures that the code following the directive begins on the byte value that you specify If the SPC is already aligned at the selected boundary it is not incremented Operands for the align directive must equal a power of 2 between 2 and 2 5 inclusive Figure 4 3 demonstrates the align directive Using the following assembled code 1 2 3 4 Assembler Directives 00000000 00000000 00000004 00000005 00000006 00000007 00000008 00000009 0000000c 40000000 4000000B 45 72 72 63 6E 74 04 field 2 3 field 11 align 2 String Errent align byte 4 SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Directives That Perform Alignment and Reserve Space Figure 4 3
37. 143 5 1 Using Ee ATI M 144 5 2 Defimng Teo PTT 144 5 3 Macro Parameters Substitution Symbols so i i 146 5 3 1 Directives That Define Substitution Symbols ppp 147 5 3 2 Built In Substitution Symbol Functions sn asne i 148 5 3 3 Recursive Substitution Symbols ee 149 5 3 4 Forced 51051111111 eet 149 5 3 5 Accessing Individual Characters of Subscripted Substitution Symbols pp 150 5 3 6 Substitution Symbols as Local Variables in Macros eeeeeeese IH 151 5 4 Macra LIDranes E 152 5 5 Using Conditional Assembly in Macros III HI mH mn enn n nne nenne 153 5 6 Using Labels in Macros aix ssusxessumer tenia keteustuau etin EUER ROEuME Eau 155 5 7 Producing Messages in Macros sm i eaaa hen NEEE ia Ea Eaa 156 5 8 Using Directives to Format the Output Listing cesses III 157 5 9 Using Recursive and Nested Macros Ce 158 5 10 Macro Directives Summary 425 159 P ieiusd reuggippe 161 6 1 Archiver QVverview sn ee se E EEEE EEEE EE 162 6 2 The Archiver s Role in the Software Development Flow ceseeeser HII 163 6 3 INVOKING thesAtchver 164 6 4 Archiver Examples 165 Contents SPNU118J August 2011 BYE T Submit Documentation Feedback men www BDF TI l TEXAS INSTRUMENTS www ti com 6 5 Library Information A
38. nnne 228 7 8 Linker Generated Copy 1 001011111000800 nnn nennen nnn nnn nnn 228 7 8 1 A Current Boot Loaded Application Development Process ppp 228 7 8 2 An Alternative Approach ppp 229 7 8 3 Overlay Management Example ccsseeseesseeee nnns nnn nnn nnn 230 7 8 4 Generating Copy Tables Automatically With the Linker pp 230 7 8 5 Thetable Operator sp a aas aaaea Saena n Ee is 231 7 8 6 Boot Time Copy Tables on i a a 232 7 8 7 Using the table Operator to Manage Object Components ppp 232 7 8 8 Compression SUppOFt serene iuis cle iles eiilemi x den pie denclibd Reip E NR FN UEM E 233 7 8 9 Copy Table COnlenls Seu inneni aE EE AE a Ea E EENE a a 236 7 8 10 General Purpose Copy Routine ee 237 7 8 11 Linker Generated Copy Table Sections and Symbols pp 238 7 8 12 Splitting Object Components and Overlay Management pp 239 7 9 Linkei Generated CRO Tables sem en a ee os 241 FQA MANE Cre table 241 7 9 2 Restiietions sad cuz nonis ee a Ris MUI RR 241 79 3 Examples T 242 100000 243 7 9 5 A Note on the TMS570 CRC64 ISO Algorithm ppp 246 7 10 Partial Incremental Linking ppt 247 OU 248 7 11 1 Run Time Initialization 218 7 11 2 Object Libraries and Run Time Support cece
39. 2 3 4 TMS470R1x Copyright generic Page Directive Example Assembler c 1996 2009 Texas Instruments Incorporated Version x xx Directive Example Assembler c 1996 2009 Texas Instruments Incorporated Version x xx Page Directive Example No Errors SPNU118J August 2011 No Warnings Day Day Time Time Submit Documentation Feedback Se oF T www BD FEe cenr TI Year PAGE 1 Year PAGE 2 Assembler Directives 121 Directives Reference sect Syntax Description Examp 122 le Assembler Directives 1 TEXAS INSTRUMENTS www ti com Assemble Into Named Section sect section name sect section name RO RW ALLOC NOALLOC The sect directive defines a named section that can be used like the default text and data sections The sect directive tells the assembler to begin assembling source code into the named section The section name identifies the section The section name must be enclosed in double quotes A section name can contain a subsection name in the form section name subsection name In ELF mode the sections can be marked read only RO or read write RW Also the sections can be marked for allocation ALLOC or no allocation NOALLOC These attributes can be specified in any order but only one attribute from each set can be selected RO conflicts with RW and ALLOC conflicts with NOALLOC If conflic
40. 7 12 Linker Example Linker Example This example links three object files named demo obj ctrl obj and tables obj and creates a program called demo out Assume that target memory has the following program memory configuration Address Range Contents 0x00000000 to 0x00001000 SLOW_MEM 0x00001000 to 0x00002000 FAST_MEM 0x08000000 to 0x08000400 EEPROM The output sections are constructed in the following manner Executable code contained in the text sections of demo obj fft obj and tables obj is linked into program memory ROM Variables contained in the var_defs section of demo obj are linked into data memory in block FAST_MEM_2 Tables of coefficients in the data sections of demo obj tables obj and fft obj are linked into FAST MEM 41 A hole is created with a length of 100 and a fill value of 0x07A1C The xy section form demo obj which contains buffers and variables is linked by default into page 1 of the block STACK since it is not explicitly linked Executable code contained in the text sections of demo obj ctrl obj and tables obj must be linked into FAST MEM Asetof interrupt vectors contained in the intvecs section of tables obj must be linked at address FAST MEM Atable of coefficients contained in the data section of tables obj must be linked into EEPROM The remainder of block FLASH must be initialized to the value OxFFOOFFOO Aset of variables contained in the bss
41. 9 00000010 arm 20 21 00000010 E0845190 UMULL r5 r4 20 1 22 00000014 E28FE001 ADD lr pc 1 23 00000018 EI2FFFIE BX lr 24 25 ww Continue assembling Thumb instructions KE 26 kk kk 27 6 thumb 28 29 0000001c 1A2D SUBS r5 rb 650 30 0000001e D201 BCS 1 31 00000020 1 SUBS r4 41 32 00000024 1 33 00000024 00000000 globl 8 word globl 34 00000028 00000000 glob2 a word glob2 Assembler Directives 135 www BRD EKireconr TI Directives Reference title Syntax Description Examp 136 le Assembler Directives 1 TEXAS INSTRUMENTS www ti com Define Page Title title string The title directive supplies a title that is printed in the heading on each listing page The source statement itself is not printed but the line counter is incremented The string is a quote enclosed title of up to 64 characters If you supply more than 64 characters the assembler truncates the string and issues a warning WARNING line x W0001 String is too long will be truncated The assembler prints the title on the page that follows the directive and on subsequent pages until another title directive is processed
42. August 2011 INSTRUMENTS Introduction to Object Modules The assembler and linker create object modules that can be executed by an ARM device Object modules make modular programming easier because they encourage you to think in terms of blocks of code and data when you write 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 focuses on the concept and use of sections in assembly language programs Topic Page 2 66 too ae terre reece A Ne eRe eT ee eee ee eT 20 22 How the Assembler Handles Sections pe 21 23 How the Linker Handles Sections 27 28 2 45 EE EI 29 25 29 26 27 516015 an Object 30 2 8 Object File Format 30 SPNUIIBU August 201 Introduction to Object Modules 19 Submit Documentation Feedback I I men BADE 0 9115 1 I TEXAS INSTRUMENTS Sections www ti com 2 1 20 Sections The smallest unit of an object file is called a section A section is a block of code or data that occupies contiguous space in the memory map with other sections Each section of an object file is separate and distinct Object files usually contain three default sections text section usually contains executable code data section usually contains initialized data bss section usually re
43. Example 7 11 Linker Command File for Example 7 10 ke ke ek kk Ck kk Ck RR KK RAK KK RR PARTIAL LINKER COMMAND FILE FOR FIR EXAMPLE J EE K k k k k k k k k k k k k k k k k k k k k k k k k k k kk k kk k kk k k kk k kkk kkk kkk kkk MEMORY FAST_MEM origin 0x00001000 length 0x00001000 SLOW_MEM origin 0x10000000 length 0x00001000 SECTIONS text load FAST MEM 5 load SLOW MEM run FAST MEM 212 Linker Description www oF Eeconzy TI SPNU118J August 2011 Submit Documentation Feedback I TEXAS INSTRUMENTS www ti com Linker Command Files Figure 7 3 Run Time Execution of Example 7 10 0x00000000 FAST_MEM fir relocated to run here 0x00001000 0x10000000 SLOW_MEM 0x10001000 OxFFFFFFFF 7 5 6 Using UNION and GROUP Statements Two SECTIONS statements allow you to conserve memory GROUP and UNION Unioning sections causes the linker to allocate them to the same run address Grouping sections causes the linker to allocate them contiguously in memory Section names can refer to sections subsections or archive library members 7 5 6 1 Overlaying Sections With the UNION Statement For some applications you may want to allocate more than one section to occupy the same address during run time For example you may have several routines you want in fast external m
44. SPNU118J August 2011 Submit Documentation Feedback 1 TEXAS INSTRUMENTS www ti com String cstring Syntax Description Example SPNU118J August 2011 Submit Documentation Feedback Directives Reference Initialize Text string expr string expr string cstring expr string expr string The string and cstring directives place 8 bit characters from a character string into the current section The expr or string can be one of the following Anexpression that the assembler evaluates and treats as an 8 bit signed number Acharacter string enclosed in double quotes Each character in a string represents a separate value and values are stored in consecutive bytes The entire string must be enclosed in quotes The cstring directive adds a NUL character needed by C the string directive does not add a NUL character In addition cstring interprets C escapes a Vo V n r t v lt octal gt The assembler truncates any values that are greater than eight bits Operands must fit on a single source statement line If you use a label it points to the location of the first byte that is initialized When you use string and cstring in a struct endstruct sequence the directive only defines a member s size it does not initialize memory For more information see the struct endstruct tag topic In this example 8 bit values are placed into con
45. SPNU118J August 2011 Submit Documentation Feedback Assembler Description 57 www BRD EKireconr TI I TEXAS INSTRUMENTS Debugging Assembly Source www ti com 3 13 Debugging Assembly Source When you invoke cl470 with symdebug dwarf or g when compiling an assembly file the assembler provides symbolic debugging information that allows you to step through your assembly code in a debugger rather than using the Disassembly window in Code Composer Studio This enables you to view source comments and other source code annotations while debugging The asmfunc and endasmfunc see Mark Function Boundaries directives enable you to use C characteristics in assembly code that makes the process of debugging an assembly file more closely resemble debugging a C C source file The asmfunc and endasmfunc directives allow you to name certain areas of your code and make these areas appear in the debugger as C functions Contiguous sections of assembly code that are not enclosed by the asmfunc and endasmfunc directives are automatically placed in assembler defined functions named with this syntax filename starting source line ending source line If you want to view your variables as a user defined type in C code the types must be declared and the variables must be defined in a C file This C file can then be referenced in assembly code using the ref directive see Identify Global Symbols Example 3 3 shows the c
46. cl470 run linker fl obj f2 0bj search_path ld search path gt 2 Windows library r lib library lib2 1ib 7 4 16 2 Name an Alternate Library Directory TMS470 C DIR Environment Variable An environment variable is a system symbol that you define and assign a string to The linker uses an environment variable named TMS470 C DIR to name alternate directories that contain object libraries The command syntaxes for assigning the environment variable are Operating System Enter UNIX Bourne shell TMS470 C DIRz pathname pathname export TMS470 C DIR Windows set TMS470 C DIRz pathname pathname The pathnames are directories that contain input files Use the library linker option on the command line or in a command file to tell the linker which library or link command file to search for The pathnames must follow these constraints Pathnames must be separated with a semicolon Spaces or tabs at the beginning or end of a path are ignored For example the space before and after the semicolon in the following is ignored set TMS470 C DIR c path one to tools c path two to tools Spaces and tabs are allowed within paths to accommodate Windows directories that contain spaces For example the pathnames in the following are valid set TMS470_C_DIR c first path to tools d second path to tools In the example below assume that two archive libraries called r lib and lib2 lib reside in Id and
47. compiler automatically generates these sections initialized sections text const cinit and Switch Uninitialized sections bss stack and sysmem Use the SECTIONS directive in a command file See Section 11 2 2 The general syntax for the SECTIONS directive is SECTIONS oname sname paddr value oname sname paddr boot oname sname boot SECTIONS begins the directive definition oname identifies the object filename the section is located within The filename is optional when only a single input file is given but required otherwise sname identifies a section in the input file If you specify a section that does not exist the utility issues a warning and ignores the name SPNU 118J August 2011 Hex Conversion Utility Description 285 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS The Load Image Format load image Option www ti com paddr value specifies the physical ROM address at which this section should be located This value overrides the section load address given by the linker This value must be a decimal octal or hexadecimal constant It can also be the word boot to indicate a boot table section for use with a boot loader f your file contains multiple sections and if one section uses a paddr parameter then all sections must use a paddr parameter boot configures a section for loading by a boot loader This is equivalent to using paddr boot
48. file for example when using debuggers and loaders The hex conversion utility can produce these output file formats ASCII Hex supporting 16 bit addresses Extended Tektronix Tektronix Intel MCS 86 Intel Motorola Exorciser Motorola S supporting 16 bit addresses Texas Instruments SDSMAC TI Tagged supporting 16 bit addresses Texas Instruments TI TXT format supporting 16 bit addresses Topic Page 11 1 The Hex Conversion Utility s Role in the Software Development Flow 274 11 2 Invoking the Hex Conversion Utility pp 275 11 3 Understanding Memory Widths pp 278 6 282 205 11 6 The Load Image Format load image Option pp 286 11 7 Excluding a Specified Section ree RENE ETE 287 11 8 Assigning Output Filenames cosas 287 11 9 Image Mode and the fill Option pp 288 11 10 Controlling the ROM Device Address pp 289 11 11 Control Hex Conversion Utility Diagnostics pp 290 11 12 Description of the Object Formats pp 291 Submit Documentation Feedback I I men YP gt 9115 1 SPNU T 18J August 2011 I TEXAS INSTRUMENTS The Hex Conversion Utility s Role in the Software Development Flow www ti com 11 1 The Hex Conversion Utility s Role in the Software Development Flow Figure 11 1 highlights the role of the hex conversion utility in the software development process Figure 11 1 The Hex Conversion Utility in the ARM Software Development Flo
49. 1 I TEXAS INSTRUMENTS Directives Reference www ti com The resulting assembly language is included in the assembly file at the point of the cdecls directive If the LIST option is used the converted assembly statements are printed in the listing file The assembly resulting from the cdecls directive is treated similarly to a include file Therefore the cdecls directive can be nested within a file being copied or included The assembler limits nesting to ten levels the host operating system may set additional restrictions The assembler precedes the line numbers of copied files with a letter code to identify the level of copying An A indicates the first copied file B indicates a second copied file etc The cdecls directive can appear anywhere in an assembly source file and can occur multiple times within a file However the C C environment created by one cdecls is not inherited by a later cdecls the C C environment starts new for each cdecls See Chapter 12 for more information on setting up and using the cdecls directive with C header files Example In this example the cdecls directive is used call the C header h file C header file define WANT_ID 10 define NAME John n extern int a_variable extern float cvt_integer int src struct myCstruct int member a float member b Jj enum status enum OK 1 FAILED 256 RUNNING 0 Source file cdecls C LIST myheader h size int sizeof
50. 11 8 Assigning Output Filenames Semi i a en ERa nana Kanai e init 287 11 9 Image Mode and the fill 0 288 11 9 1 Generaiing alMemory 8gG5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 121 IR ar 0 000 288 11 92 Specifying ai Fill Valg gt 289 11 9 3 Steps to Follow in Using Image Mode ppp 289 11 10 Controlling the ROM Device Address et 289 11 11 Control Hex Conversion Utility Diagnostics eese IH HII Hn 290 11 12 Description of The Object Formats se eiat a detis dici icu ma Ra win 291 11 12 1 ASCII Hex Object Format ascii Option ppp 291 11 12 2 Intel MCS 86 Object Format intel Option pp 292 11 12 3 Motorola Exorciser Object Format motorola Option pp 293 11 12 44 Extended Tektronix Object Format tektronix Option see 294 11 12 5 Texas Instruments SDSMAC Tl Tagged Object Format ti tagged Option 295 11 12 6 TI TXT Hex Format txt Option sea i iae aana a 296 12 Sharing C C Header Files With Assembly Source RN 297 12 1 Overview of the cdecls Directive ts 298 12 2 Notes on C C ConVersiOns 2422 298 122 1 Oommente vas on a LIII TM 298 12 2 2 Conditional Compilation if Helse ifdef etc 299 1223 112180111259 We ste 1 E 209 12 2 4 The error and warning Directives pp 299 12 2 5 Predefined symbol ASM HEADER over i esI nens hh e nnnm nte nnne 299 12
51. 328 Hex Conversion Utility Examples SPNU118J August 2011 S oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Scenario 3 Building a Hex Conversion Command File for Two 8 Bit EPROMs The hex conversion command file for Scenario 3 is shown in Example C 8 This command file uses the following options to select the requirements of the system Description Option i map example3 mxp memwidth 32 romwidth 16 Create Intel format Generate example3 mxp as the map file of the conversion Set EPROM system memory width to 32 Set physical ROM width to 16 The files keyword is used within the ROMS directive to specify the output filenames Example C 8 Hex Conversion Command File for Scenario 3 Hex Conversion Command file for Scenario 3 a out linked object file input I Intel format Optional Commands map example3 mxp Generate a map of the conversion Specify EPROM system memory width and physical ROM width memwidth 32 EPROM memory system width romwidth 16 Physical width of ROM ROMS EPROM org 0x0 length 0x20000 files lowerl6 bit upperl6 bit Example C 9 shows the contents of the resulting map file example3 mxp Example C 9 Contents of Hex Map File example3 mxp
52. 7 11 5 Initialization of Variables at Load Time Initialization of variables at load time enhances performance by reducing boot time and by saving the memory used by the initialization tables To use this method invoke the linker with the ram model option When you use the ram model linker option the linker sets the STYP COPY bit in the cinit section s header This tells the loader not to load the cinit section into memory The cinit section occupies no space in the memory map The linker also sets the cinit symbol to 1 normally cinit points to the beginning of the initialization tables This indicates to the boot routine that the initialization tables are not present in memory accordingly no run time initialization is performed at boot time A loader must be able to perform the following tasks to use initialization at load time Detect the presence of the cinit section in the object file Determine that STYP COPY is set in the cinit section header so that it knows not to copy the cinit section into memory Understand the format of the initialization tables Figure 7 9 illustrates the initialization of variables at load time SPNU118J August 2011 Linker Description 249 Submit Documentation Feedback I I men YP 0 9115 1 Linking C C Code Figure 7 9 Initialization at Load Time Object file Memory data section data section initialized RAM 7 11 6 The rom model and ram m
53. Assemble these files with the absolute_listing assembler option as follows to create the absolute listing cl470 absolute_listing filename abs The e options affect both the interpretation of filenames on the command line and the names of the output files They should always precede any filename on the command line The e options are useful when the linked object file was created from C files compiled with the debugging option symdebug dwarf compiler option When the debugging option is set the resulting linked object file contains the name of the source files used to build it In this case the absolute lister does not generate a corresponding abs file for the C header files Also the abs file corresponding to a C source file uses the assembly file generated from the C source file rather than the C source file itself For example suppose the C source file hello csr is compiled with the debugging option set the debugging option generates the assembly file hello s The hello csr file includes hello hsr Assuming the executable file created is called hello out the following command generates the proper abs file abs470 ea s ec csr eh hsr hello out An abs file is not created for hello hsr the header file and hello abs includes the assembly file hello s not the C source file hello csr SPNU118J August 2011 Absolute Lister Description 257 Submit Documentation Feedback Se oF T www BD EIC conr TI Absolute Lister Examp
54. E3 No Errors No Warnings Example 8 2 module2 Ist module2 abs PAGE 1 15 0 text 16 copy module2 asm A 1 00000020 text A 2 00001068 bss offst 1 A 3 00000020 00001068 offst a word offst A 4 COpy globals def B 1 global array B 2 global offst B 3 global dflag A 5 A 6 00000023 0 LDR r4 offst a A 7 00000028 E5840000 STR r0 r4 No Errors No Warnings 260 Absolute Lister Description www oF Eeconzy TI SPNU118J August 2011 Submit Documentation Feedback Chapter 9 SPNU118J August 2011 Cross Reference Lister Description The ARM cross reference lister is a debugging tool This utility accepts linked object files as input and produces a cross reference listing as output This listing shows symbols their definitions and their references in the linked source files Topic Page 9 1 Producing a Cross Reference Listing 9 2 Invoking the Cross Reference Lister pp 263 9 3 Cross Reference Listing Example SPNU118J August 2011 Cross Reference Lister Description 261 Submit Documentation Feedback www sok Eeconzy TI Producing a Cross Reference Listing 9 1 I TEXAS INSTRUMENTS www ti com Producing a Cross Reference Listing Figure 9 1 illustrates the steps required to produce a cross reference listing Figure 9 1 The Cross Reference Lister Development Flow Assembler source file MZ Linked object file Cross reference lister Cross reference listing
55. Each section specification beginning with name defines an output section An output section is a section in the output file A section name can be a subsection specification See Section 7 5 4 4 for information on multi level subsections After the section name is a list of properties that define the section s contents and how the section is allocated The properties can be separated by optional commas Possible properties for a section are as follows Load allocation defines where in memory the section is to be loaded Syntax load allocation or allocation Or gt allocation Run allocation defines where in memory the section is to be run Syntax run allocation or run gt allocation Input sections defines the input sections object files that constitute the output section Syntax input sections Section type defines flags for special section types See Section 7 5 7 Syntax type COPY Or type DSECT or type NOLOAD Fill value defines the value used to fill uninitialized holes See Section 7 5 9 Syntax fill value or name properties value Example 7 5 shows a SECTIONS directive in a sample link command file Example 7 5 The SECTIONS Directive E E K k k k k k k k k k k k k k k k k k k k k k k k k k kk k k k k k kk k kk k kk k ke ke ke e x Sample command file with SECTIONS directive S E E K k k k kk kk kk Ck ke kk Ck kk Ck kk kk Ck kk
56. LDR R4 RO ADD Rl R1 4 bss REAL REAL LEN word REAL struct tag REAL REC tag REAL REC endstruct tag CPLX REC Space CPLX LEN LDR R4 ADD Rl R1 4 struct int int endstruct struct String 64 field 7 field 9 field 10 int endstruct Space BIT LEN tag BIT REC LDR RO BITS BIT7 ADD R1 R1 RO www BRD EKireconr TI COMPLEX REALI 7 stag memberl 0 member2 1 real len 4 SREAL REC DEN allocate mem rec stag memberl 0 1 len 8 assign structure attribute allocate space access structure no stag puts mems into global symbol table create 3 dim templates stag 0167 64 0169 4 01610 64 int 8 length 72 Assembler Directives 131 Directives Reference 1 TEXAS INSTRUMENTS www ti com symdepend weak Effect Symbol Linkage and Visibility Syntax Description 132 Assembler Directives symdepend dst symbol name src symbol name Weak symbol name These directives are used to effect symbol linkage and visibility The weak directive is only valid when ELF mode is used The symdepend directive creates an artificial reference from the section defining src symbol name to the symbol dst symbol name This prevents the linker from removing the section containing dst symbol name if the section defining src symbol name is included in the output module If src symbol name is not
57. SPNU118J August 2011 Submit Documentation Feedback 1 TEXAS INSTRUMENTS www ti com Absolute Lister Example Step 3 Now invoke the absolute lister abs470 bttest out This command creates two files called module1 abs and module2 abs module1 abs nolist array setsym 000001001h dflag setsym 000001000h offst setsym 000001068h data setsym 000001000h edata setsym 000001000h text setsym 000000000h etext setsym 00000002ch bss setsym 000001000h end setsym 00000106ch setsect text 000000000h setsect data 000001000h setsect bss 000001000h list text COpy modulel asm module2 abs nolist array setsym 000001001h dflag Setsym 000001000h offst setsym 000001068h data setsym 000001000h edata setsym 000001000h text setsym 000000000h etext setsym 00000002ch bss setsym 000001000h end setsym 00000106ch setsect text 000000020h setsect data 000001000h setsect bss 000001068h sligt etext GOPY module2 asm These files contain the following information that the assembler needs for Step 4 They contain setsym directives which equate values to global symbols Both files contain global equates for the symbol dflag The symbol dflag was defined in the file globals def which was included in module1 asm and module2 asm They contain setsect directives which define the absolute addresses for sections They contain copy directives which defines the a
58. TEXAS INSTRUMENTS Linker Command Files www ti com 210 You can also use the gt gt operator to indicate that an output section can be split within a single memory range This functionality is useful when several output sections must be allocated into the same memory range but the restrictions of one output section cause the memory range to be partitioned Consider the following example MEMORY RAM origin 0x1000 length 0x8000 SECTIONS Special fl obj text load 0x4000 text text gt gt RAM The special output section is allocated near the middle of the RAM memory range This leaves two unused areas in RAM from 0x1000 to 0x4000 and from the end of f1 0bj text to 0x8000 The specification for the text section allows the linker to split the text section around the special section and use the available space in RAM on either side of special The lt lt operator can also be used to split an output section among all memory ranges that match a specified attribute combination For example MEMORY P MEMI RWX origin 0x1000 length 0x2000 P MEM2 RWI origin 0x4000 length 0x1000 SECTIONS text text gt gt RW The linker attempts to allocate all or part of the output section into any memory range whose attributes match the attributes specified in the SECTIONS directive This SECTIONS directive has the same effect as SECTIONS text text
59. The align Directive MEMO 77 7 New SPC 04h after assembling 02h 2 align 2 directive A Eu Current bytes SPC 03h 04h a Result of align 2 08h curent SPC 0Ah 1word New SPC 0Ch after assembling align directive OCh b Result of align without an argument The bes and space directives reserve a specified number of bytes in the current section The assembler fills these reserved byres with Os You can reserve a specified number of words by multiplying the number of bytes by 4 When you use 8 label with space it points to the first byte that contains reserved bits When you use a label with bes it points to the ast byte that contains reserved bits Figure 4 4 shows how the space and bes directives work for the following assembled code 1 2 00000000 0 word 100h 2005 00000004 00000200 3 00000008 Res 1 space 17 4 0000001c 0000000F word 15 5 00000033 Res 2 bes 20 6 00000034 BA byte OBAh Res 1 points to the first byte in the space reserved by space Res 2 points to the last byte in the space reserved by bes SPNU118J August 2011 Assembler Directives 71 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Directives That Format the Output Listings www ti com Figure 4 4 The space and bes Directives 4 Res 1 08h 17 bytes reserved Re
60. The symbol WORDX points to the first word that is reserved 1 00000000 00000004 00000008 0000000c www oF Eeconzy TI 00000C80 00004242 FFFFFF51 00000058 WORDX word 3200 1 AB OAFh X SPNU118J August 2011 Submit Documentation Feedback I TEXAS INSTRUMENTS www ti com label Syntax Description Example SPNU118J August 2011 Directives Reference Create a Load Time Address Label label symbol The label directive defines a special symbol that refers to the load time address rather than the run time address within the current section Most sections created by the assembler have relocatable addresses The assembler assembles each section as if it started at 0 and the linker relocates it to the address at which it loads and runs For some applications it is desirable to have a section load at one address and run at a different address For example you may want to load a block of performance critical code into slower memory to save space and then move the code to high speed 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 oad time address This function is useful primarily to designate where the section was
61. byte directive can have multiple parameters This syntax is shown as parameter The TMS470 and TMS570 devices are collectively referred to as ARM The ARM 16 bit instruction set is referred to as 16 BIS The ARM 32 bit instruction set is referred to as 32 BIS Following are other symbols and abbreviations used throughout this document Symbol Definition B b Suffix binary integer H h Suffix hexadecimal integer LSB Least significant bit MSB Most significant bit 0x Prefix hexadecimal integer Q q Suffix octal integer 12 Read This First SPNU 118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Related Documentation From Texas Instruments Related Documentation From Texas Instruments You can use the following books to supplement this user s guide SPRAAOS Common Object File Format Application Report Provides supplementary information on the internal format of COFF object files Much of this information pertains to the symbolic debugging information that is produced by the C compiler SPNU134 TMS470R1x User s Guide Describes the TMS470R1x RISC microcontroller its architecture including registers ICEBreaker module interfaces memory coprocessor and debugger 16 bit and 32 bit instruction sets and electrical specifications SPNU151 ARM Optimizing C C Compiler v4 6 User s Guide Describes the ARM C C compile
62. column contains the statement number that defines the symbol This column is blank for undefined symbols Reference REF column lists the line numbers of statements that reference the symbol A blank in this column indicates that the symbol was never used Table 3 5 Symbol Attributes Character or Name Meaning REF External reference global symbol UNDF Undefined i Symbol defined in a text section Symbol defined in a data section Symbol defined in a sect section Symbol defined in a bss or usect section 60 Assembler Description SPNU118J August 2011 www sok Eeconzy TI Submit Documentation Feedback F Chapter 4 IJ TEXAS SPNU118J August 2011 INSTRUMENTS Assembler Directives Assembler directives supply data to the program and control the assembly process Assembler directives enable you to do the following Assemble code and data into specified sections Reserve space in memory for uninitialized variables Control the appearance of listings Initialize memory Assemble conditional blocks Define global variables e Specify libraries from which the assembler can obtain macros Examine symbolic debugging information This chapter is divided into two parts the first part Section 4 1 through Section 4 12 describes the directives according to function and the second part Section 4 13 is an alphabetical reference Topic Page 4 7 m Directives Summary eene UII HIS 62 4 2 Directives That Define 566
63. ee 180 7 4 12 Set Default Fill Value fill value Option ee 180 7 4 13 Generate List of Dead Functions generate dead funcs list Option 77777 180 7 4 14 Define Heap Size heap size Option pt 180 Ar a Hiding 015 met 181 7 4 16 Alter the Library Search Algorithm library Option search path Option and TMS470 C DIR Environment Variable de n nn n n e nme emn n nenne nnne 181 TATT Change Symbol Localization 2 3 0 184 7 4 18 Create a Map File map file Option pp 185 7 4 19 Managing Map File Contents mapfile contents Option cesser 186 7 4 20 Disable Name Demangling no demangle ee 187 7 4 21 Disable Merge of Symbolic Debugging Information no sym merge Option 187 7 4 22 Strip Symbolic Information no sym table Option pp 187 7 4 23 Name an Output Module output file Option ee 188 7 4 24 C Language Options ram model and rom model Options pp 188 7 4 25 Retain Discarded Sections retain Option ppp 188 7 4 26 Create an Absolute Listing File run abs Option pp 188 7 4 27 Scan All Libraries for Duplicate Symbol Definitions 508 libraries esee 189 7 4 28 Define Stack Size stack size Option Nu 189 7 4 29 Enforce Strict Compatibility strict compatibility Option esee 189 7 4 80 Mapping of Symbols symbol
64. global directive declares a 16 bit symbol The mlib directive supplies the assembler with the name of an archive library that contains macro definitions When the assembler encounters a macro that is not defined in the current module it searches for it in the macro library specified with mlib The ref directive identifies a symbol that is used in the current module but is defined in another module The assembler marks the symbol as an undefined external symbol and enters it in the object symbol table so the linker can resolve its definition The ref directive forces the linker to resolve a symbol reference The symdepend directive creates an artificial reference from the section defining the source symbol name to the destination symbol The symdepend directive prevents the linker from removing the section containing the destination symbol if the source symbol section is included in the output module The weak directive identifies a symbol that is used in the current module but is defined in another module It is equivalent to the ref directive except that the reference has weak linkage SPNU118J August 2011 Assembler Directives 73 Submit Documentation Feedback I I men BADE 0 9115 1 I TEXAS INSTRUMENTS Directives That Enable Conditional Assembly www ti com 4 8 4 9 74 Directives That Enable Conditional Assembly Conditional assembly directives enable you to instruct the assembler to assemble certain s
65. lt lt P_MEM1 P_MEM2 Certain sections should not be split Certain sections created by the compiler including The cinit section which contains the autoinitialization table for C C programs The pinit section which contains the list of global constructors for C programs The bss section which defines global variables An output section with an input section specification that includes an expression to be evaluated The expression may define a symbol that is used in the program to manage the output section at run time An output section that has a START END OR SIZE operator applied to it These operators provide information about a section s load or run address and size Splitting the section may compromise the integrity of the operation The run allocation of a UNION Splitting the load allocation of a UNION is allowed If you use the lt lt operator on any of these sections the linker issues a warning and ignores the operator Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Command Files 7 5 5 Specifying a Section s Run Time Address At times you may want to load code into one area of memory and run it in another For example you may have performance critical code in slow external memory The code must be loaded into slow external memory but it would run faster in fast external memory Th
66. myCstruct aoffset int myCstruct member a boffset int myCstruct member b okvalue int status enum OK failval int status enum FAILED if defined WANT ID id cstring NAME endif Listing File 1 cdecls C LIST myheader h A 1 A 2 Assembly Generated from 0 0 Source Code A 3 p SS nece A 4 A 5 MACRO DEFINITIONS A 6 define 10 WANT_ID A 7 define John n NAME A 8 A 9 TYPE DEFINITIONS 22222 2 2 A 0 status enum enum A 1 00000001 OK emember 1 A 2 00000100 FAILED emember 256 A 3 00000000 RUNNING emember 0 A 4 endenum A 5 A 6 myCstruct struct 0 4 7 struct size 8 bytes 64 bits alignment 4 A 8 00000000 member a field 32 9 int member a offset 0 bytes size 4 bytes 32 bits A 20 00000004 member b field 32 21 float member b offset 4 bytes size 4 bytes 32 bits 84 Assembler Directives SPNU118J August 2011 E oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Directives Reference A 22 00000008 endstruct 23 final size 8 bytes 64 bits A 24 A 25 EXTERNAL FUNCTIONS A 26 global cvt integer A 27 A 28 EXTERNAL VARIABLES A 29 global a variable 2 00000000 00000008 size int sizeof myCstruct 3 00000004 00000000 aoffset int myCstruct member a 4 00000008 00000004 boffset int myCstruct member b 5 0000000c 00000001 okvalue int status e
67. path information If the assembler does not find the file in the directory that contains the current source file it searches the paths designated by the include path options For example assume that a file called source asm is in the current directory source asm contains the following directive statement copy copy asm Assume the following paths for the copy asm file UNIX tools files copy asm Windows c tools files copy asm You could set up the search path with the commands shown below Operating System Enter UNIX Bourne shell cl470 include path tools files source asm Windows cl470 include_path c tools files source asm The assembler first searches for copy asm in the current directory because source asm is in the current directory Then the assembler searches in the directory named with the include_path option 3 4 2 Using the TMS470 A DIR Environment Variable 36 An environment variable is a system symbol that you define and assign a string to The assembler uses the TMS470 A DIR environment variable to name alternate directories that contain copy include files or macro libraries The assembler looks for the TMS470 A DIR environment variable and then reads and processes it If the assembler does not find the TMS470 A DIR variable it then searches for TMS470 C DIR The processor specific variables are useful when you are using Texas Instruments tools for different processors at the same time See
68. romwidth and files parameters are invalid and are ignored When using the ROMS directive and the load image option the image option is required Default Load Image Section Formation If no ROMS directive is given the load image sections are formed by combining contiguous initialized sections in the input executables Sections with gaps smaller than the target word size are considered contiguous The default section names are image 1 image 2 If another prefix is desired the section name prefix prefix option can be used 11 6 2 Load Image Characteristics 286 All load image sections are initialized data sections In the absence of a ROMS directive the load run address of the load image section is the load address of the first input section in the load image section If the SECTIONS directive was used and a different load address was given using the paddr parameter this address will be used The load image format always creates a single load image object file The format of the load image object file is determined based on the input files The file is not marked executable and does not contain an entry point The default load image object file name is ti load image obj This can be changed using the outfile option Only one outfile option is valid when creating a load image all other occurrences are ignored Hex Conversion Utility Description SPNU118J August 2011 S oF T Submit Documentation Feedback www BD EIC conr
69. stack usage which sets the stack to num bytes Consecutive ranges of assembly code that are not enclosed within a pair of asmfunc and endasmfunc directives are given a default name in the following format filename beginning source line ending source line In this example the assembly source generates debug information for the user func section 1 00000000 Sect text 2 global user func 3 global printf 4 5 align 4 6 armfunc user func 7 00000000 State32 8 9 userfunc asmfunc 0 00000000 E92D4008 STMFD SP A4 LR 1 00000004 E28F000C ADR Al SL1 2 00000008 EBFFFFFC BL printf 3 0000000c E3A00000 MOV Al 0 4 00000010 E8BD4008 LDMFD SP A4 LR 5 00000014 E12FFFIE BX LR 6 endasmfunc 7 8 align 4 9 00000018 48 SL1 String Hello World 10 0 00000019 65 0000001a 6C 0000001b 6C 0000001c 6F 0000001d 20 0000001e 57 0000001f 6F 00000020 72 00000021 6C 00000022 64 00000023 21 00000024 0A 00000025 00 SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com bss Syntax Description Example SPNU118J August 2011 Directives Reference Reserve Space in the bss Section bss symbol size in bytes alignment The bss directive reserves space for variables in the bss section This directive is usually used to allocate space in RAM The symbolis a required parameter It defines a label that points to the first lo
70. this member is not included because there is no explicit reference to it in file1 obj or file2 obj 7 4 33 Display a Message When an Undefined Output Section Is Created warn sections Option In a link command file you can set up a SECTIONS directive that describes how input sections are combined into output sections However if the linker encounters one or more input sections that do not have a corresponding 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 that this occurred You can use the warn sections option to cause the linker to display a message when it creates a new output section For more information about the SECTIONS directive see Section 7 5 4 For more information about the default actions of the linker see Section 7 7 7 4 84 Generate XML Link Information File xml link info Option The linker supports the generation of an XML link information file through the xml link info file option This option causes the linker to generate a well formed XML file containing detailed information about the result of a link The information included in this file includes all of the information that is currently produced in a linker generated map file See Appendix B for specifics on the contents of the generated XML file 7 4 35 Zero Initialization zero init O
71. to match a single character and use to match zero or more characters The hide option hides global symbols which have a linkname matching the pattern It hides the symbols matching the pattern by changing the name to an empty string A global symbol which is hidden is also localized The unhide option reveals un hides global symbols that match the pattern that are hidden by the hide option The unhide option excludes symbols that match pattern from symbol hiding provided the pattern defined by unhide is more restrictive than the pattern defined by hide These options have the following properties The hide and unhide options can be specified more than once on the command line The order of hide and unhide has no significance Asymbol is matched by only one pattern defined by either hide or unhide Asymbol is matched by the most restrictive pattern Pattern A is considered more restrictive than Pattern B if Pattern A matches a narrower set than Pattern B Itis an error if a symbol matches patterns from hide and unhide and if one does not supersede other Pattern A supersedes pattern B if A can match everything B can and some more If Pattern A supersedes Pattern B then Pattern B is said to more restrictive than Pattern A These options affect final and partial linking In map files these symbols are listed under the Hidden Symbols heading 7 4 16 Alter the Library Search Algorithm library O
72. 2 directories The table below shows how to set the environment variable and how to use both libraries during a link Select the row for your operating system Operating System Invocation Command TMS470_C_DIR ld 1d2 export TMS470_C_DIR UNIX Bourne shell 01470 run linker fl obj f2 0bj library r lib library lib2 1lib TMS470 C DIR Md ld2 Windows 01470 run linker fl obj f2 0bj library r lib library lib2 1ib 182 Linker Description SPNU118J August 2011 Submit Documentation Feedback www BI 16co121 TI I TEXAS INSTRUMENTS www ti com Linker Options The environment variable remains set until you reboot the system or reset the variable by entering Operating System Enter UNIX Bourne shell unset TMS470 C DIR Windows set 1858470 C DIR The assembler uses an environment variable named TMS470 A DIR to name alternate directories that contain copy include files or macro libraries If TMS470 C DIR is not set the linker searches for object libraries in the directories named with TMS470 A DIR For information about TMS470 A DIR see Section 3 4 2 For more information about object libraries see Section 7 6 7 4 16 3 Exhaustively Read and Search Libraries reread libs and priority Options There are two ways to exhaustively search for unresolved symbols Reread libraries if you cannot resolve a symbol reference reread libs Search libraries in the order that they are specified priority
73. 2 4 file1 obj and file2 obj have been assembled to be used as linker input Each contains the text data and bss default sections in addition each contains a named section The executable object module shows the combined sections The linker combines the text section from file1 obj and the text section from file2 obj to form one text section then combines the two data sections and the two bss sections and finally places the named sections at the end The memory map shows how the sections are put into memory By default the linker begins at Oh and places the sections one after the other in the following order text const data bss cinit and then any named sections in the order they are encountered in the input files The C C compiler uses the const section to store string constants and variables or arrays that are declared as far const The C C compiler produces tables of data for autoinitializing global variables these variables are stored in a named section called cinit see Example 7 8 For more information on the const and cinit sections see the ARM Optimizing C C Compiler User s Guide Placing Sections in the Memory Map Figure 2 4 illustrates the linker s default method for combining sections Sometimes you may not want to use the default setup For example you may not want all of the text sections to be combined into a single text section Or you may want a named section placed where the data section would
74. 2 6 Usage Within C C asm Statements bb 299 12 2 7 Thejdnclude Directive gies rari denee sinnir aia a a aa 299 12 2 8 Conversion of define Macros 6 111111111111161166 299 12 2 9 The undef Directive 300 12 2 40 Enumerations 0 300 2 2 111 CSINOS 300 12 232 Built In FUNCHONS So noinen runt nnn rint rR ru RR an hne nh nta REX 301 12 249 Structures and Unions 2 12 22 301 12 214 Function Vatriable Prototypes 301 12 2 15 C Ooristant SUITIXGS icc ee a ime inse cv eere ln a E ns CUN RUNE 302 12 216 Basic 0 0 302 12 3 Notes on C Specific Coniversioris ri 302 12 8 1 Name Manglirig sume oe a a a 302 12 3 2 Denved ClasseS no a ee 302 12 33 Templates M oo a a a aaa 303 12 3 4 Virtual Functions 0 660 116661166616661 303 12 4 Special Assembler s a a E E E EEE 303 12 4 4 Enumerations enum emember endenum pp 303 SPNU118J August 2011
75. 2011 Sharing C C Header Files With Assembly Source 297 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Overview of the cdecls Directive www ti com 12 1 12 2 Overview of the cdecls Directive The cdecls directive allows programmers in mixed assembly and C C environments to share C headers containing declarations and prototypes between the C and assembly code Any legal C C can be used in a cdecls block and the C C declarations will cause suitable assembly to be generated automatically This allows the programmer to reference the C C constructs in assembly code calling functions allocating space and accessing structure members using the equivalent assembly mechanisms While function and variable definitions are ignored most common C C elements are converted to assembly enumerations non function like macros function and variable prototypes structures and unions See the cdecls directive description for details on the syntax of the cdecls assembler directive The cdecls directive can appear anywhere in an assembly source file and can occur multiple times within a file However the C C environment created by one cdecls is not inherited by a later cdecls the C C environment starts over for each cdecls instance For example the following code causes the warning to be issued Cdecls C NOLIST 51 define ASMTEST 1 Cdecls C NOLIST 51 ifndef ASMT
76. 2K bytes stack size Stack Sets C system stack size to size bytes and defines a global symbol that Section 7 4 28 specifies the stack size Default 2K bytes Table 7 2 Command File Preprocessing Options Summary Option Alias Description Section define Predefines name as a preprocessor macro Section 7 4 10 undefine Removes the preprocessor macro name Section 7 4 10 disable pp Disables preprocessing for command files Section 7 4 10 Table 7 3 Diagnostic Options Summary Option Alias Description Section diag error Categorizes the diagnostic identified by num as an error Section 7 4 7 diag remark Categorizes the diagnostic identified by num as a remark Section 7 4 7 diag suppress Suppresses the diagnostic identified by num Section 7 4 7 diag warning Categorizes the diagnostic identified by num as a warning Section 7 4 7 display error number Displays a diagnostic s identifiers along with its text Section 7 4 7 issue remarks Issues remarks nonserious warnings Section 7 4 7 no demangle Disables demangling of symbol names in diagnostics Section 7 4 20 no warnings Suppresses warning diagnostics errors are still issued Section 7 4 7 set error limit Sets the error limit to num The linker abandons linking after this number of Section 7 4 7 errors The default is 100 verbose diagnostics Provides verbose diagnostics that display the original source with line wrap Section 7 4 7 warn sections W Displays a message when an undefined out
77. 3 Overlay Management Example Consider an application which contains a memory overlay that must be managed at run time The memory overlay is defined using a UNION in the link command file as illustrated in Example 7 17 Example 7 17 Using a UNION for Memory Overlay SECTIONS UNION GROUP taskl taskl obj text task2 task2 obj text load ROM LOAD_START _task12_load_start SIZE _task12_size GROUP task3 task3 obj text task4 task4 obj text load ROM LOAD START task34 load start SIZE task 34 size run RAM RUN START task run start The application must manage the contents of the memory overlay at run time That is whenever any services from task1 or task2 are needed the application must first ensure that task1 and task2 are resident in the memory overlay Similarly for task3 and task4 To affect a copy of task1 and task2 from ROM to RAM at run time the application must first gain access to the load address of the tasks task12 load start the run address task run start and the size task12 size Then this information is used to perform the actual code copy 7 8 4 Generating Copy Tables Automatically With the Linker The linker supports extensions to the link command file syntax that enable you to do the following Identify any object components that may need to be copied from load space to run space at some point during the run of
78. 5 3 2 Immediate Values as Operands for Directives You use immediate values as operands primarily with instructions In some cases you can use immediate values with the operands of directives For instance you can use immediate values with the byte directive to load values into the current section It is not usually necessary to use the prefix for directives Compare the following statements ADD R1 410 byte 10 In the first statement the prefix is necessary to tell the assembler to add the value 10 to R1 In the second statement however the prefix is not used the assembler expects the operand to be a value and initializes a byte with the value 10 See Chapter 4 for more information on the syntax and usage of directives SPNU118J August 2011 Assembler Description 41 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Constants www ti com 3 5 4 3 6 3 6 1 Comment Field A comment can begin in any column and extends to the end of the source line A comment can contain any ASCII character including blanks Comments are printed in the assembly source listing but they do not affect the assembly A source statement that contains only a comment is valid If it begins in column 1 it can start with a semicolon or an asterisk Comments that begin anywhere else on the line must begin with a semicolon The asterisk identifies a comment only if it appears in column 1 Constant
79. 5 Relocatable Symbols and Legal Expressions 51 3 9 6 Expression Examples 44 52 93 10 Builtsin FunctONS a Era E Daar aa 53 3 11 Unified Assembly Language Syntax Support ppp 54 3 12 000706 15009 CE 55 3 13 Debugging Assembly SOUICG coca cca our iui toan Eie E E REGES 58 B14 Gross Reference 907 60 Assembler Directives qe 61 4 1 Directives 1 2 0 1 1 02010 00 62 4 2 Directives That Define Sections nme nonan D a w ana inian a O aaminin ain ana a aS 66 4 3 Directives That Change the Instruction Type ee 68 4 4 Directives That 68 4 5 Directives That Perform Alignment and Reserve Space ppp 70 4 6 Directives That Format the Output Listings cece 72 4 7 Directives That Reference Other Files ee 73 4 8 Directives That Enable Conditional Assembly pb 74 4 9 Directives That Define Union or Structure Types ee 74 4 10 Directives That Define Enumerated Types ee 75 4 11 Directives That Define Symbols at Assembly Time pp 75 4 12 Miscellaneous Directives ee 76 419 Directivos Reference ne n E E E 77 Macro Description oor ERE EALEN
80. Boot sections have a physical address determined by the location of the boot table The origin of the boot table is specified with the bootorg option 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 text data boot In the example below the object file contains six initialized sections text data const vectors coeff and tables Suppose you want only text and data to be converted Use a SECTIONS directive to specify this SECTIONS text data To configure both of these sections for boot loading add the boot keyword SECTIONS text boot data boot The Load Image Format image Option A load image is an object file which contains the load addresses and initialized sections of one or more executable files The load image object file can be used for ROM masking or can be relinked in a subsequent link step 11 6 1 Load Image Section Formation The load image sections are formed by collecting the initialized sections from the input executables There are two ways the load image sections are formed Using the ROMS Directive Each memory range that is given in the ROMS directive denotes a load image section The romname is the section name The origin and length parameters are required The memwidth
81. C 1 Scenario 1 Building a Hex Conversion Command File for a Single 8 Bit EPROM 320 C 2 Scenario 2 Building a Hex Conversion Command File for 16 BIS Code pp 324 C 3 Scenario 3 Building a Hex Conversion Command File for Two 8 Bit EPROMS 327 0 0557 M 00 331 Contents SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI l TEXAS INSTRUMENTS www ti com List of Figures 1 1 ARM Device Software Development Flow ee 16 2 1 Partitioning Memory Into Logical Blocks et 20 22 Using Sections Directives EXxample es a a a aa a aaae 25 2 8 Object Code Generated by the File in oo 26 2 4 Combining Input Sections to Form an Executable Object Module cessere 27 3 1 The Assembler in the ARM Software Development HH 33 3 2 Example Assembler Listing se cpa VERE el LER EMEN EM 56 4 1 EEUU BITE 69 4 2 Initialization Directives Sess em es ee 70 4 3 The align Directives sion ven naninira arinean ese Aanand eeN ewe venue deed ewan 71 4 4 The space and bes Directives si Nenen rinii enr Eea aa PEEKE deea 72 4 5 Double Precision Floating Point
82. Contents 7 Submit Documentation Feedback I I men BADE gt 9115 1 IJ TEXAS INSTRUMENTS www ti com 12 4 2 Thedefine Directive some 00 303 12 4 8 The undefine unasg Directives cesses nn m nm m enn enn nn 303 12 4 4 The defined Built In FUNCHON sn i aaaea iia 304 12 4 5 The sizeof Built In n nehmen hne nhe nennen annes 304 12 4 6 Structure Union Alignment amp alignof pp 304 12 4 7 The cstring Directive nn nena uioa Ewa raw a dia ri sai UR ERE REM ANO E EARN ERR RF RR KU 304 Symbolic Debugging Directives pp 305 A 1 DWARF Debugging Format 25 2 etre rex mene ren nan ee UAE 306 A2 COFF Debugging FORMAL 22i ee de EAEE 306 A 3 Debug Directive SYNTAX secsi eis ee pola x ERR EQ E UE SEE 307 XML Link Information File Description pp 309 B 1 XML Information File Element Types I II HII III HI mH hm mn e hm nnn nnn 310 B 2 D c ment Elements 0 310 B 2 1 Header Elements se ee ee E E 310 2 2 00 311 B 23 Object Component List ceses a DNE 312 3 2 4 ME Wee Pm 313 B 2 5 Placement Map 7 915 B 2 6 Far Call Trampoline List sas sunin ionnin anneanne oreraa eaei nai iSe E unaD K EEKi KEENAN 316 2 7 Symbol Table nuni i a a a a a a Kaea Ei aE a aSa 317 Hex Conversion Utility Examples pp 319
83. Conversion Command File for Two 8 Bit EPROMs Example C 6 Contents of Hex Map File example2 mxp continued CONTENTS 00000000 00000003 Data Width 1 secA 00001000 00001003 Data Width 1 secB Figure C 4 Contents of Hex Output File example2 hex Start character Address Data 0800000012345678ABCD123426 08100000876543214321DCBA9E 00000001FF L LI Record type Byte count Checksum C 3 Scenario 3 Building a Hex Conversion Command File for Two 8 Bit EPROMs Scenario 3 shows how to build the hex conversion command file for converting a object file for the memory system shown in Figure C 5 In this system there are two external 64K x 16 bit EPROMs interfacing with the TMS470 target processor The application code and data will be burned on the EPROM starting at address 0x20 The application code will be burned first followed by the data tables Figure C 5 EPROM Memory System for Scenario 3 7 Upper 16 bits Lower 16 bits gt ARM CPU 64K 16 64K 16 ROMO ROM1 Width 32 bits ROM width ROM width 16 bits 16 bits ys EPROM system memory width 32 bits In this scenario the EPROM load address for the application code and for the data also corresponds to the TMS470 CPU address that accesses the code and data Therefore only a load address needs to be specified Example C 7 shows the linker command file for this scenario SPNU118J August 2011 Hex Conversion Utility Examples 3
84. Example 7 23 Creating a Copy Table to Access a Split Object Component SECTIONS UNION 1 task1to3 taskl task2 task3 load lt lt LMEM1 LMEM2 LMEM4 table task13 ctbl GROUP task4 task4 task5 task5 task6 task6 task 1 task4 load lt lt LMEM1 LMEM3 LMEM4 table task47 ctbl run PMEM ovly lt 4 SPNU118J August 2011 Linker Description 239 Submit Documentation Feedback I I men BADE 0 9115 1 Linker Generated Copy Tables Example 7 24 Split Object Component Driver I TEXAS INSTRUMENTS www ti com include lt cpy_tbl h gt extern extern extern extern main 1 far COPY TABLE task13 ctbl far COPY TABLE task47 ctbl void task1 void void task7 void copy_in amp task13_ctbl task1 task2 task3 copy in amp task47 ctbl You must declare a COPY TABLE object as far to allow the overlay copy table section placement to be independent from the other sections containing data objects such as bss The contents of the task1to3 section are split in the section s load space and contiguous in its run space The linker generated copy table task13 ctbl contains a separate COPY RECORD for each piece of the split section task1to3 When the address of task13 ctbl is passed to copy in each piece of task1to3 is copied from its load location into the run location Th
85. Feedback I TEXAS INSTRUMENTS www ti com Using Labels in Macros 5 6 Using Labels in Macros All labels in an assembly language program must be unique This includes labels in macros If a macro is expanded more than once its labels are defined more than once Defining a label more than once is illegal The macro language provides a method of defining labels in macros so that the labels are unique Simply follow each label with a question mark and the assembler replaces the question mark with a period followed by a unique number When the macro is expanded you do not see the unique number in the listing file Your label appears with the question mark as it did in the macro definition You cannot declare this label as global The syntax for a unique label is label Example 5 13 shows unique label generation in a macro The maximum label length is shortened to allow for the unique suffix For example 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 To obtain a cross listing file invoke the assembler with the cross reference option see Section 3 3 Example 5 13 Unique Labels in a Macro 1 define macro to find minimum 2 MIN macro dst srcl src2 3 CMP 1 4 BCC m1 5 MOV dst SEOL 6 B m2 7 8 m1 MOV ds
86. Format Record Address Checksum type 4 r3 L1 E 00600004844521B Header record 322000000000000000000000000000000000000000000000000000000000000000000DD S31AD001FFEB000000000000000000000000000000000000000000FA Data records 570500000000 F Termination record Checksum Byte count Address for S3 records SPNU118J August 2011 Hex Conversion Utility Description 293 Submit Documentation Feedback I I men BADE 4 69115 1 1 TEXAS INSTRUMENTS Description of the Object Formats www ti com 11 12 4 Extended Tektronix Object Format tektronix Option The Tektronix object format supports 32 bit addresses and has two types of records Data records contains the header field the load address and the object code Termination records signifies the end of a module The header field in the data record contains the following information Number of ASCII Item Characters Description 96 1 Data type is Tektronix format Block length 2 Number of characters in the record minus the 96 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 characters per
87. OFO bytes in the text section EE 8 9 00000000 Space OFOh 10 000000f0 00000100 word 100h 200h 000000 4 00000200 Li 12 pem Begin assembling into the data section ER 13 ko ko ko oko 14 00000000 data 15 00000000 49 String In data 00000001 6E 00000002 20 00000003 2E 00000004 64 00000005 61 00000006 74 00000007 61 16 Reserve 100 bytes in the data section RES 1 18 points to the first byte that contains 19 KE reserved bytes XE 20 21 00000008 RES 1 Space 100 22 0000006c 0000000F word 15 23 00000
88. On sections Sections On sym defs Defined symbols per file Off sym name Symbols sorted by name On sym runaddr Symbols sorted by run address On all Enables all attributes none Disables all attributes The mapfile contents option controls display filter settings by specifying a comma delimited list of display attributes When prefixed with the word no an attribute is disabled instead of enabled For example mapfile contents copytables noentry mapfile contents all nocopytables mapfile contents none entry By default those sections that are currently included in the map file when the map file option is specified are included The filters specified in the mapfile contents options are processed in the order that they appear in the command line In the third example above the first filter none clears all map file content The second filter entry then enables information about entry points to be included in the generated map file That is when mapfile contents none entry is specified the map file contains only information about entry points There are two new filters included with the mapfile contents option load addr and sym defs These are both disabled by default If you turn on the load addr filter the map file includes the load address of symbols that are included in the symbol list in addition to the run address if the load address is different from the run address The sym defs filter can be used to include inform
89. RO r7 8 endif MSG EX EE symlen parml1 0 emsg ERROR MISSING PARAMETER ERROR MISSING PARAMETER else ADD parml r7 r8 endif Directives Reference In addition the following messages are sent to standard output by the assembler ERROR line ITI USER ERROR emsg ERROR MISSING PARAMETER 1 Error No Warnings Errors in source Assembler Aborted SPNU118J August 2011 Submit Documentation Feedback www BRD EKireconr TI ERROR MISSING PARAMETER Assembler Directives 97 Directives Reference end Syntax Description Examp 98 le Assembler Directives I TEXAS INSTRUMENTS www ti com End Assembly end The end directive is optional and terminates assembly The assembler ignores any source statements that follow a end directive If you use the end directive it must be the last source statement of a program This directive has the same effect as an end of file character You can use end when you are debugging and you want to stop assembling at a specific point in your code Ending a Macro NOTE Do not use the end directive to terminate a macro use the endm macro directive instead 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 LOCL n word LOC1 MVN RO RO ADD RO RO T
90. Sends user defined messages to the output device mmsg topic wmsg string Sends user defined warning messages to the output device wmsg topic Table 4 15 Directives That Perform Assembly Source Debug Mnemonic and Syntax Description See asmfunc Identifies the beginning of a block of code that contains a function asmfunc topic endasmfunc Identifies the end of a block of code that contains a function endasmfunc topic Table 4 16 Directives That Are Used by the Absolute Lister Mnemonic and Syntax Description See setsect Produced by absolute lister sets a section Chapter 8 setsym Produced by the absolute lister sets a symbol Chapter 8 SPNU118J August 2011 Assembler Directives 65 Submit Documentation Feedback www oF Eeconz TI I TEXAS INSTRUMENTS Directives That Define Sections www ti com Table 4 17 Directives That Perform Miscellaneous Functions Mnemonic and Syntax Description See cdecls options filename filenameZ Share C headers between C and assembly code cdecls topic end Ends program end topic In addition to the assembly directives that you can use in your code the compiler produces several directives when it creates assembly code These directives are to be used only by the compiler do not attempt to use these directives DWARF directives listed in Section A 1 COFF STABS directives listed in Section 2 The battr directive is used to encode build attributes for the
91. Size heap size Option 180 The C C compiler uses an uninitialized section called sysmem for the C run time memory pool used by malloc You can set the size of this memory pool at link time by using the heap size option The syntax for the heap size option is heap sizez size The size must be a constant This example defines a 4K byte heap 01470 run linker heap size 0x1000 defines a 4k heap sysmem section The linker creates the sysmem section only if there is a sysmem section in an input file The linker also creates a global symbol SYSMEM SIZE and assigns it a value equal to the size of the heap The default size is 2K bytes For more information about C C linking see Section 7 11 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Options 7 4 15 Hiding Symbols Symbol hiding prevents the symbol from being listed in the output file s symbol table While localization is used to prevent name space clashes in a link unit symbol hiding is used to obscure symbols which should not be visible outside a link unit Such symbol s names appear only as empty strings or no name in object file readers The linker supports symbol hiding through the hide and unhide options The syntax for these options are hidez pattern unhidez pattern The pattern is a string with optional wildcards or Use
92. T www BD EIC conr TI I TEXAS INSTRUMENTS Linking C C Code www ti com 7 11 Linking C C Code The C C compiler produces assembly language source code that can be assembled and linked For example a C program consisting of modules prog1 prog2 etc can be assembled and then linked to produce an executable file called prog out 01470 run linker rom model output file prog out progl obj prog2 obj rts470 1ib The rom model option tells the linker to use special conventions that are defined by the C C environment The archive libraries shipped by TI contain C C run time support functions C C and mixed C and C programs can use the same run time support library Run time support functions and variables that can be called and referenced from both C and 6 will have the same linkage For more information about the ARM C C language including the run time environment and run time support functions see the ARM Optimizing C C Compiler User s Guide 7 11 1 Run Time Initialization All C C programs must be linked with code to initialize and execute the program called a bootstrap routine also known as the boot obj object module The symbol c int00 is defined as the program entry point and is the start of the C boot routine in boot obj referencing c intO0O ensures that boot obj is automatically linked in from the run time support library When a program begins running it executes boot obj first The boot o
93. TI 1 TEXAS INSTRUMENTS Invoking the Linker www ti com 7 3 Invoking the Linker The general syntax for invoking the linker is cl470 run linker options filename filename cl470 run linker is the command that invokes the linker The run linker option s short form is Z options can appear anywhere on the command line or in a link command file Options are discussed in Section 7 4 filename filename can be object files link command files or archive libraries The default extension for all input files is obj any other extension must be explicitly specified The linker can determine whether the input file is an object or ASCII file that contains linker commands The default output filename is a out unless you use the output file option to name the output file There are two methods for invoking the linker e Specify options and filenames on the command line This example links two files 1161 and file2 obj and creates an output module named link out c1470 run linker filel obj file2 0bj output file link out Putfilenames and options in a link command file Filenames that are specified inside a link command file must begin with a letter For example assume the file linker cmd contains the following lines output file link out filel obj file2 obj Now you can invoke the linker from the command line specify the command filename as an input file 1470 run linker linker cmd When you use a comman
94. Two directives enable you to control the listing of macro and repeatable block expansions in the listing file The mlist directive allows macro and loop endloop block expansions in the listing file The mnolist directive suppresses macro and loop endloop block expansions in the listing file By default the assembler behaves as if the mlist directive had been specified See Chapter 5 for more information on macros and macro libraries See the loop break endloop topic for information on conditional blocks This example defines a macro named STR 3 The first time the macro is called the macro expansion is listed by default 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 again listed because a mlist directive was assembled 1 STR 3 Pl P2 pls P3 rp2 String p3z endm am H 009 00000000 00000000 00000001 00000002 00000003 00000004 00000005 00000006 00000007 00000008 00000009 0000000a 00000005 STR 3 ag I 1 Invoke STR 3 macro spar 3A 70 31 3A 3A 70 32 3A 3A 70 33 3A String mnolist 578 3 as p mlist STR 3 as IM ipli Suppress expansion 0000000c am Invoke STR 3 macro Show macro expansion ora am 000000 000000 000000 000000 000000 00
95. Visibility of Global Symbol Syntax import symbolname export symbolname hidden symbolname protected symbolname Description These directives set the dynamic visibility of a global symbol Each takes a single symbol name optionally enclosed in double quotes The import directive sets the visibility of symbolname to STV IMPORT The export directive sets the visibility of symbolname to STV EXPORT The hidden directive sets the visibility of symbolname to STV HIDDEN The protected directive sets the visibility of symbolnameto STV PROTECTED See for an explanation of symbol visibility SPNU118J August 2011 Assembler Directives 109 Submit Documentation Feedback Se oF T www BD EIC conr TI Directives Reference int long word Syntax Description Example 1 Example 2 Example 3 110 Assembler Directives Initialize 32 Bit Integers I TEXAS INSTRUMENTS www ti com int value long value Word value value value value The int long and word directives place one or more values into consecutive words in the current section Each value is placed in a 32 bit word by itself and is aligned on a word boundary A value can be either An expression that the assembler evaluates and treats as a 32 bit signed or unsigned number Acharacter string enclosed in double quotes Each character in a string represents a separate value and is stored al
96. a S modifier This is the same as how ARM ALU instructions that set status have always been handled Assembler Description SPNU118J August 2011 Ay EF T Submit Documentation Feedback men Www FIIC conr TI 1 TEXAS INSTRUMENTS www ti com Source Listings 3 12 Source Listings A source listing shows source statements and the object code they produce To obtain a listing file invoke the assembler with the asm_listing option see Section 3 3 Two banner lines a blank line and a title line are at the top of each source listing page Any title supplied by the title directive is printed on the title line A page number is printed to the right of the title If you do not use the title directive the name of the source file is printed The assembler inserts a blank line below the title line Each line in the source file produces at least one line in the listing file This line shows a source statement number an SPC value the object code assembled and the source statement and show these in actual listing files Each line in the source file produces at least one line in the listing file This line shows a source statement number an SPC value the object code assembled and the source statement Figure 3 2 shows these in an actual listing file Field 1 Source Statement Number Line number The source statement number is a decimal number The assembler numbers source lines as it encounters them in the source file some statemen
97. a hole exists in an initialized output section the linker must supply raw data to fill it The linker fills holes with a 32 bit fill value that is replicated through memory until it fills the hole The linker determines the fill value as follows 1 If the hole is formed by combining an uninitialized section with an initialized section you can specify a fill value for the uninitialized section Follow the section name with an sign and a 32 bit constant For example SECTIONS outsect 1 filel obj text file2 obj bss OxFFOOFFOO Fill this hole with OxFFOOFFOO 2 You can also specify a fill value for all the holes in an output section by supplying the fill value after the section definition SECTIONS outsect fill 0 Fills holes with OxFFOOFFO00 1 0x0010 This creates a hole Ef filel obj text filel obj bss This creates another hole 274 3 If you do not specify an initialization value for a hole the linker fills the hole with the value specified with the fill value option see Section 7 4 12 For example suppose the command file link cmd contains the following SECTIONS directive SECTIONS text 0x0100 Create a 100 word hole Now invoke the linker with the fill value option c1470 run linker fill value O0xFFFFFFFF link cmd This fills the hole with OXFFFFFFFF 4 If you do not invoke the linker with the fill value option or otherwise specify a fill value the
98. address The load and run allocations are completely independent so any qualification of one such as alignment has no effect on the other You can also specify run first then load Use parentheses to improve readability The examples below specify load and run addresses data load SLOW MEM align 32 run FAST MEM align applies only to load data load SLOW MEM align 32 run FAST MEM identical to previous example data run load FAST MEM align 32 align 16 align 32 in FAST MEM for run align 16 anywhere for load 7 5 5 2 Uninitialized Sections Uninitialized sections such as bss are not loaded so their only significant address is the run address The linker allocates uninitialized sections only once if you specify both run and load addresses the linker warns you and ignores the load address Otherwise if you specify only one address the linker treats it as a run address regardless of whether you call it load or run This example specifies load and run addresses for an uninitialized section bss load 0x1000 run FAST MEM A warning is issued load is ignored and space is allocated in FAST MEM All of the following examples have the same effect The bss section is allocated in FAST MEM bss load FAST MEM bss run FAST MEM bss FAST MEM SPNU118J August 2011 Linker Description 211 Submit Documentation Feedback Se oF T www BD EIC conr TI Linker Command Files 7 5 5 3 Referr
99. allocates all the output sections Therefore if an expression contains a symbol the address used for that symbol reflects the symbol s address in the executable output file For example suppose a program reads data from one of two tables identified by two external symbols Table1 and Table2 The program uses the symbol cur tab as the address of the current table The cur tab symbol must point to either Table1 or Table2 You could accomplish this in the assembly code but you would need to reassemble the program to change tables Instead you can use a linker assignment statement to assign cur tab at link time prog obj Input file cur tab Tablel Assign cur tab to one of the tables 7 5 8 2 Assigning the SPC to a Symbol 218 A special symbol denoted by a dot represents the current value of the section program counter SPC during allocation The SPC keeps track of the current location within a section The linker s symbol is analogous to the assembler s symbol The symbol can be used only in assignment statements within a SECTIONS directive because is meaningful only during allocation and SECTIONS controls the allocation process See Section 7 5 4 The symbol refers to the current run address not the current load address of the section For example suppose a program needs to know the address of the beginning of the data section By using the global directive see Identify Global Symbols you can create
100. an application Instruct the linker to automatically generate a copy table that contains at least the load address run address and size of the component that needs to be copied Instruct the linker to generate a symbol specified by you that provides the address of a linker generated copy table For instance Example 7 17 can be written as shown in Example 7 18 230 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI www ti com TEXAS INSTRUMENTS Linker Generated Copy Tables Example 7 18 Produce Address for Linker Generated Copy Table SECTIONS UNION GROUP taskl taskl obj text task2 task2 obj text load ROM table task12 copy table GROUP task3 task3 obj text task4 task4 obj text load ROM table task34 copy table run RAM Using the SECTIONS directive from Example 7 18 in the link command file the linker generates two copy tables named 185612 copy table and task34 copy table Each copy table provides the load address run address and size of the GROUP that is associated with the copy table This information is accessible from application source code using the linker generated symbols task12 copy table and task34 copy table which provide the addresses of the two copy tables respectively Using this method you do not have to worry about the creation or maintenance of a copy table You can ref
101. and the ROMS directive Using the image option causes the hex conversion utility to create an output file that has contiguous addresses over the specified memory range and forces the utility to fill address spaces that are not previously filled by raw data from sections defined in the input object file By default the value used to fill the unused portions of the memory range is 0 Because the image option operates over a known range of memory addresses a ROMS directive is needed to specify the origin and length of the memory for the EPROM To burn the section of data at EPROM address 0x0 the paddr option must be used This value overrides the section load address given by the linker e nthis scenario the EPROM is 128K x 8 bits Therefore the memory addresses for the EPROM must range from 0x0 to 0x20000 SPNU 118J August 2011 Hex Conversion Utility Examples 321 Submit Documentation Feedback I I men YP gt 9115 1 I TEXAS INSTRUMENTS Scenario 1 Building a Hex Conversion Command File for a Single 8 Bit EPROM www ti com Because the EPROM memory width is eight bits the memwidth value must be set to 8 Because the physical width of the ROM device is eight bits the romwidth value must be set to 8 Intel format must be used Since memwidth and romwidth have the same value only one output file is generated the number of output files is determined by the ratio of memwidth to romwidth The output
102. application to generate a map file the link command file can be annotated SECTIONS flashcode app tasks obj text load FLASH run PMEM LOAD START flash code ld start RUN START flash code rn start SIZE flash code size In this example the LOAD START RUN_START and SIZE operators instruct the linker to create three symbols Symbol Description flash code Id start Load address of flashcode section flash code rn start Run address of flashcode section flash code size Size of flashcode section These symbols can then be referenced from the copy table The actual data in the copy table will be updated automatically each time the application is linked This approach removes step 1 of the process described in Section 7 8 1 While maintenance of the copy table is reduced markedly you must still carry the burden of keeping the copy table contents in sync with the symbols that are defined in the link command file Ideally the linker would generate the boot copy table automatically This would avoid having to build the application twice and free you from having to explicitly manage the contents of the boot copy table For more information on the LOAD START RUN START and SIZE operators see Section 7 5 8 7 SPNU118J August 2011 Linker Description 229 Submit Documentation Feedback I I men YP 0 9115 1 IJ TEXAS INSTRUMENTS Linker Generated Copy Tables www ti com 7 8
103. as a register symbol or mnemonic It does not create a new symbol name space in the assembler rather it uses the existing substitution symbol name space The syntax for the directive is define substitution string substitution symbol name The define directive is used to prevent corruption of the assembly environment when converting C C headers 12 4 8 The undefine unasg Directives The undef directive is used to remove the definition of a substitution symbol created using define or asg This directive will remove the named symbol from the substitution symbol table from the point of the undef to the end of the assembly file The syntax for these directives is undefine substitution symbol name unasg substitution symbol name This can be used to remove from the assembly environment any C C macros that may cause a problem SPNU118J August 2011 Sharing C C Header Files With Assembly Source 303 Submit Documentation Feedback I I men BADE gt 9115 1 I TEXAS INSTRUMENTS Special Assembler Support www ti com Also see Section 12 4 2 which covers the define directive 12 4 4 The defined Built In Function The defined directive returns true 1 or false 0 depending on whether the name exists in the current substitution symbol table or the standard symbol table In essence defined returns TRUE if the assembler has any user symbol in scope by that name This differs from 51506160 in that isdefed only
104. assemble an entire file as 16 bit instructions for V6 and earlier architectures use the mt assembler option which instructs the assembler to begin the assembly process assembling all instructions as 16 bit instructions The state16 directive performs an implicit halfword alignment before any instructions are written to the section to ensure that all 16 bit instructions are halfword aligned The state16 directive also resets any local labels defined In this example the assembler assembles 16 bit instructions begins assembling 32 bit instructions and returns to assembling 16 bit instructions 1 global globl glob2 2 3 ER Begin assembling 16 bit instructions ER 4 5 00000000 statel6 6 7 00000000 4808 LDR r0 globl a 8 00000002 4909 LDR rl glob2 a 9 00000004 6800 LDR r0 r0 0 00000006 6809 LDR rl r1 1 00000008 0080 LSL ro rO 2 2 0000000a 3156 ADD rl 56h 3 0000000c 4778 BX pc 4 0000000e 46CO NOP 5
105. assembly code that contains line directives See Section 3 13 syms_ignore_case ac Makes case insignificant in the assembly language files For example syms_ignore_case ual makes the symbols ABC and abc equivalent If you do not use this option case is significant default Case significance is enforced primarily with symbol names not with mnemonics and register names Accepts UAL syntax when assembling for ARMv6 and earlier architectures See Section 3 11 3 4 Naming Alternate Directories for Assembler Input The copy include and mlib directives tell the assembler to use code from external files The copy and include directives tell the assembler to read source statements from another file and the mlib directive names a library that contains macro functions Chapter 4 contains examples of the copy include and mlib directives The syntax for these directives is Copy filename include filename mlib filename The filename names a copy include file that the assembler reads statements from or a macro library that contains macro definitions If filename begins with a number the double quotes are required Quotes are recommended so that there is no issue in dealing with path information that is included in the filename specification or path names that include white space The filename may be a complete pathname a partial pathname or a filename with no path information The assembler
106. byte Figure 11 9 illustrates the Tektronix object format Figure 11 9 Extended Tektronix Object Format Checksum 21h 1 5 6 8 1 0 0 0 0 0 0 0 Block length 2 0 2 0 2 0 2 0 2 0 2 1ah226 r Object code 6 bytes 4 Header 15621810000000202020202020 4 as character T Load address 10000000h 1 Blocktype 6 Length of data load address 294 Hex Conversion Utility Description SPNU118J August 2011 S oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Description of the Object Formats 11 12 5 Texas Instruments SDSMAC TI Tagged Object Format ti tagged Option The Texas Instruments SDSMAC Tl Tagged object format supports 16 bit addresses including start of file record data records and end of file record Each data records consists of a series of small fields and is signified by a tag character Tag Character Description K Followed by the program identifier 7 Followed by a checksum 8 Followed by a dummy checksum ignored 9 Followed by a 16 bit load address B Followed by a data word four characters F Identifies the end of a data record Followed by a data byte two characters Figure 11 10 illustrates the tag characters and fields in Tl Tagged object format Figure 11 10 Tl Tagged Object Format Start of file Load record Program address Tag characters identifier
107. code only if the well defined expression is true nonzero or omitted and the assembler breaks the loop and assembles the code after the endloop directive If the expression is false evaluates to 0 the loop continues The endloop directive terminates a repeatable block of code it executes when the break directive is true nonzero or when the number of loops performed equals the loop count given by loop This example illustrates how these directives can be used with the eval directive The code in the first six lines expands to the code immediately following those six lines 1 eval 0y 2 COEF loop 3 word x 100 4 eval 1 x 5 break x 6 6 endloop 00000000 00000000 word 20 eval 0 1 x break 1 6 00000004 00000064 word 1 100 eval 141 x break 2 6 000000088 8 word 2 100 eval 2 1 x break 326 0000000c 0000012C word 3 100 eval 341 x break 4 6 00000010 0 word 4 100 eval 4 1 x break 526 00000014 000001F4 word 5 100 eval 5 1 x break 6 6 114 Assembler Directives www oF Eeconzy TI SPNU118J August 2011 Submit Documentation Feedback 1 TEXAS INSTRUMENTS www ti com macro endm Syntax Description SPNU118J August 2011 Directives Reference Define Macro macname macro parameter parameter model statements or macro directives endm The macro and endm directives are used to define macros You can define a macro anywhere in your
108. conditional block if an expression is false and there is no else statement the assembler continues with the code that follows the endif The endif directive terminates a conditional block The elseif and else directives can be used in the same conditional assembly block and the elseif directive can be used more than once within a conditional assembly block See Section 3 9 4 for information about relational operators This example shows conditional assembly 1 00000001 1 Set 1 2 00000002 SYM2 set 2 3 00000003 SYM3 Set 3 4 00000004 SYM4 set 4 5 6 If 4 JE SYM4 SYM2 2 7 00000000 04 byte SYM4 Equal values 8 else 9 byte SYM2 SYM2 Unequal values 0 endif 11 2 LES if SYM1 lt 10 3 00000001 OA byte 10 Less than equal 4 else 5 byte SYM1 Greater than 6 endif 7 18 If 6 SLE SYM3 SYM2 SYM4 SYM2 9 byte SYM3 SYM2 Unequal value 20 else 21 00000002 08 byte SYM4 SYM4 Equal values 22 endif 23 24 LEST if SYM1 SYM2 25 byte SYM1 Assembler Directives 107 Submit Documentation Feedback I I men YP Ceonmy I I TEXAS INSTRUMENTS Directives Reference www ti com 26 elseif SYM2 SYM3 5 27 00000003 05 byte SYM2 3 28 endif 108 Assembler Directives SPNU 118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Directives Reference import export hidden protected Set Dynamic
109. constant in a C C program C macros whose values are strings cannot be represented as expected in assembly substitution symbols For example define MSG tHI n becomes in assembly define tHI n MSG 6 quoted characters not 5 When used in a C string context you expect this statement to be converted to 5 characters tab H newline NULL but the string assembler directive does not know how to perform the C escape conversions You can use the cstring directive to cause the escape sequences and NULL termination to be properly handled as they would in C C Using the above symbol MSG with a cstring directive results in 5 characters of memory being allocated the same characters as would result if used in a C C strong context See Section 12 4 7 for the cstring directive syntax Sharing C C Header Files With Assembly Source SPNU118J August 2011 Ay EF T Submit Documentation Feedback men WWW Fliconr TI 1 TEXAS INSTRUMENTS www ti com Notes on C C Conversions 12 2 12 C C Built In Functions The C C built in functions such as sizeof are not translated to their assembly counterparts if any if they are used in macros Also their C expression values are not inserted into the resulting assembly macro because macros are evaluated in context and there is no active context when converting the macros to assembly Suitable functions such as 5512601 are available in assembly expressions Howeve
110. cross reference listing by invoking the assembler with the cross reference option see Section 3 3 Options are not case sensitive This example shows how to limit the listings of the byte char int long word and String directives to one line each nd 2 Limit the listing of byte char int long 3 word and string directives to 1 line each 4 5 option B W T 6 00000000 BD byte C OBOh 5 7 00000003 BC char Dp OCOh 6 8 00000008 0000000A int 10 35 at abc 9 00000016 AABBCCDD long OAABBCCDDh 536 A 0 00000024 000015AA word 5546 78h 1 0000002c 45 String Extended Registers 2 3 4 Reset the listing options cte 5
111. cstructt cstruct 10 int bytes 0 3 50 short bytes 4 5 cstructllen endstruct Size 8 alignment 4 estruct2 Struct stl stag cstructl bytes 0 7 sl short bytes 8 9 cendstruct2 endstruct Size 12 alignment 4 Sect data3 word cstructl i0 structl i0 sd word cstructl s0 structl s0 34 word cstructllen structllen 8 Sect data4 word cstruct2 stl struct2 stl 0 SPNU118J August 2011 Assembler Directives 91 Submit Documentation Feedback E oF T www BD EIC conr TI 1 TEXAS INSTRUMENTS Directives Reference www ti com word cstruct2 sl struct2 s1 8 Word cendstruct2 endstruct2 12 92 Assembler Directives SPNU 118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Directives Reference data Assemble Into the data Section Syntax data Description The data directive tells the assembler to begin assembling source code into the data section data becomes the current section The data section is normally used to contain tables of data or preinitialized variables For more information about sections see Chapter 2 Example In this example code is assembled into the data and text sections T ko ko ko 2 ww Reserve space in data x 3
112. diagnostic is one whose severity can be overridden A discretionary diagnostic includes the suffix D otherwise no suffix is present See the ARM Optimizing C C Compiler User s Guide for more information on understanding diagnostic messages issue remarks Issues remarks nonserious warnings which are suppressed by default no warnings Suppresses warning diagnostics errors are still issued set error limit num Sets the error limit to num which can be any decimal value The linker abandons linking after this number of errors The default is 100 verbose diagnostics Provides verbose diagnostics that display the original source with line wrap and indicate the position of the error in the source line 7 4 8 Disable Automatic Library Selection disable auto rts Option The disable auto rts option disables the automatic selection of a run time support library See the ARM Optimizing C C Compiler User s Guide for details on the automatic selection process 7 4 9 Controlling Unreferenced and Unused Sections 7 4 9 1 Disable Conditional Linking disable clink Option The disable clink option disables removal of unreferenced sections in COFF object modules Only sections marked as candidates for removal with the clink assembler directive are affected by conditional linking See Conditionally Leave Section Out of Object Module Output for details on setting up conditional linking using the clink directive which is available
113. during copy The copy compression option controls the compression of the copy data tables The syntax for the options are cinit compression compression kind copy compression compression kind The compression kind can be one of the following types off Don t compress the data rle Compress data using Run Length Encoding l zss Compress data using Lempel Ziv Storer and Symanski compression 7 4 6 Compress DWARF Information compress dwarf Option The compress dwarf option aggressively reduces the size of DWARF information by eliminating duplicate information from input object files This is the default behavior for COFF object files and can be disabled for COFF with the legacy no sym merge option For ELF object files the compress dwarf option eliminates duplicate information that could not be removed through the use of ELF COMDAT groups see the ELF specification for information on COMDAT groups 7 4 7 Control Linker Diagnostics The linker uses certain C C compiler options to control linker generated diagnostics The diagnostic options must be specified before the run linker option diag_error num Categorizes the diagnostic identified by num as an error To determine the numeric identifier of a diagnostic message use the display_error_number option first in a separate link Then use diag_error num to recategorize the diagnostic as an error You can only alter the severity of discretionary diagnost
114. ee eee eee I nennen 218 7 11 3 Setting the Size of the Stack and Heap Sections 218 7 11 4 Autoinitialization of Variables at Run Time ee 249 7 11 5 Initialization of Variables at Load Time ceeseseeeeee I I HH HI HH mn 249 7 11 6 The rom model and ram model Linker Options pp 250 7 12 Linker Example s oi ener enete eee eseseeeeeeeneneneneeseeeeseaeenenereneseeseeseqeenanerenseseceseeqeananer 251 Absolute Lister Description 255 8 1 Producing an Absolute Listing sr in n nm em nhe nnnm ehh enne nnn 256 8 2 Invoking the Absolute Lister so rit 257 8 3 Absolute Lister Example m hne hme he e hh hh e nnnm ee nnne 258 Cross Reference Lister Description pp 261 9 1 Producing a Gross Referernce Listing 262 9 2 Invoking the Cross Reference Lister eva 4 263 9 3 Cross Reference Listing Example oo 264 Object File Utilties 0m EAr ELEA KIANA KETELS EEEIEE EEEE REEERE
115. equal to 32 768 or 8000 25 Constant equal to 25 or 1946 Assembler Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Constants 3 6 4 Hexadecimal Integers A hexadecimal integer constant is a string of up to eight hexadecimal digits followed by the suffix H or h or preceded by 0x Hexadecimal digits include the decimal values 0 9 and the letters A F or a f A hexadecimal constant must begin with a decimal value 0 9 If fewer than eight hexadecimal digits are specified the assembler right justifies the bits These are examples of valid hexadecimal constants 78h Constant equal to 120 or 0078 0x78 Constant equal to 1204 or 0078 format OFh Constant equal to 15 37ACh Constant equal to 14 2524 4 3 6 5 Character Constants A character constant is a single character enclosed in single quotes The characters are represented internally as 8 bit ASCII characters Two consecutive single quotes are required to represent each single quote that is part of a character constant A character constant consisting only of two single quotes is valid and is assigned the value 0 These are examples of valid character constants a Defines the character constant a and is represented internally as 6146 Defines the character constant C and is represented internally as 4316 Defines the character constant and is represented internally as 2
116. extern 3 LDR R1 intern 1 intern 3 intern 2 Illegal 52 Assembler Description SPNU 118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Built in Functions 3 10 Built in Functions The assembler supports built in functions for conversions and various math computations Table 3 4 describes the built in functions The expr must be a constant value The built in substitution symbol functions are discussed in Section 5 3 2 Table 3 4 Built In Mathematical Functions Function Description acos expr Returns the arc cosine of expr as a floating point value asin expr Returns the arc sin of expras a floating point value atan expr Returns the arc tangent of expr as a floating point value atan2 expr y Returns the arc tangent of expr as a floating point value in range rr rr ceil expr Returns the smallest integer not less than expr cos expr Returns the cosine of expr as a floating point value cosh expr Returns the hyperbolic cosine of expr as a floating point value cvf expr Converts expr to a floating point value cvi expr converts expr to integer value exp expr Returns the exponential function e 28 fabs expr Returns the absolute value of expr as a floating point value floor expr Returns the largest integer not greater than expr fmod expr y Returns the remainder of expr expr2 int expr Returns 1 if expr has an integer value else r
117. file is named with the o option The hex conversion command file for Scenario 1 is shown in Example C 2 This command file uses the following options to select the requirements of the system Option Description i Create Intel format image Generate a memory image map example1 mxp Generate example1 mxp as the map file of the conversion 0 example1 hex Name example1 hex as the output file memwidth 8 Set EPROM system memory width to 8 romwidth 8 Set physical ROM width to 8 Example C 2 Hex Conversion Command File for Scenario 1 Hex Conversion Command file for Scenario 1 a out linked object file input I Intel format image map examplel mxp Generate a map of the conversion o examplel hex Resulting hex output file memwidth 8 EPROM memory system width romwidth 8 Physical width of ROM ROMS EPROM origin 0x0 length 0 SECTIONS 5602 paddr 0 Select only section 8602 for conversion 322 Example C 3 shows the contents of the resulting map file example1 mxp Figure C 2 shows the contents of the resulting hex output file example1 hex The hex conversion utility places the data tables secB at address 0 and then fills the remainder of the address space with the default fill value of 0 For more information about the Intel MCS 86 object format see Figure 11 7 Hex Conversion Utility Examples SPNU118J August 2011 S oF T Submit Documen
118. fl 4 path tools lib path lt kind gt archive lt kind gt lt file gt rtsxxx lib lt file gt name printf obj name input file input file list SPNU 118J August 2011 XML Link Information File Description 311 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Document Elements www ti com B 2 3 Object Component List The next section of the XML link information file contains a specification of all of the object components that are involved in the link An example of an object component is an input section In general an object component is the smallest piece of object that can be manipulated by the linker The lt object_component_list gt is a container element enclosing any number of lt object_component gt elements Each lt object_component gt specifies a single object component Each lt object_component gt has an id attribute so that it can be referenced directly from other elements such as a lt logical_group gt An lt object_component gt is a container element enclosing the following elements The lt name gt element names the object component string The load address element specifies the load time address of the object component constant The run address element specifies the run time address of the object component constant The lt size gt element specifies the size of the object component constant The input fi
119. in bold should be entered as shown portions of a syntax that are in italics describe the type of information that should be entered Square brackets and identify an optional parameter If you use an optional parameter you specify the information within the brackets Unless the square brackets are in the bold typeface do not enter the brackets themselves The following is an example of a command that has an optional parameter cl470 options filenames run linker ink options object files e Braces and indicate that you must choose one of the parameters within the braces you do not enter the braces themselves This is an example of a command with braces that are not included in the actual syntax but indicate that you must specify either the rom model or ram model option cl470 run linker rom model ram_model filenames output file name out library ibraryname n assembler syntax statements column 1 is reserved for the first character of a label or symbol If the label or symbol is optional it is usually not shown If it is a required parameter it is shown starting against the left margin of the box as in the example below No instruction command directive or parameter other than a symbol or label can begin in column 1 symbol usect section name size in bytes alignment Some directives can have a varying number of parameters For example the
120. is used to compute the CRC of the text data from b1 obj The CRC tables generated by the linker are created in the special section Tl crctab which can be placed in the same manner as other sections In this case the CRC table my crc table for b1 is created in section Tl crctab my crc table for b1 and that section is placed in the CRCMEM memory region 242 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Linker Generated CRC Tables Example 7 27 Using a Single Table for Multiple Sections SECTIONS Section to be verified 1 al obj text crc table my crc table for al and c1 Section to be verified 3 cl obj text crc table my crc table for al and cl algorithm TMS570 CRC64 ISO In Example 7 27 the same identifier my crc table for a1 and c1 is specified for both a1 obj and c1 obj The linker creates a single table that contains entries for both text sections Example 7 28 Applying the crc table Operator to a GROUP or UNION SECTIONS 1 UNION sectionl crc table tablel section2 crc table table2 When the crc table operator is applied to a GROUP or a UNION the linker applies the table specification to the members of the GROUP or UNION In Example 7 28 the linker creates two CRC tables table1 and table2 table1 contains one entry for section1 Because both sections are me
121. ke word 9 10 word 11 12 Start assembling into a named initialized section var defs ck Sect var defs word 17 18 E Resume assembling into the data section 2 word 13 14 bss sym 19 Reserve space in bss word 15 16 Still in data x Resume assembling into the text section K
122. ke k k k k kk k A k k k k k k kk k k k k k kk k kk k kk k kk k k kk k k Of demo obj Gtrl obj tables obj RK KKK IKK k A A k kk Ck kk kk ke kk ke kk Ck kk Ck kk ke ke kk ke ke kk k k ke kkk k Josse Specify the Memory Configurations Sani E E K k k k k k k e e k k A k k k k k k kk k kk k kk k kk k k k kk k k f MEMORY FAST MEM org SLOW MEM org EEPROM gt Org E E K k k k Ck kCkCk kk Ck Ck kk Ck kk Ck kk Ck Ck kk Ck kk Ck Kk Ck kk Ck Ck kk Ck Ck Kk Ck Ck kk ko k k k ke ke ke ke ke ke k k f 0x00000000 len 0x00001000 PROGRAM MEMORY ROM 0x00001000 len 0x00001000 DATA MEMORY RAM 0x08000000 len 0x00000400 COEFFICIENTS EEPROM f Specify the Output Sections SPNU118J August 2011 Submit Documentation Feedback E oF T www BD EIC conr TI Linker Description 251 Lin
123. kk kk Ck kk ke kk kk ke ke ke ke ek MY CHECK CRC returns 1 if CRCs match 0 otherwise RRR KK KR IK RK ko IK kk Ck kk koc ke ek unsigned int my check CRC CRC TABLE tp int i SPNU118J August 2011 Linker Description 245 Submit Documentation Feedback E oF T www BD EIC conr TI I TEXAS INSTRUMENTS Linker Generated CRC Tables www ti com Example 7 30 General Purpose CRC Check Routine continued for i 0 i gt tp num recs i CRC RECORD cro rec tp recs i A E E K k k kk kk ke kk Ck ko kk Ck kk Ck kk kk ck ko ko kc kk ke ke ke ke ke ke kk COMPUTE CRC OF DATA STARTING AT crc rec addr FOR crc rec size UNITS USE crc rec crc alg ID to select algorithm COMPARE COMPUTED VALUE TO crc rec crc value RRR k k k kk ke kk kk kkk k if all CRCs match return 1 else return 0 7 9 5 A Note on the TMS570_CRC64_ISO Algorithm The MCRC module calculates CRCs on 64 bit chunks of data This is accomplished by writing a long long value to two memory mapped registe
124. length len or I The value specified in bytes is an expression of 32 bit constants which can be decimal octal or hexadecimal fill specifies a fill character for the memory range enter as fill or f Fills are optional The value is a integer constant and can be decimal octal or hexadecimal The fill value is used to fill areas of the memory range that are not allocated to a section Filling Memory Ranges NOTE f you specify fill values for large memory ranges your output file will be very large because filling a memory range even with Os 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 OFFFFFFFFh MEMORY RFILE RW o 0020 0 1 0x1000 f OxFFFF You normally use the MEMORY directive in conjunction with the SECTIONS directive to control allocation of output sections After you use MEMORY to specify the target system s memory model you can use SECTIONS to allocate output sections into specific named memory ranges or into memory that has specific attributes For example you could allocate the text and data sections into the area named FAST MEM and allocate the bss section into the area named SLOW MEM Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Command Files 7 5 8 8 Expr
125. linker fills holes with Os Whenever a hole is created and filled in an initialized output section the hole is identified in the link map along with the value the linker uses to fill it 7 5 9 4 Explicit Initialization of Uninitialized Sections You can force the linker to initialize an uninitialized section by specifying an explicit fill value for it in the SECTIONS directive This causes the entire section to have raw data the fill value For example SECTIONS bss fill 0x12341234 Fills bss with 0x12341234 Filling Sections NOTE Because filling a section even with Os causes raw data to be generated for the entire section in the output file your output file will be very large if you specify fill values for large sections or holes SPNU118J August 2011 Linker Description 225 Submit Documentation Feedback I I men BADE 0 9115 1 I TEXAS INSTRUMENTS Object Libraries www ti com 7 6 Object Libraries An object library is a partitioned archive file that contains object files as members Usually a group of related modules are grouped together into a library When you specify an object library as linker input the linker includes any members of the library that define existing unresolved symbol references You can use the archiver to build and maintain libraries Section 6 1 contains more information about the archiver Using object libraries can reduce link time and the size of the executable mo
126. loaded for purposes of the code that relocates the section This example shows the use of a load time address label sect examp label examp load load address of section start run address of section code finish run address of section end label examp end load address of section end See Section 7 5 5 for more information about assigning run time and load time addresses in the linker Assembler Directives 111 Submit Documentation Feedback Se oF T www BD EIC conr TI 1 TEXAS INSTRUMENTS Directives Reference www ti com ength width Set Listing Page Size Syntax length page length Width page width Description Two directives allow you to control the size of the output listing file The length directive sets the page length of the output listing file It affects the current and following pages You can reset the page length with another length directive Default length 60 lines If you do not use the length directive or if you use the length directive without specifying the page length the output listing length defaults to 60 lines Minimum length 1 line Maximum length 32 767 lines The width directive sets the page width of the output listing file It affects the next line assembled and the lines following You can reset the page width with another width directive Default width 132 characters If you do not use the width directive or if you use the Width directive without sp
127. macro The x and z from the out_block macro however are accessible to the in_block macro Example 5 15 Using Nested Macros in block macro y a 5 Visible parameters are y a and x z from the calling macro endm out block macro X y Z Visible parameters are x y z in block x y macro call with x and y as arguments endm out block macro call Example 5 16 shows recursive and fact macros The fact macro produces assembly code necessary to calculate the factorial of n where n is an immediate value The result is placed in data memory address loc The fact macro accomplishes this by calling fact1 which calls itself recursively Example 5 16 Using Recursive Macros fact macro N loc N is an integer constant Register loc address N E N 2 0 gt 1 1 MOV loc 41 else MOV loc N lt 2 so store in loc eval 1 N Decrement N and do the factorial of N 1 facti Call fact with current environment endm facti macro du lt 1 MOV RO N gt 1 so store in RO MUL loc 20 106 Multiply present factorial by present position eval 1 Decrement position factl Recursive call endif endm 158 Macro Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com 5 10 Macro Directives Summary Macro Directives Summary The directives listed in Table 5 2 through Tabl
128. multiplication or division by a relocatable or external symbol An expression cannot contain unresolved symbols that are relocatable to other sections Symbols that have been defined as global with the global directive can also be used in expressions in Table 3 3 these symbols are referred to as external Table 3 3 Expressions With Absolute and Relocatable Symbols If A is and If B is then A Bis and A Bis absolute absolute absolute absolute absolute relocatable relocatable illegal absolute external external illegal relocatable absolute relocatable relocatable relocatable relocatable illegal absolute relocatable external illegal illegal external absolute external external external relocatable illegal illegal external external illegal illegal A and B must be in the same section otherwise adding relocatable symbols to relocatable symbols is illegal SPNU118J August 2011 Assembler Description 51 Submit Documentation Feedback WWW BI 166o12 TI I TEXAS INSTRUMENTS Expressions www ti com 3 9 6 Expression Examples Following are examples of expressions that use relocatable and absolute symbols These examples use four symbols that are defined in the same section global extern 1 Defined in an external module intern 1 word D Relocatable defined in current 0 module 181 set 2 12581 2 intern 2 Relocatable defined in current module intern_3 Relocatable defined in cur
129. name You should use your mystrname in assembly the same as you would in C C but do not be confused by the assembly structure definition in the list which contains the temporary name You can avoid the temporary name by specifying a name for the structure as in typedef struct a st name mystrname If a shorthand method is used in C to declare a variable with a particular structure for example extern struct a name int a member a variable Then after the structure is converted to assembly a tag directive is generated to declare the structure of the external variable such as a variable tag a st name This allows you to refer a variable member in your assembly code 12 2 14 Function Variable Prototypes Non static function and variable prototypes not definitions will result in a global directive being generated for each symbol found See Section 12 3 1 for C name mangling issues Function and variable definitions will result in a warning message being generated see the WARN NOWARN parameter discussion for where these warnings are created for each and they will not be represented in the converted assembly The assembly symbol representing the variable declarations will not contain type information about those symbols Only a global will be issued for them Therefore it is your responsibility to ensure the symbol is used appropriately See Section 12 2 13 for information on variables names wh
130. name 1 attr origin expression length expression fill constant name n attr origin expression length expression fill constant name names a memory range A memory name can be one to 64 characters valid characters include A Z a z and The names have no special significance to the linker they simply identify memory ranges Memory range names are internal to the linker and are not retained in the output file or in the symbol table 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 certain memory ranges If you do not use any attributes you can allocate any output section into any range with no restrictions Any memory for which no attributes are specified including all memory in the default model has all four attributes Valid attributes are R specifies that the memory can be read W specifies that the memory can be written to X specifies that the memory can contain executable code l specifies that the memory can be initialized origin specifies the starting address of a memory range enter as origin org or o The value specified in bytes is an expression of 32 bit constants which can be decimal octal or hexadecimal length specifies the length of a memory range enter as
131. names of the individual members within the 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 See Section 5 1 for how the assembler expands macros You can control the listing of library entry expansions with the mlist directive For more information about the mlist directive see Section 5 8 and Start Stop Macro Expansion Listing Only macros that are actually called from the library are extracted and they are extracted only once You can use the archiver to create a macro library by including the desired files in an archive A macro library is no different from any other archive except that the assembler expects the macro library to contain macro definitions The assembler expects only macro definitions in a macro library putting object code or miscellaneous source files into the library may produce undesirable results For information about creating a macro library archive see Section 6 1 Macro Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Using Conditional Assembly in Macros 5 5 Using Conditional Assembly in Macros The conditional assembly directives are if elseif else endif and
132. normally be allocated Most memory maps contain various types of memory RAM ROM EPROM etc in varying amounts you may want to place a section in a specific type of memory For further explanation of section placement within the memory map see the discussions in Section 7 5 3 and Section 7 5 4 Relocation The assembler treats each section as if it began at address 0 All relocatable symbols labels are relative to address 0 in their sections Of course all sections cannot actually begin at address 0 in memory so the linker relocates sections by Allocating them into the memory map so that they begin at the appropriate address as defined with the linkers MEMORY directive Adjusting symbol values to correspond to the new section addresses Adjusting references to relocated symbols to reflect the adjusted symbol values The linker uses relocation entries to adjust references to symbol values The assembler creates a relocation entry each time a relocatable symbol is referenced The linker then uses these entries to patch the references after the symbols are relocated Example 2 1 contains a code segment for a ARM device that generates relocation entries Example 2 1 Code That Generates Relocation Entries 1 2 Li Generating Relocation Entries Wok
133. object file The template directive is used for early template instantiation It encodes information about a template that has yet to be instantiated This is 8 COFF C directive The compiler opts directive indicates that the assembly code was produced by the compiler and which build model options were used for this file 4 2 Directives That Define Sections These directives associate portions of an assembly language program with the appropriate sections The bss directive reserves space in the bss section for uninitialized variables The clink directive can be used in the COFF ABI model to indicate that a section is eligible for removal at link time via conditional linking Thus if no other sections included in the link reference the current or specified section then the section is not included in the link The clink directive can be applied to initialized or uninitialized sections The data directive identifies portions of code in the data section The data section usually contains initialized data The retain directive can be used in the EABI model to indicate that the current or specified section must be included in the linked output Thus even if no other sections included in the link reference the current or specified section it is still included in the link The sect directive defines an initialized named section and associates subsequent code or data with that section A section defined with sect can conta
134. of the library to use If the issue remarks option is specified before the run linker option the linker reports which library was chosen e Example 1 ISA v7A68 little endian cl470 mv7A8 me issue remarks main c z 1 lnk cmd mylib lib Linking remark linking in mylib THUMBv7A8 le lib in place of mylib lib Example 2 ISAv5 big endian 01470 mv5e issue remarks main c z 1 lnk cmd mylib lib Linking remark linking in mylib ARMv4 be lib in place of mylib lib In Example 2 there was no version of the library for ISAv5 but an ISAv4 library was available and is compatible so it was used 6 5 3 Listing the Contents of an Index Library The archiver s t option can be used on an index library to list the archives indexed by an index library ar470 t mylib lib SIZE DATE FILE NAME 118 Mon Apr 23 12 45 22 2007 mylib ARMv4 be lib libinfo 119 Mon Apr 23 12 45 22 2007 mylib_ARMv4_le lib libinfo 119 Mon Apr 23 12 45 22 2007 mylib_THUMBv4_be lib libinfo 119 Mon Apr 23 12 45 22 2007 mylib THUMBv4 le lib libinfo 119 Mon Apr 23 12 45 22 2007 mylib THUMBv7A8 le lib libinfo 0 Mon Apr 23 12 45 22 2007 11 SSLIBINFO The indexed object file libraries have an additional libinfo extension in the archiver listing The T LIBINFO member is a special member that designates mylib lib as an index library rather than a regular library If the archiver s d command is used on an index library to delete a libinfo membe
135. program but you must define the macro before you can use it Macros can be defined at the beginning of a source file in an include copy file or in a macro library 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 opcode field parameters are optional substitution symbols that appear as operands for the macro directive model statements are instructions or assembler directives that are executed each time the macro is called macro directives are used to control macro expansion endm marks the end of the macro definition Macros are explained in further detail in Chapter 5 Assembler Directives 115 Submit Documentation Feedback Se oF T www BD FEe cenr TI Directives Reference mlib Syntax Description Example 116 Assembler Directives I TEXAS INSTRUMENTS www ti com Define Macro Library mlib filename The mlib directive provides the assembler with the filename of a macro library A macro library is a collection of files that contain macro definitions The macro definition files are bound into a single file called a library or archive by the archiver Each file in a macro library contains one macro definition that corresponds to the name of the file The filename of a macro library member must be the same as the macro name and its extension mu
136. quotation marks do one of the following For Windows use asm_define name value V For example asm define2car V sedanV For UNIX use asm_define name value For example asm_define car sedan For Code Composer enter the definition in a file and include that file with the cmd file or option Once you have defined the name with the asm define option the symbol can be used in place of a constant value a well defined expression or an otherwise undefined symbol used with assembly directives and instructions For example on the command line you enter 01470 asm define SYM1 1 asm define SYM2 2 asm define SYM3 3 asm define SYM4 4 value asm Since you have assigned values to SYM1 SYM2 SYM3 and SYM4 you can use them in source code Example 3 2 shows how the value asm file uses these symbols without defining them explicitly Within assembler source you can test the symbol defined with the asm define option with the following directives 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 z value 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 46 Assembler Description SPNU118J August 2011 oF T Submit Documentation Feedback www BD EIC conr TI 1 T
137. related allocation unit Linker Command File Operator Equivalencies NOTE LOAD START and START are equivalent as are LOAD END END and LOAD SIZE SIZE The LOAD names are recommended for clarity SPNU118J August 2011 Submit Documentation Feedback Linker Description 221 www BRD EKireconr TI I TEXAS INSTRUMENTS Linker Command Files www ti com The new address and dimension operators can be associated with several different kinds of allocation units including input items output sections GROUPs and UNIONs The following sections provide some examples of how the operators can be used in each case 7 5 8 7 1 Input Items Consider an output section specification within a SECTIONS directive outsect sl obj text end of 1 start of s2 s2 o0bj text end of 82 or This can be rewritten using the START and END operators as follows outsect Sl obj text END end of s1 s2 0bj text START start of s2 END end of s2 The values of end of s1 and end of s2 will be the same as if you had used the dot operator in the original example but start of s2 would be defined after any necessary padding that needs to be added between the two text sections Remember that the dot operator would cause start of s2 to be defined before any necessary padding is inserted between the two input sections The syntax for using these operators in association with input sections calls f
138. representation 12 4 Special Assembler Support 12 4 1 Enumerations enum emember endenum New directives have been created to support a pseudo scoping for enumerations The format of these new directives is ENUM NAME enum MEMBEH 1 emember value MEMBER2 emember value endenum The enum directive begins the enumeration definition and endenum terminates it The enumeration name ENUM NAME cannot be used to allocate space its size is reported as zero The format to use the value of a member is ENUM NAME MEMBER similar to a structure member usage The emember directive optionally accepts the value to set the member to just as in C C If not specified the member takes a value one more than the previous member As in C C member names cannot be duplicated although values can be Unless specified with emember the first enumeration member will be given the value 0 zero as in C C The endenum directive cannot be used with a label as structure endstruct directives can because the endenum directive has no value like the endstruct does containing the size of the structure Conditional compilation directives if else elseif endif are the only other non enumeration code allowed within the enum endenum sequence 12 4 2 The define Directive The new define directive functions in the same manner as the asg directive except that define disallows creation of a substitution symbol that has the same name
139. source language refer to the ARM Optimizing C C Compiler User s Guide The value of symbol c intOO if present The _c_intOO symbol must be the entry point if you are linking code produced by the C compiler The value of symbol main if present 0 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 c1470 run linker entry point begin filel obj file2 0bj 7 4 12 Set Default Fill Value fill value Option The fill value option fills the holes formed within output sections The syntax for the option is fill valuez value The argument value is a 32 bit constant up to eight hexadecimal digits If you do not use fill value the linker uses 0 as the default fill value This example fills holes with the hexadecimal value ABCDABCD 01470 run linker fill value OxABCDABCD filel obj file2 obj 7 4 13 Generate List of Dead Functions generate dead funcs list Option The generate dead funcs list option creates a list of functions that are never referenced dead and writes the list to the specified file If no filename is specified the default filename dead funcs xml is used The syntax for the option is generate dead funcs list ilename Refer to the ARM Optimizing C C Compiler User s Guide for details on the generate dead funcs list option and the corresponding use dead funcs list option 7 4 14 Define Heap
140. system of object files configured according to a standard developed by AT amp T These files are relocatable in memory space command file A file that contains options filenames directives or commands for the linker or hex conversion utility SPNU118J August 2011 Glossary 331 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Appendix D www ti com 332 comment A source statement or portion of a source statement that documents or improves readability of a source file Comments are not compiled assembled or linked they have no effect on the object file compiler program A utility that lets you compile assemble and optionally link in one step The compiler runs one or more source modules through the compiler including the parser optimizer and code generator the assembler and the linker conditional processing A method of processing one block of source code or an alternate block of source code according to the evaluation of a specified expression configured memory Memory that the linker has specified for allocation constant A type whose value cannot change cross reference lister A utility that produces an output file that lists the symbols that were defined what file they were defined in what reference type they are what line they were defined on which lines referenced them and their assembler and linker final values The cross reference lister uses linked obje
141. tests for NON substitution symbols The syntax is defined substitution symbol name A statement such as if defined macroname is then similar to the C code ifdef macroname See Section 12 4 2 and Section 12 4 3 for the use of define and undef in assembly 12 4 5 The sizeof Built In Function The new assembly built in function sizeof can be used to query the size of a structure in assembly It is an alias for the already existing structsz The syntax is sizeof structure name The sizeof function can then be used similarly to the C built in function sizeof The assembler s sizeof built in function cannot be used to ask for the size of basic C C types such as sizeof int because those basic type names are not represented in assembly Only complex types are converted from C C to assembly Also see Section 12 2 12 which notes that this conversion does not happen automatically if the C C sizeof built in function is used within a macro 12 4 6 Structure Union Alignment amp alignof The assembly struct and union directives now take an optional second argument which can be used to specify a minimum alignment to be applied to the symbol name This is used by the conversion process to pass the specific alignment from C C to assembly The assembly built in function alignof can be used to report the alignment of these structures This can be used even on assembly structures and the function w
142. the beginning of a line in the command file to include comments See Example 6 1 for an example using an archiver command file a adds the specified files to the library This command does not replace an existing member that has the same name as an added file it simply appends 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 do not specify filenames the archiver replaces the library members 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 library If you specify filenames only those files are listed If you do not specify any filenames the archiver lists all the members in the specified library extracts the specified files If you do not specify member names the archiver extracts all library members When the archiver extracts a member it simply copies the member into the current directory it does not remove it from the library In addition to one of the commands you can specify options To use options combine them with a command for example to use the a command and the s option enter as or as The hyphen is optional for archiver options only These are the archiver options q quiet suppresses the banner and status messages S prints a list of the global symbols that are defined in
143. the call to foo that is inside of bar then with trampolines the linker changes the original call to foo into a call to foo_trampoline as shown bar call foo_trampoline call a trampoline for foo The above code generates a trampoline code section called foo_trampoline which contains code that executes a long branch to the original called function foo For example foo_trampoline branch_long foo Trampolines can be shared among calls to the same called function The only requirement is that all calls to the called function be linked near the called function s trampoline The syntax for this option is trampolines on off The default setting is on For ARM trampolines are turned on by default When the linker produces a map file the map file option and it has produced one or more trampolines then the map file will contain statistics about what trampolines were generated to reach which functions A list of calls for each trampoline is also provided in the map file The Linker Assumes R13 Contains the Stack Pointer NOTE Assembly language programmers must be aware that the linker assumes R13 contains the stack pointer The linker must save and restore values on the stack in trampoline code that it generates If you do not use R13 as the stack pointer you should use the linker option that disables trampolines trampolines off Otherwise trampolines could corrupt memory and overwrite register values 7 4 31 1 Carry
144. the filename 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 Ist that contains filenames and another file called dir cmd that contains linker directives you could enter 1470 run linker names lst dir cmd One command file can call another command file this type of nesting is limited to 16 levels If a command file calls another command file as input this statement must be the ast statement in the calling command file Blanks and blank lines are insignificant in a command file except as delimiters This also applies to the format of linker directives in a command file Example 7 2 shows a sample command file that contains linker directives SPNU118J August 2011 Linker Description 193 Submit Documentation Feedback I I men YP gt 9115 1 Linker Command Files Example 7 2 Command File With Linker Directives 1 TEXAS INSTRUMENTS www ti com a obj b obj c obj output file prog out map file prog map SECTIONS text SLOW MEM data gt SLOW MEM bss FAST MEM Input fil Options MEMORY MEMORY di 1 FAST MEM origin 0 length SLOW MEM origin 0 length enames rective 0x0100 0x1000 SECTIONS directive xf 27 f For more information see Section 7 5 3 for the MEMORY directive and Section 7 5 4 for the SECTIONS directi
145. the library This option is valid only with the a r and d commands u replaces library members only if the replacement has a more recent modification date You must use the r command with the u option to specify which members to replace V verbose provides a file by file description of the creation of a new library from an old library and its members names the archive library to be built or modified If you do not specify an extension for libname the archiver uses the default extension ib names individual files to be manipulated These files can be existing library members or new files to be added to the library When you enter a filename you must enter a complete filename including extension if applicable Naming Library Members NOTE It is possible but not desirable for a library to contain several members with the same name If you attempt to delete replace or extract a member whose name is the same as another library member the archiver deletes replaces or extracts the first library member with that name 164 Archiver Description SPNU118J August 2011 AEF T Submit Documentation Feedback men Www FIIC conr TI www ti com 6 4 TEXAS INSTRUMENTS Archiver Examples Archiver Examples The following are examples of typical archiver operations If you want to create a library called function lib that contains the files sine obj cos obj and flt obj enter ar470 a function sin
146. the stack size is different When the linker defines the stack section it also defines a global symbol STACK SIZE and assigns it a value equal to the size of the section The default software stack size is 2K bytes 7 4 29 Enforce Strict Compatibility strict compatibility Option The linker performs more conservative and rigorous compatibility checking of input object files when you specify the strict compatibility option Using this option guards against additional potential compatibility issues but may signal false compatibility errors when linking in object files built with an older toolset or with object files built with another compiler vendor s toolset To avoid issues with legacy libraries the strict compatibility option is turned off by default 7 4 30 Mapping of Symbols symbol map Option Symbol mapping allows a symbol reference to be resolved by a symbol with a different name Symbol mapping allows functions to be overridden with alternate definitions This feature can be used to patch in alternate implementations which provide patches bug fixes or alternate functionality The syntax for the symbol map option is symbol map refname defname For example the following code makes the linker resolve any references to foo by the definition foo patch symbol map foo foo patch 7 4 81 Generate Far Call Trampolines trampolines Option The ARM device has PC relative call and PC relative branch instructions
147. to 1 if the TI ARM9 ABI is enabled the abi ti arm9 abi option is used otherwise it is set to 0 Set to 1 if the EABI ABI is enabled the abi eabi option is used otherwise it is set to 0 Set to 1 if NEON SIMD extension is targeted the neon option is used otherwise it is set to 0 Set to 1 if the v4 architecture ARM7 is targeted the mv4 option is used otherwise it is set to 0 Set to 1 if the v5E architecture ARMO9E is targeted the mv5e option is used otherwise it is set to 0 Set to 1 if the v6 architecture ARM11 is targeted the mv6 option is used otherwise it is set to 0 Set to 1 if any v7 architecture Cortex is targeted otherwise it is set to 0 Set to 1 if the v7M3 architecture Cortex M3 is targeted the mv7M3 option is used otherwise it is set to O Set to 1 if the v7A8 architecture Cortex A8 is targeted the mv7A8 option is used otherwise it is set to O Set to 1 if the v7R4 architecture Cortex R4 is targeted the mv7R4 option is used otherwise it is set to O Set to 1 if the VFP coprocessor is enabled any float support option is used otherwise it is set to 0 Set to 1 if the VFP coprocessor is enabled the float support vfpv3 option is used otherwise it is set to O Set to 1 if the VFP coprocessor is enabled the float support vfpv3d16 option is used otherwise it is set to O Status registers as defined in the following table Re
148. to the first comma and removes leading and trailing blanks In either case a character string is read and assigned to the substitution symbol The syntax of the asg directive is asg character string substitution symbol Example 5 3 shows character strings being assigned to substitution symbols Example 5 3 The asg Directive asg R13 stack ptr Stack pointer The eval directive performs arithmetic on numeric substitution symbols The eval directive evaluates the expression and assigns the string value of the result to the substitution symbol If the expression is not well defined the assembler generates an error and assigns the null string to the symbol The syntax of the eval directive is eval well defined expression substitution symbol Example 5 4 shows arithmetic being performed on substitution symbols Example 5 4 The eval Directive asg 1 counter loop 100 word counter eval counter 1 counter endloop In Example 5 4 the asg directive could be replaced with the eval directive eval 1 counter without changing the output In simple cases like this you can use eval and asg interchangeably However you must use eval if you want to calculate a value from an expression While asg only assigns a character string to a substitution symbol eval evaluates an expression and then assigns the character string equivalent to a substitution symbol See As
149. to the symbol after linking The statement number where the symbol is defined The line number where the symbol is referenced If the line number is followed by an asterisk then that reference can modify the contents of the object A blank in this column indicates that the symbol was never used SPNU 118J August 2011 Submit Documentation Feedback www oF Ee conzy TI 1 TEXAS INSTRUMENTS www ti com Cross Reference Listing Example Table 9 1 Symbol Attributes in Cross Reference Listing Character Meaning Symbol defined in a text section Symbol defined in a data section Symbol defined in a sect section Symbol defined in a bss or usect section SPNU118J August 2011 Cross Reference Lister Description 265 Submit Documentation Feedback ah py I I men wwweBIDERKconr T 266 Cross Reference Lister Description SPNU118J August 2011 T4 E I T Submit Documentation Feedback 1 efas men WWW conr TI 1 Chapter 10 SPNU118J August 2011 Object File Utilities This chapter describes how to invoke the following utilities The object file display utility prints the contents of object files executable files and or archive libraries in both text and XML formats The disassembler accepts object files and executable files as input and produces an assembly listing as output This listing shows assembly instructions their opcodes and the section program counter values The name u
150. up a macro macro expansion The process of inserting source statements into your code in place of a macro call macro library An archive library composed of macros Each file in the library must contain one macro its name must be the same as the macro name it defines and it must have an extension of asm map file An output file created by the linker that shows the memory configuration section composition section allocation symbol definitions and the addresses at which the symbols were defined for your program member The elements or variables of a structure union archive or enumeration memory map A map of target system memory space that is partitioned into functional blocks mnemonic An instruction name that the assembler translates into machine code model statement Instructions or assembler directives in a macro definition that are assembled each time a macro is invoked named section An initialized section that is defined with a sect directive object file An assembled or linked file that contains machine language object code object library An archive library made up of individual object files object module A linked executable object file that can be downloaded and executed on a target system SPNU118J August 2011 Glossary 333 Submit Documentation Feedback I I men BADE Ceonmy I I TEXAS INSTRUMENTS Appendix D www ti com 334 operand An argument of an assembl
151. uses it to determine which memory locations can be used for object code The memory configurations of ARM systems differ from application to application The MEMORY directive allows you to specify a variety of configurations After you use MEMORY to define a memory model you can use the SECTIONS directive to allocate output sections into defined memory For more information see Section 2 3 and Section 2 4 7 5 3 1 Default Memory Model If you do not use the MEMORY directive the linker uses a default memory model that is based on the ARM architecture This model assumes that the full 32 bit address space 2 locations is present in the system and available for use For more information about the default memory model see Section 7 7 7 5 3 2 MEMORY Directive Syntax The MEMORY directive identifies ranges of memory that are physically present in the target system and can be used by a program Each range has several characteristics Name Starting address Length Optional set of attributes Optional fill specification When you use the MEMORY directive be sure to identify all memory ranges that are available for loading code Memory defined by the MEMORY directive is configured any memory that you do not explicitly account for with MEMORY is unconfigured The linker does not place any part of a program into unconfigured memory You can represent nonexistent memory spaces by simply not including an address range in a MEMORY dire
152. void somefunc int arg The above format is the short method for declaring a single function To use this method for multiple functions you can also use the following syntax extern C void somefunc int arg int anotherfunc int arg 12 3 2 Derived Classes 302 Derived classes are only partially supported when converting to assembly because of issues related to C scoping which does not exist in assembly The greatest difference is that base class members do not automatically become full top level members of the derived class For example class base public ine bl class derived public base public int d1 In C code the class derived would contain both integers b1 and d1 In the converted assembly structure derived the members of the base class must be accessed using the name of the base class such as derived b base b1 rather than the expected derived b1 A non virtual non empty base class will have b prepended to its name within the derived class to signify it is a base class name That is why the example above is derived b base b1 and not simply derived base b1 Sharing C C Header Files With Assembly Source SPNU118J August 2011 d oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Special Assembler Support 12 3 3 Templates No support exists for templates 12 3 4 Virtual Functions No support exists for virtual functions as they have no assembly
153. whose range is smaller than the entire address space When these instructions are used the destination address must be near enough to the instruction that the difference between the call and the destination fits in the available encoding bits If the called function is too far away from the calling function the linker generates an error The alternative to a PC relative call is an absolute call which is often implemented as an indirect call load the called address into a register and call that register This is often undesirable because it takes more instructions speed and size wise and requires an extra register to contain the address By default the compiler generates near calls The trampolines option causes the linker to generate a trampoline code section for each call that is linked out of range of its called destination The trampoline code section contains a sequence of instructions that performs a transparent long branch to the original called address Each calling instruction that is out of range from the called function is redirected to the trampoline SPNU 118J August 2011 Linker Description 189 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Linker Options www ti com For example in a section of C code the bar function calls the foo function The compiler generates this code for the function bar call foo call the function foo If the foo function is placed out of range from
154. within the union text2 and text3 In this case the linker issues a diagnostic message to request that these load allocations be specified explicitly 216 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Command Files 7 5 6 5 Naming UNIONs and GROUPs You can give a name to a UNION or GROUP by entering the name in parentheses after the declaration For example GROUP BSS SYSMEM STACK GROUP bss i Sysmem Stack load D MEM run D MEM The name you defined is used in diagnostics for easy identification of the problem LCF area For example warning LOAD placement ignored for BSS SYSMEM STACK GROUP object is uninitialized UNION TEXT CINIT UNION const load D_MEM table tablel pinit 1080 MEM table tablel run P MEM warning table tablel operator ignored table tablel has already been applied to a section in the UNION TEXT CINIT UNION in which pinit is a descendant 7 5 7 Special Section Types DSECT COPY NOLOAD and NOINIT You can assign three special types to output sections DSECT COPY and NOLOAD These types affect the way that the program is treated when it is linked and loaded You can assign a type to a section by placing the type after the section definition For example SECTIONS secl load 0x00002000 type 0x00004000 type 0x00006000 type 0x00008000 type DS
155. word refer to a word of such a width Figure 11 2 illustrates the separate and distinct phases of the hex conversion utility s process flow Figure 11 2 Hex Conversion Utility Process Flow Raw data in object files is 7 represented in the target s addressable units For the ARM device this is 32 bits Input file The raw data in the object file is grouped into words according hase to the size specified by the memwidth option The memwidth sized words are broken up according to the size specified by the romwidth option and are written to a file s according to the specified format i e Intel Tektronix etc Phase II Output file s 11 3 1 Target Width 278 Target width is the unit size in bits of the target processor s word The unit size corresponds to the data bus size on the target processor The width is fixed for each target and cannot be changed The ARM targets have a width of 32 bits Hex Conversion Utility Description SPNU118J August 2011 S oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Understanding Memory Widths 11 3 2 Specifying the Memory Width Memory width is the physical width in bits of the memory system Usually the memory system is physically the same width as the target processor width a 16 bit processor has a 32 bit memory architecture However some applications require target words to be broken into multiple consecutive and na
156. 0 SPNU118J August 2011 sti iti Assembler Description 3 Submit Documentation Feedback I I men YP 0 9115 1 I TEXAS INSTRUMENTS Assembler Overview www ti com 3 1 32 Assembler Overview The 2 pass assembler does the following Processes the source statements in a text file to produce a relocatable object file Produces a source listing if requested and provides you with control over this listing Allows you to segment your code into sections and maintain a section program counter SPC for each section of object code Defines and references global symbols and appends a cross reference listing to the source listing if requested Allows conditional assembly Supports macros allowing you to define macros inline or in a library Assembler Description SPNU118J August 2011 Ay EF T Submit Documentation Feedback men www BDF TI 1 TEXAS INSTRUMENTS www ti com The Assemblers Role in the Software Development Flow 3 2 The Assembler s Role in the Software Development Flow Figure 3 1 illustrates the assembler s role in the software development flow The shaded portion highlights the most common assembler development path The assembler accepts assembly language source files as input both those you create and those created by the ARM C C compiler Figure 3 1 The Assembler in the ARM Software Development Flow C C source files C C compiler C C name demangling utili
157. 0 endif fcnolist AE AAA ADD RO RO 41024 else ADD RO 50 0 endif Listing file ARM 1 00000001 AAA set 1 2 00000000 BBB set 0 3 fclist 4 5 E AAA 6 00000000 E2800B01 ADD RO RO 41024 d else 8 ADD RO 50 0 9 endif 10 11 fcnolist 12 14 00000004 E2800B01 ADD RO RO 41024 Assembler Directives 99 www BRD EKireconr TI Directives Reference field Syntax Description Example 100 Assembler Directives I TEXAS INSTRUMENTS www ti com Initialize Field field value size in bits The field directive initializes a multiple bit field within a single word 32 bits of memory This directive has two operands The value is a required parameter it is an expression that is evaluated and placed in the field The value must be absolute The size in bits is an optional parameter it specifies a number from 1 to 32 which is the number of bits in the field If you do not specify a size the assembler assumes the size is 32 bits If you specify a value that cannot fit in size in bits the assembler truncates the value and issues a warning message For example field 3 1 causes the assembler to truncate the value 3 to 1 the assembler also prints the message WARNING line 21 W0001 Field value truncated to 1 field 3 1 Successive field directives pack values into the specified number of bits starting at the current word Fields are packed starting at the most significant par
158. 0000 000000 000000 000000 00000020 00000021 00000022 00000023 Invoke STR 3 macro ss 3A 70 31 3A 3A 70 32 3A 3A 70 33 3A string ip2i 0000 o o Hh SPNU 118J August 2011 Submit Documentation Feedback www oF Eeconzy TI 1 TEXAS INSTRUMENTS www ti com newblock Syntax Description Example SPNU118J August 2011 Directives Reference Terminate Local Symbol Block hewblock The newblock directive undefines any local labels currently defined Local labels by nature are temporary the newblock directive resets them and terminates their scope A local label is a label in the form n where n is a single decimal digit or name where name is a legal symbol name Unlike other labels local labels are intended to be used locally cannot be used in expressions and do not qualify for branch expansion if used with a branch They can be used only as operands in 8 bit jump instructions Local labels are not included in the symbol table After a local label has been defined and perhaps used you should use the newblock directive to reset it The text data and sect directives also reset local labels Local labels that are defined within an include file are not valid outside of the include file See Section 3 8 2 for more information on the use of local labels This example shows how the local label 1 is declared reset and then declared again 1 00000000 E35
159. 00008 00000001 word x word 1 eval 1 x eval 1 1 x 0000000c 00000002 word x word 2 eval 1 x eval 2 1 x 00000010 00000003 word x word 3 eval x41 x eval 3 1 x 00000014 00000004 word x word 4 eval 1 x eval 4 1 x 00000018 00000005 word x word 5 SPNU118J August 2011 Assembler Directives 79 Submit Documentation Feedback Se oF T www BD EIC conr TI Directives Reference I TEXAS INSTRUMENTS www ti com asmfunc endasmfunc Mark Function Boundaries Syntax Description Example 80 Assembler Directives symbol asmfunc stack usage num endasmfunc The asmfunc and endasmfunc directives mark function boundaries These directives are used with the compiler g option symdebug dwarf to allow assembly code sections to be debugged in the same manner as C C functions You should not use the same directives generated by the compiler see Appendix A to accomplish assembly debugging those directives should be used only by the compiler to generate symbolic debugging information for C C source files The asmfunc and endasmfunc directives cannot be used when invoking the compiler with the backwards compatibility symdebug coff option This option instructs the compiler to use the obsolete COFF symbolic debugging format which does not support these directives The symbol is a label that must appear in the label field The asmfunc directive has an optional parameter
160. 001100120013001400150016001700180019001A001B001CO01D001E001F0008 00000001FF 1 Checksum Byte Record End of file count type record Hex Conversion Utility Description SPNU118J August 2011 S oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Description of the Object Formats 11 12 3 Motorola Exorciser Object Format motorola Option The Motorola S1 S2 and S3 formats support 16 bit 24 bit and 32 bit addresses respectively The formats consist of a start of file header record data records and an end of file termination record Each record consists of five fields record type byte count address data and checksum The three record types are Record Type Description S0 Header record S1 Code data record for 16 bit addresses S1 format S2 Code data record for 24 bit addresses S2 format S3 Code data record for 32 bit addresses S3 format S7 Termination 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 address and the code data fields Figure 11 8 illustrates the Motorola S object format Figure 11 8 Motorola S
161. 070 00000008 word RES 1 24 25 ko ko ko ko 26 Reserve 20 bits in the data section RES 2 27 Eis points to the last byte that contains EK 28 58 reserved bytes Xo 29 30 00000087 RES_2 bes 20 31 00000088 00000036 word 36h 32 0000008c 00000087 word RES 2 SPNU118J August 2011 Submit Documentation Feedback Assembler Directives www sok Eeconzy TI 125 Directives Reference sslist ssnolist Syntax Description Example 126 Assembler Directives I TEXAS INSTRUMENTS www ti com Control Listing of Substitution Symbols Sslist ssnolist Two directives allow you to control substitution symbol expansion in the listing file The sslist directive allows substitution symbol expansion in the listing file The expanded line appears below the actual source line The ssnolist directive suppresses substitution symbol expansion in the listing file By default all substitution symbol expansion in the listing file is suppressed the assembler acts as if the ssnolist directive had been used Lines with the pound character denote ex
162. 0x000000DC R2 16 0x00000048 R13 R4 R2 R2 16 Example 10 3 provides an example of how the output would appear if a copy record refers to different load and run sections and the copy_table option is used 270 Object File Utilities www sok Eeconzy TI SPNU118J August 2011 Submit Documentation Feedback 1 TEXAS INSTRUMENTS www ti com Invoking the Name Utility Example 10 3 Partial Copy Record Output With Different Load and Run Address _data2_ctb1 0 200158 200158 0 20015 3 data2 ctb1 0 0052a0 0052a0 0052a0 0052a0 0000beef 0052a4 0000beef COPY TABLE data2 ctbl 0x30 at 025810 1 record s load addr 0x200158 size 0x12B encoding lzss DATA Section data2 scn load 0x12B bytes at 0x200158 run addr 0x52A0 size 0x960 DATA Section datal scn 0x960 bytes at 0x52A0 d word 0x020f0000 word Oxbeef0003 datal d datal word 0x0000beef word 0x0000beef 10 3 Invoking the Name Utility The name utility nm470 prints the list of names defined and referenced in an object file executable file or archive library It also prints the symbol value and an indication of the kind of symbol Hidden symbols are listed as To invoke the name utility enter the following nm470 options input filenames nm470 input filename options SPNU118J August 2011 is the command that invokes the name utility is an object file ob
163. 1 I TEXAS INSTRUMENTS Miscellaneous Directives www ti com 4 12 Miscellaneous Directives 76 These directives enable miscellaneous functions or features The asmfunc and endasmfunc directives mark function boundaries These directives are used with the compiler symdebug dwarf g option to generate debug information for assembly functions The cdecls directive enables programmers in mixed assembly and C C environments to share C headers containing declarations and prototypes between C and assembly code The end directive terminates assembly If you use the end directive it should be the last source statement of a program This directive has the same effect as an end of file character The group gmember and endgroup directives define a common data section for member of an ELF group section The import export hidden and protected directives set the dynamic visibility of a global symbol for ELF only See for an explanation of symbol visibility The newblock directive resets local labels Local labels are symbols of the form n where n is a decimal digit 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 resetting them after they are used See Section 3 8 2 for information on local labels These three directives enable you to define your own error and w
164. 10000 LABEL1 CMP rl 0 2 00000004 1 BCS 1 3 00000008 E2900001 ADDS 0 r0 1 4 0000000 15 MOVCS pc lr 5 00000010 E4952004 1 LDR r2 r5 4 6 newblock Undefine 1 to use again 7 00000014 E0911002 ADDS rl r1 r2 8 00000018 5A000000 BPL 1 9 0000001 1 MVNS rfl 64 10 00000020 21208008 1 MOV po lr Assembler Directives 119 Submit Documentation Feedback Se oF T www BD EIC conr TI Directives Reference option Syntax Description Example 120 Assembler Directives 1 TEXAS INSTRUMENTS www ti com Select Listing Options option option options The option directive selects options for the assembler output listing The options must be separated by commas each option selects a listing feature These are valid options A turns on listing of all directives and data and subsequent expansions macros and blocks B limits the listing of byte and char directives to one line H limits the listing of half and short directives to one line L limits the listing of long directives to one line M turns off macro expansions in the listing N turns off listing performs nolist 0 turns on listing performs list R resets any B H M T and W turns off the limits of B H M T and W T limits the listing of string directives to one line W limits the listing of word and int directives to one line X produces a cross reference listing of symbols You can also obtain a
165. 11 1 Basic Hex Conversion Utility Options ppp 11 2 Options for Specifying Hex Conversion Formats pp A 1 Symbolic Debugging Directives pp List of Tables www sok Eeconzy TI 1 TEXAS INSTRUMENTS www ti com SPNU118J August 2011 Submit Documentation Feedback 5 TEXAS INSTRUMENTS Preface SPNU T 18J August 2011 Read This First About This Manual The ARM Assembly Language Tools User s Guide explains how to use these assembly language tools Assembler Archiver Linker Library information archiver Absolute lister e Cross reference lister Disassembler Object file display utility Name utility Strip utility Hex conversion utility How to Use This Manual This book helps you learn how to use the Texas Instruments assembly language tools designed specifically for the ARM 32 bit devices This book consists of four parts Introductory information consisting of Chapter 1 and Chapter 2 gives you an overview of the assembly language development tools It also discusses object modules which helps you to use the ARM tools more effectively Read Chapter 2 before using the assembler and linker Assembler description consisting of Chapter 3 through Chapter 5 contains detailed information about using the assembler This portion explains how to invoke the assembler and discusses source statement format valid constants and expressions assembler output and assembler directives It also desc
166. 1101351227 EEr ar E eE Eaa 66 4 3 Directives That Change the Instruction Type pp 68 4 4 Directives That Initialize Constants pp 68 4 5 Directives That Perform Alignment and Reserve Space pp 70 4 6 Directives That Format the Output Listings pp 72 4 7 Directives That Reference Other Files pp 73 4 8 Directives That Enable Conditional Assembly pp 74 4 9 Directives That Define Union or Structure Types pp 74 4 10 Directives That Define Enumerated Types pp 75 4 11 Directives That Define Symbols at Assembly Time pp 75 412 Miscellaneous 76 4 139 DirectivesiReference A O A 77 SPNU118J August 2011 Assembler Directives 61 Submit Documentation Feedback I I men BADE 0 9115 1 I TEXAS INSTRUMENTS Directives Summary www ti com 4 1 Directives Summary Table 4 1 through Table 4 17 summarize the assembler directives Besides the assembler directives documented here the ARM device software tools support the following directives The assembler uses several directives for macros Macro directives are discussed in Chapter 5 they are not discussed in this chapter The 0 compiler uses directives for symbolic debugging Unlike other directives symbolic debugging directives are not used in most assembly language programs Appendix A discusses these directives they are not discussed in this chapter Labels and Comments Are Not Shown in Syntaxes NOTE Any source statement that contai
167. 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Options Here is an example of how you could use the START and SIZE operators in association with an output section to copy the trampoline code section along with the code containing the calls that need trampolines SECTIONS foo load ROM run RAM start foo start size foo size x obj text text gt ROM far l rts lib text gt FAR MEM A function in x obj contains an run time support call The run time support library is placed in far memory and so the call is out of range A trampoline section will be added to the foo output section by the linker The copy code can refer to the symbols foo start and foo size as parameters for the load start address and size of the entire foo output section This allows the copy code to copy the trampoline section along with the original x obj code in text from its load space to its run space 7 4 31 2 Disadvantages of Using Trampolines An alternative method to creating a trampoline code section for a call that cannot reach its called function is to actually modify the source code for the call In some cases this can be done without affecting the size of the code However in general this approach is extremely difficult especially when the size of the code is affected by the transformation While generating far call trampolines provides a more straightforward sol
168. 262 Cross Reference Lister Description www sok FEeconz TI First invoke the assembler with the compiler cross_reference option This produces a cross reference table in the listing file and adds to the object file cross reference infor mation By default only global symbols are cross referenced If you use the compiler output_all_syms option local symbols are cross referenced as well Link the object file obj to obtain an executable object file out Invoke the cross reference lister The following section provides the command syntax for invoking the cross reference lister utility SPNU118J August 2011 Submit Documentation Feedback 1 TEXAS INSTRUMENTS www ti com Invoking the Cross Reference Lister 9 2 Invoking the Cross Reference Lister To use the cross reference utility the file must be assembled with the correct options and then linked into an executable file Assemble the assembly language files with the cross reference option This option creates a cross reference listing and adds cross reference information to the object file By default the assembler cross references only global symbols but if the assembler is invoked with the output all syms option local symbols are also added Link the object files to obtain an executable file To invoke the cross reference lister enter the following xref470 options input filename output filename xref470 is the command that invokes the cr
169. 27 Submit Documentation Feedback I I men YP gt 9115 1 I TEXAS INSTRUMENTS Scenario 3 Building a Hex Conversion Command File for Two 8 Bit EPROMs www ti com Example C 7 Linker Command File for Scenario 3 J EOKCKCKCKCKCkCkCkCk kk KC KK KOKCKCKCkCkCkCkCk ck ck ck ck ck ck ck KCKCKCKCKCKCKCk Ck k ck ck ck ck ck ckck KCKCKCKCKCKCk Ck ck ck ck ck ok ck ok ok ck k ck ck ckckck kk Scenario 3 Link Command Usage 121470 obj files o out file m map file 1nk32 cmd Cl470 src files gt z o out file m map file lnk32 cmd ass 3 Description This file is a sample command file that can be used af for linking programs built with the TMS470 C 527 compiler Use it as a guideline you may want to change 7 the allocation scheme according to the size of your program and the memory layout of your target system uA Notes 1 You must specify the directory in which rts32 1lib is located Either add a i lt directory gt line to this file or use the system environment variable C DIR to 7 Specify a search path for libraries es af 2 If the runtime support library you are using is not named rts32 lib be sure to use the correct name here BRK KK KKK kk Ck kk Ck Ck CK Ck kk Ck Ck Ck ke
170. 3 4 ref X 5 def Y 6 00000000 text 7 00000000 E0921003 ADDS R1 R2 R3 8 00000004 0A000001 BEQ X 9 00000008 E1C410BE STRH R1 R4 14 10 0000000c EAFFFFFB B X generates a relocation entry 11 00000010 E0821003 Y ADD Rl R2 R3 28 In Example 2 1 both symbols X and Y are relocatable Y is defined in the text section of this module X is Introduction to Object Modules SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI TEXAS INSTRUMENTS www ti com Run Time Relocation 2 5 2 6 defined in another module When the code is assembled X has a value of 0 the assembler assumes all undefined external symbols have values of 0 and Y has a value of 16 relative to address 0 in the text section The assembler generates two relocation entries one for X and one for Y The reference to X is an external reference indicated by the character in the listing The reference to Y is to an internally defined relocatable symbol indicated by the character in the listing After the code is linked suppose that X is relocated to address 0x10014 Suppose also that the text section is relocated to begin at address 0x10000 Y now has a relocated value of 0x10010 The linker uses the relocation entry for the reference t
171. 4 11 These directives set up specialized types for later use in expressions allowing you to use symbolic names to refer to compile time constants The types created are analogous to the enum type of the C language This allows enumerated types to be shared between C and assembly code See Chapter 12 See Section 12 2 10 for an example of using enum Directives That Define Symbols at Assembly Time Assembly time symbol directives equate meaningful symbol names to constant values or strings The asg directive assigns a character string to a substitution symbol The value is stored in the substitution symbol table When the assembler encounters a substitution symbol it replaces the symbol with its character string value Substitution symbols can be redefined asg 10 20 30 40 coefficients Assign string to substitution symbol byte coefficients Place the symbol values 10 20 30 and 40 into consecutive bytes in current section The eval directive evaluates a well defined expression translates the results into a character string and assigns the character string to a substitution symbol This directive is most useful for manipulating counters asg 1 x 1 loop Begin conditional loop byte x 10h Store value into current section break 4 Break loop if 4 eval 1 Increment x by 1 endloop End conditional loop The define directive assigns a character string to a subst
172. 4 byte constant immediately after the option If the options are not used the default size of the heap is 2K bytes and the default size of the stack is 2K bytes See Section 7 4 14 for setting heap sizes and Section 7 4 28 for setting stack sizes Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Linking C C Code 7 11 4 Autoinitialization of Variables at Run Time Autoinitializing variables at run time is the default method of autoinitialization To use this method invoke the linker with the rom_model option Using this method the cinit section is loaded into memory along with all the other initialized sections The linker defines a special symbol called cinit that points to the beginning of the initialization tables in memory When the program begins running the C boot routine copies data from the tables pointed to by cinit into the specified variables in the bss section This allows initialization data to be stored in slow external memory and copied to fast external memory each time the program starts Figure 7 8 illustrates autoinitialization at run time Use this method in any system where your application runs from code burned into slow external memory Figure 7 8 Autoinitialization at Run Time Object file Memory C auto init a Loader Loader table and data section ROM Boot routine data uninitialized RAM
173. 6 illustrates the ASCII Hex format Figure 11 6 ASCII Hex Object Format Nonprintable Nonprintable Address end code start code I I B SAXXXXXXXX ro XX XX XX XX XX XX XX XX XX XX G 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 AXXXXXXX in which XXXXXXXX is a 8 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 at address 0 You can avoid all discontinuities and any address records by using the image and zero options This creates output that is simply a list of byte values SPNU118J August 2011 Hex Conversion Utility Description 291 Submit Documentation Feedback I I men BADE 4 69115 1 I TEXAS INSTRUMENTS Description of the Object Formats www ti com 11 12 2 Intel MCS 86 Object Format intel Option 292 The Intel object format supports 16 bit addresses and 32 bit extended addresses Intel format consists of a 9 character 4 field prefix which defines the start of record byte count load address and record type the data and a 2 character checksum suffix The 9 character prefix represents three record types Record Type Description 00 Data record 01 End of file record 04 Extended linear address record Record type00 the data r
174. 7 Defines a null character and is represented internally as 0046 Notice the difference between character constants and character strings Section 3 7 discusses character strings A character constant represents a single integer value a string is a sequence of characters 3 6 Assembly Time Constants If you use the set directive to assign a value to a symbol see Define Assembly Time Constant the symbol becomes a constant To use this constant in expressions the value that is assigned to it must be absolute For example shift3 set 3 MOV 20 3 You can also use the set directive to assign symbolic constants for register names In this case the symbol becomes a synonym for the register AuxR1 set R1 LDR AuxR1 SP SPNU118J August 2011 Assembler Description 43 Submit Documentation Feedback wwewlAd9 E Eeconzy TI I TEXAS INSTRUMENTS Character Strings www ti com 3 7 3 8 3 8 1 Character Strings A character string is a string of characters enclosed in double quotes Double quotes that are part of character strings are represented by two consecutive double quotes The maximum length of a string varies and is defined 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 Cha
175. 7 10 This method of specifying the size and load address of the program code has limitations While it works fine for an individual input section that is contained entirely within one source file this method becomes more complicated if the program code is spread over several source files or if the programmer wants to copy an entire output section from load space to run space Another problem with this method is that it does not account for the possibility that the section being moved may have an associated far call trampoline section that needs to be moved with it 220 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI www ti com TEXAS INSTRUMENTS Linker Command Files 7 5 8 6 Why the Dot Operator Does Not Always Work The dot operator is used to define symbols at link time with a particular address inside of an output section It is interpreted like a PC Whatever the current offset within the current section is that is the value associated with the dot Consider an output section specification within a SECTIONS directive outsect sl obj text end of 1 start of 82 s2 o0bj text end of s2 This statement creates three symbols end of 8 1 51 end address of text in 51 00 Start of s2 the start address of text in 52 00 end of s2 the end address of text in 52 00 Suppose there is padding between s1 obj and s2 obj that is created
176. A0 20FFE000000000000000000000000000000000000000000000000000000000000000000001 020000040001F j Extended linear address record 200000000000000000000000000000000000000000000000000000000000000000000000E0 200020000000000000000000000000000000000000000000000000000000000000000000CO0 20FFC000000000000000000000000000000000000000000000000000000000000000000021 20FFE000000000000000000000000000000000000000000000000000000000000000000001 00000001FEF LI End oFfile record Record type Byte count Checksum SPNU118J August 2011 Submit Documentation Feedback Hex Conversion Utility Examples 323 www oF Eeconzy TI I TEXAS INSTRUMENTS Scenario 2 Building a Hex Conversion Command File for 16 BIS Code www ti com C 2 Scenario 2 Building a Hex Conversion Command File for 16 BIS Code 324 Scenario 2 shows how to build the hex conversion command file to generate the correct converted file for the application code and data that will reside on a single 16 bit EPROM The EPROM memory system for this scenario is shown in Figure C 3 For this scenario the TMS470 CPU operates with the T control bit set so the processor executes instructions in 16 BIS mode Figure C 3 EPROM Memory System for Scenario 2 4 ARM CPU 128K 16 ROMO Width 32 bits ROM width 16 bits EPROM system memory width 16 bits For this scenario the application code and data reside on the EPROM the lower 64K wo
177. ARM Assembly Language Tools v4 9 User s Guide X TEXAS INSTRUMENTS Literature Number SPNU118J August 2011 www BDTIC com TI SPNU118J August 2011 Ray EE I T Submit Documentation Feedback 1 efas men WWW conr TI I TEXAS INSTRUMENTS Contents 11 E E M RE sain da Geist ret oa Sa seat a 400 Introduction to the Software Development Tools nt 15 1 Software Development Tools Overview et 16 1 1 1 2 Tools Descriptions e E 17 2 Introduction to Object Modules se cuientenedecdetecd pond enteatennceanse 19 2 1 56 61110108 mI ee a EE EEE N ENE E P EN a EA E EEE 20 2 2 How the Assembler Handles Sections 0cceceeceeee seen eee eeeeeeeeeeeeeeeeenaeeeeeeeeeeeeeeteeeseeeneeeeeeeeeee 21 22 Uninitialized Sections nen ee N 21 2 2 2 200 56000708 esas cece i ua KANNAD u naaa Eaua 22 23 Named 2 2 3 a eU NNNM E E Eo 23 cetera unieran nee E 00959586110116 9 2 24 2 2 5 SECON Program COUNEIS ses a de Ue Casus E 24 24 me e Ti de Using Sections Directives coo a a 2 2 6 nnne nnn 27 nenne nn
178. Byte count Figure C 7 Contents of Hex Output File upper16 bit Start character Data 040020001234ABCD1E 040028008765432184 00000001FF LI Checksum T c L End offile record Record type Byte count 330 Hex Conversion Utility Examples SPNU118J August 2011 BADE T Submit Documentation Feedback men www BDF TI 1 Appendix D IJ TEXAS SPNU118J August 2011 INSTRUMENTS Glossary ABI Application binary interface absolute address An address that is permanently assigned to a ARM memory location absolute lister A debugging tool that allows you to create assembler listings that contain absolute addresses alignment A process in which the linker places an output section at an address that falls on an n byte boundary where n is a power of 2 You can specify alignment with the SECTIONS linker directive allocation A process in which the linker calculates the final memory addresses of output sections ANSI American National Standards Institute an organization that establishes standards voluntarily followed by industries archive library A collection of individual files grouped into a single file by the archiver archiver A software program that collects several individual files into a single file called an archive library With the archiver you can add delete extract or replace members of the archive library ASCII America
179. CACHE length 0x00001000 BUFFER SLOW_MEM RW origin end FAST_MEM length 0x00001800 size FAST MEM EXT MEM RX origin 0x10000000 length Size FAST MEM CACHE 7 5 4 The SECTIONS Directive The SECTIONS directive controls your sections in the following ways Describes how input sections are combined into output sections Defines output sections in the executable program Specifies where output sections are placed in memory in relation to each other and to the entire memory space Permits renaming of output sections For more information see Section 2 3 Section 2 4 and Section 2 2 4 Subsections allow you to manipulate sections with greater precision If you do not specify a SECTIONS directive the linker uses a default algorithm for combining and allocating the sections Section 7 7 describes this algorithm in detail 7 5 4 4 SECTIONS Directive Syntax The SECTIONS directive is specified in a command file by the word SECTIONS uppercase followed by a list of output section specifications enclosed in braces SPNU 118J August 2011 Linker Description 197 Submit Documentation Feedback I I men BADE COMT I 1 TEXAS INSTRUMENTS Linker Command Files www ti com The general syntax for the SECTIONS directive is SECTIONS name property property property name property property property name property property property
180. D RO R1 R2 1 00000004 3 ADD RO RO R3 SPNU118J August 2011 Macro Description 145 Submit Documentation Feedback I I men BADE 0 9115 1 1 TEXAS INSTRUMENTS Macro Parameters Substitution Symbols www ti com 5 3 Macro Parameters Substitution Symbols If you want to call a macro several times with different data each time you can assign parameters within the macro The macro language supports a special symbol called a substitution symbol which is used for macro parameters Macro parameters are substitution symbols that represent a character string These symbols can also be used outside of macros to equate a character string to a symbol name see Section 3 8 6 Valid substitution symbols can be up to 128 characters long and must begin with a letter The remainder of the symbol can be a combination of alphanumeric characters underscores and dollar signs Substitution symbols used as macro parameters are local to the macro they are defined in You can define up to 32 local substitution symbols including substitution symbols defined with the var directive per macro For more information about the var directive see Section 5 3 6 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 parameter Parameters without corresponding arguments are set to the null string If the number of arguments exceeds
181. ECT f1 0bj COPY f2 0bj NOLOAD f3 0bj NOINIT f4 0bj sec2 load sec3 load sec4 load The DSECT type creates a dummy section with the following characteristics ltis not included in the output section memory allocation It takes up no memory and is not included in the memory map listing It can overlay other output sections other DSECTs and unconfigured memory Global symbols defined in a dummy section are relocated normally They appear in the output module s symbol table with the same value they would have if the DSECT had actually been loaded These symbols can be referenced by other input sections Undefined external symbols found in a DSECT cause specified archive libraries to be searched 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 allocated but all the symbols are relocated as though the sections were linked at address 0x2000 The other sections can refer to any of the global symbols in sect A COPY section is similar to a DSECT section except that its contents and associated information are written to the output module The cinit section that contains initialization tables for the ARM C C compiler has this attribute under the run time initialization model ANOLOAD section differs from a normal output section in one respect the section s contents relocati
182. EMP LDR R4 LOCL_n STR RO R4 end byte 4 word Goch Listing file 1 00000000 START space 300 2 0000000F TEMP set 15 3 00000000 bss 1001 48h 4 0000012c 00000000 LOCL n word LOC1 5 00000130 E1E00000 MVN RO RO 6 00000134 E280000F ADD RO RO TEMP 7 00000138 E51F4014 LDR RA LOCL n 8 0000013c E5840000 STR RO R4 9 end SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com fclist fcnolist Syntax Description Example SPNU118J August 2011 Submit Documentation Feedback Directives Reference Control Listing of False Conditional Blocks felist fcnolist Two directives enable you to control the listing of false conditional blocks The fclist directive allows the listing of false conditional blocks conditional blocks that do not produce code The fcnolist directive suppresses the listing of false conditional blocks until a fclist directive is encountered With fcnolist only code in conditional blocks 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 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 mE AAA ADD RO RO 1024 else ADD RO 50
183. EST warn ASMTEST not defined will be issued endif Therefore a typical use of the cdecls block is expected to be a single usage near the beginning of the assembly source file in which all necessary C C header files are included Use the compiler include_path path options to specify additional include file paths needed for the header files used in assembly as you would when compiling C files Any 0 6 errors or warnings generated by the code of the cdecls are emitted as they normally would for the C C source code C C errors cause the directive to fail and any resulting converted assembly is not included C C constructs that cannot be converted such as function like macros or variable definitions cause a comment to be output to the converted assembly file For example ASM HEADER WARNING variable definition ABCD ignored The prefix ASM HEADER WARNING appears at the beginning of each message To see the warnings either the WARN parameter needs to be specified so the messages are displayed on STDERR or else the LIST parameter needs to be specified so the warnings appear in the listing file if any Finally note that the converted assembly code does not appear in the same order as the original C C source code and C C constructs may be simplified to a normalized form during the conversion process but this should not affect their final usage Notes on C C Conversions The following sections describ
184. EXAS INSTRUMENTS www ti com Example 3 2 Using Symbolic Constants Defined on Command Line Symbols IF_4 if byte else byte endif IF 5 it byte else byte endif IF 6 if byte else byte endif LB Lr of byte elseif byte endif SYM4 SYM4 SYM2 SYM1 10 SYM1 SYM3 SYM3 SYM4 SYM1 SYM1 SYM2 SYM2 SYM2 SYM2 SYM2 10 SYM2 SYM2 SYM4 SYM2 SYM3 SYM3 Equal values Unequal values Less than equal Greater than SYM4 SYM2 Unequal value Equal values 3 8 5 Predefined Symbolic Constants The assembler has several predefined symbols including the following types the dollar sign character represents the current value of the section program counter SPC is a relocatable symbol Register symbols the name of registers Coprocessor registers including C0 C15 VFP registers including DO D31 50 1 NEON registers including DO D31 Q0 Q15 The ARM register aliases are defined as follows Register Name Alias Register Name Alias RO A1 R8 5 1 A2 R9 V6 R2 A3 R10 V7 R3 A4 R11 V8 R4 V1 R12 V9 IP R5 V2 R13 SP R6 V3 R14 LR R7 V4 AP R15 PC Register symbols and aliases can be entered as all uppercase or all lowercase characters that is R13 could also be entered as r13 SP or sp Coprocessor IDs including PO P15 Coprocessor IDs are not case sensitive that is P12 co
185. Eeconzy TI SPNU118J August 2011 Submit Documentation Feedback 1 TEXAS INSTRUMENTS www ti com Example 7 32 Output Map File demo map Linker Example OUTPUT FILE NAME demo out ENTRY POINT SYMBOL SETUP address 000000d4 MEMORY CONFIGURATION name origin length attributes fill FAST MEM 00000000 000001000 RWIX SLOW MEM 00001000 000001000 RWIX EEPROM 08000000 000000400 RWIX SECTION ALLOCATION MAP output attributes section page origin length input sections text 0 00000020 00000138 00000020 000000a0 ctrl obj text 000000c0 00000000 tables obj text 000000c0 00000098 demo obj text intvecs 0 00000000 00000020 00000000 00000020 tables obj intvecs data 0 08000000 00000400 08000000 00000168 tables obj data 08000168 00000298 HOLE fill ff00ff00 08000400 00000000 ctrl obj data 08000400 00000000 demo obj data ctrl var 0 00001000 00000500 00001000 00000500 ctrl obj bss fill 00000100 bss 0 00001500 00000100 UNINITIALIZED 00001500 00000100 demo obj bss 00001600 00000000 tables obj bss GLOBAL SYMBOLS address name address name 00001500 bss 00000020 clear 08000000 data 00000020 text 00000020 text 00000058 set 000000d4 SETUP 000000c0 x42 00000020 clear 000000d4 SETUP 08000400 edata 00000158 etext 00001600 end 00001500 bss 00000158 etext 00001600 end 00000058 set 08000000 data 000000c0 x42 08000400 edata 10 symbols SPNU118J August 2011 S
186. IONS directive Example 7 9 Archive Members to Output Sections SECTIONS boot gt l rtsXX l rtsXX 200011 lib boot obj lib exit obj strcpy obj BOOT2 lib text text text In Example 7 9 the text sections of boot obj exit obj and strcpy obj are extracted from the run time support library and placed in the boot output section The remainder of the run time support library object that is referenced is allocated to the rts output section Finally the remainder of all other text sections are to be placed in section text An archive member or a list of members is specified by surrounding the member name s with angle brackets gt and lt after the library name Any object files separated by commas or spaces from the specified archive file are legal within the angle brackets The library option which normally implies a library path search be made for the named file following the option listed before each library in Example 7 9 is optional when listing specific archive members inside gt Using gt gt implies that you are referring to a library SPNU118J August 2011 Submit Documentation Feedback Linker Description 207 www oF Eeconzy TI I TEXAS INSTRUMENTS Linker Command Files www ti com To collect a set of the input sections from a library in one place use the library option within the SECTIONS directive For example the following collects all t
187. If you do not specify a filename for the output module the linker gives it the default name a out If you want to write the output module to a different file use the output_file option The syntax for the output_file option is output_file filename The filename is the new output module name This example links file1 obj and file2 obj and creates an output module named run out 01470 run linker output file run out filel obj file2 obj 7 4 24 C Language Options ram model and rom model Options The ram model and rom model options cause the linker to use linking conventions that are required by the C compiler The ram model option tells the linker to initialize variables at load time The rom model option tells the linker to autoinitialize variables at run time For more information see Section 7 11 Section 7 11 4 and Section 7 11 5 7 4 25 Retain Discarded Sections retain Option When unused section elimination is on the ELF linker does not include a section in the final link if it is not needed in the executable to resolve references The retain option tells the linker to retain a list of sections that would otherwise not be retained This option accepts the wildcards and When wildcards are used the argument should be in quotes The syntax for this option is retain sym or scn spec The retain option take one of the following forms retain symbol spec Specifying the symbol format retain
188. If you want a title on the first page the first source statement must contain a title directive In this example one title is printed on the first page and a different title is printed on succeeding pages Source file title Fast Fourier Transforms 3 title Floating Point Routines page Listing file TMS470R1x Assembler Version x xx Day Time Year Copyright c 1996 2009 Texas Instruments Incorporated Fast Fourier Transforms PAGE 1 2 8 3 4 5 TMS470R1x Assembler Version x xx Day Time Year Copyright c 1996 2009 Texas Instruments Incorporated Floating Point Routines PAGE 2 No Errors No Warnings SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Directives Reference union endunion tag Declare Union Type Syntax Description SPNU118J August 2011 stag union expr mem element expr mem element expr mem tag stag expr mem element expr size endunion label tag stag The union directive assigns symbolic offsets to the elements of alternate data structure definitions to be allocated in the same memory space This enables you to define several alternate structures and then let the assembler calculate the element 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 r
189. Ist uses the global directive to identify these global symbols file3 Ist uses ref and def to identify the symbols The file2 Ist and file4 Ist files are equivalent Both files define the symbols X Y and Z and make them available to other modules both files use the external symbol INIT Also file2 lst uses the global directive to identify these global symbols file4 lst uses ref and def to identify the symbols file1 Ist 1 Global symbol defined in this file 2 global INIT 3 Global symbols defined in file2 1st 4 global X Y Z 5 00000000 INIT 6 00000000 E2800056 ADD RO RO 456h 7 00000004 00000000 word X 8 8 9 0 10 E 11 end Assembler Directives 103 www sok Eeconzy TI Directives Reference file2 Ist 1 2 3 4 5 6 7 8 9 10 11 T2 file3 Ist 1 2 3 4 5 6 7 8 9 10 11 12 file4 Ist 0050 1001 WN FP 11 12 00000001 00000002 00000003 00000000 00000000 00000001 00000002 00000003 00000000 00000000 00000001 00000002 00000003 00000000 00000000 K KX global INIT Set 1 set 2 Set 3 word INIT end global INIT Set 1 Set 2 Set 3 word INIT end ref INIT set 1 Set 2 Set 3 word INIT end group gmember endgroup Define Common Data Section Syntax Description 104 Assembler Directives I TEXAS INSTRUMENTS www ti com Global symbols defined in this file global X Y Global symbol de
190. Link text and sec2 from f4 0bj f5 0bj task Link task00 task01 taskXX etc from f5 obj f6 0bj ctable Link sections ending in ctable from f6 0bj f X obj text Link text section for all files starting with X and ending in obj It is not necessary for input sections to have the same name as each other or as the output section they become part of If a file is listed with no sections all of its sections are included in the output section If any additional input sections have the same name as an output 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 8 are actually a shorthand method for the following SECTIONS text text data data bss i b858 SPNU118J August 2011 Linker Description 205 Submit Documentation Feedback I I men www BADE gt 9115 1 I TEXAS INSTRUMENTS Linker Command Files www ti com The specification text means the unallocated text sections from all the input files This format is useful when You want the output section to contain all input sections that have a specified name but the o
191. M HEADER _ The C C macro ASM HEADER is defined in the compiler while processing code within cdecls This allows you to make changes in your code such as not compiling definitions during the cdecls processing Be Careful With the ASM HEADER Macro NOTE You must be very careful not to use this macro to introduce any changes in the code that could result in inconsistencies between the code processed while compiling the C C source and while converting to assembly 12 2 06 Usage Within C C asm Statements The cdecls directive is not allowed within C C asm statements and will cause an error to be generated 12 2 7 The include Directive The C C include preprocessor directive is handled transparently by the compiler during the conversion step Such includes can be nested as deeply as desired as in C C source The assembly directives include and copy are not used or needed within a cdecls Use the command line include path option to specify additional paths to be searched for included files as you would for C compilation 12 2 8 Conversion of define Macros Only object like macros are converted to assembly Function like macros have no assembly representation and so cannot be converted Pre defined and built in C C macros are not converted to assembly i e FILE TIME COMPILER VERSION etc For example this code is converted to assembly because it is an object like macro define NAME Cha
192. MENTS www ti com Directives Reference if elseif else endif Assemble Conditional Blocks Syntax Description Example SPNU118J August 2011 Af well defined expression elseif well defined expression else endif Four directives provide conditional assembly The if directive marks the beginning of a conditional block The well defined expression is a required parameter If the expression evaluates to true nonzero the assembler assembles the code that follows the expression up to a elseif else or endif If the expression evaluates to false 0 the assembler assembles code that follows a elseif if present else if present or endif if no elseif or else is present The elseif directive identifies a block of code to be assembled when the if expression is false 0 and the elseif expression is true nonzero When the elseif expression is false the assembler continues to the next elseif if present else if present or endif if no elseif or else is present The elseif directive is optional in the conditional block 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 code that the assembler assembles when the if expression and all elseif expressions are false 0 The else directive is optional in the
193. PNU 118J August 2011 Assembler Description 59 Submit Documentation Feedback Se oF T www BD EIC conr TI Cross Reference Listings 3 14 Cross Reference Listings I TEXAS INSTRUMENTS www ti com A cross reference listing shows symbols and their definitions To obtain a cross reference listing invoke the assembler with the cross reference option see Section 3 3 or use the option directive with the X operand see Select Listing Options The assembler appends the cross reference to the end of the source listing Example 3 5 shows the four fields contained in the cross reference listing Example 3 5 An Assembler Cross Reference Listing LABEL VALUE DEFN REF TMS470 0000000 0 TMS470_16BIS 00000000 0 TMS470_32BIS 0000000 0 TMS470_BIG 0000000 0 TMS470 LITTLE 00000000 0 tms470 0000000 0 tms470 16bis 00000000 0 tms470_32bis 0000000 0 tms470 big 0000000 0 tms470 little 00000000 0 STACKSIZE 00000200 9 10 63 stack 00000000 10 5 62 dispatch REF 29 60 reset 00000000 34 16 19 30 stack 00000024 62 52 stacksz 00000028 63 54 Label column contains each symbol that was defined or referenced during the assembly Value column contains an 8 digit hexadecimal number which is the value assigned to the symbol or a name that describes the symbol s attributes A value may also be preceded by a character that describes the symbol s attributes Table 3 5 lists these characters and names Definition DEFN
194. PNU118J August 2011 Hex Conversion Utility Description 289 Submit Documentation Feedback E oF T www BD EIC conr TI I TEXAS INSTRUMENTS Control Hex Conversion Utility Diagnostics www ti com 11 11 Control Hex Conversion Utility Diagnostics 290 The hex conversion utility uses certain C C compiler options to control hex converter generated diagnostics diag_error id diag_remark d diag_suppress id diag_warning id display_error_number issue_remarks no_warnings set_error_limit count verbose_diagnostics Hex Conversion Utility Description Categorizes the diagnostic identified by id as an error To determine the numeric identifier of a diagnostic message use the display_error_number option first in a separate link Then use diag error id to recategorize the diagnostic as an error You can only alter the severity of discretionary diagnostics Categorizes the diagnostic identified by id as a remark To determine the numeric identifier of a diagnostic message use the display error number option first in a separate link Then use diag_remark d to recategorize the diagnostic as a remark You can only alter the severity of discretionary diagnostics Suppresses the diagnostic identified by id To determine the numeric identifier of a diagnostic message use the display error number option first in a separate link Then use diag suppress id to suppress the diagnostic You can only suppr
195. RC Value for text Data SECTIONS Section to be verified al obj text crc table my crc table for al Example 7 25 defines a section named section to be verified which contains the text data from the a1 obj file The crc table operator requests that the linker compute the CRC value for the text data and store that value in a table named my crc table for a1 This table will contain all the information needed to invoke a user supplied CRC calculation routine and verify that the CRC calculated at run time matches the linker generated CRC The table can be accessed from application code using the symbol my crc table for a1 which should be declared of type extern 06 TABLE This symbol will be defined by the linker The application code might resemble the following include crc tbl h extern CRC TABLE my crc table for al verify al text contents Verify CRC value for text sections of al obj if my check CRC amp my crc table for al puts OK The my check CRCY routine is discussed in detail in Section 7 9 4 Example 7 30 Example 7 26 Specifying an Algorithm in the crc table Operator SECTIONS Section to be verified 2 bl obj text load SLOW MEM run FAST MEM crc table my crc table for bl algorithm TMS570 08064 ISO TI crctab CRCMEM In Example 7 26 the CRC algorithm is specified in the crc_table operator The specified algorithm
196. T Submit Documentation Feedback men WWW Fliconr TI TEXAS INSTRUMENTS www ti com Scenario 1 Building a Hex Conversion Command File for a Single 8 Bit EPROM Example C 1 Linker Command File and Link Map for Scenario 1 m J EOKCKCKCKCKCKCkCkCk kk KC KC KCKCKCKOKCkCkCkCk Ck k ck ck ck ck ck k KCK KCKCKCKCKCk Ck k ck ck k ck ck ckck KCKCKCKCkCKCk Ck ck ck ck ck ck ok ko ko k ck ko k ck ck ck sk RRR IK kk CkCk kk Ck kk Ck Ck kk Ck k ke ke k SPECIFY THE SYSTEM MEMORY MAP MEMORY 1 I MEM org 0 len 0x00000020 INTERRUPTS D MEM org 0 len 0x00010000 DATA MEMORY RAM P MEM org 0 len 0x00100000 PROGRAM MEMORY ROM 1 SPECIFY THE SECTIONS ALLOCATION INTO MEMORY SECTIONS Scenario 1 Link Command f Usage 121470 obj files o out file m map file lnk32 cmd 01470 src files z o out file m map file lnk32 cmd 3 Description This file is a sample command file that can be used af for linking programs built with the TMS470 C 527 compiler Use it as a guideline you may want to change the allocation scheme according to the size of your program and the memory layout of your targe
197. TI 1 TEXAS INSTRUMENTS Understanding Memory Widths www ti com 11 3 3 Partitioning Data Into Output Files ROM width specifies the physical width in bits of each ROM device and corresponding output file usually one byte or eight bits The ROM width determines how the hex conversion utility partitions the data into output files After the object file data is mapped to the memory words the memory words are broken into one or more output files The number of output files is determined by the following formulas f memory width 2 ROM width number of files memory width gt ROM width f memory width ROM width number of files 1 For example for a memory width of 32 you could specify a ROM width value of 32 and get a single output file containing 32 bit words Or you can use a ROM width value of 16 to get two files each containing 16 bits of each word The default ROM width that the hex conversion utility uses depends on the output format All hex formats except TI Tagged are configured as lists of 8 bit bytes the default ROM width for these formats is 8 bits Tl Tagged is a 16 bit format the default ROM width for TI Tagged is 16 bits The 30060 Format is 16 Bits Wide NOTE You cannot change the ROM width of the Tl Tagged format The Tl Tagged format supports a 16 bit ROM width only TI TXT Format is 8 Bits Wide NOTE You cannot change the ROM width of the TI TXT format The TI TXT hex form
198. TI 1 TEXAS INSTRUMENTS www ti com Excluding a Specified Section Concerning Load Image Format NOTE These options are invalid when creating a load image memwidth e romwidth e Zero 86 If a boot table is being created either using the SECTIONS directive or the option the ROMS directive must be used 11 7 Excluding a Specified Section The exclude section name option can be used to inform the hex utility to ignore the specified section If a SECTIONS directive is used it overrides the exclude option For example if a SECTIONS directive containing the section name mysect is used and an exclude mysect is specified the SECTIONS directive takes precedence and mysect is not excluded The exclude option has a limited wildcard capability The character can be placed at the beginning or end of the name specifier to indicate a suffix or prefix respectively For example exclude sect disqualifies all sections that begin with the characters sect If you specify the exclude option on the command line with the wildcard enter quotes around the section name and wildcard For example exclude sect Using quotes prevents the from being interpreted by the hex conversion utility If exclude is in a command file then the quotes should not be specified If multiple object files are given the object file in which the section to be excluded can be given in the form oname sname If the object f
199. TIONS directive the linker combines all such input sections that have the same name into an output section with that name For example suppose the files f1 0bj and f2 obj both contain named sections called Vectors and 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 By default the linker does not display a message when it creates an output section that is not defined in the SECTIONS directive You can use the warn sections linker option see Section 7 4 33 to cause the linker to display a message when it creates a new output section After the linker determines the composition of all output sections it must allocate them into configured memory The MEMORY directive specifies which portions of memory are configured If there is no MEMORY directive the linker uses the default configuration as shown in Example 7 16 See Section 7 5 3 for more information on configuring memory SPNU118J August 2011 Linker Description 227 Submit Documentation Feedback I I men YP 0 9115 1 I TEXAS INSTRUMENTS Linker Generated Copy Tables www ti com 7 7 2 Reducing Memory Fragmentation 7 8 7 8 1 228 The linker s allocation algorithm attempts to minimize memory fragmentation This allows memory to be used more efficiently and increases t
200. TRUMENTS www ti com Linker Options 7 4 17 2 Make a Symbol Global make global Option The make_static option makes all global symbols static If you have a symbol that you want to remain global and you use the make_static option you can use the make_global option to declare that symbol to be global The make_global option overrides the effect of the make_static option for the symbol that you specify The syntax for the make_global option is make_global global symbol 7 4 18 Create a Map File map file Option The syntax for the map file option is map filez filename The linker map describes Memory configuration Input and output section allocation Linker generated copy tables Trampolines The addresses of external symbols after they have been relocated Hidden and localized symbols The map file contains the name of the output module and the entry point it can also contain up to three tables A table showing the new memory configuration if any nondefault memory is specified memory configuration The table has the following columns this information is generated on the basis of the information in the MEMORY directive in the link command file Name This is the name of the memory range specified with the MEMORY directive Origin This specifies the starting address of a memory range Length This specifies the length of a memory range Unused This specifies the total amount of unu
201. TS www ti com Defining Macros model statements are instructions or assembler directives that are executed each time the macro is called macro directives are used to control macro expansion mexit is a directive that functions as a goto endm The mexit directive is useful when error testing confirms that macro expansion fails and completing the rest of the macro is unnecessary endm is the directive that terminates the macro definition If you want to include comments with your macro definition but do not want those comments to appear in the macro expansion use an exclamation point to precede your comments If you do want your comments to appear in the macro expansion use an asterisk or semicolon See Section 5 7 for more information about macro comments Example 5 1 shows the definition call and expansion of a macro Example 5 1 Macro Definition Call and Expansion Macro definition The following code defines a macro add3 with four parameters 1 2 3 add3 4 5 m ADDRP P1 P2 P3 6 T add3 macro Pl P2 P3 ADDRP 8 9 ADD ADDRP Pl P2 10 ADD ADDRP ADDRP P3 11 endm Macro call The following code calls the add3 macro with four arguments 12 13 0 add3 R1 R2 R3 RO Macro expansion The following code shows the substitution of the macro definition for the macro call The assembler substitutes R1 R2 R3 and RO for the P1 P2 P3 and ADDRP parameters of add3 1 1 00000000 2 AD
202. The 64 bit value is stored in the format shown in Figure 4 5 Figure 4 5 Double Precision Floating Point Format ISEEEEEEEEEEEMMMMMMMMMMMMMMMMMMMM 31 20 0 MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 31 0 Legend S sign E exponent 11 bit biased M mantissa 52 bit fraction When you use double in a struct endstruct sequence double defines a member s size it does not initialize memory For more information see the struct endstruct tag topic Example This example shows the double directive 1 00000000 C5308B2A double 2 0e25 00000004 2C280291 2 00000008 40180000 double 6 0000000c 00000000 3 00000010 407C8000 double 456 00000014 00000000 94 Assembler Directives SPNU 118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Directives Reference drlist drnolist Control Listing of Directives Syntax drlist drnolist Description Two directives enable you to control the printing of assembler directives to the listing file The drlist directive enables the printing of all directives to the listing file The drnolist directive suppresses the printing of the following directives to the listing file The drnolist directive has no affect within macros asg fcnolist e ssnolist break mlist Var emsg mmsg wmsg eval mnolist e felist Sslist By default the assembler acts as if the drlist directive had been specified Exam
203. UMENTS www ti com Source Statement Format 3 5 2 Mnemonic Field The mnemonic field follows the label field The mnemonic field cannot start in column 1 if it does it is interpreted as a label There is one exception the parallel bars of the mnemonic field can start in column 1 The mnemonic field can begin with one of the following items Machine instruction mnemonic such as ADD MUL STR Assembler directive such as data list equ Macro directive such as macro var mexit Macro call 3 5 3 Operand Field The operand field follows the mnemonic field and contains one or more operands The operand field is not required for all instructions or directives An operand consists of the following items Constants see Section 3 6 Character strings see Section 3 7 Symbols see Section 3 8 Expressions combination of constants and symbols see Section 3 9 You must separate operands with commas 3 5 3 1 Operand Syntaxes for Instructions The assembler allows you to specify that an operand should be used as an address an immediate value an indirect address a register a shifted register or a register list The following rules apply to the operands of instructions prefix the operand is an immediate value If you use the sign as a prefix the assembler treats the operand as an immediate value This is true even when the operand is a register the assembler treats the register as a val
204. V RO 0 6 7 8 X Allocate 4 bytes in bss for TEMP 8 9 0 00000000 Var 1 bss TEMP 4 1 2 3 ae Still in text EE 4 5 00000004 E2801056 ADD R1 RO 56h 6 00000008 E0020091 MUL R2 R1 RO 7 8 9 Allocate 100 bytes in bss for the symbol 20 KE named ARRAY EE 21 k ko ko 22 00000004 bss ARRAY 100 4 23 24
205. XAS INSTRUMENTS www ti com Assign a Substitution Symbol asg character string substitution symbol define character string substitution symbol eval well defined expression substitution symbol The asg and define directives assign character strings to substitution symbols Substitution symbols are stored in the substitution symbol table The asg directive can be used in many of the same ways as the set directive but while set assigns a constant value which cannot be redefined to a symbol asg assigns a character string which can be redefined to a substitution symbol The assembler assigns the character string to the substitution symbol The substitution symbol must be a valid symbol name The substitution symbol is up to 128 characters long and must begin with a letter Remaining characters of the symbol can be a combination of alphanumeric characters the underscore and the dollar sign The define directive functions in the same manner as the asg directive except that define disallows creation of a substitution symbol that has the same name as a register symbol or mnemonic It does not create a new symbol name space in the assembler rather it uses the existing substitution symbol name space The define directive is used to prevent corruption of the assembly environment when converting C C headers See Chapter 12 for more information about using C C headers in assembly source The eval directiv
206. ZE operators provide a mechanism to distinguish between the size of a UNION s load space and the size of the space where its constituents are going to be copied before they are run Here is an example UNION run RAM LOAD START union load addr LOAD SIZE union ld sz RUN SIZE union run sz textl load text2 load ROM SIZE textl_size fl obj text ROM SIZE text2 size f2 obj text Here union ld sz is going to be equal to the sum of the sizes of all output sections placed in the union The union run sz value is equivalent to the largest output section in the union Both of these symbols incorporate any padding due to blocking or alignment requirements 7 5 9 Creating and Filling Holes The linker provides you with the ability to create areas within output sections that have nothing linked into them These areas are called holes In special cases uninitialized sections can also be treated as holes This section describes how the linker handles holes and how you can fill holes and uninitialized sections with values 7 5 9 1 Initialized and Uninitialized Sections There are two rules to remember about the contents of output sections An output section contains either Raw data for the entire section Noraw data A section that has raw data is referred to as initialized This means that the object file contains the actual memory image contents of the section When the section is loaded this image is loaded int
207. a epe ties 36A Binary Integers 3 6 2 Octallntegqere sun de EA EEE E 42 36 3 DeoimialIntegers Sond rie ee en o ee 42 3 6 4 Hexadecimal Integers si 1 1 1 10 101000 43 3 0 5 Character Constants 1 1 1 1 1 1 101 E E E T n eran 43 RUE 43 sisi Assembly Time Constants ow 3 6 6 3 7 jesse mmm 44 3 8 SY 00 ee tials aie aces 44 EE 11831969 ero ee cea 44 44 E Localliabels sa 3 8 2 SPNU118J August 2011 Contents 3 Submit Documentation Feedback I I men YP eonmy I I TEXAS INSTRUMENTS www ti com 3 8 3 Symbolic Constante L G 46 3 8 4 Defining Symbolic Constants asm define Option cceceeeee eee eee teen HH 46 3 9 5 Predefined Symbolic Constants sss ani aaae E aa A a 47 3 8 6 Substitution 49 3 9 EXDIGSSIONS 50 3 9 QOperatole Lm 50 3 9 2 Expression Overflow and Underflow pp 50 3 9 8 Well Defined Expressions soi III HH HH HII HII HI He nenne nn nnn 51 3 9 4 Conditional 000000000000090 nnne nnn 51 3 9
208. a macro you can use the var directive to define up to 32 local macro substitution 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 var sym syms syM The var directive is used in Example 5 8 and Example 5 9 SPNU118J August 2011 Macro Description 151 Submit Documentation Feedback Se oF T www BD EIC conr TI 1 TEXAS INSTRUMENTS Macro Libraries www ti com 5 4 152 Macro Libraries One way to define macros is by creating a macro library A macro library is a collection of files that contain macro definitions You must use the archiver to collect these files or members into a single file called an archive Each member of a macro library contains one macro definition The files in a macro library must be unassembled source files The macro name and the member name must be the same and the macro filename s extension must be asm For example Macro Name Filename in Macro Library simple simple asm add3 add3 asm You can access the macro library by using the mlib assembler directive described in Define Macro Library The syntax is mlib filename When the assembler encounters the mlib directive it opens the library named by filename and creates a table of the library s contents The assembler enters the
209. ace data and the run space data are different The linker creates the following two sections e task1 This section is uninitialized This output section represents the run space image of section task1 task1 load This section is initialized This output section represents the load space image of the section task1 This section usually is considerably smaller in size than task1 output section 7 8 8 3 Compressed Data Layout The compressed load data has the following layout 8 bit index Compressed data The first eight bits of the load data are the handler index This handler index is used to index into a handler table to get the address of a handler function that knows how to decode the data that follows The handler table is a list of 32 bit function pointers as shown in Figure 7 6 Figure 7 6 Handler Table TI Handler Table Base 32 bit handler address 1 32 bit handler address N TI Handler Table Limit The linker creates a separate output section for the load and run space For example if task1 load is compressed using RLE the handler index points to an entry in the handler table that has the address of the run time support routine decompress rle 7 8 8 4 Run Time Decompression 234 During run time you call the run time support routine copy_in to copy the data from load space to run space The address of the copy table is passed to this routine First the routine reads the rec
210. ad the next 16 bits LL Read the next byte C If C 0 copy C to the output buffer L times Go to step 2 10 End of processing The ARM run time support library has a routine Tl decompress rle to decompress data compressed using RLE The first argument to this function is the address pointing to the byte after the 8 bit index The second argument is the run address from the C auto initialization record Lempel Ziv Storer and Szymanski Compression LZSS 8 bit index Data compressed using LZSS The data following the 8 bit index is compressed using LZSS compression The ARM run time support library has the routine Tl decompress Izss to decompress the data compressed using LZSS The first argument to this function is the address pointing to the byte after the 8 bit Index and the second argument is the run address from the C auto initialization record SPNU118J August 2011 Linker Description 235 Submit Documentation Feedback I I men BADE 0 9115 1 I TEXAS INSTRUMENTS Linker Generated Copy Tables www ti com 7 8 9 Copy Table Contents In order to use a copy table that is generated by the linker you must be aware of the contents of the copy table This information is included in a new run time support library header file cpy_tbl h which contains a C source representation of the copy table data structure that is automatically generated by the linker Example 7 20 shows the ARM copy table he
211. addition palign ensures that the size of the section is a multiple of its placement alignment restrictions padding the section size up to such a boundary as needed For example the following code lines allocate text on a 2 byte boundary within the PMEM area The text section size is guaranteed to be a multiple of 2 bytes Both statements are equivalent text palign 2 gt PMEM text palign 2 gt PMEM If the linker adds padding to an initialized output section then the padding space is also initialized By default padding space is filled with a value of 0 zero However if a fill value is specified for the output section then any padding for the section is also filled with that fill value For example consider the following section specification mytext palign 8 fill Oxffffffff gt PMEM In this example the length of the mytext section is 6 bytes before the palign operator is applied The contents of mytext are as follows addr content 0000 0x1234 0002 0x1234 0004 0x1234 After the palign operator is applied the length of mytext is 8 bytes and its contents are as follows addr content 0000 0x1234 0002 0x1234 0004 0x1234 0006 Oxffff The size of mytext has been bumped to a multiple of 8 bytes and the padding created by the linker has been filled with Oxff The fill value specified in the linker command file is interpreted as a 16 bit constant so if you specify this code mytext palig
212. ader file Example 7 20 ARM cpy_tbl h File J E E K k k k Ck kk Ck kk Ck ke kk Ck kk Ck kk Ck kk kk Ck Ck kk Ck kk f cpy tbl h vi Ey Copyright c 2003 Texas Instruments Incorporated pa Specification of copy table data structures which can be automatically generated by the linker using the table operator in the LCF rd J EE K Re k k e k ke k kk k A k k k k k k kk k k k k k k k k k k k k k k k ke ke ke ke ek f ifndef _CPY_TBL define _CPY_TBL ifdef _ cplusplus extern C namespace std endif _ cplusplus ke ke kc kk ke Ck Ck Ck Ck kk Ck Ck RR KKK KKK kk Copy Record Data Structure 27 J E E K k k k k e k e e k e e k e e ke k k k k A k k k k k k kk k k k k k k k k kk k kk k k k k k k k k k k k kk k kkk kkk k kkk kkk kkk f typedef struct copy_record unsigned int load_addr unsigned int run_addr unsigned int size COPY RECORD S EE K k k k ko k k k kk Ck ke k k k kk Ck kk Ck Ck k k kk k kk Ck ke kk k
213. al wild cards or Use to match a single character and use to match zero or more characters The localize option changes the symbol linkage to local for symbols matching the pattern The globalize option changes the symbol linkage to global for symbols matching the pattern The globalize option only affects symbols that are localized by the localize option The globalize option excludes symbols that match the pattern from symbol localization provided the pattern defined by globalize is more restrictive than the pattern defined by localize Specifying 0 6 Symbols with localize and globalize NOTE For COFF ABI the compiler prepends an underscore to the beginning of all C C identifiers That is for a function named foo2 foo2 is prefixed with _ and _foo2 becomes the link time symbol The localize and globalize options accept the link time symbols Thus you specify localize foo2 to localize the C function foo2 ARM EABI is an exception to this case Under the ARM EABI the link time symbol is the same as the HLL name These options have the following properties The localize and globalize options can be specified more than once on the command line The order of localize and globalize options has no significance Asymbol is matched by only one pattern defined by either localize or globalize Asymbol is matched by the most restrictive pattern Pattern A is considered more r
214. all site caller address 0x1800 caller address caller object component ref idref oc 23 call site call site caller address 0x1810 caller address caller object component ref idref oc 23 call site caller list far call trampoline far call trampoline list 316 XML Link Information File Description SPNU118J August 2011 S oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Document Elements B 2 7 Symbol Table The lt symbol_table gt contains a list of all of the global symbols that are included in the link The list provides information about a symbol s name and value In the future the symbol table list may provide type information the object component in which the symbol is defined storage class etc The symbol is a container element that specifies the name and value of a symbol with these elements The name element specifies the symbol name string The value element specifies the symbol value constant Example B 7 Symbol Table for the fl 4 Input File symbol table symbol name c int00 name value 0xaf80 value symbol symbol name mainc name value 0xble0 value symbol symbol name printfc name value 0xac00 value symbol symbol table SPNU 118J August 2011 XML Link Information File Descript
215. alue is associated with the beginning of the structure If no stag is present the assembler puts the structure members in the global symbol table with the value of their absolute offset from the top of the structure A stag is optional for struct but is required for tag The element is one of the following descriptors byte char int long word double half short string float and field All of these except tag are typical directives that initialize memory Following a struct directive these directives describe the structure element s size They do not allocate memory A tag directive is a special case because stag must be used as in the definition of stag The expris an optional expression indicating the beginning offset of the structure The default starting point for a structure is 0 The expr is an optional expression for the number of elements described This value defaults to 1 A string element is considered to be one byte in size and a field element is one bit The mem is an optional label for a member of the structure This label is absolute and equates to the present offset from the beginning of the structure A label for a structure member cannot be declared global The size is an optional label for the total size of the structure This example illustrates a structure in C that will be accessed in assembly code SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC
216. ample 7 29 Any CRC calculation routine employed outside of the linker must function in the same way to ensure matching CRC values The linker cannot detect a mismatch in the parameters To understand these parameters see A Painless Guide to CRC Error Detection Algorithms by Ross Williams which is likely located at http www ross net crc download crc_v3 ixt Only the CRC algorithm names and identifiers specified in crc tbl h are supported All other names and ID values are reserved for future use There is one supported CRC algorithm for ARM The details of the algorithm are available in the MCRC documentation The algorithm is identified within the linker as TMS570 CRC64 ISO The initial value for the algorithm is O There are also restrictions which will be enforced by the linker CRC can only be requested at final link time CRCcan only be applied to initialized sections e CRC can be requested for load addresses only Certain restrictions also apply to CRC table names For example BINIT may not be used as a CRC table name SPNU 118J August 2011 Linker Description 241 Submit Documentation Feedback I I men BADE 0 9115 1 1 TEXAS INSTRUMENTS Linker Generated CRC Tables www ti com 7 9 3 Examples The crc_table operator is similar in syntax to the table operator used for copy tables A few simple examples of link command files follow Example 7 25 Using crc_table Operator to Compute the C
217. an external undefined variable called Dstart in the program Then assign the value of to Dstart SECTIONS text data Dstart Das This defines Dstart to be the first linked address of the data section Dstart is assigned before data is allocated The linker relocates 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 sections Any value assigned to to create a hole is relative to the beginning of the section not to the address actually represented by the symbol Holes and assignments to are described in Section 7 5 9 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Linker Command Files 7 5 8 3 Assignment Expressions These rules apply to linker expressions Expressions can contain global symbols constants and the C language operators listed in Table 7 10 All numbers are treated as long 32 bit integers Constants are identified by the linker in the same way as by the assembler That is numbers are recognized as decimal unless they have a suffix H or h for hexadecimal and Q or q for octal C language prefixes are also recognized 0 for octal and Ox for hex Hexadecimal constants must begin with a digit No binary constants are allowed Symbols within an expression have only the val
218. and SECTIONS directives the linker allocates output sections as though the definitions in Example 7 16 were specified Example 7 16 Default Allocation for ARM Devices RAM origin 0x00000000 length OxFFFFFFFF SECTIONS text ALIGN 4 gt RAM const ALIGN 4 gt RAM data ALIGN 4 gt RAM bss ALIGN 4 gt RAM cinit ALIGN 4 RAM c option only pinit ALIGN 4 RAM c option only 7 7 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 If you use a SECTIONS directive the linker performs no part of the default allocation Allocation is performed according to the rules specified by the SECTIONS directive and the general algorithm described next in Section 7 7 1 How the Allocation Algorithm Creates Output Sections An output section can be formed in one of two ways Method 1 As the result of a SECTIONS directive definition Method 2 By combining input sections with the same name into an output section that is not defined in a SECTIONS directive If an output section is formed as a result of a SECTIONS directive this definition completely determines the section s contents See Section 7 5 4 for examples of how to define an output section s content If an output section is formed by combining input sections not specified by a SEC
219. and can appear anywhere on the command line following the command Precede each option with a hyphen dwarf display attributes controls the DWARF display filter settings by specifying a comma delimited list of attributes When prefixed with no an attribute is disabled instead of enabled Examples dwarf_display nodabbrev nodline dwarf_display all nodabbrev dwarf_display none dinfo types The ordering of attributes is important see obj display The list of available display attributes can be obtained by invoking ofd470 dwarf display help dynamic info outputs dynamic linking information for ELF only g appends DWARF debug information to program output h displays help o filename sends program output to filename rather than to the Screen obj display attributes controls the object file display filter settings by specifying a comma delimited list of attributes When prefixed with no an attribute is disabled instead of enabled Examples obj_display rawdata nostrings obj_display all norawdata obj_display none header The ordering of attributes is important For instance in obj_display none header ofd470 disables all output then re enables file header information If the attributes are specified in the reverse order header none the file header is enabled the all output is disabled including the file header Thus nothing is printed to the screen for the given files The list of available display at
220. are always listed in the assembly language file that the compiler creates for program analysis purposes To list the complete set used for full symbolic debug invoke the compiler with the symdebug dwarf option as shown below 01470 symdebug dwarf keep asm input file The keep asm option instructs the compiler to retain the generated assembly file To disable the generation of all symbolic debug directives invoke the compiler with the symdebug none option 01470 symdebug none keep asm input file The DWARF debugging format consists of the following directives The dwtag and dwendtag directives define a Debug Information Entry DIE in the debug info section The dwattr directive adds an attribute to an existing DIE The dwpsn directive identifies the source position of a C C statement The dwcie and dwendentry directives define a Common Information Entry CIE in the debug frame section The dwfde and dwendentry directives define a Frame Description Entry FDE in the debug frame section The dwefi directive defines a call frame instruction for a CIE or FDE A 2 COFF Debugging Format COFF symbolic debug is now obsolete These directives are supported for backwards compatibility only The decision to switch to DWARF as the symbolic debug format was made to overcome many limitations of COFF symbolic debug including the absence of C support The COFF debugging format consists of the following
221. are not combined into output sections during a partial link unless a matching SECTIONS directive is specified in the link step command file If the intermediate files have global symbols that have the same name as global symbols in other files and you want them to be treated as static visible only within the intermediate file you must link the files with the make_static option see Section 7 4 17 1 If you are linking C code do not use ram_model or rom_model until the final linker Every time you invoke the linker with the ram_model or rom_model option the linker attempts to create an entry point See Section 7 4 24 The following example shows how you can use partial linking Step 1 Link the file file1 com use the relocatable option to retain relocation information in the output file tempout1 out c1470 run linker relocatable output file tempoutl filel com file1 com contains SECTIONS ssl f1 0bj 2 0bj fn obj Step 2 Link the file file2 com use the relocatable option to retain relocation information in the output file tempout2 out c1470 run linker relocatable output file tempout2 file2 com file2 com contains SECTIONS ss2 gl obj g2 0bj gn obj Step 3 Link tempout1 out and tempout2 out 1470 run linker map file final map output file final out tempoutl out tempout2 out SPNU118J August 2011 Linker Description 247 Submit Documentation Feedback Se oF
222. arning messages The emsg directive sends error messages to the standard output device The emsg directive generates errors in the same manner as the assembler incrementing the error count and preventing the assembler from producing an 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 the emsg directive but increments the warning count rather than the error count It does not affect the creation of the object file For more information about using the error and warning directives in macros see Section 5 7 Assembler Directives SPNU 118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Directives Reference 4 13 Directives Reference The remainder of this chapter is a reference Generally the directives are organized alphabetically one directive per topic Related directives such as if else endif however are presented together in one topic align Align SPC on the Next Boundary Syntax align size in bytes Description The align directive aligns the section program counter SPC on the next boundary
223. arry is set branch to 1 ADDS r0 rO 1 else increment to r0 MOVCS pos 5 and return 1 LDR r2 r5 4 Load indirect of r5 into r2 with write back newblock Undefine 1 so it can be used again ADDS ri ri 2 Add r2 to rl BPL 1 If the negative bit isn t set branch to 1 MVNS rl xi else negate rl SIs MOV pe ir Return The following code uses a local label illegally BCS 1 If carry is set branch to 1 ADDS xy 0 1 else increment to 0 MOVCS pc ir and return 1 LDR r2 r5 4 Load indirect of r5 into r2 with write back ADDS ri rli 2 Add r2 to rl BPL 1 If the negative bit isn t set branch to 1 MVNS ri ri else negate rl 1 MOV pe lr Return The 1 label is not undefined before being reused by the second branch instruction Therefore 1 is redefined which is illegal Local labels are especially useful in macros If a macro contains 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 of the n form can be in effect at one time Local labels of the form name are not limited 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 Because local labels are intended to be used only local
224. ary is searched and the definition of c rscr is found Member 0 of libc lib satisfies the reference to origin Member 3 of liba lib satisfies the reference to fillcir If however you enter c1470 run linker fl obj f2 0bj libc lib liba lib then the references to cirscr are satisfied by member 1 of libc lib If none of the linked files reference symbols defined in a library you can use the undef sym option to force the linker to include a library member See Section 7 4 32 The next example creates an undefined symbol rout1 in the linker s global symbol table c1470 run linker undef sym routl libc lib If any member of libc lib defines rout1 the linker includes that member Library members are allocated according to the SECTIONS directive default allocation algorithm see Section 7 5 4 Section 7 4 16 describes methods for specifying directories that contain object libraries 226 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI TEXAS INSTRUMENTS www ti com Default Allocation Algorithm 7 7 Default Allocation Algorithm The MEMORY and SECTIONS directives provide flexible methods for building combining and allocating sections However any memory locations or sections that you choose not to specify must still be handled by the linker The linker uses default algorithms to build and allocate sections within the specifications you supply If you do not use the MEMORY
225. as a result of alignment Then start of 52 is not really the start address of the text section in s2 obj but it is the address before the padding needed to align the text section in s2 obj This is due to the linker s interpretation of the dot operator as the current PC It is also due to the fact that the dot operator is evaluated independently of the input sections around it Another potential problem in the above example is that end of s2 may not account for any padding that was required at the end of the output section You cannot reliably use end of s2 as the end address of the output section One way to get around this problem is to create a dummy section immediately after the output section in question For example GROUP outsect Start of outsect dummy size of outsect start of outsect 7 5 8 7 Address and Dimension Operators Six new operators have been added to the link command file syntax LOAD START sym START sym Defines sym with the load time start address of related allocation unit LOAD END sym END sym LOAD SIZE sym SIZE sym RUN START sym RUN END sym RUN SIZE sym Defines sym with the load time end address of related allocation unit Defines sym with the load time size of related allocation unit Defines sym with the run time start address of related allocation unit Defines sym with the run time end address of related allocation unit Defines sym with the run time size of
226. assembly Section 5 5 f loop well defined expression Begin repeatable block assembly Section 5 5 Table 5 5 Producing Assembly Time Messages See Mnemonic and Syntax Description Macro Use Directive emsg Send error message to standard output Section 5 7 emsg mmsg Send assembly time message to standard output Section 5 7 mmsg wmsg Send warning message to standard output Section 5 7 wmsg Table 5 6 Formatting the Listing See Mnemonic and Syntax Description Macro Use Directive fclist Allow false conditional code block listing default Section 5 8 fclist fcnolist Suppress false conditional code block listing Section 5 8 fcnolist mlist Allow macro listings default Section 5 8 mlist mnolist Suppress macro listings Section 5 8 mnolist sslist Allow expanded substitution symbol listing Section 5 8 Sslist ssnolist Suppress expanded substitution symbol listing default Section 5 8 SSnolist SPNU118J August 2011 Submit Documentation Feedback www oF Eeconzy TI Macro Description 159 160 Macro Description SPNU 118J August 2011 T4 E I T Submit Documentation Feedback 1 efas men WWW conr TI 5 TEXAS INSTRUMENTS The ARM archiver lets you combine several individual files into a single archive file For example you can collect several macros into a macro library The assembler searches the library and uses the members Chapter 6 Archiver Description that are called as macros by the source
227. at supports only an 8 bit ROM width You can change ROM width except for Tl Tagged and TI TXT formats by Using the romwidth option This option changes the ROM width value for the entire object file Setting the romwidth parameter of the ROMS directive This parameter changes the ROM width value for a specific ROM address range and overrides the romwidth option for that range See Section 11 4 For both methods use a value that is a power of 2 greater than or equal to 8 If you select a ROM width that is wider than the natural size of the output format 16 bits for Tl Tagged or 8 bits for all others the utility simply writes multibyte fields into the file Figure 11 4 illustrates how the object file data memory and ROM widths are related to one another Memory width and ROM width are used only for grouping the object file data they do not represent values Thus the byte ordering of the object file data is maintained throughout the conversion process To refer to the partitions within a memory word the bits of the memory word are always numbered from right to left as follows memwidth 32 AABBCCDD11223 3 4 4 31 0 280 Hex Conversion Utility Description SPNU118J August 2011 S oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Data after phase of hex470 Data after phase of hex470 SPNU118J August 2011 Submit Documentation Feedback Understanding Me
228. ation about TMS470 C DIR see the ARM Optimizing C C Compiler User s GuideARP32 Optimizing C C Compiler Users Guide The copy and include directives can be nested within a file being copied or included The assembler limits nesting to 32 levels the host operating system may set additional restrictions The assembler precedes the line numbers of copied files with a letter code to identify the level of copying A indicates the first copied file B indicates a second copied file etc In this example the copy directive is used to read and assemble source statements from other files then the assembler resumes assembling into the current file The original file copy asm contains a copy statement copying the file byte asm When copy asm assembles the assembler copies byte asm into its place in the listing note listing below The copy file byte asm contains a copy statement for a second file word asm When it encounters the copy statement for word asm the assembler switches to 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 remaining statement copy asm byte asm word asm source file first copy file second copy file Space 29 In byte asm In word asm copy byte asm byte 32 1 A word OABCDh 56q Back in original file copy word asm S
229. ation about all static and global symbols defined in an application on a file by file basis You may find it useful to replace the sym name and sym runaddr sections of the map file with the sym defs section by specifying the following mapfile contents option mapfile contents nosym name nosym runaddr sym defs Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Options 7 4 20 Disable Name Demangling no demangle By default the linker uses demangled symbol names in diagnostics For example undefined symbol first referenced in file ANewClass getValue test obj The no demangle option disables the demangling of symbol names in diagnostics For example undefined symbol first referenced in file _ZN9ANewClass8getValueEv test obj 7 4 21 Disable Merge of Symbolic Debugging Information no_sym_merge Option By default the linker eliminates duplicate entries of symbolic debugging information Such duplicate information is commonly generated when a C program is compiled for debugging For example header h typedef struct define some structure members XYZ e dd include header h 2226 include header h When these files are compiled for debugging both 11 and f2 obj have symbolic debugging entries to describe type XYZ For the final output file only one set of these entries is neces
230. aults to 1 A string element is considered to be one byte in size and a field element is one bit The size is an optional label for the total size of the structure Directives That Can Appear in a struct endstruct Sequence NOTE The only directives that can appear in a struct endstruct sequence are element descriptors conditional assembly directives and the align directive which aligns the member offsets on word boundaries Empty structures are illegal SPNU118J August 2011 p 3 T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Directives Reference The following examples show various uses of the struct tag and endstruct directives Example 1 Example 2 Example 3 Example 4 SPNU118J August 2011 Submit Documentation Feedback 1 REAL REC 2 00000000 NOM 3 00000004 DEN 4 00000008 REAL LEN 5 6 00000000 E59F0004 7 00000004 E5904004 8 00000008 E0811004 9 00000000 0 0000000c 00000000 REAL A 1 2 CPLX REC 3 00000000 REALI 4 00000008 IMAGI 5 00000010 LEN 6 7 COMPLEX 8 9 00000010 COMPLEX 20 00000020 8 21 00000024 4 1 2 3 00000000 X 4 00000004 Y 5 00000008 2 6 0000000C 1 BIT REC 2 00000000 STREAM 3 00000040 BIT7 4 00000040 8 5 00000042 0 6 00000044 X INT 7 00000048 BIT_LEN 8 9 00000000 BITS 10 BITS 11 00000048 E51F0010 12 0000004c E0811000 struct int endstruct LDR RO REAL A
231. bj and file2 obj The data beta subsection combines the data beta subsections from file1 obj and file2 obj The linker places the subsections anywhere there is space for boundary them in SLOW MEM in this illustration and aligns each on a 16 byte boundary data beta EXT MEM EN 0x00001800 Empty range of memory as defined in above 0x10000000 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 0x00000800 Allocated in EXT MEM 0x10001000 Empty range of memory as defined in above OxFFFFFFFF 7 5 4 2 Allocation The linker assigns each output section two locations in target memory the location where the section will be loaded and the location where it will be run Usually these are the same and you can think of each section as having only a single address The process of locating the output section in the target s memory and assigning its address es is called allocation For more information about using separate load and run allocation see Section 7 5 5 If you do not tell the linker how a section is to be allocated it uses a default algorithm to allocate the section Generally the linker puts sections wherever they fit into configured memory You can override this default allocation for a section by defining it within a SECTIONS directive and providing ins
232. bj symbol contains code and data for initializing the run time environment and performs the following tasks Changes from system mode to user mode Sets up the user mode stack Processes the run time cinit initialization table and autoinitializes global variables when the linker is invoked with the rom model option Calls main The run time support object libraries contain boot obj You can Use the archiver to extract boot obj from the library and then link the module in directly Include the appropriate run time support library as an input file the linker automatically extracts boot obj when you use the ram model or rom model option 7 11 2 Object Libraries and Run Time Support The ARM Optimizing C C Compiler User s Guide describes additional run time support functions that are included in rts src If your program uses any of these functions you must link the appropriate run time support library with your object files You can also create your own object libraries and link them The linker includes and links only those library members that resolve undefined references 7 11 3 Setting the Size of the Stack and Heap Sections 248 The C C language uses two uninitialized sections called sysmem and stack for the memory pool used by the malloc functions and the run time stacks respectively You can set the size of these by using the heap size or stack size option and specifying the size of the section as a
233. ble word boundary The field directive places a single value into a specified number of bits in the current word With field you can pack multiple fields into a single word the assembler does not increment the SPC until a word is filled Figure 4 1 shows how fields are packed into a word Using the following assembled code notice that the SPC does not change for the first three fields the fields are packed into the same word 1 00000000 60000000 field 3 3 2 00000000 64000000 field 8 6 3 00000000 64400000 field 16 5 4 00000004 01234000 field 01234 20 5 00000008 00001234 field 012345 32 Assembler Directives SPNU 118J August 2011 BYE T Submit Documentation Feedback men www BDF TI I TEXAS INSTRUMENTS www ti com Directives That Initialize Constants Figure 4 1 The field Directive field 3 3 31 30 29 3 bits field 8 6 31 28 27 26 25 24 23 0 001000 6 bits field 16 5 31 22 2120 18 0 0 0 0 0 1 1 0 0 1 1 0 5 bits field 01234h 20 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 0 00000001001000110100 20 bits field 01234h 32 31 0 00000000000000000001001000110100 The float directive calculates the single precision 32 bit IEEE floating point representation of a single floating point value and stores it in a word in the current section that is aligned to a word boundary The half and short directives place one o
234. bugging the expansion of substitution symbols The expanded line appears below the actual source line ssnolist turns off substitution symbol expansion in the listing For substitution symbol expansion listing ssnolist is the default Directive listing drlist causes the assembler to print to the listing file all directive lines drnolist suppresses the printing of certain directives in the listing file These directives are asg eval var sslist mlist fclist ssnolist mnolist fcnolist emsg wmsg mmsg length width and break For directive listing drlist is the default SPNU 118J August 2011 Macro Description 157 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Using Recursive and Nested Macros www ti com 5 9 Using Recursive and Nested Macros The macro language supports recursive and nested macro calls This means that you can call other macros in a macro definition You can nest macros up to 32 levels deep When you use recursive macros you call a macro from its own definition the macro calls itself When you create recursive or nested macros you should pay close attention to the arguments 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 The y in the in_block macro hides the y in the out_block
235. c4 asm contains the definition of inc4 and dec4 asm contains the definition of dec4 inc4 asm dec4 asm Macro for incrementing Macro for decrementing inc4 macro regl reg2 reg3 reg4 dec4 macro regl reg2 reg3 reg4 Add regl regl 1 SUB regl regl 1 ADD reg2 reg2 1 SUB reg2 reg2 1 ADD reg3 reg3 1 SUB reg3 reg3 1 ADD reg4 reg4 1 SUB reg4 reg4 1 endm endm Use the archiver to create a macro library ar470 a mac inc4 asm dec4 asm ar32 a mac inc4 asm dec4 asm Now you can use the mlib directive to reference the macro library and define the inc4 asm and dec4 asm macros 1 mlib mac lib 2 Macro call 3 00000000 inc4 R7 R6 R5 4 1 00000000 E2877001 ADD R7 R7 1 1 00000004 E2866001 ADD R6 R6 1 1 00000008 1 ADD R5 R5 41 1 0000000c E2844001 ADD R4 R4 1 4 5 Macro call 6 00000010 dec4 RO R1 R2 R3 1 00000010 E2400001 SUB RO RO 41 1 00000013 1 SUB R1 R1 41 SPNU118J August 2011 S oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Directives Reference 1 00000018 E2422001 SUB R2 R2 41 1 0000001c E2433001 SUB R3 R3 41 SPNU118J August 2011 Assembler Directives 117 Submit Documentation Feedback Se oF www BD FICconr TI Directives Reference mlist mnolist Syntax Description Example 118 Assembler Directives 1 TEXAS INSTRUMENTS www ti com Start Stop Macro Expansion Listing mlist mnolist
236. cated into memory as a single unit Suppose there is a portion of executable code perhaps an initialization routine that you do not want allocated with text If you assemble this segment of code into a named section it is assembled separately from text and you can allocate it into memory separately You can also assemble initialized data that is separate from the data section and you can reserve space for uninitialized variables that is separate from the bss section Two directives let you create named sections The usect directive creates uninitialized sections that are used like the bss section These sections reserve space in RAM for variables The sect directive creates initialized sections like the default text and data sections that can contain code or data The sect directive creates named sections with relocatable addresses The syntaxes for these directives are symbol usect section name size in bytes alignment bank offset sect section name The section name parameter is the name of the section For COFF you can create up to 32 767 separate named sections For ELF the max number of sections is 232 1 4294967295 For the usect and sect directives a section name can refer to a subsection see Section 2 2 4 for details Each time you invoke one of these directives with a new name you create a new named section Each time you invoke one of these directives with a name that was already use
237. cation reserved by the directive The symbol name must correspond to the variable that you are reserving space for The size in bytes is a required parameter it must be an absolute expression The assembler allocates size bytes in the bss section There is no default size The alignment is an optional parameter that ensures that the space allocated to the symbol occurs on the specified boundary The boundary indicates the size of the alignment in bytes and must be set to a power of 2 between 2 and 2 5 inclusive If the SPC is aligned at the specified boundary it is not incremented For more information about sections see Chapter 2 In this example the bss directive allocates space for two variables TEMP and ARRAY The symbol TEMP points to four bytes of uninitialized space at bss SPC The symbol ARRAY points to 100 bytes of uninitialized space at bss SPC 04h Symbols declared with the bss directive can be referenced in the same manner as other symbols and can also be declared external 1 2 Start assembling into the text section 3 ck ko kk ok 4 00000000 text 5 00000000 E3A00000 MO
238. cation Shown in Example 7 12 and Example 7 13 FAST MEM Sections can run FAST MEM Copies at as a union This is run time alloca tine bss part1 tion only text 1 run bss part3 bss part3 SLOW MEM text Sections cannot load as a union NI SLOW_MEM text 1 load text 2 load Since the text sections contain raw data they cannot oad as a union although they can be run as a union Therefore each requires its own load address If you fail to provide a load allocation for an initialized section within a UNION the linker issues a warning and allocates load space anywhere it can 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 meaningless 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 run and load addresses are specified the linker issues a warning and ignores the load address 214 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Command Files 7 5 6 2 Grouping Output Sections Together The SECTIONS directive s GROUP option forces several output sections to be allocated contiguously For example assume that a se
239. ck www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Directives Reference tab Define Tab Size Syntax tab size Description The tab directive defines the tab size Tabs encountered in the source input are translated to size character spaces in the listing The default tab size is eight spaces Example In this example each of the lines of code following a tab statement 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 l default tab size 2 00000000 E1A00000 NOP 3 00000004 E1A00000 NOP 4 00000008 E1A00000 NOP 5 7 0000000c E1A00000 NOP 8 00000010 E1A00000 NOP 9 00000014 E1A00000 NOP 10 12 00000018 E1A00000 NOP 13 0000001c E1A00000 NOP 14 00000020 E1A00000 NOP SPNU118J August 2011 Submit Documentation Feedback Assembler Directives 133 www sok Eeconzy TI Directives Reference text Syntax Description Examp 134 le Assembler Directives I TEXAS INSTRUMENTS www ti com Assemble Into the text Section text The text directive tells the assembler to begin assembling into the text section which usually contains executable code The section program counter is set to 0 if nothing has yet been assembled into the text section If code has already been assembled into the text section the section program counter is restored to its previous value in the section Th
240. cls options filename filename2 Multiple Lines cdecls options ef 0 I C C code Typically a list of includes and a few defines TOL 7 The cdecls directive allows programmers in mixed assembly and C C environments to share C headers containing declarations and prototypes between the C and assembly code Any legal C C can be used in a cdecls block and the C C declarations cause suitable assembly to be generated automatically allowing you to reference the C C constructs in assembly code such as calling functions allocating space and accessing structure members using the equivalent assembly mechanisms While function and variable definitions are ignored most common C C elements are converted to assembly for instance enumerations non function like macros function and variable prototypes structures and unions The cdecls options control whether the code is treated as C or C code and how the cdecls block and converted code are presented Options must be separated by commas they can appear in any order 6 Treat the code in the cdecls block as C source code default CPP Treat the code in the cdecls block as C source code This is the opposite of the C option NOLIST Do not include the converted assembly code in any listing file generated for the containing assembly file default LIST Include the converted assembly code in any listing file g
241. conr TI 1 TEXAS INSTRUMENTS www ti com Directives Reference st i0 50 st st st 51 en typedef struct STRUCT1 int i0 offset 0 short s0 offset 4 structl size 8 alignment 4 typedef struct STRUCT2 structl stl offset 0 short sl offset 8 struct2 size 12 alignment 4 The structure will get the following offsets once the C compiler lays out the structure elements according to the C standard rules offsetof structl i0 0 offsetof structl s0 4 sizeof struct1 8 offsetof struct2 s1 0 offsetof struct2 il sizeof struct2 12 Attempts to replicate this structure in assembly using the struct union directives will not create the correct offsets because the assembler tries to use the most compact arrangement rcti Struct aint bytes 0 3 Short bytes 4 5 ructllen endstruct Size 6 alignment 4 ruct2 Struct 1 tag structl bytes 0 5 short bytes 6 7 dstruct2 endstruct Size 8 alignment 4 Sect datal word structl i0 0 word structl s0 word structllen Sect data2 word struct2 stl 9 word struct2 s1 6 word endstruct2 8 The cstruct cunion directives calculate the offsets in the same manner as the C compiler The resulting assembly structure can be used to access the elements of the C structure Compare the difference in the offsets of those structures defined via struct above and the offsets for the C code
242. container The start address specifies the address of the fragment constant The lt size gt specifies the size of the fragment constant Example 8 5 Placement Map for the fl 4 Input File Xplacement map memory area lt name gt PMEM lt name gt lt page_id gt 0x0 lt page_id gt lt origin gt 0x20 lt origin gt lt length gt 0x100000 lt length gt lt used_space gt 0xb240 lt used_space gt lt unused_space gt 0xf4dc0 lt unused_space gt lt attributes gt RWXI lt attributes gt lt usage_details gt lt allocated_space gt lt start_address gt 0x20 lt start_address gt lt size gt 0xb240 lt size gt logical group ref idref lg 7 gt allocated space available space start address 0xb260 start address lt size gt 0xf4dc0 lt size gt lt available_space gt lt usage_details gt lt memory_area gt lt placement_map gt SPNU118J August 2011 XML Link Information File Description Submit Documentation Feedback I I men BADE gt 9115 1 315 I TEXAS INSTRUMENTS Document Elements www ti com B 2 6 Far Call Trampoline List The lt far_call_trampoline_list gt is a list of lt far_call_trampoline gt elements The linker supports the generation of far call trampolines to help a call site reach a destination that is out of range A far call trampoline function is guaranteed to reach the called function callee as it may utilize an indirect call to t
243. ct component The load address The run address The size The linker collects all COPY_RECORDs that are associated with the same copy table into a COPY TABLE object The COPY TABLE object contains the size of a given COPY RECORD the number of COPY RECORDS in the table and the array of COPY RECORDsS in the table For instance in the BINIT example in Section 7 8 6 the first and extra output sections will each have their own COPY RECORD entries in the BINIT copy table The BINIT copy table will then look like this COPY TABLE binit 12 2 load address of first gt run address of first gt size of first gt load address of extra gt lt run address of extra gt lt size of extra gt 7 8 10 General Purpose Copy Routine The cpy_tbl h file in Example 7 20 also contains a prototype for a general purpose copy routine copy in which is provided as part of the run time support library The copy_in routine takes a single argument the address of a linker generated copy table The routine then processes the copy table data object and performs the copy of each object component specified in the copy table The copy_in function definition is provided in the cpy_tbl c run time support source file shown in Example 7 21 Example 7 21 Run Time Support cpy_tbl c File J E E K k k k k ke e e e k e k k e ke e k k k k A k k k k k k k k k k k k k k k k k k k kk k
244. ct files as input cross reference listing An output file created by the assembler that lists the symbols that were defined what line they were defined on which lines referenced them and their final values data section One of the default object file sections The data section is an initialized section that contains initialized data You can use the data directive to assemble code into the data section directives Special purpose commands that control the actions and functions of a software tool as opposed to assembly language instructions which control the actions of a device ELF Executable and linking format a system of object files configured according to the System V Application Binary Interface specification emulator A hardware development system that duplicates the ARM operation entry point A point in target memory where execution starts environment variable A system symbol that you define and assign to a string Environmental variables are often included in Windows batch files or UNIX shell scripts such as cshrc or profile epilog The portion of code in a function that restores the stack and returns executable module 4A linked object file that can be executed in a target system expression A constant a symbol or a series of constants and symbols separated by arithmetic operators external symbol A symbol that is used in the current program module but defined or declared in a differ
245. ction that grows beyond the available space of the memory range in which it is originally allocated Instead of modifying the link command file you can let the linker move the section into one of the other areas 7 5 4 7 Automatic Splitting of Output Sections Among Non Contiguous Memory Ranges 208 The linker can split output sections among multiple memory ranges to achieve an efficient allocation Use the lt lt operator to indicate that an output section can be split if necessary into the specified memory ranges For example MEMORY P_MEM1 origin 0x2000 length 0x1000 P_MEM2 origin 0x4000 length 0x1000 P_MEM3 origin 0x6000 length 0x1000 P_MEM4 origin 0x8000 length 0x1000 SECTIONS text text lt lt P_MEM1 P MEM2 P MEM3 P_MEM4 In this example the gt gt operator indicates that the text output section can be split among any of the listed memory areas If the text section grows beyond the available memory in P_MEM1 it is split on an input section boundary and the remainder of the output section is allocated to P MEM2 P MEM3 P_MEM4 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Command Files The operator is used to specify the list of multiple memory ranges SPNU118J August 2011 Linker Description 209 Submit Documentation Feedback Se oF T www BD EIC conr TI I
246. ction named term_rec contains a termination record for a table in the data section You can force the linker to allocate data and term_rec together Example 7 14 Allocate Sections Together SECTIONS text Normal output section bss Normal output section GROUP 0x00001000 Specify a group of sections data First section in the group af 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 address 0x1000 This means that data is allocated at 0x1000 and term_rec follows it in memory You Cannot Specify Addresses for Sections Within a GROUP NOTE When you use the GROUP option binding alignment or allocation into named memory can be specified for the group only You cannot use binding named memory or alignment for sections within a group 7 5 6 3 Nesting UNIONs and GROUPs The linker allows arbitrary nesting of GROUP and UNION statements with the SECTIONS directive By nesting GROUP and UNION statements you can express hierarchical overlays and groupings of sections Example 7 15 shows how two overlays can be grouped together Example 7 15 Nesting GROUP and UNION Statements SECTIONS GROUP 0x1000 run FAST MEM UNION mysectl load SLOW MEM mysect2 load SLOW MEM UNION mysect3 load SLOW_MEM
247. ctive acts as a ref or a def as needed A global symbol is defined in the same manner as any other symbol that is it appears as a label or is defined by the set equ bss or usect directive As with all symbols if a global symbol is defined more than once the linker issues a multiple definition error The ref directive always creates a symbol table entry for a symbol whether the module uses the symbol or not global however creates an entry only if the module actually uses the symbol A symbol can be declared global for either of two reasons fthe symbol is not defined in the current module which includes 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 definition in other modules If the symbol is defined in the current module the global or def directive declares that the symbol and its definition can be used externally by other modules These types of references are resolved at link time This example shows four files The file1 Ist and file2 Ist refer to each other for all symbols used file3 Ist and file4 Ist are similarly related The file1 Ist and file3 Ist files are equivalent Both files define the symbol INIT and make it available to other modules both files use the external symbols X Y and Z Also file1
248. ctive 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 bytes of fast external memory at address 0x0000 0000 2K bytes of slow external memory at address 0x0000 1000 and 4K bytes of slow external memory at address 0x1000 0000 It also demonstrates the use of memory range expressions as well as start end size address operators see Example 7 4 Example 7 3 The MEMORY Directive ke I ke Ck kk Ck kk ke kk RRR KK Sample command file with MEMORY directive EE K k k k k k k kk k k k k k kk k k k k kk k kk k k k kk k kk k k kkk kkk k k 14 filel obj file2 0bj Input files af output file prog out Options MEMORY FAST MEM RX origin 0x00000000 length 0x00001000 SLOW_MEM RW origin 0x00001000 length 0x00000800 EXT MEM RX origin 0x10000000 length 0x00001000 SPNU118J August 2011 Linker Description 195 Submit Documentation Feedback I I men BADE 0 9115 1 196 1 TEXAS INSTRUMENTS Linker Command Files www ti com The general syntax for the MEMORY directive is MEMORY
249. ctives Reference 1 TEXAS INSTRUMENTS www ti com cstruct cunion endstruct endunion tag Declare C Structure Type Syntax Description Example 90 Assembler Directives stag cstruct cunion expr mem element expr mem element expr mem tag stag expr mem element expr size endstruct endunion label tag stag The cstruct and cunion directives have been added to support ease of sharing of common data structures between assembly and C code The cstruct and cunion directives can be used exactly like the existing struct and union directives except that they are guaranteed to perform data layout matching the layout used by the C compiler for C struct and union data types In particular the cstruct and cunion directives force the same alignment and padding as used by the C compiler when such types are nested within compound data structures The endstruct directive terminates the structure definition The endunion directive terminates the union definition The tag directive gives structure characteristics to a abel simplifying the symbolic representation and providing the ability to define structures that contain other structures The tag directive does not allocate memory The structure tag stag of a tag directive must have been previously defined Following are descriptions of the parameters used with the struct endstruct and tag directives The stagis the structure s tag Its v
250. d the assembler assembles code or data or reserves space into the section with that name You cannot use the same names with different directives That is you cannot create a section with the usect directive and then try to use the same section with sect 2 2 4 Subsections Subsections are smaller sections within larger sections Like sections subsections can be manipulated by the linker Placing each function and object in a uniquely named subsection allows finer grained memory placement and also allows the linker finer grained unused function elimination You can create subsections by using the sect or usect directive The syntaxes for a subsection name are symbol usect section name subsection name size in bytes alignment bank offset sect section name subsection name A subsection is identified by the base section name followed by a colon and the name of the subsection A subsection can be allocated separately or grouped with other sections using the same base name For example you create a subsection called func within the text section Sect text func Using the linker s SECTIONS directive you can allocate text func separately or with all the text sections See Section 7 5 4 1 for an example using subsections You can create two types of subsections _ Initialized subsections are created using the sect directive See Section 2 2 2 Uninitialized subsections are created using the usect dir
251. d A B are supersections of A B C Among a group of supersections of a subsection the nearest supersection is the supersection with the longest name Thus among A A B the nearest supersection of A B C D is A B With multiple levels of subsections the constraints are the following 1 When specifying input sections within a file or library unit the section name selects an input section of the same name and any subsections of that name 2 Input sections that are not explicitly allocated are allocated in an existing output section of the same name or in the nearest existing supersection of such an output section An exception to this rule is that during a partial link specified by the relocatable linker option a subsection is allocated only to an existing output section of the same name 3 If no such output section described in 2 is defined the input section is put in a newly created output section with the same name as the base name of the input section Consider linking input sections with the following names europe north norway europe central france europe south spain europe north sweden europe central germany europe south italy europe north finland europe central denmark europe south malta europe north iceland This SECTIONS specification allocates the input sections as indicated in the comments SECTIONS nordic europe north europe central denmark the nordic countries central europe central fra
252. d column shows the object code that is assembled into these sections the first column shows the source statements that generated the object code Figure 2 3 Object Code Generated by the File in Figure 2 2 Line numbers Object code Section 19 E59F14D2 text 20 E2511001 21 1AFFFFFD 36 E59F3D80 37 E0120293 38 1AFFFFFD 5 00000011 data 5 00000022 5 00000033 14 00000123 26 000000AA 26 000000BB 26 000000CC 43 00000011 vectors 43 00000033 10 No data bss ten bytes reserved 30 No data newvars 31 eight bytes reserved 26 Introduction to Object Modules SPNU 118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com How the Linker Handles Sections 2 3 2 3 1 How the Linker Handles Sections The linker has two main functions related to sections First the linker uses the sections in object files as building blocks it combines input sections when more than one file is being linked to create output sections in an executable output module Second the linker chooses memory addresses for the output sections Two linker directives support these functions The MEMORY directive allows you to define the memory map of a target system You can name portions of memory and specify their starting addresses and their lengths The SECTIONS directive tells the linker how to combine input sections into output sections and where to place these output sections in memory
253. d file you can also specify other options and files on the command line For example you could enter cl470 run linker map file 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 creates an output file called link out and a map file called link map For information on invoking the linker for C C files see Section 7 11 172 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com 7 4 Linker Options Linker options control linking operations They can be placed on the command line or in a command file Linker options must be preceded by a hyphen Options can be separated from arguments if they have them by an optional space Table 7 1 summarizes the linker options Table 7 1 Basic Options Summary Linker Options Option Alias Description Section output_file 0 Names the executable output module The default filename is a out Section 7 4 23 map file m Produces a map or listing of the input and output sections including holes and Section 7 4 18 places the listing in filename heap size heap Sets heap size for the dynamic memory allocation in C to size bytes and Section 7 4 14 defines a global symbol that specifies the heap size Default
254. ddress of the bss output section It marks the beginning of uninitialized data end is assigned the first address following the bss output section It marks the end of uninitialized data The following symbols are defined only for C C support when the ram model or rom model option is used Tl STACK END is assigned the end of the stack size for ELF TI STACK SIZE is assigned the size of the stack section for ELF STACK END is assigned the end of the stack size STACK SIZE is assigned the size of the stack section for COFF Tl SYSMEM SIZE is assigned the size of the sysmem section for ELF 7 5 8 5 Assigning Exact Start End and Size Values of a Section to a Symbol The code generation tools currently support the ability to load program code in one area of slow memory and run it in another faster area This is done by specifying separate load and run addresses for an output section or group in the link command file Then execute a sequence of instructions the copying code in Example 7 10 that moves the program code from its load area to its run area before it is needed There are several responsibilities that a programmer must take on when setting up a system with this feature One of these responsibilities is to determine the size and run time address of the program code to be moved The current mechanisms to do this involve use of the label directives in the copying code A simple example is illustrated Example
255. de_state 16 32 mt code_state 16 or mt instructs the assembler to begin assembling instructions as 16 bit instructions UAL syntax thumb for ARMv7 and non UAL syntax state16 otherwise By default the assembler begins assembling 32 bit instructions You can reset the default behavior by specifying code_state 32 For information on indirect calls in 16 bit versus 32 bit code see the ARM Optimizing C C Compiler Users Guide copy_file filename ahc Copies the specified file for the assembly module The file is inserted before source file statements The copied file appears in the assembly listing files Ccross reference ax Produces a cross reference table and appends it to the end of the listing file it also adds cross reference information to the object file for use by the cross reference utility If you do not request a listing file but use the cross reference option the assembler creates a listing file automatically naming it with the same name as the input file with a lst extension endian me Produces object code in little endian format For more information see the ARM Optimizing C C Compiler Users Guide force_thumb2_mode Alters default assembler behavior By default for C or C code the assembler optimizes true false 32 bit Thumb2 instructions when possible For hand coded assembly code the assembler does not optimize 32 bit Thumb2 instructions include_file filename ahi Includes the specified file fo
256. depending on the size in bytes parameter The size can be any power of 2 although only certain values are useful for alignment An operand of 1 aligns the SPC on the next byte boundary and this is the default if no size in bytes is given The assembler assembles words containing null values 0 up to the next size in bytes boundary 1 aligns SPC to byte boundary 2 aligns SPC to halfword boundary 4 aligns SPC to word boundary 8 aligns SPC to doubleword boundary 128 aligns SPC to page boundary Using the align directive has two effects The assembler aligns the SPC on an x byte 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 memory Example This example shows several types of alignment including align 2 align 8 and a default align 1 00000000 04 byte 4 2 align 2 3 00000002 45 String Errorcnt 00000003 72 00000004 72 00000005 6F 00000006 72 00000007 63 00000008 6E 00000009 74 4 align 5 0000000c 60000000 field 3 3 6 0000000c 6A000000 field 5 4 7 align 2 8 0000000c 6A006000 field 3 3 9 align 8 10 00000010 50000000 field 5 4 11 align 12 00000014 04 byte 4 SPNU118J August 2011 Assembler Directives 77 Submit Documentation Feedback I I men BADE 0 9115 1 Directives Reference asg define eval Syntax Description 78 Assembler Directives 1 TE
257. development path Both the assembler and the linker accept libraries as input Figure 6 1 The Archiver in the ARM Software Development Flow C C source files C C compiler C C name Assembler source ponds Assembler Object Library build Debugging Archiver files process Archiver demangling utility Run time gd li support objec A libra files Linker ry Executable object file Hex conversion utility EPROM Absolutelister Cross reference programmer lister Object file utilities SPNU118J August 2011 Archiver Description 163 Submit Documentation Feedback I I men www BADE vconv I Invoking the Archiver I TEXAS INSTRUMENTS www ti com 6 3 Invoking the Archiver To invoke the archiver enter ar470 command options libname filename filename ar470 command options libname filenames is the command that invokes the archiver tells the archiver how to manipulate the existing library members and any specified A command can be preceded by an optional hyphen You must use one of the following commands when you invoke the archiver but you can use only one command per invocation The archiver commands are as follows uses the contents of the specified file instead of command line entries You can use this command to avoid limitations on command line length imposed by the host operating system Use a at
258. diagnostics errors are still issued Sets the error limit to count The linker abandons linking after this number of errors The default is 100 Section 11 11 Section 11 11 Section 11 11 Section 11 11 Section 11 11 Section 11 11 Section 11 11 Section 11 11 Output Options ascii a Select ASCII Hex Section 11 12 1 intel 4 Select Intel Section 11 12 2 motorola 1 m1 Select Motorola S1 Section 11 12 3 motorola 2 m2 Select Motorola S2 Section 11 12 3 motorola 3 m3 Select Motorola S3 default m option Section 11 12 3 darn E peer E default format when no output option is Seen ee ti_tagged t Select Tl Tagged Section 11 12 5 ti_txt Select TI Txt Section 11 12 6 Load Image Options load image Select load image Section 11 6 section name prefixestring Specify the section name prefix for load image object files Section 11 6 Hex Conversion Utility Description www oF Eeconzy TI SPNU118J August 2011 Submit Documentation Feedback I TEXAS INSTRUMENTS www ti com Invoking the Hex Conversion Utility 11 2 2 Invoking the Hex Conversion Utility With a Command File A command file is useful if you plan to invoke the utility more than once with the same input files and options It is also useful if you want to use the ROMS and SECTIONS hex conversion utility directives to customize the conversion process Command files are ASCII files that contain one or more of the following Options and filena
259. ding abs file 188 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Options 7 4 27 Scan All Libraries for Duplicate Symbol Definitions scan libraries The scan libraries option scans all libraries during a link looking for duplicate symbol definitions to those symbols that are actually included in the link The scan does not consider absolute symbols or symbols defined in COMDAT sections The scan libraries option helps determine those symbols that were actually chosen by the linker over other existing definitions of the same symbol in a library The library scanning feature can be used to check against unintended resolution of a symbol reference to a definition when multiple definitions are available in the libraries 7 4 28 Define Stack Size stack size Option The ARM C C compiler uses an uninitialized section stack to allocate space for the run time stack You can set the size of this section in bytes at link time with the stack size option The syntax for the stack size option is stack_size size The size must be a constant and is in bytes This example defines a 4K byte stack 61470 run linker stack size 0x1000 defines a 4K heap stack section If you specified a different stack size in an input section the input section stack size is ignored Any symbols defined in the input section remain valid only
260. ding so all CRC computations must be done with 64 bit values The algorithm will automatically pad the end of the data with zeros if it does not end on a 64 bit boundary 246 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Partial Incremental Linking 7 10 Partial Incremental Linking An output file that has been linked can be linked again with additional modules This is known as partial linking or incremental linking Partial linking allows you to partition large applications link each part separately and then link all the parts together to create the final executable program Follow these guidelines for producing a file that you will relink The intermediate files produced by the linker must have relocation information Use the relocatable option when you link the file the first time See Section 7 4 2 2 Intermediate files must have symbolic information By default the linker retains symbolic information in its output Do not use the no_sym_table option if you plan to relink a file because no_sym_table strips symbolic information from the output module See Section 7 4 22 Intermediate link operations should be concerned only with the formation of output sections and not with allocation All allocation binding and MEMORY directives should be performed in the final link When the ELF object file format is used input sections
261. directives The sym directive defines a global variable a local variable or a function Several parameters allow you to associate various debugging information with the variable or function The stag etag and utag directives define structures enumerations and unions respectively The member directive specifies a member of a structure enumeration or union The eos directive ends a structure enumeration or union definition The func and endfunc directives specify the beginning and ending lines of a C C function The block and endblock directives specify the bounds of C C blocks The file directive defines a symbol in the symbol table that identifies the current source filename The line directive identifies the line number of a C C source statement 306 Symbolic Debugging Directives SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Debug Directive Syntax A 3 Debug Directive Syntax Table A 1 is an alphabetical listing of the symbolic debugging directives For information on the C C compiler refer to the ARM Optimizing C C Compiler User s Guide Table A 1 Symbolic Debugging Directives Label Directive Arguments block beginning line number dwattr DIE label DIE attribute name DIE attribute value DIE attribute name attribute value dwcfi call frame instruction opcodel operandi operand CIE label
262. dule Normally if an object file that contains a function is specified at link time the file is linked whether the function is used or not however if that same function is placed in an archive library the file is included only if the function is referenced The order in which libraries are specified is important because the linker includes only those members that resolve symbols that are undefined at the time the library is searched The same library can be specified as often as necessary it is searched each time it is included Alternatively you can use the reread_libs option to reread libraries until no more references can be resolved see Section 7 4 16 3 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 several files and libraries using these assumptions e Input files f1 obj and f2 obj both reference an external function named clrscr Input file f1 0bj references the symbol origin Input file f2 0bj references the symbol fillcir Member 0 of library libc lib contains a definition of origin Member 3 of library liba lib contains a definition of fillcir Member 1 of both libraries defines clrscr If you enter c1470 run linker fl obj f2 0bj liba lib libc lib then Member 1 of liba lib satisfies the f1 obj and f2 obj references to c rscr because the libr
263. dwcie version return address register dwendentry dwendtag dwfde CIE label dwpsn filename line number column number DIE label dwtag m tag name DIE attribute name DIE attribute value DIE attribute name attribute value endblock ending line number endfunc ending line number register mask frame size eos etag name size file filename func beginning line number line line number address member name value type storage class size tag dims stag name size sym name value type storage class size tag dims utag name size SPNU118J August 2011 Symbolic Debugging Directives 307 Submit Documentation Feedback I I men BADE 0 9115 1 308 Symbolic Debugging Directives SPNU118J August 2011 T4 E I T Submit Documentation Feedback 1 efas men WWW conr TI 1 Appendix B IJ TEXAS SPNU118J August 2011 INSTRUMENTS XML Link Information File Description The ARM linker supports the generation of an XML link information file via the xml_link_info file option This option causes the linker to generate a well formed XML file containing detailed information about the result of a link The information included in this file includes all of the information that is currently produced in a linker generated map file As the linker evolves the XML link information file may be extended to include additional information that could be useful for static analysis of l
264. e BINIT or binit that you can use to create a boot time copy table For example the link command file for the boot loaded application described in Section 7 8 2 can be rewritten as follows SECTIONS flashcode app tasks obj text load FLASH run PMEM table BINIT For this example the linker creates a copy table that can be accessed through a special linker generated symbol X binit which contains the list of all object components that need to be copied from their load location to their run location at boot time If a link command file does not contain any uses of table BINIT then the binit symbol is given a value of 1 to indicate that a boot time copy table does not exist for a particular application You can apply the table BINIT specification to an output section GROUP or UNION member If used in the context of a UNION only one member of the UNION can be designated with table BINIT If applied to a GROUP then none of that GROUP s members may be marked with table BINIT The linker detects violations of these rules and reports them as warnings ignoring each offending use of the table BINIT specification 7 8 7 Using the table Operator to Manage Object Components If you have several pieces of code that need to be managed together then you can apply the same table operator to several different object components In addition if you want to manage a particular object component in multiple ways you can app
265. e Output files infile out EPROM1 rom4000 b0 rom4000 b1 0x00004000 Ox00004000 org text text 0x0000487F 0x00004880 0x00005B80 oh oh 0x00005B80 0x0000633F daa data 0x00006700 0x00005FFF Width 8 bits 0x00007C7F len 2000h 8K EPROM2 rom6000 b0 rom6000 b1 0x00006000 0x00006340 0x00006700 0x00007C80 0x00007FFF The map file specified with the map option is advantageous when you use the ROMS directive with multiple ranges The map file shows each range its parameters names of associated output files and a list of contents section names and fill values broken down by address Example 11 2 is a segment of the map file resulting from the example in Example 11 1 Example 11 2 Map File Output From Example 11 1 Showing Memory Ranges OUTPUT FILES rom4000 b0 b0 b7 rom4000 b1 b8 b15 CONTENTS 00004000 0000487f text 00004880 00005b7f FILL 00000000 00005580 00005fff data OUTPUT FILES rom6000 b0 50 57 rom6000 b1 b8 b15 CONTENTS 00006000 0000633f data 00006340 000066ff FILL ff00ff00 00006700 00007c7 table 0000780 000078828 FILL 0 EPROM1 defines the address range from 0x00004000 through 0x00005FFF with the following sections 284 Hex Conversion Utility Description SPNU118J August 2011 S oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com The SECTIONS Directive This
266. e text section is the default section Therefore at the beginning of an assembly the assembler assembles code into the text section unless you use a data or sect directive to specify a different section For more information about sections see Chapter 2 This example assembles code into the text and data sections ko ko ko ko T Begin assembling into data section 2 ko ko ko ko ko ck ck 3 data 00000000 4 5 00000000 0A byte OAh OBh 00000001 OB 6 7 Begin assembling into text section 8 ko ko ko ko kc 9 00000000 text 0 00000000 41 START String A YBN CY 00000001 42 00000002 43 1 00000003 58 END string 00000004 59 00000005 5A 2 00000008 E3A01003 MOV R1 END START 3 0000000c E1A01181 MOV Rl Rl LSL 3 4 5 ck ck ko ko ko ko kok ok 6 Resume ass
267. e 5 6 can be used with macros The macro mexit endm and var directives are valid only with macros the remaining directives are general assembly language directives Table 5 2 Creating Macros See Mnemonic and Syntax Description Macro Use Directive endm End macro definition Section 5 2 endm macname macro parameter parameter Define macro by macname Section 5 2 macro mexit Go to endm Section 5 2 Section 5 2 mlib filename Identify library containing macro definitions Section 5 4 mlib Table 5 3 Manipulating Substitution Symbols See Mnemonic and Syntax Description Macro Use Directive asg character string substitution symbol Assign character string to substitution symbol Section 5 3 1 asg eval well defined expression substitution symbol Perform arithmetic on numeric substitution symbols Section 5 3 1 eval Var sym syme SYM Define local macro symbols Section 5 3 6 var Table 5 4 Conditional Assembly See Mnemonic and Syntax Description Macro Use Directive break well defined expression Optional repeatable block assembly Section 5 5 break endif End conditional assembly Section 5 5 endif endloop End repeatable block assembly Section 5 5 endloop else Optional conditional assembly block Section 5 5 else elseif well defined expression Optional conditional assembly block Section 5 5 elseif if well defined expression Begin conditional
268. e C and C conversion elements that you need to be aware of when sharing header files with assembly source 12 2 1 Comments 298 Comments are consumed entirely at the C level and do not appear in the resulting converted assembly file Sharing C C Header Files With Assembly Source SPNU118J August 2011 d oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Notes on C C Conversions 12 2 2 Conditional Compilation if else ifdet etc Conditional compilation is handled entirely at the C level during the conversion step Define any necessary macros either on the command line using the compiler define name value option or within a cdecls block using define The if ifdef etc C C directives are not converted to assembly if else elseif and endif directives 12 2 3 Pragmas Pragmas found in the C C source code cause a warning to be generated as they are not converted They have no other effect on the resulting assembly file See the cdecls topic for the WARN and NOWARN parameter discussion for where these warnings are created 12 2 4 The error and warning Directives These preprocessor directives are handled completely by the compiler during the parsing step of conversion If one of these directives is encountered the appropriate error or warning message is emitted These directives are not converted to emsg or wmsg in the assembly output 12 2 5 Predefined symbol AS
269. e a listing of the absolute addresses of object code See Chapter 8 The cross reference lister uses object files to produce a cross reference listing showing symbols their definition and their references in the linked source files See Chapter 9 The main product of this development process is a module that can be executed in a ARM device You can use one of several debugging tools to refine and correct your code Available products include An instruction accurate and clock accurate software simulator An XDS emulator In addition the following utilities are provided The object file display utility prints the contents of object files executable files and or archive libraries in both human readable and XML formats See Section 10 1 The disassembler writes the disassembled object code from object or executable files See Section 10 2 The name utility prints a list of names defined and referenced in a object or an executable file See Section 10 3 The strip utility removes symbol table and debugging information from object and executable files SPNU118J August 2011 Introduction to the Software Development Tools 17 Submit Documentation Feedback I I men gt 9115 1 I TEXAS INSTRUMENTS Tools Descriptions www ti com See Section 10 4 18 Introduction to the Software Development Tools SPNU 118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI P Chapter 2 IJ TEXAS SPNU118J
270. e contents of the GROUP containing tasks 4 through 7 are also split in load space The linker performs the GROUP split by applying the split operator to each member of the GROUP in order The copy table for the GROUP then contains a COPY RECORD entry for every piece of every member of the GROUP These pieces are copied into the memory overlay when the task47 ctbl is processed by copy in The split operator can be applied to an output section GROUP or the load placement of a UNION or UNION member The linker does not permit a split operator to be applied to the run placement of either a UNION or of a UNION member The linker detects such violations emits a warning and ignores the offending split operator usage Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Linker Generated CRC Tables 7 9 Linker Generated CRC Tables The linker supports an extension to the link command file syntax that enables the verification of code or data by means of a CRC The linker computes a CRC value for the specified region at link time and stores that value in target memory such that it is accessible at boot or run time The application code can then compute the CRC for that region and ensure that the value matches the linker computed value The run time support library does not supply a routine to calculate CRC values at boot or run time 7 9 1 The crc table Operator Fo
271. e current load address of the section Expressions that decrement the symbol are illegal For example it is invalid to use the operator in an assignment to the symbol The most common operators used in assignments to the symbol are and align If an output section contains all input sections of a certain type such as text you can use the following statements to create a hole at the beginning or end of the output section text 0x0100 Hole at the beginning data data 0x0100 Hole at the end Another way to create a hole in an output section is to combine an uninitialized section with an initialized section to form a single output section n this case the linker treats the uninitialized section as a hole and supplies data for it The following example illustrates this method SECTIONS outsect filel obj text filel obj bss This becomes a hole Because the text section has raw data all of outsect must also contain raw data 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 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Linker Command Files 7 5 9 3 Filling Holes When
272. e defined in two ways n where n is a decimal digit in the range 0 9 For example 4 and 1 are valid local labels See Example 3 1 name where name is any legal symbol name as described above The assembler replaces the question mark with a period followed by a unique number When the source code is expanded you will not see the unique number in the listing file Your label appears with the question mark as it did in the source definition You cannot declare this label as global Normal labels must be unique they can be declared only once and they can be used as constants in the operand field Local labels however can be undefined and defined again Local labels cannot be defined by directives A local label can be undefined or reset in one of these ways Byusing the newblock directive Assembler Description SPNU118J August 2011 BADE T Submit Documentation Feedback men www BDF TI 1 TEXAS INSTRUMENTS www ti com Symbols e By changing sections using a sect text or data directive Bychanging the state of generated code using the state16 or state32 directives Byentering an include file specified by the include or copy directive e By leaving an include file specified by the include or copy directive Example 3 1 Local Labels of the Form n This is an example of code that declares and uses a local label legally Labell CMP rl 0 Compare rl to zero BCS 1 If c
273. e linker provides a simple way to accomplish this You can use the SECTIONS directive to direct the linker to allocate a section twice once to set its load address and again to set its run address For example fir load SLOW MEM run FAST MEM Use the oad keyword for the load address and the run keyword for the run address See Section 2 5 for an overview on run time relocation 7 5 5 1 Specifying Load and Run Addresses The load address determines where a loader places the raw data for the section Any references to the section such as labels in it refer to its run address The application 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 loads and runs at the same address If you provide both allocations the section is allocated as if it were two sections of the same size This means that both allocations occupy space in the memory map and cannot overlay each other or other sections The UNION directive provides a way to overlay sections see Section 7 5 6 1 If either the load or run address has additional parameters such as alignment or blocking list them after the appropriate keyword Everything related to allocation after the keyword oad affects the load address until the keyword run is seen after which everything affects the run
274. e obj cos obj flt obj The archiver responds as follows new archive function lib building new archive function lib You can print a table of contents of function lib with the t command enter ar470 t function The archiver responds as follows FILE NAME SIZE DATE sine obj 300 Wed Jun 14 10 00 24 2006 cos obj 300 Wed Jun 14 10 00 30 2006 flt obj 300 Wed Jun 14 09 59 56 2006 If you want to add new members to the library enter ar470 as function atan obj The archiver responds as follows symbol defined sin lt symbol defined sin symbol defined cos gt symbol defined cos symbol defined tan gt symbol defined Stan gt symbol defined _atan gt symbol defined Satan gt building archive function lib Because this example does not specify an extension for the libname the archiver adds the files to the library called function lib If function lib does not exist the archiver creates it The s option tells the archiver to list the global symbols that are defined in the library If you want to modify a library member you can extract it edit it and replace it In this example assume there is a library named macros lib that contains the members push asm pop asm and swap asm ar470 x macros push asm The archiver makes a copy of push asm and places it in the current directory it does not remove push asm from the library Now you can edit
275. e performs arithmetic on substitution symbols which are stored in the substitution symbol table This directive evaluates the well defined expression and assigns the string value of the result to the substitution symbol The eval directive is especially useful as a counter in loop endloop blocks The well defined expression is an alphanumeric expression in which all symbols have been previously defined in the current source module so that the result is an absolute The substitution symbol must be a valid symbol name The substitution symbol is up to 128 characters long and must begin with a letter Remaining characters of the symbol can be a combination of alphanumeric characters the underscore and the dollar sign See the unasg undefine topic for information on turning off a substitution symbol SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Directives Reference Example This example shows how asg and eval can be used 1 Sslist show expanded sub symbols 2 using asg and eval 3 4 asg R13 STACKPTR 5 asg amp AND 6 7 00000000 E28DD018 ADD STACKPTR STACKPTR 4280 AND 255 d ADD R13 R13 280 amp 255 8 00000004 E28DD018 ADD STACKPTR STACKPTR 280 amp 255 d ADD R13 R13 280 amp 255 9 10 asg 0 x 11 loop 5 12 eval 1 x 13 word x 14 endloop eval x41 x eval 0 1 x 000
276. e section in the address specified by 3 The zero option When you use the zero option the utility resets the address origin to 0 for each output file Since each file starts at 0 and counts upward any address records represent offsets from the beginning of the file the address within the ROM rather than actual target 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 4 The byte option Some EPROM programmers 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 Oh 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 Oh the first line contains eight words and you use the byte option the second line would start at address 16 010h The data in both examples are the same byte affects only the calculation of the output file address field not the actual target processor address of the converted data The byte option causes the address records in an output file to refer to byte locations within the file whether the target processor is byte addressable or not S
277. e utility does not convert that section and issues no messages or warnings Thus you can exclude sections without listing them by name with the SECTIONS directive However if a section falls partially in a range and partially in unconfigured memory the utility issues a warning and converts only the part within the range Use image mode When you use the image option you must use a ROMS directive Each range is filled completely so that each output file in a range contains data for the whole range Holes before between or after sections are filled with the fill value from the ROMS directive with the value specified with the fill option or with the default value of 0 11 4 2 An Example of the ROMS Directive The ROMS directive in Example 11 1 shows how 16K bytes of 16 bit memory could be partitioned for two 8K byte 8 bit EPROMs Figure 11 5 illustrates the input and output files Example 11 1 A ROMS Directive Example 8 ROMS infile out memwidth 16 EPROM1 org 0x00004000 len 0x2000 romwidth 8 files rom4000 b0 rom4000 b1 EPROM2 org 0x00006000 len 0x2000 romwidth 8 fill 07 files rom6000 b0 rom6000 b1 SPNU118J August 2011 Hex Conversion Utility Description 283 Submit Documentation Feedback I I men re gt 1 I TEXAS INSTRUMENTS The ROMS Directive www ti com Figure 11 5 The infile out File Partitioned Into Four Output Files COFF fil
278. eadability text load SLOW MEM align 16 You can also use an input section specification to identify the sections from input files that are combined to form an output section See Section 7 5 4 3 7 5 4 2 1 Binding You can supply a specific starting address for an output section by following the section name with an address text 0x00001000 This example specifies that the text section must begin at location 0x1000 The binding address must be a 32 bit constant Output sections can be bound anywhere in configured memory assuming there is enough space but they cannot overlap If there is not enough space to bind a section to a specified address the linker issues an error message Binding is Incompatible With Alignment and Named Memory NOTE You cannot bind a section to an address if you use alignment or named memory If you try to do this the linker issues an error message 7 5 4 2 Named Memory 200 You can allocate a section into a memory range that is defined by the MEMORY directive see Section 7 5 3 This example names ranges and links sections into them MEMORY SLOW MEM RIX origin 0x00000000 length 0x00001000 FAST MEM RWIX origin 0x03000000 length 0 SECTIONS text 5 lt SLOW MEM data FAST MEM ALIGN 128 bss g gt FAST_MEM Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linke
279. ecedence E F ALALB 1 is equivalent to em A B is equivalentto A A B TS A B is equivalentto A A B lt Less than or equal to 5 Greater than or equal to A B is equivalentto A A B SPNU118J August 2011 Linker Description 219 Submit Documentation Feedback I I men YP 0 9115 1 I TEXAS INSTRUMENTS Linker Command Files www ti com 7 5 8 4 Symbols Defined by the Linker The linker automatically defines several symbols based on which sections are used in your assembly source A program can use these symbols at run time to determine where a section is linked Since these symbols are external they appear in the linker map Each symbol can be accessed in any assembly language module if it is declared with a global directive see Identify Global Symbols You must have used the corresponding section in a source module for the symbol to be created Values are assigned to these symbols as follows text is assigned the first address of the text output section It marks the beginning of executable code etext 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 a
280. ecifying a page width the output listing width defaults to 132 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 truncated in the listing The assembler does not list the width and length directives Example The following example shows how to change the page length and width ER Page length 65 lines ER XM Page width 85 characters length 65 width 85 xo Page length 55 lines e o Page width 100 characters e length 55 width 100 112 Assembler Directives SPNU118J August 2011 oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com list nolist Syntax Description Example SPNU118J August 2011 Di
281. ecord begins with a colon and is followed by the byte count the address of the first data byte the record type 00 and the checksum The address is the least significant 16 bits of a 32 bit address this value is concatenated with the value from the most recent 04 extended linear address record to create a full 32 bit address The checksum is the 2s complement in binary form of the preceding 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 Oh the record type 04 the most significant 16 bits of the address and the checksum The subsequent address fields in the data records contain the least significant bytes of the address Figure 11 7 illustrates the Intel hexadecimal object format Figure 11 7 Intel Hexadecimal Object Format Start character Address Extended linear address record Most significant 16 bits d 2000000000000100020003000400050006000700080009000A000B000C000D000E000F0068 2000200010001100120013001400150016001700180019001A001BO001CO01D001EO001FO0048 Data 2000400000000100020003000400050006000700080009000A000B8000C000D000E000F0028 records 2000600010
282. ections of code according to a true or false evaluation of an expression Two sets of directives allow you to assemble conditional blocks of code The if elseif else endif directives tell the assembler to conditionally assemble a block of code according to the evaluation of an expression if well defined expression marks the beginning of a conditional block and assembles code if the if well defined expression is true elseif well defined expression marks a block of code to be assembled if the if well defined expression is false and the elseif condition is true else marks a block of code to be assembled if the if well defined expression is false and any elseif conditions are false endif marks the end of a conditional block and terminates 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 well defined expression marks the beginning of a repeatable block of code The optional expression evaluates to the loop count break well defined expression tells the assembler to assemble repeatedly when the break well defined expression is false and to go to the code immediately after endloop when the expression is true or omitted endloop marks the end of a repeatable block The assembler supports several relational operators that are useful for conditional expressions For more information about relational operato
283. ective See Section 2 2 1 Subsections are allocated in the same manner as sections See Section 7 5 4 for information on the SECTIONS directive SPNU118J August 2011 Introduction to Object Modules 23 Submit Documentation Feedback I I men YP gt 1 1 TEXAS INSTRUMENTS How the Assembler Handles Sections www ti com 2 2 5 Section Program Counters The assembler maintains a separate program counter for each section These program counters are known as section program counters or SPCs An SPC represents the current address within a section of code or data Initially the assembler sets each SPC to 0 As the assembler fills a section with code or data it increments the appropriate SPC If you resume assembling into a section the assembler remembers the appropriate SPC s previous value and continues incrementing the SPC from that value The assembler treats each section as if it began at address 0 the linker relocates each section according to its final location in the memory map See Section 2 4 for information on relocation 2 2 6 Using Sections Directives 24 Introduction to Object Modules Figure 2 2 shows how you can build sections incrementally using the sections directives to swap back and forth between the different sections You can use sections directives to begin assembling into a section for the first time or to continue assembling into a section that already contains code In the latter case the as
284. ed char crp load addr unsigned char rn addr unsigned char crp run addr if crp size y Copy record has a non zero size so the data is not compressed f Just copy the data SPNU118J August 2011 Linker Description 237 Submit Documentation Feedback S oF T www BD EIC conr TI I TEXAS INSTRUMENTS Linker Generated Copy Tables www ti com Example 7 21 Run Time Support cpy_tbl c File continued memcpy rn addr ld addr crp size 7 8 11 Linker Generated Copy Table Sections and Symbols The linker creates and allocates a separate input section for each copy table that it generates Each copy table symbol is defined with the address value of the input section that contains the corresponding copy table The linker generates a unique name for each overlay copy table input section For example table first ctbl would place the copy table for the first section into an input section called ovly first ctbl The linker creates a single input section binit to contain the entire boot time copy table Example 7 22 illustrates how you can control the placement of the linker generated copy table sections using the input section names in the link command file Example 7 22 Controlling the Placement of the Linker Generated Copy Table Sections SECTIONS UNION first al obj text bl obj text cl obj text load EMEM run PMEM table BINIT tab
285. embling into data section 7 8 00000002 data 9 00000002 0C byte OCh 0Dh 00000003 0D 20 21 Resume assembling into text section 22 23 00000010 text 24 00000010 51 string QUIT 00000011 55 00000012 49 00000013 54 SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com thumb Syntax Description Example SPNU118J August 2011 Submit Documentation Feedback Directives Reference Assemble Thumb or Thumb 2 Instructions UAL Syntax thumb You can use the thumb directive to tell the assembler to begin assembling all instructions after the thumb directive using Thumb 32 bit or Thumb 2 16 bit or 32 bit UAL syntax The assembler determines whether instructions are 16 or 32 bit instructions based on the syntax structure of the code The thumb directive performs an implicit halfword alignment before any instructions are written to the section to ensure t
286. emonic operand list and comment The general syntax for source statements is as follows abel mnemonic operand list comment Following are examples of source statements SYM1 Set 2 Symbol SYM1 2 Begin MOV RO 4SYMI Load RO with 2 word 016h Initialize word 016 The ARM assembler reads up to 200 characters per line Any characters beyond 200 are truncated Keep the operational part of your source statements that is everything other than comments less than 200 characters in length for correct assembly Your comments can extend beyond the 200 character limit but the truncated portion is not included in the listing file Follow these guidelines All statements must begin with a label a blank an asterisk or a semicolon Labels are optional if used they must begin in column 1 One or more blanks must separate each field Tab and space characters are blanks You must separate the operand list from the preceding field with a blank Comments are optional Comments that begin in column 1 can begin with an asterisk or a semicolon or but comments that begin in any other column must begin with a semicolon Amnemonic cannot begin in column 1 or it will be interpreted as a label The following sections describe each of the fields Label Field Labels are optional for all assembly language instructions and for most but not all assembler directives When used a label must begin i
287. emory at various stages of execution Or you may want several data objects that are not active at the same time to share a block of memory The UNION statement within the SECTIONS directive provides a way to allocate several sections at the same run time address In Example 7 12 the bss sections from file1 obj and file2 obj are allocated at the same address in FAST MEM 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 12 The UNION Statement SECTIONS text load UNION run 1 SLOW MEM FAST MEM bss partl filel obj bss bss part2 file2 0bj bss bss part3 run FAST MEM globals obj bss Allocation of a section as part of a union affects only its run address Under no circumstances can sections be overlaid for loading If an initialized section is a union member an initialized section such as text has raw data its load allocation must be separately specified See Example 7 13 SPNU118J August 2011 Linker Description 213 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Linker Command Files www ti com Example 7 13 Separate Load Addresses for UNION Sections UNION run FAST_MEM text partl load SLOW MEM filel obj text text part2 load SLOW MEM file2 obj text Figure 7 4 Memory Allo
288. endunion real len 2 7 138 Assembler Directives SPNU 118J August 2011 BADE T Submit Documentation Feedback men www BD FKconr TI 1 TEXAS INSTRUMENTS www ti com usect Syntax Description Example SPNU118J August 2011 Directives Reference Reserve Uninitialized Space symbol usect section name size in bytes alignment bank offset The usect directive reserves space for variables in an uninitialized named section This directive is similar to the bss directive both simply reserve space for data and that space has no contents However usect defines additional sections that can be placed anywhere in memory independently of the bss section The symbol points to the first location reserved by this invocation of the usect directive The symbol corresponds to the name of the variable for which you are reserving space The section name must be enclosed in double quotes This parameter names the uninitialized section A section name can contain a subsection name in the form section name subsection name The size in bytes is an expression that defines the number of bytes that are reserved in section name The alignment is an optional parameter that ensures that the space allocated to the symbol occurs on the specified boundary The boundary indicates the size of the slot in bytes and can be set to any power of 2 The bank offset is an optional parameter that ensures that the space al
289. enerated for the containing assembly file This is the opposite of the NOLIST option NOWARN Do not emit warnings STDERR about C C constructs that cannot be converted while parsing the cdecls source block default WARN Generate warnings on STDERR about C C constructs that cannot be converted while parsing the cdecls source block This is the opposite of the NOWARN option In the single line format the options are followed by one or more filenames to include The filenames and options are separated by commas Each file listed acts as if include filename was specified in the multiple line format In the multiple line format the line following cdecls must contain the opening cdecls block indicator Everything after the up to the closing block indicator 96 is treated as C C source and processed Ordinary assembler processing then resumes on the line following the closing 96 The text within and is passed to the C C compiler to be converted into assembly language Much of C language syntax including function and variable definitions as well as function like macros is not supported and is ignored during the conversion However all of what traditionally appears in C header files is supported including function and variable prototypes structure and union declarations non function like macros enumerations and define s Assembler Directives 83 Submit Documentation Feedback I I men e gt
290. ent Elements B 2 2 Input File List The next section of the XML link information file is the input file list which is delimited with a lt input_file_list gt container element The lt input_file_list gt can contain any number of lt input_file gt elements Each lt input_file gt instance specifies the input file involved in the link Each lt input_file gt has an id attribute that can be referenced by other elements such as an lt object_component gt An lt input_file gt is a container element enclosing the following elements The path element names a directory path if applicable string The kind element specifies a file type either archive or object string The file element specifies an archive name or filename string The name element specifies an object file name or archive member name string Example B 2 Input File List for the hi out Output File input file list input file id fl 1 lt kind gt object lt kind gt lt file gt hi obj lt file gt lt name gt hi obj lt name gt lt input_file gt input file id fl 2 path tools lib path lt kind gt archive lt kind gt lt file gt rtsxxx lib lt file gt lt name gt boot obj lt name gt lt input_file gt input file id fl 3 path tools lib path lt kind gt archive lt kind gt lt file gt rtsxxx lib lt file gt lt name gt exit obj lt name gt lt input_file gt input file id
291. ent program module field For the ARM a software configurable data type whose length can be programmed to be any value in the range of 1 32 bits global symbol A symbol that is either defined in the current module and accessed in another or accessed in the current module but defined in another GROUP An option of the SECTIONS directive that forces specified output sections to be allocated contiguously as a group hex conversion utility A utility that converts object files into one of several standard ASCII hexadecimal formats suitable for loading into an EPROM programmer high level language debugging The ability of a compiler to retain symbolic and high level language information such as type and function definitions so that a debugging tool can use this information Glossary SPNU 118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Appendix D hole An area between the input sections that compose an output section that contains no code incremental linking Linking files in several passes Incremental linking is useful for large applications because you can partition the application link the parts separately and then link all of the parts together initialization at load time An autoinitialization method used by the linker when linking C C code The linker uses this method when you invoke it with the ram model link option This method initiali
292. entation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Directives Reference 31 32 0000000c 00004321 field 04321h 32 Figure 4 6 The field Directive Word Code 0 field OABCh 14 31 30 29 28 27 26 25 24 23 22 21 20 19 18 0 00101010111100 14 bit field 0 field 00Ah 5 31 18 17 16 15 14 13 0 0 0 1 0 1 0 1 0 1 1 1 1 0 0 0 1 0 10 iy 5 bit field align 4 1 field 00Ch 5 31 30 29 28 0 1100 YY 4 bit field 2 field x 31 0 00000000000000000000000000000010 3 field 04321 32 31 0 00000000000000000000100001100001 SPNU118J August 2011 Assembler Directives 101 Submit Documentation Feedback Se oF T www BD FEe cenr TI 1 TEXAS INSTRUMENTS Directives Reference www ti com float Initialize Single Precision Floating Point Value Syntax float value value Description The float directive places the IEEE single precision floating point representation of a single floating point constant into a word in the current section The value must be a floating point constant or a symbol that has been equated to a floating point constant Each constant is converted to a floating point value in IEEE single precision 32 bit format The 32 bit value is stored exponent byte first most significant byte of fraction second and least significant byte of fraction third i
293. ents are comments that appear in the definition of the macro but do not show up in the expansion of the macro An exclamation point in column 1 identifies a macro comment If you want your comments to appear in the macro expansion precede your comment with an asterisk or semicolon Example 5 14 shows user messages in macros and macro comments that do not appear in the macro expansion For more information about the emsg mmsg and wmsg assembler directives see Define Messages Example 5 14 Producing Messages in a Macro USER ERROR ERROR Missing Parameter 1 Error No Warnings MUL I macro x y if symlen x 0 emsg ERROR Missing Parameter mexit elseif Ssymlen y 0 emsg ERROR Missing Parameter mexit else MOV R1 x MOV R2 y MUL RO R1 R2 endif endm 03900 1 00 P 4 00000000 MUL I 50 1 if symlen x 0 emsg ERROR Missing Parameter mexit elseif symlen y 0 emsg ERROR Missing Parameter mexit else 00000000 E3A01032 MOV R1 50 00000004 3 MOV R2 1 00000008 E0000291 MUL 30 R1 R2 endif 16 17 0000000c MUL I if symlen x 0 emsg ERROR Missing Parameter mexit 156 Macro Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Using Directives to Format the O
294. epeatedly A struct definition can contain a union definition and structs and unions can be nested The endunion directive terminates the union definition The tag directive gives structure or union characteristics to a abel simplifying the symbolic representation and providing the ability to define structures or unions that contain other structures or unions The tag directive does not allocate memory The structure or union tag of a tag directive must have been previously defined Following are descriptions of the parameters used with the struct endstruct and tag directives The utag is the union s tag is the union s tag Its value is associated with the beginning of the union If no utag is present the assembler puts the union members in the global symbol table with the value of their absolute offset from the top of the union In this case each member must have a unique name The expris an optional expression indicating the beginning offset of the union Unions default to start at 0 This parameter can only be used with a top level union It cannot be used when defining a nested union The mem is an optional label for a member of the union This label is absolute and equates to the present offset from the beginning of the union A label for a union member cannot be declared global The element is one of the following descriptors byte char int long word double half short string float a
295. erence the address of any copy table generated by the linker in C C or assembly source code passing that value to a general purpose copy routine which will process the copy table and affect the actual copy 7 8 5 The table Operator You can use the table operator to instruct the linker to produce a copy table A table operator can be applied to an output section a GROUP or a UNION member The copy table generated for a particular table specification can be accessed through a symbol specified by you that is provided as an argument to the table operator The linker creates a symbol with this name and assigns it the address of the copy table as the value of the symbol The copy table can then be accessed from the application using the linker generated symbol Each table specification you apply to members of a given UNION must contain a unique name If a table operator is applied to a GROUP then none of that GROUP s members may be marked with a table specification The linker detects violations of these rules and reports them as warnings ignoring each offending use of the table specification The linker does not generate a copy table for erroneous table operator specifications SPNU 118J August 2011 Linker Description 231 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Linker Generated Copy Tables www ti com 7 8 6 Boot Time Copy Tables The linker supports a special copy table nam
296. es in the current section a label points to the end bes topic of the reserved space space size Reserves size bytes in the current section a label points to the Space topic beginning of the reserved space Table 4 4 Directives That Change the Instruction Type Mnemonic and Syntax Description See arm Begins assembling ARM UAL instructions Equivalent to state32 arm topic state16 Begins assembling non UAL 16 bit instructions State16 topic State32 Begins assembling 32 bit instructions default State32 topic thumb Begins assembling Thumb or Thumb 2 UAL instructions thumb topic Table 4 5 Directives That Format the Output Listing Mnemonic and Syntax Description See drlist Enables listing of all directive lines default drlist topic drnolist Suppresses listing of certain directive lines drnolist topic fclist Allows false conditional code block listing default fclist topic fcnolist Suppresses false conditional code block listing fenolist topic length page length Sets the page length of the source listing length topic list Restarts the source listing list topic mlist Allows macro listings and loop blocks default mlist topic mnolist Suppresses macro listings and loop blocks mnolist topic nolist Stops the source listing nolist topic option option options Selects output listing options available options are A B H M N option topic O R T W and X page Ejects a page in the source listing page topic SSli
297. es the define for FOO When one command file includes another preprocessing context is carried from parent to child in the usual way that is macros defined in the parent are visible in the child However when a command file is invoked other than through include either on the command line or by the typical way of being named in another command file preprocessing context is not carried into the nested file The exception to this is define and undefine options which apply globally from the point they are encountered For example define GLOBAL define LOCAL include incfile cmd sees GLOBAL and LOCAL nestfile cmd only sees GLOBAL Two cautions apply to the use of define and undefine in command files First they have global effect as mentioned above Second since they are not actually preprocessing directives themselves they are subject to macro substitution probably with unintended consequences This effect can be defeated by quoting the symbol name For example define MYSYM 123 undefine MYSYM expands to undefine 123 undefine MYSYM ahh that s better The linker uses the same search paths to find include files as it does to find libraries That is include files are searched in the following places 1 If the include file name is in quotes rather than lt brackets gt in the directory of the current file 2 In the list of directories specified with library options or environme
298. es the strip utility input filename is an object file obj or an executable file out options identifies the strip utility options you want to use Options are not case sensitive and can appear anywhere on the command line following the invocation Precede each option with a hyphen The strip utility option is as follows 0 filename writes the stripped output to filename p removes all information not required for execution This option causes more information to be removed than the default behavior but the object file is left in a state that cannot be linked This option should be used only with executable out files When the strip utility is invoked without the o option the input object files are replaced with the stripped version 272 Object File Utilities SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI The ARM assembler and linker create object files which are in binary formats that encourage modular programming and provide powerful and flexible methods for managing code segments and target system memory Most EPROM programmers do not accept object files as input The hex conversion utility converts an object file into one of several standard ASCII hexadecimal formats suitable for loading into an EPROM programmer The utility is also useful in other applications requiring hexadecimal conversion of an object TEXAS INSTRUMENTS Chapter 11 Hex Conversion Utility Description
299. es with statements different from or beyond the parameters stated by TI for that product or service voids all express and any implied warranties for the associated TI product or service and is an unfair and deceptive business practice TI is not responsible or liable for any such statements TI products are not authorized for use in safety critical applications such as life support where a failure of the TI product would reasonably be expected to cause severe personal injury or death unless officers of the parties have executed an agreement specifically governing such use Buyers represent that they have all necessary expertise in the safety and regulatory ramifications of their applications and acknowledge and agree that they are solely responsible for all legal regulatory and safety related requirements concerning their products and any use of TI products in such safety critical applications notwithstanding any applications related information or support that may be provided by TI Further Buyers must fully indemnify TI and its representatives against any damages arising out of the use of TI products in such safety critical applications TI products are neither designed nor intended for use in military aerospace applications or environments unless the TI products are specifically designated by TI as military grade or enhanced plastic Only products designated by TI as military grade meet military specifications Buyers acknowledge and agree that a
300. ess discretionary diagnostics Categorizes the diagnostic identified by id as a warning To determine the numeric identifier of a diagnostic message use the display error number option first in a separate link Then use diag_warning id to recategorize the diagnostic as a warning You can only alter the severity of discretionary diagnostics Displays a diagnostic s numeric identifier along with its text Use this option in determining which arguments you need to supply to the diagnostic suppression options diag suppress diag error diag remark and diag warning This option also indicates whether a diagnostic is discretionary A discretionary diagnostic is one whose severity can be overridden A discretionary diagnostic includes the suffix D otherwise no suffix is present See the ARM Optimizing C C Compiler Users Guide for more information on understanding diagnostic messages Issues remarks nonserious warnings which are suppressed by default Suppresses warning diagnostics errors are still issued Sets the error limit to count which can be any decimal value The linker abandons linking after this number of errors The default is 100 Provides verbose diagnostics that display the original source with line wrap and indicate the position of the error in the source line SPNU118J August 2011 BYE T Submit Documentation Feedback men www BDF TI I TEXAS INSTRUMENTS www ti com Description of
301. essions and Address Operators Memory range origin and length can now use expressions of integer constants with below operators Binary operators gt gt gt gt gt lt gt gt 8 868 Unary operators Expressions are evaluated using standard C operator precedence rules No checking is done for overflow or underflow however expressions are evaluated using a larger integer type Preprocess directive define constants can be used in place of integer constants Global symbols cannot be used in Memory Directive expressions Three new address operators have been added for referencing memory range properties from prior memory range entries START MR Returns start address for previously defined memory range MR SIZE MR Returns size of previously defined memory range MR END MR Returns end address for previously defined memory range MR Example 7 4 Origin and Length as Expressions EE K k k k k k k k k k k k k k k k k kk k kk k k k k kk k kkk k kkk k Sample command file with MEMORY directive EE K k k k k k k ee k k k k k k k k k k k k k k kk k kk k k k filel obj file2 0bj Input files 5 output file prog out ex Options define ORIGIN 0x00000000 define BUFFER 0x00000200 define CACHE 0x0001000 MEMORY FAST_MEM RX origin ORIGIN
302. est out array a dflag a offst a Wed Nov 13 17 07 42 xxxx Page 1 RTYP AsmVal LnkVal DefLn RefLn RefLn RefLn EDEF 00000001 00001001 3 A 5 RTYP AsmVal LnkVal DefLn RefLn RefLn RefLn STAT 00000004 00000004 5 9 RTYP AsmVal LnkVal DefLn RefLn RefLn RefLn EDEF 00000000 00001000 2 3A 4 RTYP AsmVal LnkVal DefLn RefLn RefLn RefLn STAT 00000000 00000000 4 11 RTYP AsmVal LnkVal DefLn RefLn RefLn RefLn EREF 00000000 00001068 2A 6 EDEF 00000000 00001068 2 2A 3 RTYP AsmVal LnkVal DefLn RefLn RefLn RefLn STAT 00000008 00000008 6 10 STAT 00000000 00000020 3 6 The terms defined below appear in the preceding cross reference listing Symbol Filename RTYP AsmVal LnkVal DefLn RefLn 264 Cross Reference Lister Description Name of the symbol listed Name of the file where the symbol appears The symbol s reference type in this file The possible reference types are STAT The symbol is defined in this file and is not declared as global EDEF The symbol is defined in this file and is declared as global EREF The symbol is not defined in this file but is referenced as global UNDF The symbol is not defined in this file and is not declared as global This hexadecimal number is the value assigned to the symbol at assembly time A value may also be preceded by a character that describes the symbol s attributes Table 9 1 lists these characters and names This hexadecimal number is the value assigned
303. estrictive than Pattern B if Pattern A matches a narrower set than Pattern B ltis an error if a symbol matches patterns from localize and globalize and if one does not supersede other Pattern A supersedes pattern B if A can match everything B can and some more If Pattern A supersedes Pattern B then Pattern B is said to more restrictive than Pattern A These options affect final and partial linking In map files these symbols are listed under the Localized Symbols heading 7 4 17 1 Make AII Global Symbols Static make static Option 184 The make static option makes all global symbols static Static symbols are not visible to externally linked modules By making global symbols static global symbols are essentially hidden This allows external symbols with the same name in different files to be treated as unique The make static option effectively nullifies all global assembler directives All symbols become local to the module in which they are defined so no external references are possible For example assume file1 obj and file2 obj both define global symbols called EXT By using the make static option you can link these files without conflict The symbol EXT defined in file1 obj is treated separately from the symbol EXT defined in file2 obj 01470 run linker make static filel obj file2 0bj Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INS
304. et to 16 Intel format must be used The EPROM programmer does not require a ROM image so the addresses in the input hex output file do not need to be contiguous Because memwidth and romwidth have the same value only one output file is generated the number of output files is determined by the ratio of memwidth to romwidth The output file is named with the o option A ROMS directive is used in this scenario since the paddr option is used to relocate both secA and secB SPNU118J August 2011 Hex Conversion Utility Examples 325 Submit Documentation Feedback I I men BADE 4 9115 1 I TEXAS INSTRUMENTS Scenario 2 Building a Hex Conversion Command File for 16 BIS Code www ti com The hex conversion command file for Scenario 2 is shown in Example C 5 This command file uses the following options to select the requirements of the system Option Description i Create Intel format map example2 mxp Generate example2 mxp as the map file of the conversion 0 example2 hex Name example2 hex as the output file memwidth 8 Set EPROM system memory width to 8 romwidth 8 Set physical ROM width to 8 Example C 5 Hex Conversion Command File for Scenario 2 Hex Conversion Command file for Scenario 2 a out linked object file input I Intel format The following two options are optional map example2 mxp Generate a map of the conversion o example2 hex Resulting Hex Output
305. eturns 0 Returns an integer ldexp expr expr2 Multiplies expr by an integer power of 2 That is expr1 x 2 log expr Returns the natural logarithm of expr where expr gt 0 log10 expr Returns the base 10 logarithm of expr where expr gt 0 max expr1 expr2 min expr1 expr2 pow expr1 expr2 Returns the maximum of two values Returns the minimum of two values Returns expr raised to the power of expr2 round expr Returns expr rounded to the nearest integer sgn expr Returns the sign of expr sin expr Returns the sine of expr sinh expr Returns the hyperbolic sine of expr as a floating point value sqrt expr Returns the square root of expr expr20 as a floating point value tan expr Returns the tangent of expr as a floating point value tanh expr Returns the hyperbolic tangent of expr as a floating point value trunc expr Returns expr rounded toward 0 SPNU118J August 2011 Submit Documentation Feedback Assembler Description 53 wwewlAd9 E Eeconzy TI I TEXAS INSTRUMENTS Unified Assembly Language Syntax Support www ti com 3 11 Unified Assembly Language Syntax Support 54 Unified assembly language UAL is the new assembly syntax introduced by ARM Ltd to handle the ambiguities introduced by the original Thumb 2 assembly syntax and provide similar syntax for ARM Thumb and Thumb 2 UAL is backwards compatible with old ARM assembly but incompatible with the previous Thumb assembly syntax UAL s
306. ex conversion utility enter hex470 options filename SPNU118J August 2011 Submit Documentation Feedback hex470 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 command file Table 11 1 lists the basic options All options are preceded by a hyphen and are not case sensitive Several options have an additional parameter that must be separated from the option by at least one space Options with multi character names must be spelled exactly as shown in this document no abbreviations are allowed Options are not affected by the order in which they are used The exception to this rule is the quiet option which must be used before any other options filename names an object file or a command file for more information see Section 11 2 2 Table 11 1 Basic Hex Conversion Utility Options Option Alias Description See General Options E Number output locations by bytes rather than by target byte byte addressing exclude fname sname If the filename fname is omitted all sections matching sname exclude sname will be excluded Saction 11 7 fill value fill Fill holes with value Section 11 9 2 Display the syntax for invoking the utility and list available help options h options If the option is followed by another option or phrase Section 11 2 2 detailed informat
307. f 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 Figure 3 2 shows an assembler listing with each of the four fields identified SPNU 118J August 2011 Assembler Description 55 Submit Documentation Feedback I I men BADE 0 9115 1 Source Listings I TEXAS INSTRUMENTS Figure 3 2 Example Assembler Listing www ti com Include file Line number letter TE 1 00000000 State32 2 copy macl inc A 1 tol6 macro A 2 ADD r0 pc 1 A 3 BX 0 A 4 Statel6 A 5 A 6 endm 3 4 global stack 5 gp ce ce e e ee ee eoe he e ee hee hoe hee ee he e hee e e he he e e he e e e e e kkk 6 DEFINE THE USER MODE STACK 7 8 00000200 STACKSIZE set 2 9 00000000 Stack usect stack STACKSIZE 4 10 CE ce ee e e ee ee hee e e ee he e hee he e hoe he e hee e e e e e he e e e e e e e e n 11 INTERRUPT VECTORS 12 go 36 36 36 36 36 e e ke ke e e ce e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e 13 global reset 14 00000000 sect intvecs 15 16 00000000 EAFFFFFE B reset 17 00000004 00000000 word 0 18 00000008 00000000 word 0 19 0000000c 00000000 word 0 20 00000010 00000000 word 0 21 00000014 00000000 wo
308. file Specify EPROM system Memory Width and Physical ROM width memwidth 16 EPROM memory system width romwidth 16 Physical width of ROM ROMS EPROM origin 0x0 length 0 SECTIONS SecA paddr 0x0 5602 paddr 0 Example 6 6 shows the contents of the resulting map file example2 mxp Figure 0 4 shows the contents of the resulting hex output file example2 hex Example C 6 Contents of Hex Map File example2 mxp TMS470 COFF Hex Converter Version x xx Mon Sep 18 19 34 47 1995 INPUT FILE NAME lt a out gt OUTPUT FORMAT Intel PHYSICAL MEMORY PARAMETERS Default data width 8 Default memory width 16 Default output width 16 OUTPUT TRANSLATION MAP 00000000 0001ffff Page 0 ROM Width 16 Memory Width 16 EPROM OUTPUT FILES example2 hex b0 515 326 Hex Conversion Utility Examples SPNU118J August 2011 S oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Scenario 3 Building a Hex
309. file You can also use the archiver to collect a group of object files into an object library The linker includes in the library the members that resolve external references during the link The archiver allows you to modify a library by deleting replacing extracting or adding members On architectures like ARM it is often desirable to have multiple versions of the same object file libraries each built with different sets of build options When several versions of a single library are available the library information archiver can be used to create an index library of all the object file library versions This index library is the used in the link step in place of a particular version of your object file library Topic Page 6 I Archiver Overview oeenn aaea eE aaa EEE Ea EAE Aa AAEE EEEE AE AE A AEE EERE a aAa 162 6 2 The Archiver s Role in the Software Development Flow 163 6 3 Invoking the Archiver eee tourner e seman Ee e EE aeee rE 164 S 165 aE ex Ns Archiver Examples oce ee 6 4 6 5 Library Information Archiver Description ppp 166 SPNU 118J August 2011 Archiver Description 161 Submit Documentation Feedback I I men BADE 0 9115 1 SPNUT118J August 2011 I TEXAS INSTRUMENTS Archiver Overview www ti com 6 1 162 Archiver Overview You can build libra
310. file and copies the program into target memory You can use the hex conversion utility hex470 which is shipped as part of the assembly language package to convert the executable object module into one of several object file formats You can then use the converted file with an EPROM programmer to burn the program into an EPROM SPNU118J August 2011 Introduction to Object Modules 29 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Symbols in an Object File www ti com 2 7 2 7 1 2 8 30 Symbols in an Object File An object file contains a symbol table that stores information about symbols in the program The linker uses this table when it performs relocation External Symbols External symbols are symbols that are defined in one file and referenced in another file You can use the def ref or global directive to identify symbols as external def The symbol is defined in the current file and used in another file ref The symbol is referenced in the current file but defined in another file global The symbol can be either of the above The following code segment illustrates these definitions x ADD RO 56h B y global x global y Define x Reference y def of x ref of y The global directive for x declares that it is an external symbol defined in this module and that other modules can reference x The global directive for y declares that it is an undefined
311. fined in filel lst Z Global symbols defined in this file global X Y Global symbol defined in filel lst Z Global symbols defined in this file def Xy X Global symbol defined in file3 1st Z group group section name group type gmember section name endgroup Three directives instruct the assembler to make certain sections members of an ELF group section see ELF specification for more information on group sections The group directive begins the group declaration The group section name designates the name of the group section The group type designates the type of the group The following types are supported 0x0 0x1 www BRD EKireconr TI Regular ELF group COMDAT ELF group SPNU118J August 2011 Submit Documentation Feedback I TEXAS INSTRUMENTS www ti com Directives Reference The gmember directive designates section name as a member of the group The endgroup directive ends the group declaration SPNU118J August 2011 Assembler Directives 105 Submit Documentation Feedback I I men BADE 0 9115 1 Directives Reference half short Syntax Description Example 106 Assembler Directives I TEXAS INSTRUMENTS www ti com Initialize 16 Bit Integers half value value Short value value The half and short directives place one or more values into consecutive halfwords in the current section A value can be either An expressi
312. formation file are children of the link info element The following sections describe the elements that an XML information file can contain B 2 1 Header Elements The first elements in the XML link information file provide general information about the linker and the link session The banner element lists the name of the executable and the version information string The copyright element lists the TI copyright information string The link time is a timestamp representation of the link time unsigned 32 bit int The output file element lists the name of the linked output file generated string The entry point element specifies the program entry point as determined by the linker container with two entries The name is the entry point symbol name if any string The address is the entry point address constant Example 8 1 Header Element for the hi out Output File lt banner gt TMS320Cxx Linker Version x xx Jan 6 2008 banner copyright Copyright c 1996 2008 Texas Instruments Incorporated lt copyright gt link time 0x43dfd8a4 link time output file hi out output file entry point name c int00 name address 0xaf80 address entry point 310 XML Link Information File Description SPNU118J August 2011 BYE T Submit Documentation Feedback men www BD TI 1 TEXAS INSTRUMENTS www ti com Docum
313. g all instructions in a file as 32 bit instructions When you use the mt assembler option or the state16 directive to assemble 16 bit instructions you can use the state32 or arm directive to tell the assembler to begin assembling all instructions after the state32 arm directive as 32 bit instructions When you are writing assembly code the arg directive is used to specify ARM UAL syntax The state32 and arm directives are equivalent since UAL syntax is backward compatible These directives perform an implicit word alignment before any instructions are written to the section to ensure that all 32 bit instructions are word aligned These directives also reset any local labels defined In this example the assembler assembles 32 bit instructions begins assembling 16 bit instructions and returns to assembling 32 bit instructions 1 global 61008 filter 2 ko ko ko ko 3 Begin assembling 32 bit instructions KE 4 ko ko ko ko ko 5 00000000 State32 6 00000000 E28F4001 ADD r4 pc 1 7 00000004 4 BX r4 8 ck
314. gible for removal via conditional linking by default So under the COFF ABI mode the retain directive does not have any real effect on the section In this example the Vars and Counts sections are set for conditional linking Set Vars section for conditional linking e S sect Vars clink 000000AA 000000AA 000000AA 000000AA 000000AA 000000AA 86 Assembler Directives X word 0AAh Y word 0AAh Z word 0AAh C Set Counts section for conditional linking
315. gister Description CPSR CPSR ALL Current processor status register CPSR FLG Current processor status register flag bits only SPSR SPSR ALL Saved processor status register SPSR FLG Saved processor status register flag bits only Status registers can be entered as all uppercase or all lowercase characters that is CPSR could also be entered as cpsr CPSR ALL or cpsr all 48 Assembler Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Symbols 3 8 6 Substitution Symbols Symbols can be assigned a string value variable This enables you to alias character strings by equating them to symbolic names Symbols that represent character strings are called substitution symbols When the assembler encounters a substitution symbol its string value is substituted for the symbol name Unlike symbolic constants substitution symbols can be redefined A string can be assigned to a substitution symbol anywhere within a program for example asg SP stack pointer Assigns the string SP to the substitution symbol stack pointer asg 0x20 block2 Assigns the string 40x20 to the substitution symbol block2 ADD stack pointer stack pointer block2 Adds the value in SP to 020 and stores the result in SP When you are using macros substitution symbols are important because macro parameters are actually substitution symbols that are assigned a macro argument T
316. gram an optimizer and an interlist utility are included in the compiler package The shell program enables you to compile assemble and link source modules in one step The optimizer modifies code to improve the efficiency of C C programs The interlist utility interlists C C source statements with assembly language output to correlate code produced by the compiler with your source code See the ARM Optimizing 0 6 Compiler User s Guide for more information The assembler translates assembly language source files into machine language object modules Source files can contain instructions assembler directives and macro directives You can use assembler directives to control various aspects of the assembly process such as the source listing format data alignment and section content See Chapter 3 through Chapter 5 See the TMS470R1x User s Guide for detailed information on the assembly language instruction set The linker combines object files into a single executable object module As it creates the executable module it performs relocation and resolves external references The linker accepts relocatable object modules created by the assembler as input It also accepts archiver library members and output modules created by a previous linker run Link directives allow you to combine object file sections bind sections or symbols to addresses or within memory ranges and define or redefine global symbols See Chapter 7 For m
317. gs symbol contains the address of the args section The loader and the target boot code use the args section and the c args symbol to determine whether and how to pass arguments from the host to the target program See the ARM Optimizing C C Compiler User s Guide for information about the loader Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Options 7 44 Changing Encoding of Big Endian Instructions When you are creating big endian executable files you can determine whether instruction encoding is in little or big endian The be8 option produces big endian executable modules with little endian encoded instructions This is the default behavior for architecture version 6 and higher The be32 option produces big endian executable modules with big endian encoded instructions This is the default behavior for architecture version 5 and lower 7 4 5 Compression cinit compression and copy compression Option By default the linker does not compress data There are two options that specify compression through the linker The ELF mode cinit compression option specifies the compression type the linker applies to the C autoinitialization data The default is rle Overlays can be managed by using linker generated copy tables To save ROM space the linker can compress the data copied by the copy tables The compressed data is decompressed
318. hat all Thumb Thumb 2 instructions are halfword aligned These directives also reset any local labels defined In this example the assembler assembles 16 bit instructions begins assembling 32 bit instructions and returns to assembling 16 bit instructions 1 global 81001 2 2 3 xk Begin assembling Thumb instructions xk 4 5 00000000 thumb 6 7 00000000 4808 LDR r0 globl a 8 00000002 4909 LDR rl glob2 a 9 00000004 6800 LDR r0 r0 0 00000006 6809 LDR ri ri 1 00000008 0080 LSLS rO r0 2 2 0000000a 3156 ADDS rl 56h 3 0000000c 4778 BX pc 4 00000006 0 NOP 5 3k ke ke ke ke ke ke eee See See ee e e e x x 6 ew Switch to ARM mode to use the long e 7 ee multiply instruction 8
319. he text sections from rts470 lib into the rtstest section SECTIONS rtstest l rts470 lib text gt RAM SECTIONS Directive Effect on priority NOTE Specifying a library in a SECTIONS directive causes that library to be entered in the list of libraries that the linker searches to resolve references If you use the priority option the first library specified in the command file will be searched first 7 5 4 6 Allocation Using Multiple Memory Ranges The linker allows you to specify an explicit list of memory ranges into which an output section can be allocated Consider the following example MEMORY P_MEM1 origin 0x02000 length 0x01000 P_MEM2 origin 0x04000 length 0x01000 P MEM3 origin 0x06000 length 0x01000 P MEMA origin 0x08000 length 0 SECTIONS text gt P MEMI P MEM2 P MEM4 The operator is used to specify the multiple memory ranges The text output section is allocated as a whole into the first memory range in which it fits The memory ranges are accessed in the order specified In this example the linker first tries to allocate the section in P_MEM1 If that attempt fails the linker tries to place the section into P_MEM2 and so on If the output section is not successfully allocated in any of the named memory ranges the linker issues an error message With this type of SECTIONS directive specification the linker can seamlessly handle an output se
320. he called function The lt far_call_trampoline_list gt enumerates all of the far call trampolines that are generated by the linker for a particular link The lt far_call_trampoline_list gt can contain any number of lt far_call_trampoline gt elements Each far call trampoline is a container enclosing the following elements The callee name element names the destination function string The callee address is the address of the called function constant The trampoline object component ref is a reference to an object component that contains the definition of the trampoline function reference The trampoline address is the address of the trampoline function constant The caller list enumerates all call sites that utilize this trampoline to reach the called function container The trampoline call site provides the details of a trampoline call site container and consists of these items The caller address specifies the call site address constant The caller object component ref is the object component where the call site resides reference Example B 6 Fall Call Trampoline List for the fl 4 Input File far call trampoline list far call trampoline callee name foo callee name callee address 0x08000030 callee address trampoline object component ref idref oc 123 trampoline address 0x2020 trampoline address caller list c
321. he first reference of the symbol is encountered at run time this does not happen automatically simply because you specify a separate run address For an example that illustrates how to move a block of code at run time see Example 7 10 If you provide only one allocation either load or run for a section the section is allocated only once and loads and runs at the same address If you provide both allocations the section is actually allocated as if it were two separate sections of the same size Uninitialized sections such as bss are not loaded so the only significant address is the run address The linker allocates uninitialized sections only once if you specify both run and load addresses the linker warns you and ignores the load address For a complete description of run time relocation see Section 7 5 5 Loading a Program The linker produces executable object modules An executable object module has the same format as object files that are used as linker input the sections in an executable object module however are combined and relocated into target memory To run a program the data in the executable object module must be transferred or loaded into target system memory Several methods can be used for loading a program depending on the execution environment Common situations are described below Code Composer Studio can load an executable object module onto hardware The Code Composer Studio loader reads the executable
322. he following code shows how substitution symbols are used in macros addl macro dest src addl macro definition ADDS dest dest src Add the value in register dest to the value in register src and store the result in src BLCS reset ctr Handle overflow endm addl invocation addl R4 R5 Calls the macro addl and substitutes R4 for dest and R5 for src The macro adds the value of 24 and the value of R5 stores the result in 24 and handles overflow See Chapter 5 for more information about macros SPNU118J August 2011 Assembler Description 49 Submit Documentation Feedback Se oF T www BD EIC conr TI 1 TEXAS INSTRUMENTS Expressions www ti com 3 9 Expressions An expression is a constant a symbol or a series of constants and symbols separated by arithmetic operators The 32 bit ranges of valid expression values are 2147 483 648 to 2147 483 647 for signed values and 0 to 4 294 967 295 for unsigned values Three main factors influence the order of expression evaluation Parentheses Expressions enclosed in parentheses are always evaluated first 8 4 2 4 but8 4 2 1 You cannot substitute braces or brackets for parentheses Precedence groups Operators listed in Table 3 2 are divided into nine precedence groups When parentheses 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
323. he probability that your program will fit into memory The algorithm comprises these steps 1 Each output section for which you have supplied a specific binding address is placed in memory at that address 2 Each output section that is included in a specific named memory range or that has memory attribute restrictions is allocated Each output section is placed into the first available space within the named area considering alignment where necessary 3 Any remaining sections are allocated in the order in which they are defined Sections not defined in a SECTIONS directive are allocated in the order in which they are encountered Each output section is placed into the first available memory space considering alignment where necessary Linker Generated Copy Tables The linker supports extensions to the link command file syntax that enable the following Make it easier for you to copy objects from load space to run space at boot time Make it easier for you to manage memory overlays at run time Allow you to split GROUPs and output sections that have separate load and run addresses A Current Boot Loaded Application Development Process In some embedded applications there is a need to copy or download code and or data from one location to another at boot time before the application actually begins its main execution thread For example an application may have its code and or data in FLASH memory and need to copy it into on chip memo
324. ic Page 721 EinkermOvernview O 170 7 2 The Linker s Role in the Software Development Flow ssss 171 7 3 Invoking the Linket reet ce anag cegsttstac tance ant eyes tnasiiae cance aa 172 DtiOnNS ee 173 7 5 Binker CommandiEiles 2 Ee EEE AEE Ea EEA EE A E EEE REA EAE AER 193 76 Object 226 TI Default Allocation AlgornthmM ae ete Re EEE AEEA E E EEEE 227 7 8 Einker Generated Copy Tables ee aea 228 7 9 Linker Generated CRC TableSs cecus cene EE TETUR E canoes 241 7 10 Partial Incremental Linking pp 247 Ady ET Ae 6 6006 248 7 12 Einker Example no e Ie a EE EEEE aa EE EEA EEEE 251 Submit Documentation Feedback I I men BADE 0 9115 1 Chapter 7 SPNU T 18J August 2011 I TEXAS INSTRUMENTS Linker Overview www ti com 7 1 Linker Overview The ARM linker allows you to configure system memory by allocating output sections efficiently into the memory map As the linker combines object files it performs the following tasks Allocates sections into the target system s configured memory Relocates symbols and sections 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 assignment and evaluation You c
325. ich are of a structure union type SPNU118J August 2011 Sharing C C Header Files With Assembly Source 301 Submit Documentation Feedback Se oF T www BDFIKG conr TI I TEXAS INSTRUMENTS Notes on C Specific Conversions www ti com 12 2 15 C Constant Suffixes The C constant suffixes u and f are passed to the assembly unchanged The assembler will ignore these suffixes if used in assembly expressions 12 2 16 Basic C C Types 12 3 Only complex types structures and unions in the C C source code are converted to assembly Basic types such as int char or float are not converted or represented in assembly beyond any existing int char float etc directives that previously existed in assembly Typedefs of basic types are therefore also not represented in the converted assembly Notes on C Specific Conversions The following sections describe C specific conversion elements that you need to be aware of when sharing header files with assembly source 12 3 1 Name Mangling Symbol names may be mangled in C source files When mangling occurs the converted assembly will use the mangled names to avoid symbol name clashes You can use the demangler dem470 to demangle names and identify the correct symbols to use in assembly To defeat name mangling in C for symbols where polymorphism calling a function of the same name with different kinds of arguments is not required use the following syntax extern C
326. ics diag_remark num Categorizes the diagnostic identified by num as a remark To determine the numeric identifier of a diagnostic message use the display_error_number option first in a separate link Then use diag_remark num to recategorize the diagnostic as a remark You can only alter the severity of discretionary diagnostics diag_suppress num Suppresses the diagnostic identified by num To determine the numeric identifier of a diagnostic message use the display_error_number option first in a separate link Then use diag_suppress num to suppress the diagnostic You can only suppress discretionary diagnostics SPNU118J August 2011 Linker Description 177 Submit Documentation Feedback oF T www BD EIC conr TI I TEXAS INSTRUMENTS Linker Options www ti com diag_warning num Categorizes the diagnostic identified by num as a warning To determine the numeric identifier of a diagnostic message use the display_error_number option first in a separate link Then use diag_warning num to recategorize the diagnostic as a warning You can only alter the severity of discretionary diagnostics display_error_number Displays a diagnostic s numeric identifier along with its text Use this option in determining which arguments you need to supply to the diagnostic suppression options diag suppress diag error diag remark and diag warning This option also indicates whether a diagnostic is discretionary A discretionary
327. ifferent sets of build options For example you might have different versions of your object file library for big and little endian for different architecture revisions or for different ABIs depending on the typical build environments of client applications Unfortunately if there are several different versions of your library it can become cumbersome to keep track of which version of the library needs to be linked in for a particular application When several versions of a single library are available the library information archiver can be used to create an index library of all of the object file library versions This index library is used in the linker in place of a particular version of your object file library The linker looks at the build options of the application being linked and uses the specified index library to determine which version of your object file library to include in the linker If one or more compatible libraries were found in the index library the most suitable compatible library is linked in for your application 6 5 1 Invoking the Library Information Archiver To invoke the library information archiver enter libinfo470 options o libname libname libnames libname libinfo470 is the command that invokes the library information archiver options changes the default behavior of the library information archiver These options are 0libname specifies the name of the index library to create or upda
328. ified the disassembly is written to standard output SPNU118J August 2011 Object File Utilities 269 Submit Documentation Feedback Se oF T www BD EIC conr TI Invoking the Disassembler 1 TEXAS INSTRUMENTS www ti com When the example file in Example 10 1 is compiled the assembler produces an object file memcpy32 obj Example 10 1 Object File memcpy32 asm global C_MEMCPY C_MEMCPY CMP r2 BXEQ Ilr STMFD sp TST i BNE una TST r0 BNE _sal aln CMP 2 BCC 116 STMFD sp SUB r2 0 r0 0x3 in 0x3 n 16 r4 EZ lr 16 asmfunc stack usage 12 CHECK FOR n SAVE RETURN VALUE AND ADDRESS ADDRESS ALIGNMENT IF NOT WORD ALIGNED HANDLE SPECIALLY CHECK FOR n 16 As shown in Example 10 2 the disassembler can produce disassembly from the object file memcpy32 obj The first two lines are entered on the command line Example 10 2 Disassembly From memcpy32 asm TEXT S 000000 000004 000008 00000c 000010 000014 000018 00001c 000020 000024 000028 ection te 000000 000000 E3520000 012FFF1E E92D4001 E3110003 1A00002B E3100003 1A00002F E3520010 3A000008 E92D0010 E2422010 xt 0x180 bytes at 0 C MEMCPY State32 CMP BXEQ STMFD TST BNE TST BNE CMP BCC STMFD SUB R2 0 R14 R131 RO R14 R1 43 0x000000C4 RO 3
329. ignment before any instructions are written to the section to ensure that all 16 bit instructions are halfword aligned The State16 directive also resets any local labels defined The state32 directive tells the assembler to begin assembling 32 bit instructions starting at the location of the directive The state32 directive performs an implicit word alignment before any instructions are written to the section to ensure that all 32 bit instructions are word aligned The State32 directive also resets any local labels defined The thumb directive tells the assembler to begin assembling Thumb or Thumb 2 UAL syntax instructions starting at the location of the directive The thumb directive performs an implicit word alignment before any instructions are written to the section to ensure that all instructions are word aligned The thumb directive also resets any local labels defined Directives That Initialize Constants Several directives assemble values for the current section The byte and char directives place one or more 8 bit values into consecutive bytes of the current section These directives are similar to long and word except that the width of each value is restricted to eight bits The double directive calculates the double precision 64 bit IEEE floating point representation of one or more floating point values and stores them in two consecutive words in the current section The double directive automatically aligns to the dou
330. ile format Under the COFF ABI model the linker assumes that all sections are ineligible for removal via conditional linking by default If you want to make a section eligible for removal you must apply a clink directive to it In contrast under the ELF EABI model the linker assumes that all sections are eligible for removal via conditional linking Therefore the clink directive has no effect under EABI A section in which the entry point of a C program is defined cannot be marked as a conditionally linked section The retain directive indicates that the current or specified section is not eligible for removal via conditional linking You can also override conditional linking for a given section with the retain linker option You can disable conditional linking entirely with the unused_section_elimination off linker option Since under the ELF EABI model the linker assumes that all sections are eligible for removal via conditional linking by default the retain directive becomes useful for overriding the default conditional linking behavior for those sections that you want to keep included in the link even if the section is not referenced by any other section in the link For example you could apply a retain directive to an interrupt function that you have written in assembly language but which is not referenced from any normal entry point in the application Under the COFF ABI model the linker assumes that all sections are not eli
331. ilename is not provided all sections matching the section name are excluded Wildcards cannot be used for the filename but can appear within the parentheses 11 8 Assigning Output Filenames When the hex conversion utility translates your object file into a data format it partitions the data into one or more output files When multiple files are formed by splitting memory words into ROM words filenames are always assigned in order from least to most significant where bits in the memory words are numbered from right to left This is true regardless of target or endian ordering The hex conversion utility follows this sequence when assigning output filenames 1 It looks for the ROMS directive If a file is associated with a range in the ROMS directive and you have included a list of files files on that range the utility takes the filename from the list For example assume that the target data is 32 bit words being converted to four 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 bl xyz b2 xyz b3 The utility creates the output files by writing the least significant bits to xyz b0 and the most significant bits to xyz b3 2 It looks for the outfile options You can specify names for the output files by using the outfile option If no filenames are listed in the ROMS directive and you use outfile options the utility takes
332. ility to define structures that contain other structures The tag directive does not allocate memory The structure tag stag of a tag directive must have been previously defined Following are descriptions of the parameters used with the struct endstruct and tag directives The stag is the structure s tag Its value is associated with the beginning of the structure If no stag is present the assembler puts the structure members in the global symbol table with the value of their absolute offset from the top of the structure A stag is optional for struct but is required for tag The expris an optional expression indicating the beginning offset of the structure The default starting point for a structure is 0 The mem is an optional label for a member of the structure This label is absolute and equates to the present offset from the beginning of the structure A label for a structure member cannot be declared global The elementis one of the following descriptors byte char int long word double half short string float field and tag All of these except tag are typical directives that initialize memory Following a struct directive these directives describe the structure element s size They do not allocate memory The tag directive is a special case because stag must be used as in the definition of stag The expr is an optional expression for the number of elements described This value def
333. ill return the minimum alignment calculated by the assembler 12 4 7 The cstring Directive 304 You can use the new cstring directive to cause the escape sequences and NULL termination to be properly handled as they would in C C cstring String with C escapes nWill be NULL terminated N012 See Section 12 2 11 for more information on the new cstring directive Sharing C C Header Files With Assembly Source SPNU118J August 2011 d oF T Submit Documentation Feedback www BD EIC conr TI Appendix A SPNU118J August 2011 Symbolic Debugging Directives The assembler supports several directives that the ARM C C compiler uses for symbolic debugging These directives differ for the two debugging formats DWARF and COFF These directives are not meant for use by assembly language programmers They require arguments that can be difficult to calculate manually and their usage must conform to a predetermined agreement between the compiler the assembler and the debugger This appendix documents these directives for informational purposes only Topic Page A 1 DWARF Debugging Formats ee ee ee ee E SEE e 306 306 23 Debug Directive Syntax 307 SPNU118J August 2011 Symbolic Debugging Directives 305 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS DWARF Debugging Format www ti com A 1 DWARF Debugging Format A subset of the DWARF symbolic debugging directives
334. in code or data The text directive identifies portions of code in the text section The text section usually contains executable code The usect directive reserves space in an uninitialized named section The usect directive is similar to the bss directive but it allows you to reserve space separately from the bss section Chapter 2 discusses these sections in detail Example 4 1 shows how you can use sections directives to associate code and data with the proper sections This is an output listing column 1 shows line numbers and column 2 shows the SPC values Each section has its own program counter or SPC When code is first placed in a section its SPC equals 0 When you resume assembling into a section 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 bytes Xy reserves 20 bytes 66 Assembler Directives SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com The bss and usect directives do not end the current section or begin new sections they reserve the specified amount of space and then the assembler resumes assembling code o
335. ing 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 4 7 Directives That Reference Other Files These directives supply information for or about other files that can be used in the assembly of the current file The copy and include directives tell the assembler to begin reading source statements from another file When the assembler finishes reading the source statements in the copy include file it resumes reading source statements from the current file The statements read from a copied file are printed in the listing file the statements read from an included file are not printed in the listing file The def directive identifies a symbol that is defined in the current module and that can be used in 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 Section 2 7 1 The global directive does double duty acting as a def for defined symbols and as a ref for undefined symbols The linker resolves an undefined global symbol reference only if the symbol is used in the program The
336. ing Trampolines From Load Space to Run Space 190 It is sometimes useful to load code in one location in memory and run it in another The linker provides the capability to specify separate load and run allocations for a section The burden of actually copying the code from the load space to the run space is left to you A copy function must be executed before the real function can be executed in its run space To facilitate this copy function the assembler provides the label directive which allows you to define a load time address These load time addresses can then be used to determine the start address and size of the code to be copied However this mechanism will not work if the code contains a call that requires a trampoline to reach its called function This is because the trampoline code is generated at link time after the load time addresses associated with the label directive have been defined If the linker detects the definition of a label symbol in an input section that contains a trampoline call then a warning is generated To solve this problem you can use the START END and SIZE operators see Section 7 5 8 7 These operators allow you to define symbols to represent the load time start address and size inside the link command file These symbols can be referenced by the copy code and their values are not resolved until link time after the trampoline sections have been allocated Linker Description SPNU118J August
337. ing to the Load Address by Using the label Directive 1 TEXAS INSTRUMENTS www ti com Normally any reference to a symbol in a section refers to its run time address However it may be necessary at run time to refer to a load time address Specifically the code that copies a section from its load address to its run address must have access to the load address The label directive defines a special symbol that refers to the section s load address Thus whereas normal symbols are relocated with respect to the run address label symbols are relocated with respect to the load address See Create a Load Time Address Label for more information on the label directive Example 7 10 and Example 7 11 show the use of the label directive to copy a section from its load address in SLOW MEM to its run address in FAST MEM Figure 7 3 illustrates the run time execution of Example 7 10 Example 7 10 Copying Section Assembly Language File sect afir label fir src load address of section fir run address of section code here Code for section label fir end load address of section end text LDR r4 fir s get fir load address start LDR r5 fir e get fir load address stop LDR r3 fir a get fir run address 1 CMP r4 r5 LDRCC r0 r4 4 copy fir routine to its run address STRCC 0 r3 4 jump to fir routine now in FAST_MEM B fir fir a word fir fir s word fir start fir e word fir end
338. ining Macros 2621 eee are dee SR E ERE ME RETE 144 5 3 Macro Parameters Substitution Symbols pp 146 5 4 s Macroll ibrariesa et t etum 152 5 5 Using Conditional Assembly in Macros ppp 153 5 6 Using Labels in Macros Se ee RIEN EIER 155 57 Producing Messages in Macros 0 eee eue ee eei eee eam ree REESE ERES 156 5 8 Using Directives to Format the Output Listing pp 157 5 9 Using Recursive and Nested Macros sees 158 5 10 Macro Directives Summary 0 ee ea eE ea E Ee e AA AA Ae EE E AA E 159 SPNU118J August 20160000 Macro Description 143 Submit Documentation Feedback oF T www BD EIC conr TI I TEXAS INSTRUMENTS Using Macros www ti com 5 1 5 2 144 Using Macros Programs often contain routines that are executed several times Instead of repeating the source statements for a routine you can define the routine as a macro then call the macro in the places where you would normally repeat the routine This simplifies and shortens your source program If you want to call a macro several times but with different data each time you can assign parameters within a macro This enables you to pass different information to the macro each time you call it The macro language supports a special symbol called a substitution symbol which is used for macro parameters See Section 5 3 for more information Using a macro is a 3 step process Step 1 Define the macro You must define macros bef
339. inker results This appendix enumerates all of the elements that are generated by the linker into the XML link information file Topic Page B 1 XML Information File Element Types eeceeeeeeeeee eee ence ee eee 310 B2 Document 61625062616 a AAAA ENEE E NEE AA EAA aE E AAR ea aE AN 310 SPNU118J August 2011 XML Link Information File Description 309 Submit Documentation Feedback I I men BADE gt 69115 1 I TEXAS INSTRUMENTS XML Information File Element Types www ti com B 1 XML Information File Element Types These element types will be generated by the linker Container elements represent an object that contains other elements that describe the object Container elements have an id attribute that makes them accessible from other elements String elements contain a string representation of their value Constant elements contain a 32 bit unsigned long representation of their value with a Ox prefix Reference elements are empty elements that contain an idref attribute that specifies a link to another container element In Section B 2 the element type is specified for each element in parentheses following the element description For instance the link time element lists the time of the link execution string B 2 Document Elements The root element or the document element is link info All other elements contained in the XML link in
340. ion 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 Section 11 3 2 Any value you specify here overrides the memwidth option The value must be a decimal octal or hexadecimal constant that is a power of 2 greater than or equal to 8 When using the memwidth parameter you must also specify the paddr parameter for each section in the SECTIONS directive See Section 11 5 Hex Conversion Utility Description SPNU118J August 2011 S oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com The ROMS Directive fill specifies a fill value to use for the range In image mode the hex conversion utility uses this value to fill any holes between sections in a range A hole is an area between the input sections that comprises an output section that contains no actual code or data The fill value must be a decimal octal or hexadecimal constant with a width equal to the target width Any value you specify here overrides the fill option When using fill you must also use the image command line option See Section 11 9 2 files identifies the names of the output files that correspond to this range Enclose the list of names in curly braces and order them from east significant to most significant output file where the bits of the memory word are numbered from right to left The number of fi
341. ion 317 Submit Documentation Feedback Se oF T www BD EIC conr TI 318 XML Link Information File Description SPNU 118J August 2011 T4 E I T Submit Documentation Feedback 1 efas men WWW conr TI Appendix C IJ TEXAS SPNU118J August 2011 INSTRUMENTS Hex Conversion Utility Examples The flexible hex conversion utility offers many options and capabilities Once you understand the proper ways to configure your EPROM system and the requirements of the EPROM programmer you will find that converting a file for a specific application is easy The three scenarios in this appendix show how to develop a hex conversion command file for avoiding holes using 16 BIS 16 bit instruction set code and using multiple EPROM systems The scenarios use this assembly code Assemble two words into section secA E Sect secA word 012345678h word 0abcd1234h Assemble two words into section secB
342. ion about that option or phrase is displayed image image Select image mode Section 11 9 1 linkerfill linkerfill Include linker fill sections in images map filename map Generate a map file Section 11 4 2 memwidth value memwidth Define the system memory word width default 16 bits Section 11 3 2 olength value olength Specify maximum number of data items per line of output outfile filename 0 Specify an output filename Section 11 8 quiet q Run quietly when used it must appear before other options Section 11 2 2 qpmwidihizvalue aomwidif ue the ROM device width default depends on format Section 11 3 3 zero Zero 2 Reset the address origin to 0 in image mode Section 11 9 3 Hex Conversion Utility Description 275 WWW I6con TI Invoking the Hex Conversion Utility 276 I TEXAS INSTRUMENTS www ti com Table 11 1 Basic Hex Conversion Utility Options continued Option Alias Description See Diagnostic Options diag_error id diag remark id diag_suppress id diag_warning id display_error_number issue_remarks no_warnings set_error_limit count Categorizes the diagnostic identified by id as an error Categorizes the diagnostic identified by id as a remark Suppresses the diagnostic identified by id Categorizes the diagnostic identified by id as a warning Displays a diagnostic s identifiers along with its text Issues remarks nonserious warnings Suppresses warning
343. ion scheme according to the size of your program and the memory layout of your target system uA Notes 1 You must specify the directory in which rtsl6 lib is located Either add a i lt directory gt line to this file or use the system environment variable C DIR to 7 Specify a search path for libraries es af 2 If the runtime support library you are using is not named rtsl6 lib be sure to use the correct name here ke ke ke k ke kk kk Ck Ck Ck kk k kk Ck Ck BRK KK m example2 map SPECIFY THE SYSTEM MEMORY MAP MEMORY 1 I MEM org 0 len 0x00000020 INTERRUPTS ur D MEM org 0 len 0x00010000 DATA MEMORY RAM P MEM org 0 len 0x00100000 PROGRAM MEMORY ROM SPECIFY THE SECTIONS ALLOCATION INTO MEMORY SECTIONS secA load 0x3000 secB load 0x20 You must create a hex conversion command file to generate a hex output with the correct addresses and format for the EPROM programmer The EPROM programmer in this scenario has the following system requirements Because the EPROM memory width is 16 bits the memwidth value must be set to 16 Because the physical width of the ROM device is 16 bits the romwidth value must be s
344. irective sends an error message to the standard output device in the same manner as the assembler It increments the error count and prevents the assembler from producing an object file The mmsg directive sends an assembly time message to the standard output device in the same manner as the emsg and wmsg directives It does not however set the error or warning counts and it does not prevent the assembler from producing an object file The wmsg directive sends a warning message to the standard output device in the same manner as the emsg directive It increments the warning count rather than the error count however It does not prevent the assembler from producing an object file Example In this example the message ERROR MISSING PARAMETER is sent to the standard output device Source file MSG_EX macro parmi sif symlen parm1 0 emsg ERROR MISSING PARAMETER else ADD parml r7 r8 endif endm MSG EX RO MSG EX Listing file 1 MSG EX macro 1 2 dE symlen parml 0 3 emsg ERROR MISSING PARAMETER 4 else 5 ADD parml r7 r8 6 endif 7 endm 96 Assembler Directives SPNU 118J August 2011 oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com 8 9 00000000 00000000 E0870008 10 11 00000004 USER ERROR 1 Error No Warnings MSG EX 0 E symlen parml 0 emsg ERROR MISSING PARAMETER else ADD
345. itution symbol The value is stored in the substitution symbol table When the assembler encounters a substitution symbol it replaces the symbol with its character string value Substitution symbols created with define cannot be redefined The label directive defines a special symbol that refers to the load time address 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 See the label topic for an example using a load time address label The set and equ directives set a constant value to a symbol The symbol is stored in the symbol table and cannot be redefined for example bval set 0100h Set bval 0100h long bval bval 2 bval 12 Store the values 0100h 0200h and 010Ch into consecutive words in current section The set and equ directives produce no object code The two directives are identical and can be used interchangeably The unasg directive turns off substitution symbol assignment made with asg The undefine directive turns off substitution symbol assignment made with define The var directive allows you to use substitution symbols as local variables within a macro SPNU118J August 2011 Assembler Directives 75 Submit Documentation Feedback I I men BADE 0 9115
346. ive bytes The entire string must be enclosed in quotes The first byte occupies the eight least significant bits of a full 32 bit word The second byte occupies bits eight through 15 while the third byte occupies bits 16 through 23 The assembler truncates values greater than eight bits If you use a label it points to the location of the first byte 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 see the struct endstruct tag topic In this example 8 bit values 10 1 abc and a are placed into consecutive bytes in memory with byte Also 8 bit values 8 3 def and b are placed into consecutive bytes in memory with char The label STRX has the value Oh which is the location of the first initialized byte The label STRY has the value 6h which is the first byte initialized by the char directive 1 00000000 Space 100h 2 00000100 0A STRX byte 10 1 abc a 00000101 FF 00000102 61 00000103 62 00000104 63 00000105 61 3 00000106 08 STRY shar 8 3 def 5 00000107 00000108 4 00000109 5 00000108 6 00000100 2 11180 August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com cdecls Syntax Syntax Description SPNU118J August 2011 Directives Reference Share C Headers Between C and Assembly Code Single Line cde
347. ives the id of the memory page in which this memory area is defined constant The lt origin gt specifies the beginning address of the memory area constant The lt length gt specifies the length of the memory area constant The lt used_space gt specifies the amount of allocated space in this area constant The unused space specifies the amount of available space in this area constant The attributes lists the RWXI attributes that are associated with this area if any string The fill value specifies the fill value that is to be placed in unused space if the fill directive is specified with the memory area constant The usage details lists details of each allocated or available fragment in this memory area If the fragment is allocated to a logical group then a logical group ref element is provided to facilitate access to the details of that logical group All fragment specifications include start address and size elements The allocated space element provides details of an allocated fragment within this memory area container The start address specifies the address of the fragment constant The lt size gt specifies the size of the fragment constant The logical group ref provides a reference to the logical group that is allocated to this fragment reference The available space element provides details of an available fragment within this memory area
348. j bss memory obj bss lock obj bss fopen obj bss s boot obj stack memory obj sysmem 7 5 4 2 4 Alignment and Blocking You can tell the linker to place an output section at an address that falls on an n byte boundary where n is a power of 2 by using the align keyword For example the following code allocates text so that it falls on a 32 byte boundary align 32 text load You can specify the same alignment with the palign keyword In addition palign ensures the section s size is a multiple of its placement alignment restrictions padding the section size up to such a boundary as needed Blocking is a weaker form of alignment that allocates a section anywhere within a block of size n The specified block size must be a power of 2 For example the following code allocates bss so that the entire section is contained in a single 128 byte page or begins on that boundary bss load block 0x0080 You can use alignment or blocking alone or in conjunction with a memory area but alignment and blocking cannot be used together 202 Linker Description www oF Eeconzy TI SPNU118J August 2011 Submit Documentation Feedback 1 TEXAS INSTRUMENTS www ti com Linker Command Files 7 5 4 2 5 Alignment With Padding As with align you can tell the linker to place an output section at an address that falls on an n byte boundary where n is a power of 2 by using the palign keyword In
349. j executable file out or archive library lib identifies the name utility options you want to use Options are not case sensitive and can appear anywhere on the command line following the invocation Precede each option with a hyphen The name utility options are as follows a prints all symbols 0 also prints C NULL symbols for a COFF object module d also prints debug symbols for a COFF object module f prepends file name to each symbol g prints only global symbols h shows the current help screen 4 produces a detailed listing of the symbol information n sorts symbols numerically rather than alphabetically o file outputs to the given file p causes the name utility to not sort any symbols q quiet mode suppresses the banner and all progress information r sorts symbols in reverse order 5 lists symbols in the dynamic symbol table for an ELF object module t also prints tag information symbols for a COFF object module Object File Utilities 271 Submit Documentation Feedback jn I I men gt 9115 1 1 TEXAS INSTRUMENTS Invoking the Strip Utility www ti com u only prints undefined symbols 10 4 Invoking the Strip Utility The strip utility strip470 removes symbol table and debugging information from object and executable files To invoke the strip utility enter the following strip470 p input filename input filename strip470 is the command that invok
350. k k k k k k k kk k kk k k k k k kk k kk k kkk kkk f cpy_tbl c v Copyright c 2003 Texas Instruments Incorporated xf General purpose copy routine Given the address of a linker generated xy COPY TABLE data structure effect the copy of all object components that are designated for copy via the corresponding LCF table operator ke ek ke ke Ck ke kk ke kk Ck kk Ck ke kk Ck ke RR KKK kk Ck kk kk kk include cpy tbl h include lt string h gt typedef void handler_fptr const unsigned char in unsigned char out k k k k k A k k kk ke ek AA RK KKK KKK IK KKK IK COPY IN koe He ko ke kk Kk Ck AA AK Ck Kk Ck Kk Ck kk RR KKK KKK kk kk kk Ck kk void copy in COPY TABLE tp unsigned short I for I 0 I gt tp num recs I COPY RECORD crp tp recs il unsigned char ld_addr unsign
351. k kk k kk k k kkk kkk f include lt stdint h gt For uintXX t ke kk ke ke kk kk Kk Ck ke Kk Ck A kk kk Ck Ck kk I kk Ck kk RR CRC Algorithm Specifiers ass ur The following specifications based on the above cited document are used by the linker to generate CRC values ID Name Order Polynomial Initial Ref Ref CRC XOR Zero Value In Out Value Pad 10 TMS570 CRC64 ISO 64 020000001 0x00000000 0 0 02200000000 1 Users should specify the name such as 185570 02064 ISO in the linker f command file The resulting CRC RECORD structure will contain the corresponding ID value in the crc alg ID field ke ke Ck Ck Ck Ck kk Ck BRK RK KKK kk define 145570 02064 ISO 10 2 CRC Record Data Structure x NOTE The list of fields and the size of each field varies by target and memory model ke ke ek ko ke
352. ker Example Example 7 31 Linker Command File demo cmd continued I TEXAS INSTRUMENTS www ti com 7 E E K k k e e e ee e k k ke k k k ke ke kk f SECTIONS text gt FAST MEM Link all text sections into ROM intvecs gt 0 Link interrupt vectors at 0 data 3 Link data sections tables obj data 07 Create hole at end of block OxFFOOFFOO gt EEPROM Fill and link into EEPROM ctrl_vars Create new sections for ctrl variables ctrl obj bss 0x00000100 gt SLOW MEM Fill with 0x100 and link into RAM bss gt SLOW MEM Link remaining bss sections into RAM E a y 51 57 SE E K k k k k k k A k A A k k A k k A K k A K k A A k k k k k k Ak A A k k A k k k kk k Ak k k k k k k k k k k k k k k kk k kk kkk k k kk k k End of Command File et ee e k k K k k A k k k k k k kk k k k k k k k k kk k k k k k k k k kk k kk k kk k k kk k k Of Invoke the linker by entering the following command c1470 run linker demo cmd This creates the map file shown in Example 7 32 and an output file called demo out that can be run on an ARM devicean ARP32 252 Linker Description www sok
353. kkkkkkkkkkkkkkk 9 bss buffer 10 00000000 10 11 gt ck cec ke ck ke kk ko ko ko 12 Still in data 13 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 14 0000000c 00000123 ptr word 0123h 15 gt ck ck ck kk kc ko kc ko ko ko ko 16 Assemble code into the text section 17 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 18 00000000 text 19 00000000 E59F14D2 add LDR R1 1234 20 00000004 82511001 aloop SUBS R1 R1 71 21 00000008 1AFFFFFD BNE aloop 22 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 23 Another initialized table into data 24 cec ce ke kc kk 25 0 data 26 00000010000000AA ivals word OAAh OBBh OCCh 00000014 000000BB 000000188 27 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 28 Define another section for more variables 29 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 30 00000000 var2 usect newvars 1 31 00000001 inbuf usect newvars 7 32 kkkkkkkkkkkkk
354. kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 33 Assemble more code into text 34 gt ke ecce e ck kk kc ko kc ko ko kc ko ko 35 0000000c text 36 0000000c E59F3D80 mpy LDR R3 3456 37 00000010E0120293 mloop MULS R2 R3 R2 38 00000014 1AFFFFFD BNE mloop 39 gt ke cec ce ke ck ke ck ke ck ko 40 Define a named section for int vectors 41 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 42 00000000 sect vectors 43 0000000000000011 word 011h 033h 00000004 00000033 Field 1 Field 2 Field 3 Field 4 As Figure 2 3 shows the file in Figure 2 2 creates five sections text contains six 32 bit words of object code data contains seven words of initialized data vectors is a named section created with the sect directive it contains two words of initialized data bss reserves ten bytes in memory newvars is a named section created with the usect directive it reserves eight bytes in memory SPNU118J August 2011 Introduction to Object Modules 25 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS How the Assembler Handles Sections www ti com The secon
355. le 8 3 258 Absolute Lister Example I TEXAS INSTRUMENTS www ti com This example uses three source files The files module1 asm and module2 asm both include the file globals def module1 asm text bss dfla bss arra dflag a word dfla array a word arra offst a word offs COPY glob LDR r4 LDR r5 LDR r3 LDR r0 STR r0 module2 asm text bss offs offst a word offs COPY glob LDR r4 STR r0 globals def global arra global offs global dfla g 1 y 0 g y t als def array a offst a dflag a r4 r5 r3 by d E als def offst a r4 y t g The following steps create absolute listings for the files module1 asm and module2 asm Step 1 First ass emble module1 asm and module2 asm c1470 modulel c1470 module2 This creates two object files called module1 obj and module2 obj Step 2 Next link module1 obj and module2 obj using the following linker command file called bttest cmd output file bttest out map fi modulel module2 MEMORY P MEM D MEM SECTIONS data text bss Invoke th le bttest map obj obj 0x00000000 len 0x00001000 len 0x00001000 0x00001000 org org D MEM gt P_MEM gt D_MEM e linker 01470 run linker bttest cmd This command creates an executable object file called bttest out use this new file as input for the absolute lister Absolute Lister Description www oF Eeconzy TI
356. le _first_ctbl second a2 obj text b2 0bj text load EMEM run PMEM table second ctbl extra load EMEM run PMEM table BINIT ovly gt BMEM binit gt BMEM For the link command file in Example 7 22 the boot time copy table is generated into a binit input section which is collected into the binit output section which is mapped to an address in the BMEM memory area The first ctbl is generated into the ovly first ctbl input section and the second ctbl is generated into the ovly second ctbl input section Since the base names of these input sections match the name of the ovly output section the input sections are collected into the ovly output section which is then mapped to an address in the BMEM memory area If you do not provide explicit placement instructions for the linker generated copy table sections they are allocated according to the linker s default placement algorithm The linker does not allow other types of input sections to be combined with a copy table input section in the same output section The linker does not allow a copy table section that was created from a partial link session to be used as input to a succeeding link session 238 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Generated Copy Tables 7 8 12 Splitting Object Components and Overlay Management In p
357. le names must equal the number of output files that the range generates To calculate the number of output files see Section 11 3 3 The utility warns you if you list too many or too few filenames Unless you are using the image option all of the parameters that define a range are optional the commas and equal signs are also optional A range with no origin or length defines the entire address space In image mode an origin and length are required for all ranges Ranges must not overlap and must be listed in order of ascending address 11 4 1 When to Use the ROMS Directive If you do not use a ROMS directive the utility defines a single default range that includes the entire address space This is equivalent to a ROMS directive with a single range without origin or length Use the ROMS directive when you want to Program large amounts of data into fixed size ROMs When you specify 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 directive to restrict the conversion to a certain segment or segments of the target address space The utility does not convert the data that falls outside of the ranges defined by the ROMS directive Sections can span range boundaries the utility splits them at the boundary into multiple ranges If a section falls completely outside any of the ranges you define th
358. le ref element specifies the source file where the object component originated reference Example B 3 Object Component List for the fl 4 Input File object component id oc 20 name text name load address 0xac00 load address run address 0xac00 run address lt size gt 0xc0 lt size gt input file ref idref fl 4 object component object component id oc 21 lt name gt data lt name gt lt load_address gt 0x80000000 lt load_address gt lt run_address gt 0x80000000 lt run_address gt size 0x0 size input file ref idref fl 4 object component object component id oc 22 lt name gt 5 5 gt 23116 lt load address 0x80000000 10ad address run address 0x80000000 run address size 0x0 size input file ref idref fl 4 object component 312 XML Link Information File Description SPNU118J August 2011 S oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Document Elements B 2 4 Logical Group List The lt logical_group_list gt section of the XML link information file is similar to the output section listing in a linker generated map file However the XML link information file contains a specification of GROUP and UNION output sections which are not represented in a map file There are three kinds of list items that can occur in a lt logical_group_list gt The
359. lem See Chapter 12 for more information about using C C headers in assembly source Use Substitution Symbols as Local Variables Var sym syms sym The var directive allows you to use substitution symbols as local variables within a macro With this directive you can define up to 32 local macro substitution 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 See Chapter 5 for information on macros Assembler Directives 141 Submit Documentation Feedback I I men BADE 0 9115 1 142 Assembler Directives SPNU 118J August 2011 TE I T Submit Documentation Feedback 1 efas men WWW conr TI 1 Chapter 5 IJ TEXAS SPNU118J August 2011 INSTRUMENTS Macro Description The ARM device assembler supports a macro language that enables you to create your own instructions This is especially useful when a program executes a particular task several times The macro language lets you Define your own macros and redefine existing macros Simplify long or complicated assembly code Access 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 15 Using Macross eet EPI 144 5 2 Def
360. llocation Using The HIGH Location Specifier The linker allocates output sections from low to high addresses within a designated memory range by default Alternatively you can cause the linker to allocate a section from high to low addresses within a memory range by using the HIGH location specifier in the SECTION directive declaration For example given this MEMORY directive MEMORY 1 RAM origin 0x0200 length 0x0800 FLASH origin 0x1100 length 0 VECTORS origin OxFFEO length 8 RESET origin OxFFFE length 0x0002 and an accompanying SECTIONS directive SECTIONS 1 bss gt RAM sysmem gt RAM Stack gt RAM HIGH The HIGH specifier used on the stack section allocation causes the linker to attempt to allocate stack into the higher addresses within the RAM memory range The bss and sysmem sections are allocated into the lower addresses within RAM Example 7 6 illustrates a portion of a map file that shows where the given sections are allocated within RAM for a typical program Example 7 6 Linker Allocation With the HIGH Specifier bss 0 00000200 00000270 UNINITIALIZED 00000200 0000011a rtsxxx lib defs obj bss 0000031a 00000088 trgdrv obj bss 000003a2 00000078 lowlev obj bss 0000041a 00000046 exit obj bss 00000460 00000008 memory obj bss 00000468 00000004 lock obj bss 0000046c 00000002 fopen obj bss 0000046e 00000002 hello obj bss
361. located to the symbol occurs on a specific memory bank boundary The bank offset value measures the number of bytes to offset from the alignment specified before assigning the symbol to that location Initialized sections directives text data and sect end the current section and tell the assembler to begin assembling into another section A usect or bss directive encountered in the current section is simply assembled and assembly continues in the current section Variables that can be located contiguously in memory can be defined in the same specified section to do so repeat the usect directive with the same section name and the subsequent symbol variable name For more information about sections see Chapter 2 This example uses the usect directive to define two uninitialized named sections var1 and var2 The symbol ptr points to the first byte reserved in the var1 section The symbol array points to the first byte in a block of 100 bytes reserved in var1 and dflag points to the first byte in a block of 50 bytes in var1 The symbol vec points to the first byte reserved in the var2 section Assembler Directives 139 Submit Documentation Feedback I I men YP Ceonmy I Directives Reference 140 Assembler Directives I TEXAS INSTRUMENTS www ti com Figure 4 8 shows how this example reserves space in two uninitialized sections var1 and var2 00 014 F2 OO i000 120 C1 4 CO
362. loop break endloop They can be nested within each other up to 32 levels deep The format of a conditional block is Af well defined expression elseif well defined expression else endif The elseif and else directives are optional in conditional assembly The elseif directive can be used more than once within a conditional assembly code block When elseif and else are omitted and when the if expression is false 0 the assembler continues to the code following the endif directive See Assemble Conditional Blocks for more information on the if elseif else endif directives The loop break endloop directives enable you to assemble a code block repeatedly The format of a repeatable block is loop well defined expression break well defined expression endloop The loop directive s optional well defined 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 See Assemble Conditional Blocks Repeatedly for more information on the loop break endloop directives The break directive and its expression are optional in repetitive assembly If the expression evaluates to false the loop continues The assembler breaks the loop when the break expression evaluates to true or when the break expression is omitted When the lo
363. lower16 bit et 330 C 7 Contents of Hex Output File uppert16 bitess enne nennen nnne nnne nnn 330 SPNU 118J August 2011 List of Figures 9 Submit Documentation Feedback I I men BADE 0 9115 1 10 List of Tables 3 1 ARM Assembler Options ps 3 2 Operators Used in Expressions Precedence pp 3 3 Expressions With Absolute and Relocatable Symbols sus 3 4 Built In Mathematical Functions esses HH 3 5 SYMDOL ADUE Ssss a a a ai 4 1 Directives That Define Sections 4 2 Directives That Initialize Values Data and Memory eere 4 3 Directives That Perform Alignment and Reserve 50806 7777 4 4 Directives That Change the Instruction Type pp 4 5 Directives That Format the Output Listing pp 4 6 Directives That Reference Other Files pp 4 7 Directives That Effect Symbol Linkage and Visibility es 4 8 Directives That Control Dynamic Symbol Visibility eee eeeesese 4 9 Directives That Enable Conditional Assembly pp 4 10 Directives That Define Union or Structure Types eee 4 11 Directives That Define Symbols HI 4 12 Directives That Define Common Data Sections
364. lt logical_group gt is the specification of a section or GROUP that contains a list of object components or logical group members Each lt logical_group gt element is given an id so that it may be referenced from other elements Each lt logical_group gt is a container element enclosing the following elements The lt name gt element names the logical group string The load address element specifies the load time address of the logical group constant The run address element specifies the run time address of the logical group constant The lt size gt element specifies the size of the logical group constant The contents element lists elements contained in this logical group container These elements refer to each of the member objects contained in this logical group The object component ref is an object component that is contained in this logical group reference The logical group ref is a logical group that is contained in this logical group reference The overlay is a special kind of logical group that represents a UNION or a set of objects that share the same memory space container Each overlay element is given an id so that it may be referenced from other elements like from an allocated space element in the placement map Each overlay contains the following elements The lt name gt element names the overlay string The run address element s
365. lude Syntax Description Example 1 88 1 TEXAS INSTRUMENTS www ti com Copy Source File copy filename include filename The copy and include directives tell the assembler to read source statements from a different file The statements that are assembled from a copy file are printed in the assembly listing The statements that are assembled from an included file are not printed in the assembly listing regardless of the number of list nolist directives assembled When a copy or include directive is assembled the assembler 1 Stops assembling statements in the current source file 2 Assembles the statements in the copied included file 3 Resumes assembling statements in the main source file starting with the statement that follows the copy or include directive The filename is a required parameter that names a source file It is enclosed in double quotes and must follow operating system conventions You can specify a full pathname for example 320tools file1 asm If you do not specify 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 include path assembler option 3 Any directories specified by the TMS470 A DIR environment variable 4 Any directories specified by the TMS470 C DIR environment variable For more information about the include path option and TMS470 A DIR see Section 3 4 For more inform
366. lue with the fill option The fill option is valid only when you use image otherwise it is ignored 11 9 3 Steps to Follow in Using Image Mode Step 1 Define the ranges of target memory with a ROMS directive See Section 11 4 Step 2 Invoke the hex conversion utility with the image option You can optionally use the zero option to reset the address origin to 0 for each output file If you do not specify a fill value with the ROMS directive and you want a value other than the default of 0 use the fill option 11 10 Controlling the ROM Device Address The hex conversion utility output address field corresponds to the ROM device address The EPROM programmer burns the data into the location specified by the hex conversion utility output file address field The hex conversion utility offers some mechanisms to control the starting address in ROM of each section However many EPROM programmers offer direct control of the location in ROM in which the data is burned The address field of the hex conversion utility output file is controlled by the following items which are listed from low to high priority 1 The linker command file By default the address field of the hex conversion utility output file is the load address as given in the linker command file 2 The paddr parameter of the SECTIONS directive When the paddr parameter is specified for a section the hex conversion utility bypasses the section load address and places th
367. ly branches to local labels are not expanded in case the branch s offset is out of range SPNU118J August 2011 Assembler Description 45 Submit Documentation Feedback Se oF T www BD EIC conr TI 1 TEXAS INSTRUMENTS Symbols www ti com 3 8 8 Symbolic Constants Symbols can be set to constant values By using constants you can equate meaningful names with constant values The set and struct tag endstruct directives enable you to set constants to symbolic names Symbolic constants cannot be redefined The following example shows how these directives can be used K set 1024 constant definitions maxbuf set 2 K item struct item structure definition int value constant offsets value 0 int delta constant offsets delta 1 i len endstruct array tag item array declaration bss array i len K The assembler also has several predefined symbolic constants these are discussed in Section 3 8 5 3 8 4 Defining Symbolic Constants asm define Option The asm define option equates a constant value or a string with a symbol The symbol can then be used in place of a value in assembly source The format of the asm define option is as follows cl470 asm definezname zvalue The name is the name of the symbol you want to define The value is the constant or string value you want to assign to the symbol If the value is omitted the symbol is set to 1 If you want to define a quoted string and keep the
368. ly more than one table operator to it Consider the link command file excerpt in Example 7 19 Example 7 19 Linker Command File to Manage Object Components SECTIONS UNION first al obj text bl obj text cl obj text load EMEM run PMEM table BINIT table first ctbl second a2 0bj text b2 0bj text load EMEM run PMEM table second ctbl extra load EMEM run PMEM table BINIT In this example the output sections first and extra are copied from external memory EMEM into program memory PMEM at boot time while processing the BINIT copy table After the application has started executing its main thread it can then manage the contents of the overlay using the two overlay copy tables named _first_ctbl and _second_ctbl 232 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Generated Copy Tables 7 8 8 Compression Support When automatically generating copy tables the linker provides a way to compress the load space data This can reduce the read only memory foot print This compressed data can be decompressed while copying the data from load space to run space You can specify compression in two ways The linker command line option copy_compression compression_kind can be used to apply the specified compression to any output section that has a table operator applied to it
369. m Expressions 3 9 3 3 9 4 3 9 5 Well Defined Expressions Some assembler directives require well defined expressions as operands Well defined expressions contain only symbols or assembly time constants that are defined before they are encountered in the expression The evaluation of a well defined expression must be absolute This is an example of a well defined expression 1000h4X where X was previously defined as an absolute symbol Conditional Expressions The assembler supports relational operators that can be used in any expression they are especially useful for conditional assembly Relational operators include the following Equal to Not equal to lt Less than lt Less than or equal to gt Greater than gt Greater than or equal to Conditional expressions evaluate to 1 if true and 0 if false and can be used only on operands of equivalent types for example absolute value compared to absolute value but not absolute value compared to relocatable value Relocatable Symbols and Legal Expressions All legal expressions can be reduced to one of two forms relocatable symbol absolute symbol or absolute value Unary operators can be applied only to absolute values they cannot be applied to relocatable symbols Expressions that cannot be reduced to contain only one relocatable symbol are illegal Table 3 3 summarizes valid operations on absolute relocatable and external symbols An expression cannot contain
370. map Option pp 189 7 4 31 Generate Far Call Trampolines trampolines Option eee 189 7 4 32 Introduce an Unresolved Symbol undef sym Option pp 191 7 4 33 Display a Message When an Undefined Output Section Is Created warn sections Option 192 7 4 84 Generate XML Link Information File xml link info Option eere 192 7 4 35 Zero Initialization zero init Option co 192 7 5 193 7 5 1 Reserved Names in Linker Command Files pp 194 7 5 2 Constants in Linker Command Files et 194 75 3 The MEMORY Directive ote nrme itm cbe ROO ca pA Eae ER ca EEEE DORMI AER UEM P CE VENERE ANS 195 7 5 4 The SEG 0 197 7 5 5 Specifying a Section s Run Time Address ppp 211 7 5 6 Using UNION and GROUP Statements pp 213 SPNU118J August 2011 Contents 5 Submit Documentation Feedback I I men YP Ceonmy I IJ TEXAS INSTRUMENTS www ti com 7 5 7 Special Section Types DSECT COPY NOLOAD and NOINIT 7 217 7 5 8 Assigning Symbols at Link TIME sesser a nme h emma n nd vinnie via uentus Rex a a 218 759 Greating and Filing Holes svi i aaa a 223 7 6 bjeet sage ee MN DEM 226 7 7 Default Allocation Algorithm 227 7 7 1 How the Allocation Algorithm Creates Output Sections ee 227 7 7 2 Reducing Memory Fragmentation n nmm meme
371. mbers of the UNION table2 contains entries for section1 and section2 The order of the entries in table2 is unspecified 7 9 4 Interface The CRC generation function uses a mechanism similar to the copy table functionality Using the syntax shown above in the linker command file allows specification of code data sections that have CRC values computed and stored in the run time image This section describes the table data structures created by the linker and how to access this information from application code The CRC tables contain entries as detailed in the run time support header file crc tbl h as illustrated in Figure 7 7 SPNU 118J August 2011 Linker Description 243 Submit Documentation Feedback I I men BADE 0 9115 1 Linker Generated CRC Tables Figure 7 7 CRC TABLE Conceptual Model table name such as linker generated symbol my crc table for a1 rec size 8 num recs 2 recs I TEXAS INSTRUMENTS www ti com The crc tbl h header file is included in Example 7 29 This file specifies the C structures created by the linker to manage CRC information It also includes the specifications of the supported CRC algorithms A full discussion of CRC algorithms is beyond the scope of this document and the interested reader should consult the referenced document for a description of the fields shown in the table The following fields are relevant to this document
372. mbol and its address sorted by symbol name A table showing each external symbol and its address sorted by symbol address SPNU 118J August 2011 Linker Description 185 Submit Documentation Feedback I I men gt 9115 1 I TEXAS INSTRUMENTS Linker Options www ti com The following example links file1 obj and file2 obj and creates a map file called map out cl470 run linker filel obj file2 obj map_file map out Example 7 32 shows an example of a map file 7 4 19 Managing Map File Contents mapfile_contents Option 186 The mapfile_contents option assists with managing the content of linker generated map files The syntax for the mapfile_contents option is mapfile_contents filter filter When the map file option is specified the linker produces a map file containing information about memory usage placement information about sections that were created during a link details about linker generated copy tables and symbol values The new mapfile contents option provides a mechanism for you to control what information is included in or excluded from a map file When you specify mapfile contents help from the command line a help screen listing available filter options is displayed The following filter options are available Attribute Description Default State crctables CRC tables On copytables Copy tables On entry Entry point On load addr Display load addresses Off memory Memory ranges
373. mbol functions used with subscripted substitution symbols In Example 5 8 subscripted substitution symbols redefine the ADD instruction so that it handles short immediate values In Example 5 9 the subscripted substitution symbol is used to find a substring 1 beginning at position start in the string strg2 The position of the substring strg1 is assigned to the substitution symbol pos Macro Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Macro Parameters Substitution Symbols Example 5 8 Using Subscripted Substitution Symbols to Redefine an Instruction ADDX macro dst imm Var TMP asg imm 1 TMP if symcmp TMP 0 ADD dst dst imm else emsg Bad Macro Parameter endif endm ADDX R9 4100 macro call ADDX R9 R8 macro call Example 5 9 Using Subscripted Substitution Symbols to Find Substrings substr macro start strgl strg2 pos Var LEN1 LEN2 I TMP it symlen start 0 eval 1 start endif eval 0 pos eval 7 eval symlen strgl LEN1 eval symlen strg2 LEN2 loop break I LEN2 LEN1 1 asg istrg2 I LEN1 TMP eval i pos break else eval I lyi endif endloop endm asg 0 pos asg arl ar2 ar3 ar4 regs substr 1 ar2 regs pos word pos 5 3 6 Substitution Symbols as Local Variables in Macros If you want to use substitution symbols as local variables within
374. mes These are specified in a command file in exactly the same manner as on the command line ROMS directive The ROMS directive defines the physical memory configuration of your system as a list of address range parameters See Section 11 4 SECTIONS directive The hex conversion utility SECTIONS directive specifies which sections from the object file are selected See Section 11 5 Comments You can add comments to your command file by using the and delimiters For example This is a comment To invoke the utility and use the options you defined in a command file enter hex470 command filename You can also specify other options and files on the command line For example you could invoke the utility by using both a command file and command line options hex470 firmware cmd map firmware mxp The order in which these options and filenames appear is not important The utility reads all input from the command line and all information from the command file before starting the conversion process However if you are using the q option it must appear as the first option on the command line or in a command file The help option displays the syntax for invoking the compiler and lists available options If the help option is followed by another option or phrase detailed information about the option or phrase is displayed For example to see information about options associated with generating a boot table use help bo
375. monics to prevent the conversion from corrupting the basic assembly environment To remove a macro from the assembly scope undef can be used following the cdecls that defines it see Section 12 4 3 The macro functionality of stringize operator is only useful within functional macros Since functional macros are not supported by this process is not supported either The concatenation operator is only useful in a functional context but can be used degenerately to concatenate two strings and so it is supported in that context 12 2 9 The undef Directive Symbols undefined using the undef directive before the end of the cdecls are not converted to assembly 12 2 10 Enumerations Enumeration members are converted to enum elements in assembly For example enum state ACTIVE 0x10 SLEEPING 0x01 INTERRUPT 0x100 POWEROFF LAST is converted to the following assembly code state senum ACTIVE emember 16 SLEEPING emember 1 NTERRUPT emember 256 POWEROFF emember 257 LAST emember 258 endenum The members are used via the pseudo scoping created by the enum directive The usage is similar to that for accessing structure members enum name member This pseudo scoping is used to prevent enumeration member names from corrupting other symbols within the assembly environment 12 2 11 C Strings 300 Because C string escapes such as n and X are not converted to hex characters 0 0 and 0x09 until their use in a string
376. mory Widths Figure 11 4 Data Memory and ROM Widths Source file word OAABBCCDDh word 011223344h Object file data assumed to be in big endian format AA 88 CC DD 11 Memory widths variable pe peces o Pd N S N memwidth 32 memwidth 10 memwidth 8 AABBCCDD 11223344 Output files romwidth 8 outfile file bO DD 44 outfile file b CC 33 e outfile file b2 BB 22 e e e outfile fileb3 AA 1 romwidth 16 outfile fileswrd AABBCCDD11223344 ye ee 77 N romwidth 8 Ed outfile fileb0 BB DD 22 44 eee outfile file b1 AA CC 11 3 coe romwidth 8 outfile file byt AABBCCDD11223344 eee Hex Conversion Utility Description 281 www oF Eeconzy TI I TEXAS INSTRUMENTS The ROMS Directive www ti com 11 4 The ROMS Directive 282 The ROMS directive specifies the physical memory configuration of your system as a list of address range parameters Each address range produces one set of files containing the hex conversion utility output data that corresponds to that address range Each file can be used to program one single ROM device The ROMS directive is similar to the MEMORY directive of the ARM linker both define the memory map of the target address space Each line entry in the ROMS directive defines a specific address range The general syntax is ROMS romname origin value length
377. mory at address STR R14 R1 R3 LSL 2 Form address by adding the value in R3 shifted left by 2 to the value in R1 Store from R14 to memory at address LDR R1 R1 45 Load from address in R1 into R1 then add 5 to the address SPNU 118J August 2011 Assembler Description 39 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Source Statement Format www ti com STR R2 Rl R5 Store value in R2 in the address in R1 then add the value in R5 to the address 40 Assembler Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Source Statement Format e I suffix write back to register If you use the sign as a suffix the assembler writes the computed address back to the base register Write back to register is used only with the indirect addressing mode syntax This is an example of an instruction using the write back to register suffix LDR R1 R4 4 Form address by adding the value in R4 to 4 Load from this address into 1 then replace the value in R4 with the address suffix set S bit If you use the sign as a suffix the assembler sets the S bit The resulting action depends on the type of instruction being executed and whether R15 is in the transfer list For more information see the LDM and STM instructions in the TMS470H1x User s Guide LDMIA SP 4124 8211 21514 Load register
378. mysect4 load SLOW_MEM For this example the linker performs the following allocations The four sections mysect1 mysect2 mysect3 mysect4 are assigned unique non overlapping load addresses The name you defined with the label directive is used in the SLOW_MEM memory region This assignment is determined by the particular load allocations given for each section SPNU118J August 2011 Linker Description 215 Submit Documentation Feedback I I men YP 0 9115 1 I TEXAS INSTRUMENTS Linker Command Files www ti com Sections mysect1 and mysect2 are assigned the same run address in FAST MEM Sections mysect3 and mysect4 are assigned the same run address in FAST MEM The run addresses of mysect1 mysect2 and mysect3 mysect4 are allocated contiguously as directed by the GROUP statement subject to alignment and blocking restrictions To refer to groups and unions linker diagnostic messages use the notation GROUP n UNION 7n In this notation n is a sequential number beginning at 1 that represents the lexical ordering of the group or union in the linker control file without regard to nesting Groups and unions each have their own counter 7 5 6 4 Checking the Consistency of Allocators The linker checks the consistency of load and run allocations specified for unions groups and sections The following rules are used Run allocations are only allowed for top level sections groups or unions section
379. n 181 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Linker Options www ti com 3 If TMS470 C DIR is not set it searches directories named with the assembler s TMS470 A DIR environment variable 4 lt searches the current directory 7 4 16 1 Name an Alternate Library Directory search path Option The search path option names an alternate directory that contains input files The search path option s short form is 1 The syntax for this option is search pathz pathname The pathname names a directory that contains input files When the linker is searching for input files named with the library option it searches through directories named with search path first Each search path option specifies only one directory but you can have several search path options per invocation When you use the search path option to name an alternate directory it must precede any library option used on the command line or in a command file For example assume that there are two archive libraries called r lib and lib2 lib that reside in Id and 2 directories The table below shows the directories that r lib and lib2 lib reside in how to set environment variable and how to use both libraries during a link Select the row for your operating system Operating System Enter 61470 run linker fl obj f2 0bj search path ld search_path 1d2 UNIX Bourne shell library r lib library lib2 1ib
380. n 8 fill Oxff gt PMEM The fill value assumed by the linker is OxOOff and mytext will then have the following contents addr content 0000 0x1234 0002 0x1234 0004 0x1234 0006 Oxffff 0008 5 0008 5 If the palign operator is applied to an uninitialized section then the size of the section is bumped to the appropriate boundary as needed but any padding created is not initialized The palign operator can also take a parameter of power2 This parameter tells the linker to add padding to increase the section s size to the next power of two boundary In addition the section is aligned on that power of 2 as well For example consider the following section specification nytext palign power2 gt PMEM Assume that the size of the mytext section is 120 bytes and PMEM starts at address 0x10020 After applying the palign power2 operator the mytext output section will have the following properties name addr size align SPNU118J August 2011 Linker Description 203 Submit Documentation Feedback jn I I men YP 0 9115 1 I TEXAS INSTRUMENTS Linker Command Files www ti com mytext 0x00010080 0x80 128 204 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Linker Command Files 7 5 4 3 Specifying Input Sections An input section specification identifies the sections from input files that are combined to form an output
381. n Standard Code for Information Interchange a standard computer code for representing and exchanging alphanumeric information assembler A software program that creates a machine language program from a source file that contains assembly language instructions directives and macro definitions The assembler substitutes absolute operation codes for symbolic operation codes and absolute or relocatable addresses for symbolic addresses assembly time constant A symbol that is assigned a constant value with the set directive big endian An addressing protocol in which bytes are numbered from left to right within a word More significant bytes in a word have lower numbered addresses Endian ordering is hardware specific and is determined at reset See also ittle endian binding A process in which you specify a distinct address for an output section or a symbol BIS Bit instruction set block A set of statements that are grouped together within braces and treated as an entity bss section One of the default object file sections You use the assembler bss directive to reserve a specified amount of space in the memory map that you can use later for storing data The bss section is uninitialized byte Per ANSI ISO C the smallest addressable unit that can hold a character C C compiler A software program that translates C source statements into assembly language source statements COFF Common object file format a
382. n about the COFF object file format The ELF object files generated by the assembler and linker conform to the December 17 2003 snapshot of the System V generic ABI or gABI This specification is currently maintained by SCO Introduction to Object Modules SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 Chapter 3 IJ TEXAS SPNU118J August 2011 INSTRUMENTS Assembler Description The ARM assembler translates assembly language source files into machine language object files These files are in object modules which are discussed in Chapter 2 Source files can contain the following assembly language elements Assembler directives described in Chapter 4 Macro directives described in Chapter 5 Assembly language instructions described in the TMS470R1x User s Guide Topic Page 31 Assembler 32 3 2 The Assembler s Role in the Software Development Flow 33 3 3 Invoking the Assembler So eee EE EAEE E E EAEE eMe iem em ns 34 3 4 Naming Alternate Directories for Assembler Input pp 35 35 S Source Statement 38 3 6 c Gonstants 55e dee AT 42 3 CharactenStringss 44 3 8 Symbols 9 44 319 20 3 10 eee IEEE EET EIER EET IEIS 53 3 11 Unified Assembly Language Syntax Support pp 54 3 02 Sourcejlistings neruos der eee METER ER STE TEE EE EI E E EDO 55 3 13 Debugging 5 58 3 14 Cross Reference 6
383. n column 1 of a source statement A label can contain up to 128 alphanumeric characters A Z a z 0 9 and Labels are case sensitive except when the syms ignore case option is used and the first character cannot be a number A label can be followed by a colon The colon is not treated as part of the label name If you do not use a label the first character position must contain a blank a semicolon or an asterisk When you use a label its value is the current value of the SPC The label points to the statement it is associated with For example if you use the word directive to initialize several words a label points to the first word In the following example the label Start has the value 40h 9 Assume some code was assembled 10 00000040 0000000A Start word 0Ah 3 7 00000044 00000003 00000048 00000007 A label on a line by itself is a valid statement The label assigns the current value of the section program counter to the label this is equivalent to the following directive statement label equ provides the current value of the SPC When a label appears on a line by itself it points to the instruction on the next line the SPC is not incremented 1 00000000 Here 2 00000000 00000003 word 3 If you do not use a label the character in column 1 must be a blank an asterisk or a semicolon Assembler Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTR
384. n the format shown in Figure 4 7 Figure 4 7 Single Precision Floating Point Format ISEEEEEEEEMMMMMMMMMMMMMMMMMMMMMMM 31 23 0 exponent 127 value 1 x 1 0 mantissa x 2 Legend S sign 1 bit E exponent 8 bit biased M mantissa 23 bit fraction When you use float in a struct endstruct sequence float defines a member s size it does not initialize memory For more information see the struct endstruct tag topic Example Following are examples of the float directive 1 00000000 E9045951 float 1 0e25 2 00000004 40400000 float 3 3 00000008 42F60000 float 3 102 Assembler Directives SPNU 118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com global def ref Syntax Description Example SPNU118J August 2011 Submit Documentation Feedback Directives Reference Identify Global Symbols global symbol symbol def symbol symbol ref symbol symbol Three directives identify global symbols that are defined externally or can be referenced externally The def directive identifies a symbol that is defined in the current module and can be accessed by other files The assembler places this symbol in the symbol table The ref directive identifies a symbol that is used in the current module but is defined in another module The linker resolves this symbol s definition at link time The global dire
385. nE KEREI RENSE 267 10 1 Invoking the Object File Display Utility sseeseeeeen HH 268 10 2 Invoking the Disassembler pt 269 10 3 Invoking the Name Utility 7 27 10 4 Invoking sd O E 272 Hex Conversion Utility Description eee eee nee 273 11 1 The Hex Conversion Utility s Role in the Software Development Flow eene 274 11 2 Invoking the Hex Conversion Utility ne eee eee e eee eee ee knit 275 11 2 1 Invoking the Hex Conversion Utility From the Command Line eese 275 Contents SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com 11 2 2 Invoking the Hex Conversion Utility With a Command File esee 277 11 3 Understanding Memory 278 11 3 1 El 278 11 3 2 Specifying the Memory Width 4 279 11 3 3 Partitioning Data Into 1 1 1 1 1 1 0 000000 280 11 4 The ROMS Directive 2 2 282 11 4 1 When to Use the ROMS Directive ee 283 11 4 2 An Example of the ROMS Directive e II mn n ne nen nnn 283 TS The JSEGTIONS JBIFGCIVe 0 M RESTE 285 11 6 The Load Image Format load image Option pt 286 11 6 1 Load Image Section ee 286 11 6 2 Load Image Characteristics nn 286 11 7 Excluding a Specified Section oo 287
386. nce germany 206 Linker Description SPNU118J August 2011 E oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com therest europe spain italy malta Linker Command Files This SECTIONS specification allocates the input sections as indicated in the comments SECTIONS islands europe europe europe europe italy spain NOTE europe north iceland north finland north central europe south malta 11 central france malta iceland finland norway Sweden germany france denmark 51 2 go into a linker generated output section europe Upward Compatibility of Multi Level Subsections Existing linker commands that use the existing single level subsection features and which do not contain section names containing multiple colon characters continue to behave as before However if section names in a link command file or in the input sections supplied to the linker contain multiple colon characters some change in behavior could be possible You should carefully consider the impact of the new rules for multiple levels to see if it affects a particular system link 7 5 4 5 Specifying Library or Archive Members as Input to Output Sections You can specify one or more members of an object library or archive for input to an output section Consider this SECT
387. nctions that were removed by the linker to file Section 7 4 13 fname mapfile contents Controls the information that appears in the map file Section 7 4 19 relocatable r Produces a nonexecutable relocatable output module Section 7 4 2 2 rom Create a ROM object run_abs abs Produces an absolute listing file Section 7 4 26 xml link info Generates a well formed XML file containing detailed information about the result of a link Section 7 4 34 Table 7 6 Symbol Management Options Summary Option Alias Description Section entry point e Defines a global symbol that specifies the primary entry point for the output Section 7 4 11 module globalize Changes the symbol linkage to global for symbols that match pattern Section 7 4 17 hide Hides global symbols that match pattern Section 7 4 15 localize Changes the symbol linkage to local for symbols that match pattern Section 7 4 17 make global g Makes symbol global overrides h Section 7 4 17 2 make static h Makes all global symbols static Section 7 4 17 1 no sym merge b Disables merge of symbolic debugging information in COFF object files Section 7 4 21 no sym table S Strips symbol table information and line number entries from the output Section 7 4 22 module retain Retains a list of sections that otherwise would be discarded Section 7 4 25 scan_libraries scanlibs Scans all libraries for duplicate symbol definitions Section 7 4 27 symbol map Map
388. nd field An element can also be a complete 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 The expr is an optional expression for the number of elements described This value defaults to 1 A string element is considered to be one byte in size and a field element is one bit The size is an optional label for the total size of the union Assembler Directives 137 Submit Documentation Feedback Se oF T www BD FEe cenr TI I TEXAS INSTRUMENTS Directives Reference www ti com Directives That Can Appear in a union endunion Sequence NOTE The only directives that can appear in a union endunion sequence are element descriptors structure and union tags and conditional assembly directives Empty structures are illegal These examples show unions with and without tags Example 1 1 global employid 2 xample union utag 3 0000 ival word memberl int 4 0000 fval float member2 float 5 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 utag 3 0000 x long memberl long 4 0000 y float member2 float 5 0000 2 word member3 word 6 0002 size u
389. ng name with a set directive in the case of a numeric value or with an asg directive otherwise If value is omitted the symbol is set to 1 See Section 3 8 4 asm dependency apd Performs preprocessing for assembly files but instead of writing preprocessed output writes a list of dependency lines suitable for input to a standard make utility The list is written to a file with the same name as the source file but with a ppa extension asm includes api Performs preprocessing for assembly files but instead of writing preprocessed output writes a list of files included with the include directive The list is written to a file with the same name as the source file but with a ppa extension asm listing al Produces a listing file with the same name as the input file with a Ist extension asm_undefine name au Undefines the predefined constant name which overrides any asm_define options for the specified constant cmd_file filename Appends the contents of a file to the command line You can use this option to avoid limitations on command line length imposed by the host operating system Use an asterisk or a semicolon or at the beginning of a line in the command file to include comments Comments that begin in any other column must begin with a semicolon Within the command file filenames or option parameters containing embedded spaces or hyphens must be surrounded with quotation marks For example this file asm co
390. ns a directive can also contain a label and a comment Labels begin in the first column only labels and comments can appear in the first column and comments must be preceded by a semicolon or an asterisk if the comment is the only element in the line To improve readability labels and comments are not shown as part of the directive syntax Table 4 1 Directives That Define Sections Mnemonic and Syntax Description See bss symbol size in 0105 alignment Reserves size bytes in the bss uninitialized data section bss topic bank offset Enables conditional linking for the current or specified section clink topic data Assembles into the data initialized data section data topic retain Instructs the linker to include the current or specified section in the retain topic linked output file regardless of whether the section is referenced or not sect section name Assembles into a named initialized section sect topic text Assembles into the text executable code section text topic symbol usect section name size in bytes Reserves size bytes in a named uninitialized section usect topic alignment bank offset Table 4 2 Directives That Initialize Values Data and Memory Mnemonic and Syntax Description See byte value value Initializes one or more successive bytes in the current section byte topic char value value Initializes one or more successive bytes in
391. nt variables see Section 7 4 16 There are two exceptions relative pathnames such as name always search the current directory and absolute pathnames such as usr tools name bypass search paths entirely The linker has the standard built in definitions for the macros FILE DATE and TIME lt does not however have the compiler specific options for the target TMS470 version COMPILER VERSION run time model and so on SPNU 118J August 2011 Linker Description 179 Submit Documentation Feedback I I men BADE 0 9115 1 I TEXAS INSTRUMENTS Linker Options www ti com 7 4 11 Define an Entry Point entry_point Option The memory address at which a program begins executing is called the entry point When a loader loads a program into target memory the program counter PC must be initialized to the entry point the PC then points to the beginning of the program The linker can assign one of four values to the entry point These values are listed below in the order in which the linker tries to use them If you use one of the first three values it must be an external symbol in the symbol table The value specified by the entry point option The syntax is entry pointz global symbol where global symbol defines the entry point and must be defined as an external symbol of the input files The external symbol name of C or 6 objects may be different than the name as declared in the
392. num OK 6 00000010 00000100 failval int status enum FAILED 7 if Sdefined WANT ID 8 00000014 0000004A id cstring NAME 00000015 0000006F 00000016 00000068 00000017 0000006E 00000018 0000000A 00000019 00000000 9 endif SPNU118J August 2011 Assembler Directives 85 Submit Documentation Feedback Se oF T www BD FEe cenr TI Directives Reference clink retain Syntax Description Example 00000000 00000000 00000004 00000008 00000000 00000000 00000004 00000008 0 i WMATA 00 00 1 TEXAS INSTRUMENTS www ti com Control Whether to Conditionally Leave Section Out of Object Module Output section name retain section name The clink directive enables conditional linking by telling the linker to leave a section out of the final object module output of the linker if there are no references found to any symbol in that section The clink directive can be applied to initialized or uninitialized sections The section name identifies the section If the directive is used without a section name it applies to the current initialized section If the directive is applied to an uninitialized section the section name is required The section name must be enclosed in double quotes A section name can contain a subsection name in the form section name subsection name The clink directive is useful only with the COFF object f
393. ny such use of TI products which TI has not designated as military grade is solely at the Buyer s risk and that they are solely responsible for compliance with all legal and regulatory requirements in connection with such use TI products are neither designed nor intended for use in automotive applications or environments unless the specific TI products are designated by TI as compliant with ISO TS 16949 requirements Buyers acknowledge and agree that if they use any non designated products in automotive applications TI will not be responsible for any failure to meet such requirements Following are URLs where you can obtain information on other Texas Instruments products and application solutions Products Audio Amplifiers Data Converters DLPG Products DSP Clocks and Timers Interface Logic Power Mgmt Microcontrollers RFID RF IF and ZigBee Solutions www ti com audio amplifier ti com dataconverter ti com www dlp com www ti com clocks interface ti com logic ti com power ti com microcontroller ti com www ti rfid com www ti com lprf Applications Communications and Telecom Computers and Peripherals Consumer Electronics Energy and Lighting Industrial Medical Security Space Avionics and Defense Transportation and Automotive Video and Imaging Wireless TI E2E Community Home Page www ti com communications www ti com computers www ti com consumer apps www ti com energy www ti c
394. o X to patch the branch instruction in the object code EAFFFFFB B X becomes EA000000 Each section in an object module has a table of relocation entries The table contains one relocation entry for each relocatable reference in the section The linker usually removes relocation entries after it uses them This prevents the output file from being relocated again if it is relinked or when it is loaded A file that contains no relocation entries is an absolute file all its addresses are absolute addresses If you want the linker to retain relocation entries invoke the linker with the relocatable option see Section 7 4 2 2 Run Time Relocation At times you may want to load code into one area of memory and run it in another For example you may have performance critical code in an external memory based system The code must be loaded into external memory but it would run faster in internal memory The linker provides a simple way to handle this Using the SECTIONS directive you can optionally direct the linker to allocate a section twice first to set its load address and again to set its run address Use the load keyword for the load address and the run keyword for the run address The load address determines where a loader places the raw data for the section Any references to the section such as references to labels in it refer to its run address The application must copy the section from its load address to its run address before t
395. o memory at the section s specified starting address The text and data sections always have raw data if anything was assembled into them Named sections defined with the sect assembler directive also have raw data By default the bss section see Reserve Space in the bss Section and sections defined with the usect directive see Reserve Uninitialized Space have no raw data they are uninitialized They occupy space in the memory map but have no actual contents Uninitialized sections typically reserve space in fast external memory for variables In the object file an uninitialized section has a normal section header and can have symbols defined in it no memory image however is stored in the section 7 5 9 2 Creating Holes You can create a hole in an initialized output section A hole is created when you force the linker to leave extra space between input sections within an output section When such a hole is created the linker must supply raw data for the hole Holes can be created only within output sections Space can exist between output sections but such space is not a hole To fill the space between output sections see Section 7 5 3 2 To create a hole in an output section you must use a special type of linker assignment statement within an output section definition The assignment statement modifies the SPC denoted by by adding to it assigning a greater value to it or aligning it on an address boundary The operators e
396. odel Linker Options 250 1 TEXAS INSTRUMENTS www ti com The following list outlines what happens when you invoke the linker with the ram_model or rom_model option The symbol _c_int00 is defined as the program entry point The 6 int00 symbol is the start of the C boot routine in boot obj referencing c intOO ensures that boot obj is automatically linked in from the appropriate run time support library The cinit output section is padded with a termination record to designate to the boot routine autoinitialize at run time or the loader initialize at load time when to stop reading the initialization tables When you initialize at load time xram model option The linker sets cinit to 1 This indicates that the initialization tables are not in memory so no initialization is performed at run time The STYP COPY flag 0010h is set in the cinit section header STYP COPY is the special attribute that tells the loader to perform initialization directly and not to load the cinit section into memory The linker does not allocate space in memory for the cinit section When you autoinitialize at run time rom model option the linker defines cinit as the starting address of the cinit section The C boot routine uses this symbol as the starting point for autoinitialization Linker Description www oF Eeconzy TI SPNU118J August 2011 Submit Documentation Feedback 1 TEXAS INSTRUMENTS www ti com
397. oduct is not necessarily performed TI assumes no liability for applications assistance or customer product design Customers are responsible for their products and applications using Tl components To minimize the risks associated with customer products and applications customers should provide adequate design and operating safeguards TI does not warrant or represent that any license either express or implied is granted under any TI patent right copyright mask work right or other TI intellectual property right relating to any combination machine or process in which TI products or services are used Information published by TI regarding third party products or services does not constitute a license from TI to use such products or services or a warranty or endorsement thereof Use of such information may require a license from a third party under the patents or other intellectual property of the third party or a license from TI under the patents or other intellectual property of TI Reproduction of TI information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompanied by all associated warranties conditions limitations and notices Reproduction of this information with alteration is an unfair and deceptive business practice TI is not responsible or liable for such altered documentation Information of third parties may be subject to additional restrictions Resale of TI products or servic
398. om industrial www ti com medical www ti com security www ti com space avionics defense www ti com automotive www ti com video www ti com wireless apps Mailing Address Texas Instruments Post Office Box 655303 Dallas Texas 75265 Copyright 2011 Texas Instruments Incorporated www BDTIC com TI
399. on Section cinit compression Specifies the type of compression to apply to the c auto initialization data Section 7 4 5 default is rle compress dwarf Aggressively reduces the size of DWARF information from input object files Section 7 4 6 compression Compresses data copied by linker copy tables Section 7 4 5 unused section elimination Eliminates sections that are not needed in the executable module on by default Table 7 9 Miscellaneous Options Summary Option Alias Description Section disable clink j Disables conditional linking of COFF object modules linker_help help Displays information about syntax and available options minimize trampolines preferred order strict compatibility trampoline min spacing zero init Places sections to minimize number of far trampolines required Section 7 4 31 3 Prioritizes placement of functions Performs more conservative and rigorous compatibility checking of input object Section 7 4 29 files When trampoline reservations are spaced more closely than the specified limit Section 7 4 31 4 tries to make them adjacent Controls preinitialization of uninitialized variables Default is on Section 7 4 35 7 4 1 7 4 2 Wild Cards in File Section and Symbol Patterns The linker allows file section and symbol names to be specified using the asterisk and question mark wild cards Using matches any number of characters and using matches a single cha
400. on information and line number information are not placed in the output module The linker allocates space for the section and it appears in the memory map listing ANOINIT section is not C auto initialized by the linker It is your responsibility to initialize this section as needed SPNU 118J August 2011 Linker Description 217 Submit Documentation Feedback I I men BADE 0 9115 1 I TEXAS INSTRUMENTS Linker Command Files www ti com 7 5 8 Assigning Symbols at Link Time 7 5 8 1 Linker assignment statements allow you to define external global symbols and assign values to them at link time You can use this feature to initialize a variable or pointer to an allocation dependent value Syntax of Assignment Statements The syntax of assignment statements in the linker is similar to that of assignment statements in the C language symbol expression assigns the value of expression to symbol symbol expression adds the value of expression to symbol symbol expression subtracts the value of expression from symbol symbol t expression multiplies symbol by expression symbol expression divides symbol by expression The symbol should be defined 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 Section 7 5 8 3 Assignment statements must terminate with a semicolon The linker processes assignment statements after it
401. on that the assembler evaluates and treats as a 16 bit signed or unsigned number Acharacter string enclosed in double quotes Each character in a string represents a separate value and is stored alone in the least significant eight bits of a 16 bit field which is padded with Os The assembler truncates values greater than 16 bits If you use a label with half or short it points to the location where the assembler places the first byte These directives perform a halfword 16 bit alignment before data is written to the section This guarantees that data resides on a 16 bit boundary When you use half or short in a struct endstruct sequence they define a member s size they do not initialize memory For more information see the struct endstruct tag topic In this example half is used to place 16 bit values 10 1 abc and a into consecutive halfwords in memory short is used to place 16 bit values 8 3 def and b into consecutive halfwords in memory The label STRN has the value 100ch which is the location of the first initialized halfword for short 1 00000000 Space 100 16 2 00001000 000A half 10 2 abo a 00001002 FFFF 00001004 0061 00001006 0062 00001008 0063 0000100a 0061 3 0000100c 0008 STRN short 8 3 def p 0000100e FFFD 00001010 0064 00001012 0065 00001014 0066 00001016 0062 SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRU
402. one in the least significant eight bits of a 32 bit field which is padded with Os A value can be either an absolute or a relocatable expression If an expression is relocatable the assembler generates a relocation entry that refers to the appropriate symbol the linker can then correctly patch relocate the reference This allows you to initialize memory with pointers to variables or labels If you use a label with these directives 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 See the struct endstruct tag topic This example uses the int directive to initialize words 1 00000000 2 00000000 3 00000080 4 00000074 5 00000078 0000007c 00000080 00000084 00000088 0000008c 00000090 00000094 E3A00056 0000000A 00000080 FFFFFFFF 00000084 00000074 00000061 00000062 00000063 This example shows how the the first word that is reserved 1 00000000 00000004 00000008 0000000c 2 00000010 00000014 3 00000018 0000ABCD 00000141 00000067 0000006F 00000000 AABBCCDD INST 2 DAT2 Space 73h bss PAGE 128 bss SYMPTR 4 MOV RO 056h int 10 SYMPTR 1 35 a INST abc long long long directive initializes words The symbol DAT1 points to OABCDh A 100h g DAT1 OAABBCCDDh In this example the word directive is used to initialize words
403. onfigure system memory by defining and creating a memory model that you design Two powerful directives MEMORY and SECTIONS allow you to Allocate sections into specific areas of memory Combine object file sections Define or redefine global symbols at link time 170 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com The Linkers Role in the Software Development Flow 7 2 The Linker s Role in the Software Development Flow Figure 7 1 illustrates the linker s role in the software development process The linker accepts several types of files as input including object files command files libraries and partially linked files The linker creates an executable object module that can be downloaded to one of several development tools or executed by a ARM device Figure 7 1 The Linker in the ARM Software Development Flow C C source files C C compiler C C name demangling utility Assembler source Macro Object Archiver Library build Debugging Archiver process tools Run time support library Library of object files Executable object file Hex conversion utility EPROM Absolute licter Cross reference Object file programmer lister utilities SPNU118J August 2011 Linker Description 171 Submit Documentation Feedback jd 3 T www BD EIC conr
404. op is broken the assembler continues with the code after the endloop directive For more information see Section 4 8 Example 5 10 Example 5 11 and Example 5 12 show the loop break endloop directives properly nested conditional assembly directives and built in substitution symbol functions used in a conditional assembly code block Example 5 10 The loop break endloop Directives asg 1 x Loop break x 10 if 10 quit loop break with expression eval 8 endloop SPNU118J August 2011 Macro Description 153 Submit Documentation Feedback I I men YP 0 9115 1 Using Conditional Assembly in Macros Example 5 11 Nested Conditional Assembly Directives I TEXAS INSTRUMENTS www ti com asg l x loop JE x 10 if x 10 quit loop x 10 force break eval xt1 x endloop Example 5 12 Built In Substitution Symbol Functions in a Conditional Assembly Code Block fcnolist Double Add or Subtract DBL macro ABC dsth dstl srch srcl add or subtract double if symcmp ABC ADDS dstl dstl srel add double ADC dsth dsth srch elseif symcmp ABC SUBS dstl dstl 1 subtract double SUBS dsth dsth srch else emsg Incorrect Operator Parameter endif endm Macro Call DBL R4 R5 R6 R7 154 Macro Description www oF Eeconzy TI SPNU118J August 2011 Submit Documentation
405. opic weak symbol name Identifies a symbol used in the current module that is defined in Weak topic another module Table 4 8 Directives That Control Dynamic Symbol Visibility Mnemonic and Syntax Description See export symbolname Sets visibility of symbolname to STV EXPORT export topic hidden symbolname Sets visibility of symbolname to STV HIDDEN hidden topic import symbolname Sets visibility of symbolname to STV IMPORT import topic protected symbolname Sets visibility of symbolname to STV PROTECTED protected topic Table 4 9 Directives That Enable Conditional Assembly Mnemonic and Syntax Description See break well defined expression Ends loop assembly if well defined expression is true When using break topic the loop construct the break construct is optional else Assembles code block if the if well defined expression is false else topic When using the if construct the else construct is optional elseif well defined expression Assembles code block if the if well defined expression is false and elseif topic the elseif condition is true When using the if construct the elseif construct is optional endif Ends if code block endif topic endloop Ends loop code block endloop topic if well defined expression Assembles code block if the well defined expression is true if topic loop well defined expression Begins repeatable assembly of a code block the loop count is loop topic determined by the well defined e
406. or braces to enclose the operator list The operators in the list are applied to the input item that occurs immediately before the list 7 5 8 7 2 Output Section The START END and SIZE operators can also be associated with an output section Here is an example outsect START start of outsect SIZE size of outsect list of input items In this case the SIZE operator defines size of outsect to incorporate any padding that is required in the output section to conform to any alignment requirements that are imposed The syntax for specifying the operators with an output section does not require braces to enclose the operator list The operator list is simply included as part of the allocation specification for an output section 7 5 8 7 3 GROUPs 222 Here is another use of the START and SIZE operators in the context of a GROUP specification GROUP outsectl 1 oj outsect2 f load ROM run RAM START group start SIZE group size This can be useful if the whole GROUP is to be loaded in one location and run in another The copying code can use group start and group size as parameters for where to copy from and how much is to be copied This makes the use of label in the source code unnecessary Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Linker Command Files 7 5 8 7 4 UNIONS The RUN_SIZE and LOAD_SI
407. ord count Then it repeats the following steps for each record 1 Read load address run address and size from record If size is zero go to step 5 Call memcpy passing the run address load address and size Go to step 1 if there are more records to read Read the first byte from load address Call this index Read the handler address from amp __Tl_Handler_Base index Call the handler and pass load address 1 and run address Go to step 1 if there are more records to read 5 4 35 9 The routines to handle the decompression of load data are provided in the run time support library Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Generated Copy Tables 7 8 8 5 Compression Algorithms Run Length Encoding RLE 8 bit index Initialization data compressed using run length encoding The data following the 8 bit index is compressed using run length encoded RLE format ARM uses a simple run length encoding that can be decompressed using the following algorithm 1 5 9 Read the first byte Delimiter D Read the next byte B If B l D copy B to the output buffer and go to step 2 Read the next byte L If L gt 0 and L lt 4 copy D to the output buffer L times Go to step 2 If L 4 read the next byte B Copy B to the output buffer L times Go to step 2 Re
408. ore information about creating a dynamic object module see http processors wiki ti com index php C6000 Dynamic Linking The archiver allows you to collect a group of files into a single archive file called a library For example 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 You can also use the archiver to collect a group of object files into an object library The linker includes in the library the members that resolve external references during the link The archiver allows you to modify a library by deleting replacing extracting or adding members See Section 6 1 The library information archiver allows you to create an index library of several object file library versions which is useful when several versions of a single library are available This index library is the used in the link step in place of a particular version of your object file library See Section 6 5 You can use the library build process to build your own customized run time support library See the ARM Optimizing C C Compiler User s Guide for more information The hex conversion utility converts an object file into Tl Tagged ASCII Hex Intel Motorola S or Tektronix object format The converted file can be downloaded to an EPROM programmer See Chapter 11 The absolute lister uses linked object files to create abs files These files can be assembled to produc
409. ore you can use them in your program There are two methods for defining macros a Macros can be defined at the beginning of a source file or in a copy include file See Section 5 2 Defining Macros for more information b Macros can also 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 may contain one macro definition corresponding to the member name You can access a macro library by using the mlib directive For more information see Section 5 4 Step 2 Call the macro After you have defined a macro call it by using the macro name as a mnemonic in the source program This is referred to as a macro call Step 3 Expand the macro The assembler expands your macros when the source program calls them During expansion the assembler passes arguments by variable to the macro parameters replaces the macro call statement with the macro definition then assembles the source code By default the macro expansions are printed in the listing file You can turn off expansion listing by using the mnolist directive For more information see Section 5 8 When the assembler encounters a macro definition it places the macro name in the opcode table This redefines any previously defined macro library entry directive or instruction mnemonic that has the same name as the macro This allows you to expand the functions of directives and ins
410. ormation Item Description ADDR Hexadecimal start address of a section DATAn Hexadecimal data byte q End of file termination character Figure 11 11 TI TXT Object Format Section start ADDR1 DATAO1 DATA02 DATA16 DATA17 DATA32 DATA32 L DATAM DATAn Data bytes Section ADDR2 start C DATAOL iii DATAn j Data bytes q End of line character Example 11 3 TI TXT Object Format 000 31 40 00 03 B2 40 80 5A 20 01 D2 D3 22 00 D2 3 21 00 3F 40 8 FD 1F 83 FE 23 F9 QFFFE 00 FO Q 296 Hex Conversion Utility Description SPNU118J August 2011 S oF T Submit Documentation Feedback www BD EIC conr TI P Chapter 12 RE MENTIS SPNU118J August 2011 Sharing C C Header Files With Assembly Source You can use the cdecls assembler directive to share C headers containing declarations and prototypes between C and assembly code Any legal C C can be used in a cdecls block and the C C declarations will cause suitable assembly to be generated automatically allowing you to reference the C C constructs in assembly code Topic Page 12 1 Overview of the cdecls Directive reete ee RENE IND EN EE cae 298 12 2 Notes C C GonversionS ene UTE I I TETUER E ENS 298 12 3 Notes on C Specific Conversions pp 302 12 4 Special Assembler SUpport aeneae eee ene eea aaaea AAEE naa ea EEEE Ea ae 303 SPNU118J August
411. oss reference utility options identifies the cross reference lister options you want to use Options are not case sensitive and can appear anywhere on the command line following the command lowercase L specifies the number of lines per page for the output file The format of the option is Inum where num is a decimal constant For example 30 sets the number of lines per page in the output file to 30 The space between the option and the decimal constant is optional The default is 60 lines per page q suppresses the banner and all progress information run quiet input filename _ is a linked object file If you omit the input filename the utility prompts for a filename output filename is the name of the cross reference listing file If you omit the output filename the default filename is the input filename with an xrf extension SPNU118J August 2011 Cross Heference Lister Description 263 Submit Documentation Feedback Se oF T www BD EIC conr TI Cross Reference Listing Example 1 TEXAS INSTRUMENTS www ti com 9 3 Cross Reference Listing Example Example 9 1 is an example of cross reference listing Example 9 1 Cross Reference Listing File Symbol Filename array modulel asm Symbol Filename modulel asm Symbol dflag Filename modulel asm Symbol Filename modulel asm Symbol Filename 55226 modulel asm module2 asm Symbol Filename modulel asm module2 asm btt
412. ot The quiet option suppresses the hex conversion utility s normal banner and progress information Assume that a command file named firmware cmd contains these lines firmware out input file ti tagged TI Tagged outfile firm lsb output file outfile firm msb output file You can invoke the hex conversion utility by entering hex470 firmware cmd This example shows how to convert a file called appl out into eight hex files in Intel format Each output file is one byte wide and 4K bytes long appl out input file intel Intel format map appl mxp map file f ROMS 1 520111 origin 0x00000000 len 0x4000 romwidth 8 files appl u0 appl ul appl u2 appl u3 ROW2 origin 0x00004000 len 0x4000 romwidth 8 files appl u4 appl u5 appl u6 appl u7 SECTIONS text data cinit sectl vectors const SPNU118J August 2011 Hex Conversion Utility Description 277 Submit Documentation Feedback I I men BADE 4 69115 1 I TEXAS INSTRUMENTS Understanding Memory Widths www ti com 11 3 Understanding Memory Widths The hex conversion utility makes your memory architecture more flexible by allowing you to specify memory and ROM widths To use the hex conversion utility you must understand how the utility treats word widths Three widths are important in the conversion process Target width Memory width ROM width The terms target word memory word and ROM
413. panded substitution symbols This example shows code that by default suppresses the listing of substitution symbol expansion and it shows the sslist directive assembled instructing the assembler to list substitution symbol code expansion 1 ADDL macro dest src 2 global reset ctr 3 ADDS dest dest src 4 BLCS reset ctr 5 endm 6 7 00000000 ADDL R4 R5 global reset ctr 00000000 E0944005 ADDS R4 R4 R5 00000004 2BFFFFFD BLCS reset ctr 8 00000008 E5954000 LDR R4 R5 9 0000000c ADDL RO R4 global reset ctr 0000000c E0900004 ADDS RO RO R4 00000010 2BFFFFFA BLCS reset ctr 10 11 Sslist 12 13 00000014 E5B53004 LDR R3 R5 4 14 00000018 E5954000 LDR R4 R5 15 0000001c ADDL R4 R3 1 global reset ctr 1 0000001c E0944003 ADDS dest dest src ADDS R4 R4 R3 1 00000020 2BFFFFF6 BLCS reset ctr SPNU118J August 2011 Submit Documentation Feedback www oF Eeconzy TI 1 TEXAS INSTRUMENTS www ti com state16 Syntax Description Example SPNU118J August 2011 Directives Reference Assemble 16 Bit Instructions Non UAL Syntax state16 By default the assembler begins assembling all instructions in a file as 32 bit instructions Use the state16 directive to direct the assembler to begin assembling all instructions at that point as 16 bit instructions This directive and the state32 directive allow you to switch between the two assembly modes for non UAL syntax If you want to
414. pecifies the run time address of overlay constant The lt size gt element specifies the size of logical group constant The contents container element lists elements contained in this overlay These elements refer to each of the member objects contained in this logical group The object component ref is an object component that is contained in this logical group reference The logical group ref is a logical group that is contained in this logical group reference The split section is another special kind of logical group that represents a collection of logical groups that is split among multiple memory areas Each split section element is given an id so that it may be referenced from other elements The id consists of the following elements The lt name gt element names the split section string The contents container element lists elements contained in this split section The logical group ref elements refer to each of the member objects contained in this split section and each element referenced is a logical group that is contained in this split section reference SPNU 118J August 2011 XML Link Information File Description 3138 Submit Documentation Feedback I I men BADE gt 69115 1 Document Elements Example 8 4 Logical Group List for the fl 4 Input File I TEXAS INSTRUMENTS www ti com lt logical_group_list gt logical group id lg 7 gt
415. ple This example shows how drnolist inhibits the listing of the specified directives Source file asg 0 x Loop 2 eval 1 x endloop drnolist asg Ty X loop 3 eval 1 x endloop Listing file 3 asg 0 x 4 Loop 2 5 eval 1 x 6 endloop 1 eval 0 1 x 1 eval 141 x E 8 drnolist 12 loop 3 13 eval xtl x 14 endloop SPNU118J August 2011 Assembler Directives 95 Submit Documentation Feedback I I men BADE 0 9115 1 1 TEXAS INSTRUMENTS Directives Reference www ti com elfsym ELF Symbol Information Syntax elfsym name SYM SIZE size Description The elfsym directive provides additional information for symbols in the ELF format This directive is designed to convey different types of information so the type data pair is used to represent each type Currently this directive only supports the SYM SIZE type SYM SIZE indicates the allocation size in bytes of the symbol indicated by name Example This example shows the use of the ELF symbol information directive Sect examp alignment 4 elfsym ex sym SYM SIZE 4 ex sym emsg mmsg wmsg Define Messages Syntax emsg string mmsg string wmsg string Description These directives allow you to define your own error and warning messages When you use these directives the assembler tracks the number of errors and warnings it encounters and prints these numbers on the last line of the listing file The emsg d
416. ption 192 In ANSI C global and static variables that are not explicitly initialized must be set to 0 before program execution The C C EABI compiler supports preinitialization of uninitialized variables by default This can be turned off by specifying the linker option zero_init off COFF ABI does not support zero initialization The syntax for the zero init option is zero_init onl off Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Command Files 7 5 Linker Command Files Linker command files allow you to put linking information in a file this is useful when you invoke the linker often with the same information Linker command files are also useful because they allow you to use the MEMORY and SECTIONS directives to customize your application You must use these directives in a command file you cannot use them on the command line Linker command files are ASCII files that contain one or more of the following Input filenames which specify object files archive libraries or other command files If a command file calls another command file as input this statement must be the ast 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 di
417. ption search path Option and TMS470 C DIR Environment Variable Usually when you want to specify a file as linker input you simply enter the filename the linker looks for the file in the current directory For example suppose the current directory contains the library object lib Assume that this library defines symbols that are referenced in the file file1 obj This is how you link the files 01470 run linker filel obj object lib If you want to use a file that is not in the current directory use the library linker option The library option s short form is The syntax for this option is library pathname filename The filename is the name of an archive an object file or link command file You can specify up to 128 search paths The library option is not required when one or more members of an object library are specified for input to an output section For more information about allocating archive members see Section 7 5 4 5 You can augment the linker s directory search algorithm by using the search path linker option or the TMS470 C DIR environment variable The linker searches for object libraries and command files in the following order 1 It searches directories named with the search path linker option The search path option must appear before the library option on the command line or in a command file 2 lt searches directories named with TMS470 6 DIR SPNU118J August 2011 Linker Descriptio
418. put Module absolute_exe option When you use the absolute_exe option without the relocatable option the linker produces an absolute executable output module Absolute files contain no relocation information Executable files contain the following Special symbols defined by the linker see Section 7 5 8 4 An optional header that describes information such as the program entry point Nounresolved references The following example links file1 obj and file2 obj and creates an absolute output module called a out cl470 run linker absolute exe filel obj file2 0bj The absolute exe and relocatable Options NOTE f you do not use the absolute exe or the relocatable option the linker acts as if you specified absolute exe 7 4 2 2 Producing a Relocatable Output Module relocatable option When you use the ar option the linker retains relocation entries in the output module If the output module is relocated at load time or relinked by another linker execution use relocatable to retain the relocation entries The linker produces a file that is not executable when you use the relocatable option without the absolute exe option A file that is not executable does not contain special linker symbols or an optional header The file can contain unresolved references but these references do not prevent creation of an output module This example links file1 obj and file2 obj and creates a relocatable outp
419. put section is created Section 7 4 33 Table 7 4 File Search Path Options Summary Option Alias Description Section library 4 Names an archive library or link command filename as linker input Section 7 4 16 search path I Alters library search algorithms to look in a directory named with pathname Section 7 4 16 1 before looking in the default location This option must appear before the library option disable auto rts Disables the automatic selection of a run time support library Section 7 4 8 priority priority Satisfies unresolved references by the first library that contains a definition for Section 7 4 16 3 that symbol reread_libs X Forces rereading of libraries which resolves back references Section 7 4 16 3 SPNU118J August 2011 Submit Documentation Feedback Linker Description 173 www BRD EKireconr TI I TEXAS INSTRUMENTS Linker Options www ti com Table 7 5 Linker Output Options Summary Option Alias Description Section output_file 0 Names the executable output module The default filename is a out Section 7 4 23 map file m Produces a map or listing of the input and output sections including holes and Section 7 4 18 places the listing in filename absolute exe a Produces an absolute executable module This is the default if neither Section 7 4 2 1 absolute exe nor relocatable is specified the linker acts as if absolute exe were specified generate dead funcs list Writes a list of the dead fu
420. r This C C compiler accepts ANSI standard C C source code and produces assembly language source code for the ARM platform of devices ARM is a registered trademark of ARM Limited All other trademarks are the property of their respective owners Read This First SPNU118J August 2011 Submit Documentation Feedback I I men YP 0 9115 1 13 14 Read This First SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI P Chapter 1 NN SPNU118J August 1 Introduction to the Software Development Tools The ARMe is supported by a set of software development tools which includes an optimizing C C compiler an assembler a linker and assorted utilities This chapter provides an overview of these tools The ARM device is supported by the following assembly language development tools Assembler Archiver Linker Library information archiver Absolute lister Cross reference lister Object file display utility Disassembler Name utility Strip utility Hex conversion utility This chapter shows how these tools fit into the general software tools development flow and gives a brief description of each tool For convenience it also summarizes the C C compiler and debugging tools For detailed information on the compiler and debugger and for complete descriptions of the ARM device refer to the books listed in Related Documentation From Texas Instruments
421. r a b Top member of list b is assigned to string a 0 if bis a null string 951560115 a 1 string ais a binary constant 2 if string a is an octal constant 3 if string a is a hexadecimal constant 4 if string a is a character constant 5 if string a is a decimal constant isname a 1 if string ais a valid symbol name 0 if string a is not a valid symbol name isreg a 1 if string a is a valid predefined register name 0 if string a is not a valid predefined register name For more information about predefined register names see Section 3 8 5 Example 5 5 shows built in substitution symbol functions Example 5 5 Using Built In Substitution Symbol Functions asg label ADDR ADDR label et Ssymcmp ADDR label 0 evaluates to true LDR R4 ADDR endif asg xoy pz lust list x y z JE ismember ADDR list ADDR x list y z SUB R4 R4 4 sub x endif 148 Macro Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Macro Parameters Substitution Symbols 5 3 3 Recursive Substitution Symbols When the assembler encounters a substitution symbol it attempts to substitute the corresponding 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 subs
422. r as the basic types such as int char float have no type representation in assembly there is no way to ask for sizeof int for example in assembly 12 2 13 Structures and Unions C C structures and unions are converted to assembly struct and union elements Padding and ending alignments are added as necessary to make the resulting assembly structure have the same size and member offsets as the C C source The primary purpose is to allow access to members of C C structures as well as to facilitate debugging of the assembly code For nested structures the assembly tag feature is used to refer to other structures unions The alignment is also passed from the C C source so that the assembly symbol is marked with the same alignment as the C C symbol See Section 12 2 3 for information about pragmas which may attempt to modify structures Because the alignment of structures is stored in the assembly symbol built in assembly functions like sizeof and alignof can be used on the resulting structure name symbol When using unnamed structures or unions in typedefs such as typedef struct int a member mystrname This is really a shorthand way of writing struct temporary name int a member typedef temporary name mystrname The conversion processes the above statements in the same manner generating a temporary name for the structure and then using define to output a typedef from the temporary name to the user
423. r the linker will no longer choose the corresponding library when the index library is specified Using any other archiver option with an index library or using d to remove the TI LIBINFO member results in undefined behavior and is not supported SPNU 118J August 2011 Archiver Description 167 Submit Documentation Feedback I I men BADE 0 9115 1 I TEXAS INSTRUMENTS Library Information Archiver Description www ti com 6 5 4 Requirements You must follow these requirements to use library index files Atleast one of the application s object files must appear on the linker command line before the index library e Each object file library specified as input to the library information archiver must only contain object file members that are built with the same build options The linker expects the index library and all of the libraries it indexes to be in a single directory 168 Archiver Description SPNU 118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 5 TEXAS INSTRUMENTS The ARM linker creates executable modules by combining object modules This chapter describes the linker options directives and statements used to create executable modules Object libraries command Linker Description files and other key concepts are discussed as well The concept of sections is basic to linker operation Chapter 2 discusses the object module sections in detail Top
424. r Command Files In this example the linker places text into the area called SLOW_MEM The data and bss output sections are allocated into FAST_MEM You can align a section within a named memory range the data section is aligned on a 128 byte boundary within the FAST_MEM range Similarly you can link a section into an area of memory that has particular attributes To do this specify a set of attributes enclosed in parentheses instead of a memory name Using the same MEMORY directive declaration you can specify SECTIONS etext gt X text executable memory data gt RI data gt read or init memory bss gt RW bss lt read or write memory f In this example the text output section can be linked into either the SLOW_MEM or FAST_MEM area because both areas have the X attribute The data section can also go into either SLOW_MEM or FAST MEM because both areas have the R and attributes The bss output section however must go into the FAST MEM area because only FAST MEM is declared with the W attribute You cannot control where in a named memory range a section is allocated although the linker uses lower memory addresses first and avoids fragmentation when possible In the preceding examples assuming no conflicting assignments exist the text section starts at address O If a section must start on a specific address use binding instead of named memory 7 5 4 2 3 Controlling A
425. r after sections are filled with a fill value that you supply An output file converted by using image mode still has address records because many of the hexadecimal formats require an address on each line However in image mode these addresses are always contiguous 288 Hex Conversion Utility Description SPNU118J August 2011 S oF T Submit Documentation Feedback www BDE conr TI I TEXAS INSTRUMENTS www ti com Controlling the ROM Device Address Defining the Ranges of Target Memory NOTE f you use image mode you must also use a ROMS directive In image mode each output file corresponds directly to a range of target memory You must define the ranges If you do not supply the ranges of target memory the utility tries to build a memory image of the entire target processor address space This is potentially a huge amount of output data To prevent this situation the utility requires you to explicitly restrict the address space with the ROMS directive 11 9 2 Specifying a Fill Value The fill option specifies a value for filling the holes between sections The fill value must be specified as an integer constant following the fill option The width of the constant is assumed to be that of a word on the target processor For example specifying fill OxFFFF results in a fill pattern of OX0000FFFF The constant value is not sign extended The hex conversion utility uses a default fill value of 0 if you do not specify a va
426. r any section that should be verified with a CRC the linker command file must be modified to include the crc table operator The specification of a CRC algorithm is optional crc table user specified table name algorithm xxx The linker uses the CRC algorithm from any specification given in a crc table operator If that specification is omitted the TMS570 CRC64 1SO algorithm is used The CRC table generated for a particular crc table instance can be accessed through the table name provided as an argument to the crc table operator The linker creates a symbol with this name and assigns the address of the CRC table as the value of the symbol The CRC table can then be accessed from the application using the linker generated symbol The crc table operator can be applied to an output section a GROUP a GROUP member a UNION or a UNION member If applied to a GROUP or UNION the operator is applied to each member of the GROUP or UNION You can include calls in your application to a routine that will verify CRC values for relevant sections You must provide this routine See below for more details on the data structures and suggested interface The linker includes CRC table information in the map file This includes the CRC value as well as the algorithm used for the calculation 7 9 2 Restrictions It is important to note that the CRC generator used by the linker is parameterized as described in the crc tbl h header file see Ex
427. r data into the current section Example 4 1 Sections Directives Directives That Define Sections DPO o0 o OP WN w 00041 6 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 00000000 00000000 00000004 00000008 0000000c 00000000 00000000 00000004 00000008 0000000c 00000000 00000000 00000004 00000010 00000010 00000014 00000000 00000018 0000001c 00000010 00000010 00000014 00000000 00000018 0000001c 00000001 00000002 00000003 00000004 data 00000009 0000000A 000000058 0000000C 00000011 00000012 data 0000000D O0000000E 0000000F 00000010 00000005 00000006 00000007 00000008 K Start assembling into the text section ko ko text word 1 2 word 3 4 Start assembling into the data section ko ko ok ok
428. r more 16 bit values into consecutive 16 bit fields halfwords in the current section The half and short directives automatically align to a short 2 byte boundary The int long and word directives place one or more 32 bit values into consecutive 32 bit fields words in the current section The int long and word directives automatically align to a word boundary The string and cstring directives place 8 bit characters from one or more character strings into the current section The string and cstring directives are similar to byte placing an 8 bit character in each consecutive byte of the current section The cstring directive adds a NUL character needed by C the string directive does not add a NUL character Directives That Initialize Constants When Used in a struct endstruct Sequence NOTE The byte char int long word double half short string float and field directives do not initialize memory when they are part of a struct endstruct sequence rather they define a member s size For more information see the struct endstruct directives SPNU118J August 2011 Assembler Directives 69 Submit Documentation Feedback I I men www BADE gt 9115 1 Directives That Perform Alignment and Reserve Space I TEXAS INSTRUMENTS www ti com Figure 4 2 compares the byte char int long float word and string directives Using the following assembled code 1 4 6 UO BW Ph
429. r the assembly module The file is included before source file statements The included file does not appear in the assembly listing files include_path pathname I Specifies a directory where the assembler can find files named by the copy include or mlib directives There is no limit to the number of directories you can specify in this manner each pathname must be preceded by the include path option See Section 3 4 1 34 Assembler Description SPNU 118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Naming Alternate Directories for Assembler Input Table 3 1 ARM Assembler Options continued Option Alias Description max branch chain num Controls the depth of branch chaining through the assembler For information on optimizations see the ARM Optimizing C C Compiler Users Guide output all syms as Puts all defined symbols in the object file s symbol table The assembler usually puts only global symbols into the symbol table When you use output all syms symbols defined as labels or as assembly time constants are also placed in the table quiet q Suppresses the banner and progress information assembler runs in quiet mode symdebug dwarf g Enables assembler source debugging in the C source debugger Line information is output to the object module for every line of source in the assembly language source file You cannot use the symdebug dwarf option on
430. racter Using wild cards can make it easier to handle related objects provided they follow a suitable naming convention For example mp3 obj matches anything obj that begins with mp3 task o matches taskl obj task2 0bj taskX o55 etc SECTIONS fast code obj fast FAST MEM vectors vectors obj vector partl gt OxFFFFFFO00 str code rts lib str obj text gt S1ROM Relocation Capabilities absolute exe and relocatable Options The linker performs relocation which is the process of adjusting all references to a symbol when the symbol s address changes The linker supports two options absolute exe and relocatable that allow you to produce an absolute or a relocatable output module The linker also supports a third option ar that allows you to produce an executable relocatable output module When the linker encounters a file that contains no relocation or symbol table information it issues a warning message but continues executing Relinking an absolute file can be successful only if each input file contains no information that needs to be relocated that is each file has no unresolved references and is bound to the same virtual address that it was bound to when the linker created it SPNU118J August 2011 Submit Documentation Feedback Linker Description 175 www BRD EKireconr TI I TEXAS INSTRUMENTS Linker Options www ti com 7 4 2 1 Producing an Absolute Out
431. racter strings are used for the following Filenames as in copy filename Section names as in sect section name Datainitialization directives as in byte charstring Operands of string directives Symbols Symbols are used as labels constants and substitution symbols A symbol name is a string of alphanumeric characters the dollar sign and underscores A Z 8 2 0 9 and _ The first character in a symbol cannot be a number and symbols cannot contain embedded blanks The symbols you define are case sensitive for example the assembler recognizes ABC Abc and abc as three unique symbols You can override case sensitivity with the syms ignore case assembler option see Section 3 3 A symbol is valid only during the assembly in which it is defined unless you use the global directive or the def directive to declare it as an external symbol see Identify Global Symbols Labels Symbols used as labels become symbolic addresses that are associated with locations in the program Labels used locally within a 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 Eb LDR Al 1 STR Al sp 0 BL f CONI field 269488145 32 3 8 2 Local Labels 44 Local labels are special labels whose scope and effect are temporary A local label can b
432. rampoline min spacing option to try to make them adjacent The syntax is trampoline min spacingzsize A higher value minimizes fragmentation but may result in more trampolines A lower value may reduce trampolines at the expense of fragmentation and linker running time Specifying 0 for this option disables coalescing The default is 16K 7 4 32 Introduce an Unresolved Symbol undef sym Option The undef sym option introduces the linkname for 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 undef sym option before it links in the member that defines the symbol The syntax for the undef sym option is undef symz symbol SPNU118J August 2011 Linker Description 191 Submit Documentation Feedback I I men YP 0 9115 1 I TEXAS INSTRUMENTS Linker Options www ti com For example suppose a library named rts470 lib contains a member that defines the symbol symtab none of the object files being linked reference symtab However suppose you plan to relink the output module and you want to include the library member that defines symtab in this link Using the undef_sym option as shown below forces the linker to search rts470 lib for the member that defines symtab and to link in the member 61470 run linker undef_sym symtab filel obj file2 0bj rts470 1ib If you do not use undef sym
433. rchiver Description ee 166 6 5 1 Invoking the Library Information Archiver eeeseeeeseee I m Hmm nnn 166 6 5 2 Library Information Archiver Example ee 167 6 5 3 Listing the Contents of an Index Library ee 167 6 5 4 lier eese nem E AN E heh h enn ananas sn nennen kann nnne nn 168 7 Ics redirent 169 7 1 Linker Overview Em 0 cadence E O ENEE EErEE TOE 170 7 2 The Linker s Role in the Software Development Flow ee 171 7 3 172 7 4 Ml eee de 1 E E N 173 7 4 4 Wild Cards in File Section and Symbol Patterns pp 175 7 4 2 Relocation Capabilities absolute exe and relocatable Options eese 175 7 4 3 Allocate Memory for Use by the Loader to Pass Arguments arg size Option 176 7 4 4 Changing Encoding of Big Endian Instructions esce 177 7 4 5 Compression cinit compression and copy compression Option ee TE 7 4 6 Compress DWARF Information compress dwarf Option ee 177 TAT Control linker 0505 177 7 4 8 Disable Automatic Library Selection disable auto rts Option cesses 178 7 4 9 Controlling Unreferenced and Unused Sections pp 178 7 4 10 Link Command File Preprocessing disable pp define and undefine Options 179 7 4 11 Define an Entry Point entry point Option
434. rd 0 22 00000018 00000000 word 0 23 0000001c 00000000 word 0 24 25 00000000 text 26 globaldispatch 27 global reset 28 go 36 36 36 36 36 ke ke ec ke c e e ERE EEE EEE e e e e e e e EEE e e e e e e e e e e e e e e e 29 RESET ROUTINE 30 p ee ee e e e e e e ee ee ee he e hee e e ee he e hoe hee eoe e e e e e e e e e e e n n 31 00000000 reset 32 33 SET TO USER MODE 34 RS SS SS SSS SS SS SS SS SS 35 00000000 E10F0000 MRS r0 cpsr 36 00000004 2300001 BIC r0 r0 0x1F Clear modes 37 00000008 E3800010 ORR r0 r0 0x10 Set user mode 38 0000000c E129F000 MSR cpsr 0 39 Field 1 Field 2 Field 3 Field 4 56 Assembler Description SPNU118J August 2011 www oF Eeconzy TI Submit Documentation Feedback 1 TEXAS INSTRUMENTS www ti com Figure 3 2 Example Assembler Listing Continued number Nesting level Source Listings 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 Field 1 00000010 00000010 E28F0001 00000014 E12FFF10 00000018 00000018 4802 0000001a 4685 0000001c 4802 0000001e 4485 00000020 F7FF 00000022 FFEE 00000024 00000000 stack 0000002800000200 stacksz Field 2 Field 3 tol6 ADD r0 pc 1 BX ro Statel6 LDR r0 stack MOV sp 0 LDR r0 stacksz ADD sp 0 BL dispatch long stack long STACKSIZE eye MF s SS Field 4
435. rds of EPROM memory are dedicated to application code space and the upper 64K words are dedicated to the data tables The application code is loaded starting at address 0x0 on the EPROM but maps to the 0 CPU at address 0x3000 The data tables are loaded starting at address 0x1000 on the EPROM and map to the TMS470 CPU address 0x20 Example C 4 shows the linker command file that resolves the addresses needed for the load on EPROM and the TMS470 CPU access Hex Conversion Utility Examples SPNU118J August 2011 BYE T Submit Documentation Feedback men www BD TI 1 TEXAS INSTRUMENTS www ti com Scenario 2 Building a Hex Conversion Command File for 16 BIS Code Example C 4 Linker Command File for Scenario 2 KCKCKCKCKCk Ck ck ck ck ck ok ok ok ko k kc k ok ck ck sk kk A RR Scenario 2 Link Command Usage 1nk470 obj files o out file m map file lInkl6 cmd 61470 src files z o out file m map file lnkl6 cmd JE 3 Description This file is a sample command file that can be used af for linking programs built with the 12115470 C 527 compiler Use it as a guideline you may want to change 7 the allocat
436. reated as a nonnegative number regardless of its actual sign variable A symbol representing a quantity that can assume any of a set of values veneer A sequence of instructions that serves as an alternate entry point into a routine if a state change is required well defined expression A term or group of terms that contains only symbols or assembly time constants that have been defined before they appear in the expression word A 32 bit addressable location in target memory SPNU118J August 2011 Glossary 335 Submit Documentation Feedback I I men BADE Ceonmy I IMPORTANT NOTICE Texas Instruments Incorporated and its subsidiaries TI reserve the right to make corrections modifications enhancements improvements and other changes to its products and services at any time and to discontinue any product or service without notice Customers should obtain the latest relevant information before placing orders and should verify that such information is current and complete All products are sold subject to TI s terms and conditions of sale supplied at the time of order acknowledgment TI warrants performance of its hardware products to the specifications applicable at the time of sale in accordance with Tl s standard warranty Testing and other quality control techniques are used to the extent TI deems necessary to support this warranty Except where mandated by government requirements testing of all parameters of each pr
437. rectives The MEMORY directive defines the target memory configuration see Section 7 5 3 The SECTIONS directive controls how sections are built and allocated see Section 7 5 4 Assignment statements which define and assign values to global symbols To invoke the linker with a command file enter the cl470 run linker command and follow it with the name of the command file cl470 run linker command filename The linker processes input files in the order that it encounters them If the linker recognizes a file as an object file it links the file Otherwise it assumes that a file is a command file and begins reading and processing commands from it Command filenames are case sensitive regardless of the system used Example 7 1 shows a sample link command file called link cmd Example 7 1 Linker Command File a obj b obj out First input filename x Second input filename put file prog out Option to specify output file map file prog map Option to specify map file ay The sample file in Example 7 1 contains only filenames and options You can place comments in a command file by delimiting them with and To invoke the linker with this command file enter 1470 run linker link cmd You can place other parameters on the command line when you use a command file c1470 run linker relocatable link cmd c obj d obj The linker processes the command file as soon as it encounters
438. rectives Reference Start Stop Source Listing list nolist Two directives enable you to control the printing of the source listing The list directive allows the printing of the source listing The nolist directive suppresses the source listing output until a list directive is encountered The nolist directive can be used to reduce assembly time and the source listing size It can be used in macro definitions to suppress the listing of the macro expansion The assembler does not print the list or nolist directives or the source statements that appear after a nolist directive However it continues to increment the line counter 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 used However if you do not request a listing file when you invoke the assembler by including the asm listing option on the command line see Section 3 3 the assembler ignores the list directive This example shows how the copy directive inserts source statements from another file The first time this directive is encountered the assembler lists the copied source lines in the listing file The second time this directive is encountered the assembler does not list the copied source lines because a nolist directive was assembled The nolist the second copy and the list directive
439. rent 0 module Example 1 The statements in this example use an absolute symbol LAB1 which is defined to have a value of 2 The first statement loads the value 51 into RO The second statement loads the value 27 into RO MOV RO LAB1 4 3 7 1 p sw QUE wT 2 49 51 MOV RO LABl 4 3 7 RO 7 2 4 21 7 Example 2 The first statement in the following example is valid the statements that follow it are invalid LDR R1 intern 1 10 Legal LDR R1 10 intern 1 Can t negate reloc symbol LDR R1 intern 1 Can t negate reloc symbol LDR R1 intern 1 10 isn t additive operator LDR R1 intern 1 intern 2 Multiple relocatables Example 3 The first statement below is legal although intern 1 and intern 2 are relocatable their difference is absolute because they are in the same section Subtracting one relocatable symbol from another reduces the expression to relocatable symbol absolute value The second statement is illegal because the sum of two relocatable symbols is not an absolute value LDR R1 intern 1 intern 2 intern 3 Legal LDR R1 intern 1 intern 2 intern 3 Illegal Example 4 A relocatable symbol s placement in the expression is important to expression evaluation Although the statement below is similar to the first statement in the previous example it is illegal because of left to right operator precedence the assembler attempts to add intern 1 to
440. revious versions of the linker splitting sections that have separate load and run placement instructions was not permitted This restriction was because there was no effective mechanism for you the developer to gain access to the load address or run address of each one of the pieces of the split object component Therefore there was no effective way to write a copy routine that could move the split section from its load location to its run location However the linker can access both the load address and run address of every piece of a split object component Using the table operator you can tell the linker to generate this information into a copy table The linker gives each piece of the split object component a COPY RECORD entry in the copy table object For example consider an application which has seven tasks Tasks 1 through 3 are overlaid with tasks 4 through 7 using a UNION directive The load placement of all of the tasks is split among four different memory areas LMEM1 LMEM2 LMEM3 and LMEM4 The overlay is defined as part of memory area PMEM You must move each set of tasks into the overlay at run time before any services from the set are used You can use table operators in combination with splitting operators lt lt to create copy tables that have all the information needed to move either group of tasks into the memory overlay as shown in Example 7 23 Example 7 24 illustrates a possible driver for such an application
441. ribes the macro language Additional assembly language tools description consisting of Chapter 6 through Chapter 11 describes in detail each of the tools provided with the assembler to help you create executable object files For example Chapter 7 explains how to invoke the linker how the linker operates and how to use linker directives Chapter 11 explains how to use the hex conversion utility Reference material consisting of Appendix A through Appendix D provides supplementary information including symbolic debugging directives that the ARM C C compiler uses It also provides hex utility examples a description of the XML link information file and a glossary SPNU118J August 2011 Read This First 11 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Notational Conventions www ti com Notational Conventions This document uses the following conventions Program listings program examples and interactive displays are shown in a special typeface Interactive displays use a bold version of the special typeface to distinguish commands that you enter from items that the system displays such as prompts command output error messages etc Here is a sample of C code include lt stdio h gt main printf hello cruel world n n syntax descriptions the instruction command or directive is in a bold typeface and parameters are in an italic typeface Portions of a syntax that are
442. ries from any type of files Both the assembler and the linker accept archive libraries as input the assembler can use libraries that contain individual source files and the linker can use libraries that contain individual object files One of the most useful applications of the 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 searches the library and includes members that resolve external references You can also use the archiver to build macro libraries You can create several source files each of which contains a single macro and use the archiver to collect these macros into a single functional group You can use the mlib directive during assembly to specify that macro library to be searched for the macros that you call Chapter 5 discusses macros and macro libraries in detail while this chapter explains how to use the archiver to build libraries Archiver Description SPNU118J August 2011 BADE T Submit Documentation Feedback men www BD FKconr TI 1 TEXAS INSTRUMENTS www ti com The Archiver s Role in the Software Development Flow 6 2 The Archiver s Role in the Software Development Flow Figure 6 1 shows the archiver s role in the software development process The shaded portion highlights the most common archiver
443. right evaluation When parentheses and precedence groups do not determine the order of expression evaluation the expressions are evaluated from left to right except for Group 1 which is evaluated from right to left 8 4 2 4 but 8 4 2 1 3 9 1 Operators Table 3 2 lists the operators that can be used in expressions according to precedence group Table 3 2 Operators Used in Expressions Precedence Group Operator Description 1 Unary plus Unary minus 1s complement Logical NOT 2 di Multiplication Division 96 Modulo 3 Addition Subtraction 4 Shift left lt lt Shift right 5 lt Less than gt Less than or equal to gt Greater than gt Greater than or equal to 6 Equal to l Not equal to 7 amp Bitwise AND 8 4 Bitwise exclusive OR XOR 9 Bitwise OR Group 1 operators are evaluated right to left All other operators are evaluated left to right 2 Unary and have higher precedence than the binary forms 3 9 2 Expression Overflow and Underflow 50 The assembler checks for overflow and underflow conditions when arithmetic operations are performed at assembly time It issues a warning the message Value Truncated whenever an overflow or underflow occurs The assembler does not check for overflow or underflow in multiplication Assembler Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti co
444. rley This code is not converted to assembly because it is a function like macro define MAX x y x y x y Some macros while they are converted have no functional use in the containing assembly file For example the following results in the assembly substitution symbol FOREVER being set to the value while 1 although this has no useful use in assembly because while 1 is not legal assembly code define FOREVER while 1 SPNU118J August 2011 Sharing C C Header Files With Assembly Source 299 Submit Documentation Feedback I I men BADE gt 9115 1 I TEXAS INSTRUMENTS Notes on C C Conversions www ti com Macro values are not interpreted as they are converted For example the following results in the assembler substitution symbol OFFSET being set to the literal string value 5 12 and not the value 17 This happens because the semantics of the C C language require that macros are evaluated in context and not when they are parsed define OFFSET 5 12 Because macros in C C are evaluated in their usage context C C printf escape sequences such as n are not converted to a single character in the converted assembly macro See Section 12 2 11 for suggestions on how to use C C macro strings Macros are converted using the new define directive see Section 12 4 2 which functions similarly to the asg assembler directive The exception is that define disallows redefinitions of register symbols and mne
445. rocess FlOW eee I I mI n emn he 278 11 8 Object File Data and Memory Widths nnne 279 11 4 Data Memory and ROM Widths eene a n a nnne 281 11 5 The infile out File Partitioned Into Four Output Files 4 284 1156 ASGIEEHeX Object EF omatee ee a uit nienPiesiucic sin eu aitelnts cinis letum ins ufcfa e cin 291 11 7 Intel Hexadecimal Object Format nnn nnn nnne 292 11 88 MotorolasS 0 11 24 20 203 11 9 Extended Tektronix Object Format ea ssir e ind E 294 115107 TI Fagged Ob ect FOFITIaL ss es oe ee ese en E E EE E EN EE 295 Tisti MIXT OBJEC FORMAL 296 0 1 EPROM Memory System for Scenario 1 pt 320 C 2 Contents of Hex Output File example1 hex ee 323 0 3 EPROM Memory System for Scenario 2 et 324 C 4 Contents of Hex Output File example2 hex 2 2 nnn n nennen nnn 327 C 5 EPROM Memory System for ScenariO 3 aurcs 1 1 1 1 imu EE DER EM REN MEM EN EUEUNM E MN E E NNUE 327 0 6 Contents of Hex Output File
446. rrower memory words By default the hex conversion utility sets memory width to the target width in this case 32 bits You can change the memory width except for TI TXT format 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 in the ROMS directive and overrides the memwidth option for that range See Section 11 4 For both methods use a value that is a power of 2 greater than or equal to 8 You should change the memory width default value of 16 only when you need to break single target words into consecutive narrower memory words TI TXT Format is 8 Bits Wide NOTE You cannot change the memory width of the TI TXT format The TI TXT hex format supports an 8 bit memory width only Figure 11 3 demonstrates how the memory width is related to object file data Figure 11 3 Object File Data and Memory Widths Source file word OAABBCCDDh word 011223344 Object file data assumed to be in big endian format Memory widths variable memwidth 32 default memwidth 16 memwidth 8 AABBCCDD AABB 11223344 CCDD 2 QO lt Data after x 1122 C phase of hex470 3344 SPNU118J August 2011 Hex Conversion Utility Description 279 Submit Documentation Feedback Se oF T www BD EIC conr
447. rs In C this looks like a normal write of a long long to memory The code generated to read write a long long to memory is something like the following where R2 contains the most significant word and R3 contains the least significant word So the most significant word is written to the low address and the least significant word is written to the high address LDM RO R2 R3 STM R1 R2 R3 The CRC memory mapped registers are in the reverse order from how the compiler performs the store The least significant word is mapped to the low address and the most significant word is mapped to the high address This means that the words are actually swapped before performing the CRC calculation It also means that the calculated CRC value has the words swapped The TMS570 CRC64 ISO algorithm takes these issues into consideration and performs the swap when calculating the CRC value The computed CRC value stored in the table has the words swapped so the value is the same as it is in memory For the end user these details should be transparent If the run time CRC routine is written in C the long long loads and stores will be generated correctly The DMA mode of the MCRC module will also work correctly Another issue with the algorithm is that it requires the run time CRC calculation to be done with 64 bit chunks The MCRC module allows smaller chunks of data but the values are padded to 64 bits The TMS570 CRC64A ISO algorithm does not perform any pad
448. rs see Section 3 9 4 Directives That Define Union or Structure Types These directives set up specialized types for later use with the tag directive allowing you to use symbolic names to refer to portions of a complex object The types created are analogous to the struct and union types of the C language The struct union cstruct and cunion directives group related data into an aggregate structure which is more easily accessed These directives do not allocate space for any object Objects must be separately allocated and the tag directive must be used to assign the type to the object type Struct Structure tag definition X int Y int T LEN endstruct COORD tag type declare COORD coordinate COORD Space T LEN actual memory allocation LDR RO COORD Y load member Y of structure COORD into register RO The cstruct and cunion directives guarantee that the data structure will have the same alignment and padding as if the structure were defined in analogous C code This allows structures to be shared between C and assembly code See Chapter 12 For struct and union element offset calculation is left up to the assembler so the layout may be different than cstruct and cunion Assembler Directives SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI TEXAS INSTRUMENTS www ti com Directives That Define Enumerated Types 4 10 Directives That Define Enumerated Types
449. rsion utility s image mode to fill any holes before between or after sections with a fill value For this scenario the application code resides in the program memory ROM on the TMS470 CPU but the data tables used by this code reside in an off chip EPROM The circuitry of the target board handles the access to the data the native TMS470 address of 0x1000 accesses location 0x0 on the EPROM To satisfy the address requirements for the code this scenario requires a linker command file that allocates sections and memory as follows The program application code represented in this scenario by the secA section shown in Example C 1 must be linked so that its address space resides in the program memory ROM on the TMS470 CPU To satisfy the condition that the data be loaded on the EPROM at address 0x0 but be referenced by the application code at address 0x1000 secB the section that contains the data for this application must be assigned a linker load address of 0x1000 so that all references to data in this section will be resolved with respect to the TMS470 CPU address In the hex conversion utility command file the paddr option must be used to burn the section of data at EPROM address 0x0 This value overrides the section load address given by the linker Example C 1 shows the linker command file that resolves the addresses needed in the stated specifications 320 Hex Conversion Utility Examples SPNU118J August 2011 Ay EF
450. rtitioning Memory Into Logical Blocks Object file Target memory EEPROM Introduction to Object Modules SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com How the Assembler Handles Sections 2 2 2 2 1 How the Assembler Handles Sections The assembler identifies the portions of an assembly language program that belong in a given section The assembler has five directives that support this function e bss USect text data sect The bss and usect directives create uninitialized sections the text data and sect directives create initialized sections You can create subsections of any section to give you tighter control of the memory map Subsections are created using the sect and usect directives Subsections are identified with the base section name and a subsection name separated by a colon see Section 2 2 4 Default Sections Directive NOTE f you do not use any of the sections directives the assembler assembles everything into the text section Uninitialized Sections Uninitialized sections reserve space in ARM 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 at run time for creating and storing variables Uninitialized data areas are built by using the bss and usect assembler directives The bss direc
451. ry before the application begins execution One way you can develop an application like this is to create a copy table in assembly code that contains three elements for each block of code or data that needs to be moved from FLASH into on chip memory at boot time The load address The run address The size The process you follow to develop such an application might look like this 1 Build the application to produce a map file that contains the load and run addresses of each section that has a separate load and run placement 2 Edit the copy table used by the boot loader to correct the load and run addresses as well as the size of each block of code or data that needs to be moved at boot time 3 Build the application again incorporating the updated copy table 4 Run the application This process puts a heavy burden on you to maintain the copy table by hand no less Each time a piece of code or data is added or removed from the application you must repeat the process in order to keep the contents of the copy table up to date Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Linker Generated Copy Tables 7 8 2 An Alternative Approach You can avoid some of this maintenance burden by using the LOAD_START RUN START and SIZE operators that are already part of the link command file syntax For example instead of building the
452. s The assembler supports several types of constants Binary integer e Octal integer Decimal integer Hexadecimal integer Character Assembly time The assembler maintains each constant internally as a 32 bit quantity Constants are not sign extended For example the constant OOFFh is equal to OOFF base 16 or 255 base 10 it does not equal 1 However when used with the byte directive 1 is equivalent to OOFFh Binary Integers A binary integer constant is a string of up to 32 binary digits Os and 1s followed by the suffix B or b If fewer than 32 digits are specified the assembler right justifies the value and fills the unspecified bits with zeros These are examples of valid binary constants 00000000B Constant equal to 0 or 6 0100000b Constant equal to 32 4 or 2046 01b Constant equal to 14 or 146 11111000B Constant equal to 248 or OF8 3 6 2 Octal Integers An octal integer constant is a string of up to 11 octal digits 0 through 7 followed by the suffix Q or q These are examples of valid octal constants 10Q Constant equal to 8 or 846 010 Constant equal to 8 or 8 4 format 100000Q Constant equal to 32 768 or 8000 226q Constant equal to 1504 or 46 3 6 3 Decimal Integers 42 A decimal integer constant is a string of decimal digits ranging from 2147 483 648 to 4 294 967 295 These are examples of valid decimal constants 1000 Constant equal to 1000 or 3E8 32768 Constant
453. s all symbols in the expression must be previously defined in the current source module Undefined external symbols and symbols that are defined later in the module cannot be used in the expression If the expression is relocatable the symbol to which it is assigned is also relocatable The value of the expression 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 see the global def ref topic In this way you can define global absolute constants This example shows how symbols can be assigned with set and equ x e e e e Se See Sce ke ke ke ke kk nd 2 Equate symbol AUX R1 to register AR 1 and use 3 it instead of the register 4 5 00000001 AUX R1 set R1 6 00000000 E3A01056 MOV AUX R1 56h 7 8
454. s groups or unions that are not nested under any other groups or unions The linker uses the run address of the top level structure to compute the run addresses of the components within groups and unions The linker does not accept a load allocation for UNIONs The linker does not accept a load allocation for uninitialized sections In most cases you must provide a load allocation for an initialized section However the linker does not accept a load allocation for an initialized section that is located within a group that already defines a load allocator As a shortcut you can specify a load allocation for an entire group to determine the load allocations for every initialized section or subgroup nested within the group However a load allocation is accepted for an entire group only if all of the following conditions are true The group is initialized that is it has at least one initialized member The group is not nested inside another group that has a load allocator The group does not contain a union containing initialized sections If the group contains a union with initialized sections it is necessary to specify the load allocation for each initialized section nested within the group Consider the following example SECTIONS GROUP load SLOW_MEM run SLOW_MEM textl UNION text2 text3 The load allocator given for the group does not uniquely specify the load allocation for the elements
455. s 2 33h 20 bytes reserved 4 6 Directives That Format the Output Listings These directives format the listing file The drlist directive causes printing of the directive lines to the listing the drnolist directive turns it off for certain directives You can use the drnolist directive to suppress the printing of the following directives You can use the drlist directive to turn the listing on again asg eval length mnolist Var break fclist mlist sslist Width emsg fcnolist mmsg ssnolist wmsg The source code listing includes false conditional blocks that do not generate code The fclist and fcnolist directives turn this listing on and off You can use the fclist directive to list false conditional blocks exactly as they appear in the source code You can use the fcnolist directive to list only the conditional blocks that are actually assembled The length directive controls the page length of the listing file You can use this 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 prevent the assembler from printing selected source statements in the listing file Use the list directive to turn the listing on again The source code listing includes macro expansions and loop blocks The mlist and mnolist directives turn this listing on and off You can use the mlist directive to print all macro e
456. s R4 through R11 and R15 from memory at SP Load CPSR with SPSR Shifted registers If a register symbol is followed by a shift type the computed value is the value in the register shifted according to the type as defined below LSL Logical shift left LSR Logical shift right ASL Arithmetic shift left ASR Arithmetic shift right ROR Rotate right RRX Rotate right extended The shift type can be followed by a register or an immediate whose value defines the shift amount The following are examples of instructions that use shifted registers as operands B ADD R1 R4 R5 LSR R2 Logical shift right the value in R5 by the value in R2 Add the value in R5 to R4 Place result in R1 LDR R1 R5 R4 LSL 4 Form address by adding the value in R4 shifted left by 4 to the value in R5 Load from address into R1 CMP R3 R4 RRX Compare the value in R3 with the value in R4 rotate right extend Curly braces the operand is a register list If you surround registers with curly braces the assembler treats the operand as a list of registers You can separate registers with commas or indicate a range of registers with a dash The following are examples of instructions that use register lists LDMEA R2 R1 R3 R6 Pre decrement stack load Load registers R1 R3 and R6 from memory at the address in R2 STMFD R12 R1 R3 R5 Pre increment stack store Store from registers R1 and R3 through R5 to memory at the address in R12 3
457. s assembling into the current section acting as an implied end of current section command It then assembles subsequent code into the designated section until it encounters another text data or sect directive Sections are built through an iterative process For example when the assembler first encounters a data directive the data section is empty The statements following this first data directive are assembled into the data section until the assembler encounters a text or sect directive If the assembler encounters subsequent data directives it adds the statements following these data directives to the statements already in the data section This creates a single data section that can be allocated continuously into memory Initialized subsections are created with the sect directive The sect directive can also be used to create initialized subsections See Section 2 2 4 for more information on creating subsections Introduction to Object Modules SPNU118J August 2011 BAY EE T Submit Documentation Feedback men www BDF TI I TEXAS INSTRUMENTS www ti com How the Assembler Handles Sections 2 2 3 Named Sections Named sections are sections that you create You can use them like the default text data and bss sections but they are assembled separately For example repeated use of the text directive builds up a single text section in the object file When linked this text section is allo
458. s do not appear in the listing file Also the line counter is incremented even when source statements are not listed Source file Copy copy2 asm Back in original file 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 00000000 00000020 word 32 1 A 00000004 00000042 2 Back in original file 3 00000008 E1A00000 NOP 7 Back in original file 8 00000014 44 String Done 00000015 6F 00000016 6E 00000017 65 Assembler Directives 113 Submit Documentation Feedback Se oF T www BD FEe cenr TI Directives Reference 1 TEXAS INSTRUMENTS www ti com loop endloop break Assemble Code Block Repeatedly Syntax Description Example loop well defined expression break well defined expression endloop Three directives allow you to repeatedly assemble a block of code The loop directive begins a repeatable block of code The optional expression evaluates to the loop count the number of loops to be performed If there is no well defined expression the loop count defaults to 1024 unless the assembler first encounters a break directive with an expression that is true nonzero or omitted The break directive along with its expression is optional This means that when you use the loop construct you do not have to use the break construct The break directive terminates a repeatable block of
459. s sections that define symbol spec For example this code retains sections that define symbols that start with init retain init You cannot specify retain retainz file spec scn spec scn spec Specifying the file format retains sections that match one or more scn spec from files matching the file spec For example this code retains initvec sections from all input files retain init You can specify retain to retain all sections from all input files However this does not prevent sections from library members from being optimized out retain ar spec mem spec mem spec scn spec scn spec Specifying the archive format retains sections matching one or more scn spec from members matching one or more mem spec from archive files matching ar spec For example this code retains the text sections from printf obj in the rts32eabi lib library retain rts32eabi lib printf obj text retain rts32eabi lib printf obj text retain rts32arp eabi lib printf obj text If the library is specified with the library option library rts32eabi lib the library search path is used to search for the library You cannot specify 7 4 26 Create an Absolute Listing File run abs Option The run abs option produces an output file for each file that was linked These files are named with the input filenames and an extension of abs Header files however do not generate a correspon
460. s symbol references to a symbol definition of a different name Section 7 4 30 undef sym U Places an unresolved external symbol into the output module s symbol table Section 7 4 32 unhide Reveals un hides global symbols that match pattern Section 7 4 15 Table 7 7 Run Time Environment Options Summary Option Alias Description Section heap size heap Sets heap size for the dynamic memory allocation in C to size bytes and Section 7 4 14 defines a global symbol that specifies the heap size Default 2K bytes stack size Stack Sets C system stack size to size bytes and defines a global symbol that Section 7 4 28 specifies the stack size Default 2K bytes arg size args Allocates memory to be used by the loader to pass arguments Section 7 4 3 be32 Forces the linker to generate BE 32 object code Section 7 4 4 be8 Forces the linker to generate BE 8 object code Section 7 4 4 fill value f Sets default fill values for holes within output sections fill_value is a 32 bit Section 7 4 12 constant ram_model Cr Initializes variables at load time Section 7 4 24 rom_model C Autoinitializes variables at run time Section 7 4 24 trampolines Generates far call trampolines on by default Section 7 4 31 174 Linker Description www sok Eeconzy TI SPNU118J August 2011 Submit Documentation Feedback 1 TEXAS INSTRUMENTS www ti com Linker Options Table 7 8 Link Time Optimization Options Summary Option Alias Descripti
461. s where a section runs run time support library A library file rts src that contains the source for the run time support functions section A relocatable block of code or data that ultimately will be contiguous with other sections in the memory map section program counter SPC An element that keeps track of the current location within a section each section has its own SPC sign extend A process that fills the unused MSBs of a value with the value s sign bit simulator A software development system that simulates ARM operation source file A file that contains C C code or assembly language code that is compiled or assembled to form an object file static variable A variable whose scope is confined to a function or a program The values of static variables are not discarded when the function or program is exited their previous value is resumed when the function or program is reentered storage class An entry in the symbol table that indicates how to access a symbol string table A table that stores symbol names that are longer than eight characters symbol names of eight characters or longer cannot be stored in the symbol table instead they are stored in the string table The name portion of the symbol s entry points to the location of the string in the string table structure A collection of one or more variables grouped together under a single name subsection A relocatable block of code or da
462. sary The linker eliminates the duplicate entries automatically Use the COFF only no sym merge option if you want the linker to keep such duplicate entries in COFF object files Using the no sym merge option has the effect of the linker running faster and using less host memory during linking but the resulting executable file may be very large due to duplicated debug information 7 4 22 Strip Symbolic Information no sym table Option The no sym table option creates a smaller output module by omitting symbol table information and line number entries The no sym table option is useful for production applications when you do not want to disclose symbolic information to the consumer This example links file1 obj and file2 obj and creates an output module stripped of line numbers and symbol table information named nosym out 61470 run linker output file nosym out no sym table filel obj file2 0bj Using the no sym table option limits later use of a symbolic debugger Stripping Symbolic Information NOTE The no sym table option is deprecated To remove symbol table information use the strip470 utility as described in Section 10 4 SPNU118J August 2011 Linker Description 187 Submit Documentation Feedback I I men gt 9115 1 I TEXAS INSTRUMENTS Linker Options www ti com 7 4 23 Name an Output Module output file Option The linker creates an output module when no errors are encountered
463. searches for the file in the following locations in the order given 1 The directory that contains the current source file The current source file is the file being assembled when the copy include or mlib directive is encountered 2 Any directories named with the include path option 3 Any directories named with the TMS470 A DIR environment variable 4 Any directories named with the TMS470 C DIR environment variable Because of this search hierarchy you can augment the assembler s directory search algorithm by using the include path option described in Section 3 4 1 or the TMS470 A DIR environment variable described in Section 3 4 2 The TMS470 C DIR environment variable is discussed in the ARM Optimizing C C Compiler User s Guide SPNU118J August 2011 Assembler Description 35 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Naming Alternate Directories for Assembler Input www ti com 3 4 4 Using the include path Assembler Option The include path assembler option names an alternate directory that contains copy include files or macro libraries The format of the include path option is as follows cl470 include pathz pathname source filename other options There is no limit to the number of include path options per invocation each include path option names one pathname In assembly source you can use the copy include or mlib directive without specifying
464. section Has this range text 0x00004000 through 0x0000487F data 0x00005B80 through 0x00005FFF The rest of the range is filled with Oh the default fill value converted into two output files e rom4000 b0 contains bits 0 through 7 rom4000 b1 contains bits 8 through 15 EPROM2 defines the address range from 0x00006000 through 0x00007FFF with the following sections This section Has this range data 0x00006000 through 0x0000633F table 0x00006700 through 0x00007C7F The rest of the range is filled with OxFFOOFFOO from the specified fill value The data from this range is converted into two output files rom6000 b0 contains bits 0 through 7 rom6000 b1 contains bits 8 through 15 11 5 The SECTIONS Directive You can convert specific sections of the object file by name with the hex conversion utility SECTIONS directive You can also specify those sections that you want to locate in ROM at a different address than the oad address specified in the linker command file If you Use a SECTIONS directive the utility converts only the sections that you list in the directive and ignores all other sections in the object file Do not use a SECTIONS directive the utility converts all initialized sections that fall within the configured memory Uninitialized sections are never converted whether or not you specify them in a SECTIONS directive Sections Generated by the 0 6 Compiler NOTE The ARM C C
465. section In general the linker combines input sections by concatenating them in the order in which they are specified However if alignment or blocking is specified for an input section all of the input sections within the output section are ordered as follows All aligned sections from largest to smallest All blocked sections from largest to smallest All other sections from largest to smallest The size of an output section is the sum of the sizes of the input sections that it comprises Example 7 8 shows the most common type of section specification note that no input sections are listed Example 7 8 The Most Common Method of Specifying Section Contents SECTIONS 1 text data bss In Example 7 8 the linker takes all the text sections from the input files and combines them into the text output section The linker concatenates the text input sections in the order that it encounters them in the input files The linker performs similar operations with the data and bss sections You can use this type of specification for any output section You can explicitly specify the input sections that form an output section Each input section is identified by its filename and section name SECTIONS 1 text Build text output section fl obj text Link text section from fl obj f 2 0bj secl Link secl section from f2 0bj 3 0bj Link ALL sections from 3 2 f4 obj text sec2
466. section of ctrl obj must be linked into SLOW MEM and preinitialized to 0x00000100 The bss sections of demo obj and tables obj must be linked into SLOW MEM Example 7 31 shows the link command file for this example Example 7 32 shows the map file Example 7 31 Linker Command File demo cmd ke ke k k ke ke kk kk Ck kk kk Kk Ck kk Ck kk Ck kk RK KKK I KK IKK kk Ree Specify Link Options f KCKCKCKCk kk kCkCk kk Ck Ck kk kk Ck kk Ck Ck kk Ck kk kk Ck Ck k kk k kk kc ko kk ke k ke ke ke ke ke ke k k f entry point SETUP Define the program entry point output file demo out Name the output file map file demo map Create an output map file RR KKK Ck kk ke kk Ck ke kk kk ke kk Ck Kk ke kc k Specify the Input Files A E E K k ee A k k A k k k k k k K k k A k
467. secutive bytes in the current section 1 00000000 41 ABCD 00000001 42 00000002 43 00000003 44 2 00000004 41 00000005 42 00000006 43 00000007 44 3 00000008 41 00000009 75 0000000a 73 00000000 74 0000000c 69 0000000d 6E 0000000e 48 00000005 6F 00000010 75 000000 73 000000 74 000000 6F 000000 6E 000000 44 000000 61 000000 6c 000000 6c 000000 61 000000 73 4 000000 30 string Str Ptr String String 41h 42h 43h 44h String Austin Houston Dallas O 0 5 Q NH 36 F 12 Assembler Directives 129 www sok Eeconzy TI Directives Reference 1 TEXAS INSTRUMENTS www ti com struct endstruct tag Declare Structure Type Syntax Description 130 Assembler Directives stag struct expr mem element expr mem element expr mem tag stag expr mem element expr size endstruct label tag stag The struct directive assigns symbolic offsets to the elements of a data structure definition This allows you to group similar data elements together and let the assembler calculate the element offset This is similar to a C structure or a Pascal record The Struct directive does not allocate memory it merely creates a symbolic template that can be used repeatedly The endstruct directive terminates the structure definition The tag directive gives structure characteristics to a abel simplifying the symbolic representation and providing the ab
468. sed available memory in that memory area Attributes This specifies one to four attributes associated with the named range specifies that the memory can be read specifies that the memory can be written to specifies that the memory can contain executable code specifies that the memory can be initialized xg For more information about the MEMORY directive see Section 7 5 3 A table showing the linked addresses of each output section and the input sections that make up the output sections section allocation map This table has the following columns this information is generated on the basis of the information in the SECTIONS directive in the link command file Output section This is the name of the output section specified with the SECTIONS directive Origin The first origin listed for each output section is the starting address of that output section The indented origin value is the starting address of that portion of the output section Length The first length listed for each output section is the length of that output section The indented length value is the length of that portion of the output section Attributes input sections This lists the input file or value associated with an output section If the input section could not be allocated the map file will indicate this with FAILED TO ALLOCATE For more information about the SECTIONS directive see Section 7 5 4 A table showing each external sy
469. sembler options identifies the name utility options you want to use Options are not case sensitive and can appear anywhere on the command line following the invocation Precede each option with a hyphen The name utility options are as follows a disables printing of address along with label names within instructions b displays data as bytes instead of words be8 disassembles in BE 8 mode 0 dumps the object file information copy tables aliased as y or Y displays copy tables and the sections copied The table information is dumped first then each record followed by its load and run data See Example 10 3 d disables display of data sections e displays integer values in hexadecimal h shows the current help screen i disassembles data sections as text I disassembles text as data n dumps the symbol table q quiet mode suppresses the banner and all progress information qq super quiet mode suppresses all headers r uses raw register IDs RO R1 etc R shows run time address if different from load time address S Suppresses printing of address and data words input is the name of the input file If the optional extension is not specified the file is filename ext searched for in this order 1 infile 2 infile out an executable file 3 infile obj an object file output filename is the name of the optional output file to which the disassembly will be written If an output filename is not spec
470. sembler simply appends the new code to the code that is already in the section The format in Figure 2 2 is a listing file Figure 2 2 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 Field 2 contains the section program counter Field 3 contains the object code Field 4 contains the original source statement See Section 3 12 for more information on interpreting the fields in a source listing SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com How the Assembler Handles Sections Figure 2 2 Using Sections Directives Example 1 KKK KKK KKK KKK KKK ko ko kx kx 2 Assemble an initialized table into data e e 3 4 00000000 data 5 0000000000000011 coeff word 011 022h 033h 00000004 00000022 00000008 00000033 6 ck ke ck ke e e ce cec ck gt 7 Reserve space in bss for a variable kk 8 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
471. serves space for uninitialized variables In addition the assembler and linker allow you to create name and link named sections that are used like the data text and bss sections There are two basic types of sections Initialized sections contain data or code The text and data sections are initialized named sections created with the sect assembler directive are also initialized Uninitialized sections reserve space in the memory map for uninitialized data The bss section is uninitialized named sections created with the usect assembler directive are also uninitialized Several assembler directives allow you to associate various portions of code and data with the appropriate sections The assembler builds these sections during the assembly process creating an object file organized as shown in Figure 2 1 One of the linker s functions is to relocate sections into the target system s memory map this function is called allocation 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 2 1 shows the relationship between sections in an object file and a hypothetical target memory Figure 2 1 Pa
472. sign a Substitution Symbol for more information about the asg and eval assembler directives SPNU118J August 2011 Macro Description 147 Submit Documentation Feedback I I men YP 0 9115 1 I TEXAS INSTRUMENTS Macro Parameters Substitution Symbols www ti com 5 3 2 Built In Substitution Symbol Functions The following built in substitution symbol functions enable you to make decisions on the basis of the string value of substitution symbols These functions always return a value and they can be used in expressions Built in substitution symbol functions are especially useful in conditional assembly expressions Parameters of these functions are substitution symbols or character string constants In the function definitions shown in Table 5 1 a and b are parameters that represent substitution symbols or character string constants The term string refers to the string value of the parameter The symbol ch represents a character constant Table 5 1 Substitution Symbol Functions and Return Values Function Return Value symlen a Length of string 2 symcmp a b lt Oifa lt b0ifa b gt 0ifa gt 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 a 1 if string ais defined in the symbol table 0 if string a is not defined in the symbol table ismembe
473. specified a reference from the current section is created The weak directive identifies a symbol that is used in the current module but is defined in another module The linker resolves this symbol s definition at link time The weak directive is equivalent to the ref directive except that the reference has weak linkage A global symbol is defined in the same manner as any other symbol that is it appears as a label or is defined by the set equ bss or usect directive As with all symbols if a global symbol is defined more than once the linker issues a multiple definition error The weak directive always creates a symbol table entry for a symbol whether the module uses the symbol or not symdepend however creates an entry only if the module actually uses the symbol A symbol can be declared global for either of two reasons Ifthe symbol is not defined in the current module which includes macro copy and include files the weak 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 definition in other modules fthe symbol is defined in the current module the symdepend directive declares that the symbol and its definition can be used externally by other modules These types of references are resolved at link time SPNU118J August 2011 Se oF T Submit Documentation Feedba
474. ssembly language source file to include The setsym and setsect directives are useful only for creating absolute listings not normal assembly Step 4 Finally assemble the abs files created by the absolute lister remember that you must use the absolute listing option when you invoke the assembler c1470 absolute listing modulel abs c1470 absolute listing module2 abs This command sequence creates two listing files called module1 Ist and module2 Ist no object code is produced These listing files are similar to normal listing files however the addresses shown are absolute addresses The absolute listing files created are module1 Ist see Example 8 1 and module2 Ist see Example 8 2 SPNU118J August 2011 Absolute Lister Description 259 Submit Documentation Feedback Se oF T www BD EIC conr TI Absolute Lister Example Example 8 1 modulet Ist I TEXAS INSTRUMENTS www ti com modulel abs PAGE 1 15 00000000 text 16 COpy modulel asm A 1 00000000 text A 2 00001000 bss dflag 1 A 3 00001001 bss array 100 A 4 00000000 00001000 dflag a word dflag A 5 00000004 00001001 array a word array A 6 00000008 00001068 offst a word offst A 7 COpy globals def B 1 global array B 2 global offst B 3 global dflag A 8 A 9 0000000c 25 0 LDR r4 array a A 10 00000010 E51F5010 LDR r5 offst a A 11 00000014 E51F301C LDR r3 dflag a A 12 00000018 E7940005 LDR 0 r4 r5 A 13 0000001c E5830000 STR ro
475. st Allows expanded substitution symbol listing SSlist topic Ssnolist Suppresses expanded substitution symbol listing default Ssnolist topic tab size Sets tab to size characters tab topic title string Prints a title in the listing page heading title topic Width page width Sets the page width of the source listing Width topic Table 4 6 Directives That Reference Other Files Mnemonic and Syntax Description See copy filename Includes source statements from another file copy topic include filename Includes source statements from another file include topic mlib filename Specifies a macro library from which to retrieve macro definitions mlib topic SPNU 118J August 2011 Assembler Directives 63 Submit Documentation Feedback www BRD EKireconr TI 1 TEXAS INSTRUMENTS Directives Summary www ti com Table 4 7 Directives That Effect Symbol Linkage and Visibility Mnemonic and Syntax Description See def symbol symbol Identifies one or more symbols that are defined in the current def topic module and that can be used in other modules global symbol symbol Identifies one or more global external symbols global topic ref symbol symbol Identifies one or more symbols used in the current module that are ref topic defined in another module symdepend dst symbol name src symbol name Creates an artificial reference from a section to a symbol symdepend t
476. st be asm The filename must follow host operating system conventions it can be enclosed in double quotes You can specify a full pathname for example c 320tools macs lib If you do not specify a full pathname the assembler searches for the file in the following locations in the order given 1 The directory that contains the current source file 2 Any directories named with the include_path assembler option 3 Any directories specified by the TMS470_A_DIR environment variable 4 Any directories specified by the TMS470_C_DIR environment variable See Section 3 4 for more information about the include_path option When the assembler encounters a mlib directive it opens the library specified by the filename and creates a table of the library s contents The assembler enters the names of the individual library members into the opcode table 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 but it does not place the source code into the listing Only macros that are actually called from the library are extracted and they are extracted only once See Chapter 5 for more information on macros and macro libraries The code creates a macro library that defines two macros inc4 asm and dec4 asm The file in
477. substitution symbol label symbol Defines a load time relocatable label in a section label topic newblock Undefines local labels newblock topic symbol set value Equates value with symbol Set topic unasg symbol Turns off assignment of symbol as a substitution symbol unasg topic undefine symbol Turns off assignment of symbol as a substitution symbol unasg topic Table 4 12 Directives That Define Common Data Sections Mnemonic and Syntax Description See endgroup gmember section name Ends the group declaration Designates section name as a member of the group endgroup topic gmember topic group group section name group type Begins a group declaration group topic Table 4 13 Directives That Create or Effect Macros Mnemonic and Syntax Description See endm End macro definition endm topic E Begins repeatable assembly of a code block the loop count is loop well defined expression determined by the well defined expression op topig macname macro parameter parameter Define macro by macname macro topic mexit Go to endm Section 5 2 mlib filename Identify library containing macro definitions mlib topic Var Adds a local substitution symbol to a macro s parameter list var topic Table 4 14 Directives That Control Diagnostics Mnemonic and Syntax Description See emsg string Sends user defined error messages to the output device emsg topic produces no obj file mmsg string
478. symbol that is defined in another module The assembler determines that y is defined in another module because it is not defined in the current module The assembler places both x and y in the object file s symbol table When the file is linked with other object files the entry for x resolves references to x in other files The entry for y causes the linker to look through the symbol tables of other files for y s definition The linker must match all references with corresponding definitions If the linker cannot find a symbol s definition it prints an error message about the unresolved reference This type of error prevents the linker from creating an executable object module Object File Format Specifications The object files created by the assembler and linker conform to either the ELF Executable and Linking Format or COFF Common Object File Format binary formats depending on the ABI selected when building your program When using the EABI mode the ELF format is used For the older TIABI and TI ARM9 ABI modes the legacy COFF format is used The ELF format cannot be used with the TIABI or TI ARM9 ABI modes Some features of the assembler may apply only to the ELF or COFF object file format In these cases the proper object file format is stated in the feature description See the ARM Optimizing C C Compiler User s Guide for information on the different ABls available See the Common Object File Format Application Note for informatio
479. t src2 9 m2 10 endm 1 12 call macro 13 00000000 Statel6 14 00000000 MIN 24 rl 2 1 00000000 1 CMP rl r2 1 00000002 1 BEC m1 1 00000004 60 MOV 242 xd 1 00000006 0 8 m2 1 1 00000008 4 m1 MOV r4 r2 1 0000000a m2 SPNU118J August 2011 Macro Description 155 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Producing Messages in Macros www ti com 5 7 Producing Messages in Macros The macro language supports three directives that enable you to define your own assembly time error and warning messages These directives are especially useful when you want to create messages specific to your needs The last line of the listing file shows the error and warning counts These counts alert you to problems in your code and are especially useful during debugging emsg sends error messages to the listing file The emsg directive generates errors in the same manner as the assembler incrementing the error count and preventing the assembler 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 prevent the generation of an object file Macro comm
480. t of the word moving toward the least significant part as more fields are added If the assembler encounters a field size that does not fit into the current word it writes out the word and begins packing fields into the next word You can use the align directive to force the next field directive to begin packing into a new word If you use a label it points to the byte that contains the specified field When you use field in a struct endstruct sequence field defines a member s size it does not initialize memory For more information see the struct endstruct tag topic This example shows how fields are packed into a word The SPC does not change until a word is filled and the next word is begun Figure 4 6 shows how the directives in this example affect memory e e ke ke ke ke sk n 2 Initialize a 14 bit field 3 ko 4 00000000 0 field OABCh 14 5 6 T ER Initialize a 5 bit field ER 8 p in the same word Wk 9
481. t system uA Notes 1 You must specify the directory in which rts32 lib is located Either add a i directory line to this file or use the system environment variable C DIR to Specify a search path for libraries af 2 If the runtime support library you are using is not named rts32 lib be sure to use the correct name here examplel map SecA load P MEM 5602 load 0 You must create a hex conversion command file to generate a hex output with the correct addresses and format for the EPROM programmer In the memory system outlined in Figure C 1 only the application data is stored on the EPROM the data resides in secB of the object file created by the linker By default the hex conversion utility converts all initialized sections that appear in the object file To prevent the conversion of the application code in secA a SECTIONS directive must be defined in the hex conversion command file to list explicitly the section s to be converted In this case secB must be listed explicitly as the section to be converted The EPROM programmer in this scenario has the following system requirements The EPROM programmer loads only a complete ROM image A complete ROM image is one in which there is a contiguous address space there are no holes in the addresses in the converted file and each address in the range contains a known value Creating a complete ROM image requires the use of the image option
482. ta that ultimately will occupy continuous space in the memory map Subsections are smaller sections within larger sections Subsections give you tighter control of the memory map symbol A string of alphanumeric characters that represents an address or a value symbolic debugging The ability of a software tool to retain symbolic information that can be used by a debugging tool such as a simulator or an emulator Glossary SPNU118J August 2011 1 2 EF T Submit Documentation Feedback men WWW FIC conr TI I TEXAS INSTRUMENTS www ti com Appendix D tag An optional type name that can be assigned to a structure union or enumeration target memory Physical memory in a system into which executable object code is loaded text section One of the default object file sections The text section is initialized and contains executable code You can use the text directive to assemble code into the text section unconfigured memory Memory that is not defined as part of the memory map and cannot be loaded with code or data uninitialized section A object file section that reserves space in the memory map but that has no actual contents These sections are built with the bss and usect directives UNION An option of the SECTIONS directive that causes the linker to allocate the same address to multiple sections union A variable that can hold objects of different types and sizes unsigned value 4A value that is t
483. tation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Scenario 1 Building a Hex Conversion Command File for a Single 8 Bit EPROM Example C 3 Contents of Hex Map File example1 mxp TMS470 COFF Hex Converter Version x xx Mon Sep 18 15 57 00 1995 INP OUT UT FILE NAME PUT FORMAT lt a out gt Intel PHYSICAL MEMORY PARAMETERS Default data width Default memory width Default output width 8 8 8 PUT TRANSLATION MAP 00000000 0001ffff Page 0 ROM Width 8 Memory Width 8 OUTPUT FILES bO EPROM examplel hex 00000000 00000007 00000007 0001ffff CONTENTS Data Width 1 secB FILL 00000000 Figure C 2 Contents of Hex Output File example1 hex Start character Address secB data tables 20000000876543214321DCBA00000000000000000000000000000000000000000000000096 200020000000000000000000000000000000000000000000000000000000000000000000C0 200040000000000000000000000000000000000000000000000000000000000000000000
484. te This option is required u updates any existing information in the index library specified with the o option instead of creating a new index libnames names individual object file libraries to be manipulated When you enter a libname you must enter a complete filename including extension if applicable 166 Archiver Description SPNU118J August 2011 BYE T Submit Documentation Feedback men www BDF TI 1 TEXAS INSTRUMENTS www ti com Library Information Archiver Description 6 5 2 Library Information Archiver Example Consider these object file libraries that all have the same members but are built with different build options Object File Library Name Build Options mylib ARMv4 be lib 0006 state 32 silicon version 4 endian big mylib_ARMv4_le lib code_state 32 silicon_version 4 endian little mylib_THUMBv4_be lib code_state 16 silicon_version 4 endian big mylib_THUMBv4_le lib code_state 16 silicon_version 4 endian little mylib_THUMBv7A8_le lib code_state 16 silicon_version 7A8 endian little Using the library information archiver you can create an index library called mylib lib from the above libraries libinfo470 o mylib lib mylib_ARMv4_be lib mylib_THUMBv4_be lib mylib THUMBv7A8 le lib mylib ARMv4 le lib mylib_THUMBv4_le lib You can now specify mylib lib as a library for the linker of an application The linker uses the index library to choose the appropriate version
485. the number of parameters the last parameter is assigned the character string equivalent of all remaining arguments If you pass a list of arguments to one parameter or if you pass a comma or semicolon to a parameter you must surround these terms with quotation marks At assembly time the assembler replaces the macro parameter substitution symbol with its corresponding character string then translates the source code into object code Example 5 2 shows the expansion of a macro with varying numbers of arguments Example 5 2 Calling a Macro With Varying Numbers of Arguments Macro definition Parms macro o PA Pae a igi b b e endm Calling the macro Parms 100 1abel Parms 100 1abel x y 0 8 0 0 8 0 b label H b label o E E c X Y Parms 100 x Parms 100 200 300 x y a 100 0 a 100 200 300 beau 5E C 8 6 Parms stringM sy H a string H b c y 146 Macro Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Macro Parameters Substitution Symbols 5 83 1 Directives That Define Substitution Symbols You can manipulate substitution symbols with the asg and eval directives The asg directive assigns a character string to a substitution symbol For the asg directive the quotation marks are optional If there are no quotation marks the assembler reads characters up
486. the ARM Optimizing C C Compiler User s Guide for details on TMS470 C DIR The command syntax for assigning the environment variable is as follows Operating System Enter UNIX Bourne Shell TMS470 A DIR z pathname pathname export TMS470 A DIR Windows set TMS470 A DIRz pathname pathnames The pathnames are directories that contain copy include files or macro libraries The pathnames must follow these constraints Pathnames must be separated with a semicolon Spaces or tabs at the beginning or end of a path are ignored For example the space before and after the semicolon in the following is ignored set TMS470 A DIR c path one to tools c path two to tools Spaces and tabs are allowed within paths to accommodate Windows directories that contain spaces For example the pathnames in the following are valid Assembler Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Naming Alternate Directories for Assembler Input In assembly source you can use the copy include or mlib directive without specifying path information If the assembler does not find the file in the directory that contains the current source file or in directories named by the include path option it searches the paths named by the environment variable For example assume that a file called source asm contains these statements copy cop
487. the Object Formats 11 12 Description of the Object Formats The hex conversion utility has options that identify each format Table 11 2 specifies the format options They are described in the following sections You need to use only one of these options on the command line If you use more than one option the last one you list overrides the others The default format is Tektronix tektronix option Table 11 2 Options for Specifying Hex Conversion Formats Option Alias Format Address Bits Default Width ascii a ASCII Hex 16 8 intel i Intel 32 8 motorola 1 m1 Motorola S1 16 8 motorola 2 m2 Motorola S2 24 8 motorola 3 m3 Motorola S3 32 8 ti tagged t TI Tagged 16 16 ti txt TI TXT 8 8 tektronix 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 available bits The default width determines the default output width of the format You can change the default width by using the romwidth option or by using the romwidth parameter in the ROMS directive You cannot change the default width of the Tl Tagged format which supports a 16 bit width only 11 12 1 ASCII Hex Object Format ascii Option The ASCII Hex object format supports 16 bit addresses The format consists of a byte stream with bytes separated by spaces Figure 11
488. the current section char topic cstring expr string L expr string Initializes one or more text strings String topic double value value Initializes one or more 64 bit IEEE double precision floating point double topic constants field value size Initializes a field of size bits 1 32 with value field topic float value value Initializes one or more 32 bit IEEE single precision floating point float topic constants half va ue value Initializes one or more 16 bit integers halfword half topic int value value Initializes one or more 32 bit integers int topic long value value Initializes one or more 32 bit integers long topic Short value value Initializes one or more 16 bit integers halfword Short topic String expr string expr string Initializes one or more text strings String topic word value value Initializes one or more 32 bit integers Word topic 62 Assembler Directives SPNU 118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Table 4 3 Directives That Perform Alignment and Reserve Space Directives Summary Mnemonic and Syntax Description See align size in bytes Aligns the SPC on a boundary specified by size inbytes which align topic must be a power of 2 defaults to byte boundary bes size Reserves size byt
489. the extracted file To replace the copy of push asm in the library with the edited copy enter ar470 r macros push asm If you want to use a command file specify the command filename after the command For example ar470 imodules cmd The archiver responds as follows lt building archive modules lib Example 6 1 is the modules cmd command file The r command specifies that the filenames given in the command file replace files of the same name in the modules lib library The u option specifies that these files are replaced only when the current file has a more recent revision date than the file that is in the library SPNU 118J August 2011 Archiver Description 165 Submit Documentation Feedback I I men YP gt 1 I TEXAS INSTRUMENTS Library Information Archiver Description www ti com Example 6 1 Archiver Command File Command file to replace members of the 0 modules library with updated files Use r command and u option ru Specify library name modules lib List filenames to be replaced if updated align asm bss asm data asm text asm sect asm clink asm copy asm double asm drnolist asm emsg asm end asm 6 5 Library Information Archiver Description Section 6 1 explains how to use the archiver to create libraries of object files for use in the linker of one or more applications You can have multiple versions of the same object file libraries each built with d
490. the filename from the list of outfile options The following line has the same effect as the example above using the ROMS directive outfile xyz b0 outfile xyz bl outfile xyz b2 outfile xyz b3 If both the ROMS directive and outfile options are used together the ROMS directive overrides the outfile options 3 It assigns a default filename If you specify no filenames or fewer names than output files the utility assigns a default filename A default filename consists of the base name from the input file plus a 2 to SPNU118J August 2011 Hex Conversion Utility Description 287 Submit Documentation Feedback I I men YP gt 9115 1 I TEXAS INSTRUMENTS Image Mode and the fill Option www ti com 3 character extension The extension has three parts a A format character based on the output format see Section 11 12 a for ASCII Hex i for Intel m for Motorola S t for Tl Tagged for Tektronix b The range number in the ROMS directive 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 O for the least significant file For example assume a out is for a 32 bit target processor and you are creating Intel format output With no output filenames specified the utility produces four output files named 3 10 a i1 a i2 a i3 If you include the following ROMS directi
491. tility prints a list of names defined and referenced in an object file executable files and or archive libraries The strip utility removes symbol table and debugging information from object and executable files Topic Page 10 1 Invoking the Object File Display Utility pp 268 l0 2 Invoking the Disassemblen 5 7 5 mere 2 mre EEEE eaea a Ee 11 269 10 3 Invoking the Name 271 10 4 Invoking the Strip Utility o ae eE EE EE E EAA EE EE EAER 272 SPNU118J August 2011 Object File Utilities 267 Submit Documentation Feedback oF T www BD EIC conr TI I TEXAS INSTRUMENTS Invoking the Object File Display Utility www ti com 10 1 268 Invoking the Object File Display Utility The object file display utility ofd470 prints the contents of object files obj executable files out and or archive libraries lib in both text and XML formats Hidden symbols are listed as no name while localized symbols are listed like any other local symbol To invoke the object file display utility enter the following ofd470 options input filename input filename ofd470 is the command that invokes the object file display utility input filename names the object file obj executable file out or archive library lib source file The filename must contain an extension options identify the object file display utility options that you want to use Options are not case sensitive
492. ting attributes are specified the assembler generates an error for example t asm ERROR at line 1 E0000 Attribute RO cannot be combined with attr RW Sect illegal sect RO RW The extra operands are allowed only in ELF mode They are ignored but generate a warning in COFF mode For example t asm WARNING at line 1 W0000 Trailing operands ignored Sect cosnt sect RO See Chapter 2 for more information about sections This example defines two special purpose sections Sym Defs and Vars and assembles code into them 1 2 Begin assembling into text section 3 ko ko ko ko ko kokok 4 00000000 text 5 00000000 8 MOV RO 78h 6 00000004 E2801078 ADD R1 RO 478h 7 8 Begin assembling into Sym Defs section 9 ck ck
493. titution 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 for x The assembler recognizes this as infinite recursion and ceases substitution Example 5 6 Recursive Substitution asg x z declare z and assign z x asg z y declare y and assign y z asg y x declare x and assign x y LDR RO x LDR RO x recursive expansion 5 3 4 Forced Substitution In some cases substitution symbols are not recognizable to the assembler The forced substitution operator which is a set of colons surrounding the symbol enables you to force the substitution of a Symbol s character string Simply enclose a symbol with colons to force the substitution Do not include any spaces between the colons and the symbol The syntax for the forced substitution operator is symbol The assembler expands substitution symbols surrounded by colons before expanding 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 SPNU 118J August 2011 Macro Description 149 Submit Documentation Feedback Se oF T www BD EIC conr TI I TEXAS INSTRUMENTS Macro Parameters Substi
494. tive reserves space in the bss section The usect directive reserves space in a specific uninitialized named section Each time you invoke the bss or usect directive the assembler reserves additional space in the bss or the named section The syntaxes for these directives are bss symbol size in bytes alignment bank offset symbol usect section name size in bytes alignment bank offset symbol points to the first byte reserved by this invocation of the bss or usect directive The symbol corresponds to the name of the variable that you are reserving space for It can be referenced by any other section and can also be declared as a global symbol with the global directive size in bytes is an absolute expression The bss directive reserves size in bytes bytes in the bss section The usect directive reserves size in bytes bytes in section name For both directives you must specify a size there is no default value alignment is an optional parameter It specifies the minimum alignment in bytes required by the space allocated The default value is byte aligned The value must be power of 2 bank offset is an optional parameter It ensures that the space allocated to the symbol occurs on a specific memory bank boundary The bank offset measures the number of bytes to offset from the alignment specified before assigning the symbol to that location section name tells the assembler which named section to reser
495. to A in lib2 pulling in a reference to B but now B is resolved by searching the libraries in order and resolves B to the first definition it finds namely the one in lib1 The priority option is useful for libraries that provide overriding definitions for related sets of functions in other libraries without having to provide a complete version of the whole library For example suppose you want to override versions of malloc and free defined in the rts470 lib without providing a full replacement for rts470 lib Using priority and linking your new library before rts470 lib guarantees that all references to malloc and free resolve to the new library The priority option is intended to support linking programs with DSP BIOS where situations like the one illustrated above occur SPNU 118J August 2011 Linker Description 183 Submit Documentation Feedback I I men BADE 0 9115 1 I TEXAS INSTRUMENTS Linker Options www ti com 7 4 17 Change Symbol Localization Symbol localization changes symbol linkage from global to local static This is used to obscure global symbols in a library which should not be visible outside the library but must be global because they are accessed by several modules in the library The linker supports symbol localization through the localize and globalize linker options The syntax for these options are localizez pattern globalizez pattern The pattern is a string with option
496. tributes can be obtained by invoking ofd470 obj display help V prints verbose text output X displays output in XML format xml_indent num sets the number of spaces to indent nested XML tags If an archive file is given as input to the object file display utility each object file member of the archive is processed as if it was passed on the command line The object file members are processed in the order in which they appear in the archive file If the object file display utility is invoked without any options it displays information about the contents of the input files on the console screen Object File Utilities SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Invoking the Disassembler Object File Display Format NOTE The object file display utility produces data in a text format by default This data is not intended to be used as input to programs for further processing of the information XML format should be used for mechanical processing 10 2 Invoking the Disassembler The disassembler dis470 examines the output of the assembler or linker This utility accepts an object file or executable file as input and writes the disassembled object code to standard output or a specified file To invoke the disassembler enter the following dis470 options input filename output filename dis470 is the command that invokes the disas
497. tring done Back in byte asm byte 67h 3q Assembler Directives SPNU118J August 2011 Submit Documentation Feedback www EIL 16co12 TI 1 TEXAS INSTRUMENTS www ti com Directives Reference Listing file 1 00000000 Space 29 2 copy byte asm A 1 In byte asm A 2 0000001d 20 byte 32 1 A 0000001e 42 A 3 copy word asm B 1 In word asm B 2 00000020 0000ABCD word OABCDh 56q 00000024 0000002E A 4 Back in byte asm A 5 00000028 6A byte 67h 3q 3 4 Back in original file 5 00000029 64 String done 0000002a 6F 0000002b 6E 0000002c 65 Example 2 In this example the include directive is used to read and assemble source statements from other files then the assembler resumes assembling into the current file The mechanism is similar to the copy directive except that statements are not printed in the listing file include asm byte2 asm word2 asm source file first copy file second copy file Space 29 In byte2 asm In word2 asm include byte2 asm byte 32 1 A word OABCDh 56q Back in original file include word2 asm string done Back in byte2 asm byte 67h 3q Listing file 1 00000000 2 3 4 5 00000029 4 0000002a 6F 0000002b 6E 0000002c 65 SPNU118J August 2011 Space 29 include byte2 asm Back in original file String done Assembler Directives 89 Submit Documentation Feedback I I men BADE 0 9115 1 Dire
498. tructions as well as to add new instructions Defining Macros You can define a macro anywhere in your program but you must define the macro before you can use it Macros can be defined at the beginning of a source file or in a copy include file see Copy Source File they can also be defined in a macro library For more information about macro libraries see Section 5 4 Macro definitions can be nested and they can call other macros but all elements of the macro must be defined in the same file Nested macros are discussed in Section 5 9 A macro definition is a series of source statements in the following format macname macro parameter parameter 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 128 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 is the directive that identifies the source statement as the first line of a macro definition You must place macro in the opcode field parameter are optional substitution symbols that appear as operands for the macro directive parameter Parameters are discussed in Section 5 3 Macro Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMEN
499. tructions 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 are separate all parameters following the keyword LOAD apply to load allocation and those following the keyword RUN apply to run allocation The allocation parameters are SPNU118J August 2011 Submit Documentation Feedback Linker Description 199 www oF Eeconzy TI I TEXAS INSTRUMENTS Linker Command Files www ti com Binding allocates a section at a specific address text load 0x1000 Named memory allocates the section into a range defined in the MEMORY directive with the specified name like SLOW_MEM or attributes text load gt SLOW MEM Alignment uses the align or palign keyword to specify that the section must start on an address boundary text align 0 Blocking uses the block keyword to specify that the section must fit between two address boundaries if the section is too big it starts on an address boundary text block 0x100 For the load usually the only allocation you can simply use a greater than sign and omit the load keyword text SLOW MEM text lt SLOW MEM text 0x4000 If more than one parameter is used you can string them together as follows text SLOW MEM align 16 Or if you prefer use parentheses for r
500. ts increment the line counter but are not listed For example title statements and statements following a nolist are not listed The difference between two consecutive source line numbers indicates the number of intervening statements in the source file that are not listed Include file letter A letter preceding the line number indicates the line is assembled from the include file designated by the letter Nesting level number A number preceding the line number indicates the nesting level of macro expansions or loop blocks Field 2 Section Program Counter This field contains the SPC value which is hexadecimal All sections text data bss and named sections maintain separate SPCs Some directives do not affect the SPC and leave this field blank Field 3 Object Code This field contains the hexadecimal representation of the object code All machine instructions and directives use this field to list object code This field also indicates the relocation type associated with an operand for this line of source code If more than one operand is relocatable this column indicates the relocation type for the first operand The characters that can appear in this column and their associated relocation types are listed below undefined external reference text relocatable sect relocatable data relocatable bss usect relocatable 96 relocation expression Field 4 Source Statement Field This field contains the characters o
501. tution Symbols www ti com Example 5 7 Using the Forced Substitution Operator FP 1 force macro 2 asg 0 x 3 loop 8 4 AUX x Set x 5 eval x 1 x 6 endloop 7 endm 8 9 00000000 force asg 0 x loop 8 AUX x Set x eval xtl x endloop 00000000 AUXO set 0 eval O 1 x 00000001 AUX1 set 1 eval 1 1 00000002 AUX2 set 2 eval 2 1 x 00000003 AUX3 set 3 eval 3 1 x 00000004 AUX4 set 4 eval 4 1 00000005 AUX5 set 5 eval 5 1 x 00000006 AUX6 set 6 eval 8 00000007 AUX7 set 3 eval 7 1 5 3 5 Accessing Individual Characters of Subscripted Substitution Symbols 150 In a macro you can access the individual characters substrings of a substitution symbol with subscripted substitution symbols You must use the forced substitution operator for clarity You can access substrings in two ways Symbol well defined expression This method of subscripting evaluates to a character string with one character Symbol well defined expression well defined expression In this method expression represents the substring s starting position and expression 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 sy
502. ty Assembler source Macro Archiver Archiver Library build Debugging process tools Run time support library Library of object files Executable object file Hex conversion utility EPROM Absolute lister Cross reference Object file programmer lister utilities SPNU118J August 2011 Assembler Description 33 Submit Documentation Feedback wwewlAd9 E Eeconzy TI I TEXAS INSTRUMENTS Invoking the Assembler www ti com 3 3 Invoking the Assembler To invoke the assembler enter the following cl470 input file options cl470 is the command that invokes the assembler through the compiler The compiler considers any file with an asm extension to be an assembly file and calls the assembler input file names the assembly language source file options identify the assembler options that you want to use Options are case sensitive and can appear anywhere on the command line following the command Precede each option with one or two hyphens as shown The valid assembler options are listed in Table 3 1 Table 3 1 ARM Assembler Options Option Alias Description absolute listing aa Creates an absolute listing When you use absolute listing the assembler does not produce an object file The absolute listing option is used in conjunction with the absolute lister asm define name def ad Sets the name symbol This is equivalent to defini
503. ubmit Documentation Feedback Se oF T www BD EIC conr TI Linker Description 253 254 Linker Description SPNU118J August 2011 TE I T Submit Documentation Feedback 1 efas men WWW conr TI 1 Chapter 8 SPNU118J August 2011 Absolute Lister Description The ARM absolute lister is a debugging tool that accepts linked object files as input and creates abs files as output These abs files can be assembled to produce a listing that shows the absolute addresses of object code Manually this could be a tedious process requiring many operations however the absolute lister utility performs these operations automatically Topic Page Producingian Absolute Eisting o euse eee E ae e eee e e E E e E 256 8 2 121010113016 Absolute Lister c ae e E E E E E 257 a3 VA EO 258 SPNU118J August 2011 Absolute Lister Description 255 Submit Documentation Feedback oF T www BD EIC conr TI 1 TEXAS INSTRUMENTS Producing an Absolute Listing www ti com 8 1 Producing an Absolute Listing Figure 8 1 illustrates the steps required to produce an absolute listing Figure 8 1 Absolute Lister Development Flow Assembler First assemble a source file source file Assembler Object file Linked object file Absolute lister Assembler Absolute listing 256 Absolute Lister Description SPNU118J August 2011 a oF T Submit Documentation Feedback www BD FECconr TI 1 TEXAS INSTRUMENTS
504. ue instead of using the contents of the register These are examples of an instruction that uses an operand with the prefix Label ADD R1 R1 3 Add 123 decimal to the value of R1 and place the result in R1 Square brackets the operand is an indirect address If the operand is enclosed in square brackets the assembler treats the operand as an indirect address that is it uses the contents of the operand as an address Indirect addresses consist of a base and an offset The base is specified by a register and is formed by taking the value in the register The offset can be specified by a register an immediate value or a shifted register Furthermore the offset can be designated as one of the following Pre index where the base and offset are combined to form the address To designate a pre index offset include the offset within the enclosing right bracket Postindex where the address is formed from the base and then the base and offset are combined To designate a postindex offset include the offset outside of the right bracket The offset can be added to or subtracted from the base The following are examples of instructions that use indirect addresses as operands A LDR R1 R1 Load from address in R1 into R1 LDR R7 R1 5 Form address by adding the value in R1 to 5 Load from address into R7 STR R3 Rl R2 Form address by subtracting the value in R2 from the value in R1 Store from R3 to me
505. ue of the symbol s address No type checking is performed Linker expressions can be absolute or relocatable If an expression contains any relocatable symbols and 0 or more constants or absolute symbols it is relocatable Otherwise the expression is absolute If a symbol is assigned the value of a relocatable expression it is relocatable if it is assigned the value of an absolute expression it is absolute The linker supports the C language operators listed in Table 7 10 in order of precedence Operators in the same group have the same precedence Besides the operators listed in Table 7 10 the linker also has an align operator that allows a symbol to be aligned on an n byte boundary within an output section nis a power of 2 For example the following expression aligns the SPC within the current section on the next 16 byte 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 align 16 Table 7 10 Groups of Operators Used in Expressions Precedence Group 1 Highest Precedence Group 6 Logical NOT s Bitwise NOT amp Bitwise AND Negation Group 2 Group 7 Multiplication Division Bitwise OR Modulus Group 3 Group 8 Addition Subtraction 58 Logical AND Group 4 Group 9 gt gt Arithmetic right shift lt lt Arithmetic left shift Logical QR Group 5 Group 10 Lowest Pr
506. uld also be entered as p12 SPNU118J August 2011 Submit Documentation Feedback Assembler Description 47 www BRD EKireconr TI Symbols I TEXAS INSTRUMENTS www ti com Predefined symbols as defined in the following table Macro Name Description TMS470 TMS470 16BIS TMS470 32BIS TMS470 5 TMS470 LITTLE TMS470 BIG 23 ARM7ABI ASSEMBLER ARM9ABI ASSEMBLER T EABI ASSEMBLER NEON SUPPORT _ TI TMS470 V4 T TMS470_V5E T TMS470_V6 T TMS470_V7 T TMS470_V7M3 T TMS470_V7A8 T TMS470_V7R4 T VFP SUPPORT _ TL VFPV3 SUPPORT H VFPV3D16 SUPPORT Always set to 1 Set to 1 if the default state is 16 bit Thumb mode the code state 16 option is used for an ARMv6 or prior architecture otherwise set to 0 Set to 1 if the default state is 32 bit the code state 16 option is not used or the code_state 32 option is used otherwise set to 0 Set to 1 if the default state is Thumb 2 mode the code state 16 option is used for an ARMvV7 or higher architecture otherwise set to 0 Set to 1 if little endian mode is selected the endian assembler option is used otherwise set to 0 Set to 1 if big endian mode is selected the endian assembler option is not used otherwise set to 0 Set to 1 if the TI ARM7 ABI is enabled the abi tiabi option is used otherwise it is set to 0 Set
507. under ELF as well as COFF 7 4 9 2 Do Not Remove Unused Sections unused section elimination Option In order to minimize the foot print the ELF linker does not include a section that is not needed to resolve any references in the final executable Use unused section eliminationzoff to disable this optimization The syntax for the option is unused section elimination on off The linker default behavior is equivalent to unused section elimination on 178 Linker Description SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Linker Options 7 4 10 Link Command File Preprocessing disable pp define and undefine Options The linker preprocesses link command files using a standard C preprocessor Therefore the command files can contain well known preprocessing directives such as define include and if endif Three linker options control the preprocessor disable pp Disables preprocessing for command files define name val Predefines name as a preprocessor macro undefine name Removes the macro name The compiler has define and undefine options with the same meanings However the linker options are distinct only define and undefine options specified after run linker are passed to the linker For example 01470 define FOO 1 main c run linker define BAR 2 lnk cmd The linker sees only the define for BAR the compiler only se
508. ut module called a out 61470 run linker relocatable filel obj file2 obj The output file a out can be relinked with other object files or relocated at load time Linking a file that will be relinked with other files is called partial linking For more information see Section 7 10 7 4 2 3 Producing an Executable Relocatable Output Module ar Option If you invoke the linker with both the absolute exe and relocatable 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 retained This example links file1 obj and file2 obj and creates an executable relocatable output module called xr out 01470 run linker ar filel obj file2 0bj output file xr out 7 43 Allocate Memory for Use by the Loader to Pass Arguments arg size Option 176 The arg size option instructs the linker to allocate memory to be used by the loader to pass arguments from the command line of the loader to the program The syntax of the arg size option is arg_size size The size is a number representing the number of bytes to be allocated in target memory for command line arguments By default the linker creates the 6 args symbol and sets it to 1 When you specify arg_size size the following occur The linker creates an uninitialized section named args of size bytes The c ar
509. ution trampolines have the disadvantage that they are somewhat slower than directly calling a function They require both a call and a branch Additionally while inline code could be tailored to the environment of the call trampolines are generated in a more general manner and may be slightly less efficient than inline code 7 4 31 3 Minimizing the Number of Trampolines Required minimize trampolines Option The minimize trampolines option attempts to place sections so as to minimize the number of far call trampolines required possibly at the expense of optimal memory packing The syntax is minimize trampolines postorder The argument selects a heuristic to use The postorder heuristic attempts to place functions before their callers so that the PC relative offset to the callee is known when the caller is placed When a call is placed and the callee s address is unknown the linker must provisionally reserve space for a far call trampoline in case the callee turns out to be too far away Even if the callee ends up being close enough the trampoline reservation can interfere with optimal placement for very large code sections By placing the callee first its address is known when the caller is placed so the linker can definitively know if a trampoline is required 7 4 31 4 Making Trampoline Reservations Adjacent trampoline min spacing Option When trampoline reservations are spaced more closely than the specified limit use the t
510. utput section name is different from the input sections name You want the linker to allocate the input sections before it processes additional input sections or commands within the braces The following example illustrates the two purposes above SECTIONS text abc obj xqt text data 5 data fil obj table In this example the text output section contains a named section xqt from file abc obj 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 the second output section 7 5 4 4 Using Multi Level Subsections Subsections can be identified with the base section name and one or more subsection names separated by colons For example A B and A B C name subsections of the base section A In certain places in a link command file specifying a base name such as A selects the section A as well as any subsections of A such as A B or A C D A name such as A B can be used to specify a sub section of that name as well as any multi level subsections beginning with that name such as A B C A B OTHER etc All the subsections of A B are also subsections of A A an
511. utput Listing 5 8 Using Directives to Format the Output Listing Macros substitution symbols and conditional assembly directives may hide information You may need to see this hidden information so the macro language supports an expanded listing capability By default the assembler shows macro expansions and false conditional blocks in the list output file You may want to turn this listing off or on within your listing file Four sets of directives enable you to control the listing of this information Macro and loop expansion listing mlist expands macros and loop endloop blocks The mlist directive prints all code encountered in those blocks mnolist suppresses the listing of macro expansions and loop endloop blocks For macro and loop expansion listing mlist is the default False conditional block listing fclist causes the assembler to include in the listing file all conditional blocks that do not generate code false conditional 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 listing fclist is the default Substitution symbol expansion listing SSlist expands substitution symbols in the listing This is useful for de
512. value romwidth value memwidth value fill value files filename filename romname origin value length value romwidth va ue memwidth value fill va ue files filename filename ROMS begins the directive definition romname identifies a memory range The name of the memory range can be one to eight characters in length The name has no significance to the program it simply identifies the range except when the output is for a load image in which case it denotes the section name Duplicate memory range names are allowed origin specifies the starting address of a memory range It can be entered as origin org or o The associated value must be a decimal octal or hexadecimal constant If you omit the origin value the origin defaults to 0 The following table summarizes the notation you can use to specify a decimal octal or hexadecimal constant Constant Notation Example Hexadecimal Ox prefix or h suffix 0x77 or 077h Octal 0 prefix 077 Decimal No prefix or suffix 77 length specifies the length of a memory range as the physical length of the ROM device It can be entered as length len or The value must be a decimal octal or hexadecimal constant If you omit the length value it defaults to the length of the entire address space romwidth specifies the physical ROM width of the range in bits see Section 11 3 3 Any value you specify here overrides the romwidth opt
513. var c C program that defines a variable svar as the structure type X The svar variable is then referenced in the addfive asm assembly program in Example 3 4 and 5 is added to svar s second data member Compile both source files with the symdebug dwarf option g and link them as follows 01470 symdebug dwarf cvars c addfive asm run linker library lnk cmd library rts470 1ib output file addfive out When you load this program into a symbolic debugger addfive appears as a C function You can monitor the values in svar while stepping through main just as you would any regular C variable Example 3 3 Viewing Assembly Variables as C Types C Program typedef struct 1 int m1 int m2 X X svar 1 2 Example 3 4 Assembly Program for Example 3 3 Tell the assembler we re referencing variable svar which is defined in another file cvars c addfive Add five to the second data member of svar j a 5 text global addfive addfive asmfunc LDW D2T2 B14 _svar 4 B4 load svar m2 into B4 RET 82 B3 return from function NOP 3 delay slots 1 3 ADD D2 5 B4 B4 add 5 to B4 delay slot 4 STW D2T2 24 214 svar 4 store 24 back into svar m2 delay slot 5 endasmfunc 58 Assembler Description SPNU118J August 2011 T oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Debugging Assembly Source S
514. ve 7 5 1 Reserved Names in Linker Command Files The following names in lowercase also are reserved as keywords for linker directives Do not use them as symbol or section names in a command file algorithm ALIGN ATTR BLOCK COMPRESSION COPY crc table DSECT END f FILL GROUP HIGH lowercase L len LENGTH LOAD LOAD_END LOAD_SIZE LOAD_START MEMORY NOINIT NOLOAD 0 7 5 2 Constants in Linker Command Files org SECTIONS ORIGIN SIZE PAGE START PALIGN TABLE RUN TYPE RUN END UNION RUN SIZE UNORDERED RUN START You can specify constants with either of two syntax schemes the scheme used for specifying decimal octal or hexadecimal constants used in the assembler see Section 3 6 or the scheme used for integer constants in C syntax Examples Format Decimal Octal Hexadecimal Assembler format 32 40q 020h C format 32 040 0x20 194 Linker Description SPNU118J August 2011 Ay EF T Submit Documentation Feedback men WWW ors Ceonmy I 1 TEXAS INSTRUMENTS www ti com Linker Command Files 75 3 The MEMORY Directive The linker determines where output sections are allocated into memory it must have a model of target memory to accomplish this The MEMORY directive allows you to specify a model of target memory so that you can define the types of memory your system contains and the address ranges they occupy The linker maintains the model as it allocates output sections and
515. ve space in See Section 2 2 3 SPNU118J August 2011 Introduction to Object Modules 21 Submit Documentation Feedback I I men YP gt 9115 1 1 TEXAS INSTRUMENTS How the Assembler Handles Sections www ti com The initialized section directives text data and sect tell the assembler to stop assembling into the current section and begin assembling into the indicated section The bss and usect directives however do not end the current section and begin a new one they simply escape from the current section temporarily The bss and usect directives can appear anywhere in an initialized section without affecting its contents For an example see Section 2 2 6 The usect directive can also be used to create uninitialized subsections See Section 2 2 4 for more information on creating subsections 2 2 2 Initialized Sections 22 Initialized sections contain executable code or initialized data The contents of these sections are stored in the object file and placed in ARM memory when the program is loaded Each initialized section is independently relocatable and may reference symbols that are defined in other sections The linker automatically resolves these section relative references Three directives tell the assembler to place code or data into a section The syntaxes for these directives are text data sect section name When the assembler encounters one of these directives it stop
516. ve when you invoke the hex conversion utility you would have eight output files ROMS 0x00001000 1 0x00002000 1 0x1000 0x1000 rangel o range2 o These output files Contain data in these locations 8 100 a i01 a i02 a i03 0x00001000 through 0x00001FFF 8 110 8 111 a i12 a i13 0x00002000 through 0x00002FFF 11 9 Image Mode and the fill Option This section points out the advantages of operating in image mode and describes how to produce output files with a precise continuous image of a target memory range 11 9 1 Generating a Memory Image With the image option the utility generates a memory image by completely filling all of the mapped ranges specified in the ROMS directive An object file consists of blocks of memory sections with assigned memory locations Typically all sections are not adjacent there are holes between sections in the address space for which there is no data When such a file is converted without the use of image mode the hex conversion utility bridges these holes by using the address records in the output file to skip ahead to the start of the next section In other words there may be discontinuities in the output file addresses Some EPROM programmers do not support address discontinuities In image mode there are no discontinuities Each output file contains a continuous stream of data that corresponds exactly to an address range in target memory Any holes before between o
517. w C C source files C C compiler C C name Assembler source Archiver Macro library Archiver demangling utility Assembler Object Library build Debugging ike process p Run time Library of li support object library files Executable object file Hex conversion utility EPROM Absolute lister Cross reference Object file programmer lister utilities 274 Hex Conversion Utility Description SPNU118J August 2011 a 3 T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Invoking the Hex Conversion Utility 11 2 Invoking the Hex Conversion Utility There are two basic methods for invoking the hex conversion utility Specify the options and filenames on the command line The following example converts the file firmware out into Tl Tagged format producing two output files firm lsb and firm msb hex470 t firmware o firm lsb Specify the options and filenames in a command file You can create a file that stores command line options and filenames for invoking the hex conversion utility The following example invokes the utility using a command file called hexutil cmd hex470 hexutil cmd o firm msb In addition to regular command line information you can use the hex conversion utility ROMS and SECTIONS directives in a command file 11 2 1 Invoking the Hex Conversion Utility From the Command Line To invoke the h
518. www ti com Invoking the Absolute Lister 8 2 Invoking the Absolute Lister The syntax for invoking the absolute lister is abs470 options input file abs470 is the command that invokes the absolute lister options identifies the absolute lister options that you want to use Options are not case sensitive and can appear anywhere on the command line following the command Precede each option with a hyphen The absolute lister options are as follows e enables you to change the default naming conventions for filename extensions on assembly files C source files and C header files The valid options are ea asmext for assembly files default is asm e ec cext for C source files default is c eh hext for C header files default is h ep pext for CPP source files default is cpp The in the extensions and the space between the option and the extension are optional q quiet suppresses the banner and all progress information input file names the linked object file If you do not supply an extension the absolute lister assumes that the input file has the default extension out If you do not supply an input filename when you invoke the absolute lister the absolute lister prompts you for one The absolute lister produces an output file for each file that was linked These files are named with the input filenames and an extension of abs Header files however do not generate a corresponding abs file
519. xpansions and loop blocks to the listing and the mnolist directive to suppress this listing The option directive controls certain features in the listing file This directive has the following operands A turns on listing of all directives and data and subsequent expansions macros and blocks B limits the listing of byte and char directives to one line H limits the listing of half and short directives to one line M turns off macro expansions in the listing N turns off listing performs nolist 0 turns on listing performs list R resets the B H M T and W directives turns off the limits of B H M T and W T limits the listing of string directives to one line W limits the listing of word and int directives to one line X produces a cross reference listing of symbols You can also obtain a cross reference listing by invoking the assembler with the cross reference option see Section 3 3 72 Assembler Directives SPNU118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI 1 TEXAS INSTRUMENTS www ti com Directives That Reference Other Files The page directive causes a page eject in the output listing The source code listing includes substitution symbol expansions The sslist and ssnolist directives turn this listing on and off You can use the sslist directive to print all substitution symbol expansions to the listing and the ssnolist directive to suppress this list
520. xpression Table 4 10 Directives That Define Union or Structure Types Mnemonic and Syntax Description See cstruct Acts like struct but adds padding and alignment like that which is cstruct topic done to C structures cunion Acts like union but adds padding and alignment like that which is cunion topic done to C unions emember Sets up C like enumerated types in assembly code Section 4 10 endenum Sets up C like enumerated types in assembly code Section 4 10 endstruct Ends a structure definition cstruct topic Struct topic endunion Ends a union definition cunion topic union topic enum Sets up C like enumerated types in assembly code Section 4 10 union Begins a union definition union topic struct Begins structure definition Struct topic tag Assigns structure attributes to a label cstruct topic Struct topic union topic 64 Assembler Directives SPNU 118J August 2011 Se oF T Submit Documentation Feedback www BD EIC conr TI I TEXAS INSTRUMENTS www ti com Directives Summary Table 4 11 Directives That Define Symbols Mnemonic and Syntax Description See asg character string substitution symbol Assigns a character string to substitution symbol asg topic symbol equ value Equates value with symbol equ topic elfsym name SYM SIZE size Provides ELF symbol information elfsym topic eval well defined expression Performs arithmetic on a numeric substitution symbol eval topic
521. xpressions and syntaxes of assignment statements are described in Section 7 5 8 SPNU118J August 2011 Linker Description 223 Submit Documentation Feedback I I men YP gt 1 I TEXAS INSTRUMENTS Linker Command Files www ti com 224 The following example uses assignment statements to create holes in output sections SECTIONS outsect filel obj text 0x0100 Create a hole with size 0x0100 file2 0bj text align 16 Create a hole to align the SPC file3 obj text The output section outsect is built as follows 1 The text section from file1 obj is linked in 2 The linker creates a 256 byte hole 3 The text section from file2 obj is linked in after the hole 4 The linker creates another hole by aligning the SPC on a 16 byte boundary 5 Finally the text section from file3 obj is linked in All values assigned to the symbol within a section refer to the relative address within the section The linker handles 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 the file3 obj text section to start on a 16 byte boundary within outsect If outsect is ultimately allocated to start on an address that is not aligned the file3 obj text section will not be aligned either The symbol refers to the current run address not th
522. y language instruction assembler directive or macro directive that supplies information to the operation performed by the instruction or directive optimizer A software tool that improves the execution speed and reduces the size of C programs options Command line parameters that allow you to request additional or specific functions when you invoke a software tool output module A linked executable object file that is downloaded and executed on a target system output section A final allocated section in a linked executable module partial linking Linking files in several passes Incremental linking is useful for large applications because you can partition the application link the parts separately and then link all of the parts together quiet run An option that suppresses the normal banner and the progress information raw data Executable code or initialized data in an output section relocation A process in which the linker adjusts all the references to a symbol when the symbol s address changes ROM width The width in bits of each output file or more specifically the width of a single data value in the hex conversion utility file The ROM width determines how the utility partitions the data into output files After the target words are mapped to memory words the memory words are broken into one or more output files The number of output files is determined by the ROM width run address The addres
523. yl asm copy copy2 asm Assume the following paths for the files UNIX tools files copy1 asm and dsys copy2 asm Windows c Mtools files copy1 asm and c dsys copy2 asm You could set up the search path with the commands shown below Operating System Enter UNIX Bourne shell TMS470_A_DIR dsys export TMS470_A_DIR c1470 include path tools files source asm Windows TMS470_A_DIR c dsys c1470 include_path c tools files source asm The assembler first searches for copy1 asm and copy2 asm in the current directory because source asm is in the current directory Then the assembler searches in the directory named with the include_path option and finds copy1 asm Finally the assembler searches the directory named with TMS470_A_DIR and finds copy2 asm The environment variable remains set until you reboot the system or reset the variable by entering one of these commands Operating System Enter UNIX Bourne shell unset TMS470_A_DIR Windows set TMS470 A DIR SPNU 118J August 2011 Assembler Description 37 Submit Documentation Feedback I I men BADE 0 9115 1 I TEXAS INSTRUMENTS Source Statement Format www ti com 3 5 3 5 1 38 Source Statement Format ARM assembly language source programs consist of source statements that can contain assembler directives assembly language instructions macro directives and comments A source statement can contain four ordered fields label mn
524. yntax is the default assembly syntax beginning with ARMv7 architectures The old syntax remains the default for ARMv6 and earlier while the ual option can be used to accept UAL syntax when assembling for these architectures When writing assembly code the arm and thumb directives are used to specify ARM and Thumb UAL syntax respectively The state32 and state16 directives remain to specify non UAL ARM and Thumb syntax The arm and state32 directives are equivalent since UAL syntax is backwards compatible in ARM mode Since non UAL syntax is not supported for Thumb 2 instructions Thumb 2 instructions cannot be used inside of a state16 section However assembly code with state16 sections that contain only non UAL Thumb code can be assembled for ARMv7 architectures to allow easy porting of older code See Section 4 3 for more information about the state16 state32 arm and thumb directives A full description of the UAL syntax can be found in the ARM Ltd documentation but there are a few key differences related to Thumb 2 syntax The W extension is used to indicate that an instruction should be encoded in a 32 bit form A N extension is used to indicate that an instruction should be encoded in a 16 bit form the assembler reports an error if this is not possible If no extension is used then the assembler uses a 16 bit encoding whenever possible 16 bit Thumb ALU instructions that set status indicate this with a syntax that has
525. zes variables at load time instead of run time initialized section A section from an object file that will be linked into an executable module input section A section from an object file that will be linked into an executable module ISO International Organization for Standardization a worldwide federation of national standards bodies which establishes international standards voluntarily followed by industries label A symbol that begins in column 1 of an assembler source statement and corresponds to the address of that statement A label is the only assembler statement that can begin in column 1 linker A software program that combines object files to form an object module that can be allocated into system memory and executed by the device listing file An output file created by the assembler that lists source statements their line numbers and their effects on the section program counter SPC little endian An addressing protocol in which bytes are numbered from right to left within a word More significant bytes in a word have higher numbered addresses Endian ordering is hardware specific and is determined at reset See also big endian loader A device that places an executable module into system memory macro A user defined routine that can be used as an instruction macro call The process of invoking a macro macro definition A block of source statements that define the name and the code that make
Download Pdf Manuals
Related Search
Related Contents
OPERATIONS GUIDE - Public Christian Library Model - S&S Cycle dGefahr! - Klint Wärme-Wasser PDF - Harmonic Drive AG 0.01°c - Delta Ohm S.r.l. Miia MTV-40DLEFHD 39" Full HD Black LED TV 取扱説明書 - Bose Philips 46677134136 halogen lamp SITRANS LR 400 Copyright © All rights reserved.
Failed to retrieve file