Professional Documents
Culture Documents
Sprui 03 B
Sprui 03 B
v8.2.x
User's Guide
Preface....................................................................................................................................... 10
1 Introduction to the Software Development Tools .................................................................... 13
1.1 Software Development Tools Overview ................................................................................. 14
1.2 Tools Descriptions.......................................................................................................... 15
2 Introduction to Object Modules ............................................................................................ 17
2.1 Object File Format Specifications ........................................................................................ 18
2.2 Executable Object Files ................................................................................................... 18
2.3 Introduction to Sections ................................................................................................... 18
2.3.1 Special Section Names ........................................................................................... 19
2.4 How the Assembler Handles Sections .................................................................................. 19
2.4.1 Uninitialized Sections ............................................................................................. 20
2.4.2 Initialized Sections ................................................................................................ 21
2.4.3 User-Named Sections ............................................................................................ 21
2.4.4 Current Section .................................................................................................... 22
2.4.5 Section Program Counters ....................................................................................... 22
2.4.6 Subsections ........................................................................................................ 22
2.4.7 Using Sections Directives ........................................................................................ 23
2.5 How the Linker Handles Sections ........................................................................................ 26
2.5.1 Combining Input Sections ........................................................................................ 26
2.5.2 Placing Sections ................................................................................................... 27
2.6 Symbols ..................................................................................................................... 28
2.6.1 External Symbols .................................................................................................. 28
2.6.2 Weak Symbols ..................................................................................................... 29
2.6.3 The Symbol Table ................................................................................................. 30
2.7 Symbolic Relocations ...................................................................................................... 30
2.7.1 Dynamic Relocation Entries...................................................................................... 31
2.8 Loading a Program ......................................................................................................... 31
3 Program Loading and Running ............................................................................................ 32
3.1 Loading ...................................................................................................................... 33
3.1.1 Load and Run Addresses ........................................................................................ 33
3.1.2 Bootstrap Loading ................................................................................................. 34
3.2 Entry Point................................................................................................................... 35
3.3 Run-Time Initialization ..................................................................................................... 35
3.3.1 _c_int00............................................................................................................. 35
3.3.2 RAM Model vs. ROM Model ..................................................................................... 35
3.3.3 Copy Tables........................................................................................................ 37
3.4 Arguments to main ......................................................................................................... 38
3.5 Run-Time Relocation ...................................................................................................... 38
3.6 Additional Information ...................................................................................................... 38
4 Assembler Description ........................................................................................................ 39
4.1 Assembler Overview ....................................................................................................... 40
4.2 The Assembler's Role in the Software Development Flow ........................................................... 41
4.3 Invoking the Assembler .................................................................................................... 42
4.4 The Application Binary Interface ......................................................................................... 43
List of Figures
1-1. TMS320C6000 Software Development Flow .......................................................................... 14
2-1. Partitioning Memory Into Logical Blocks ................................................................................ 19
2-2. Using Sections Directives Example ...................................................................................... 24
2-3. Object Code Generated by the File in .................................................................................. 25
2-4. Combining Input Sections to Form an Executable Object Module................................................... 27
3-1. Bootloading Sequence (Simplified) ...................................................................................... 34
3-2. Autoinitialization at Run Time ............................................................................................. 36
3-3. Initialization at Load Time ................................................................................................. 37
4-1. The Assembler in the TMS320C6000 Software Development Flow ................................................ 41
4-2. Example Assembler Listing ............................................................................................... 71
5-1. The .field Directive ......................................................................................................... 82
5-2. Initialization Directives ..................................................................................................... 83
5-3. The .align Directive......................................................................................................... 83
5-4. The .space and .bes Directives .......................................................................................... 84
5-5. Double-Precision Floating-Point Format ............................................................................... 105
5-6. The .field Directive ........................................................................................................ 114
5-7. Single-Precision Floating-Point Format ................................................................................ 115
5-8. The .usect Directive ..................................................................................................... 153
7-1. The Archiver in the TMS320C6000 Software Development Flow .................................................. 173
8-1. The Linker in the TMS320C6000 Software Development Flow .................................................... 180
8-2. Section Placement Defined by ......................................................................................... 211
8-3. Run-Time Execution of .................................................................................................. 224
8-4. Memory Allocation Shown in and ...................................................................................... 226
8-5. Compressed Copy Table ................................................................................................ 252
8-6. Handler Table ............................................................................................................. 253
8-7. A Basic DSP Run-Time Model .......................................................................................... 266
8-8. Dynamic Linking Model .................................................................................................. 267
8-9. Base Image Executable .................................................................................................. 268
10-1. The Hex Conversion Utility in the TMS320C6000 Software Development Flow ................................. 280
10-2. Hex Conversion Utility Process Flow................................................................................... 284
10-3. Object File Data and Memory Widths .................................................................................. 285
10-4. Data, Memory, and ROM Widths ....................................................................................... 287
10-5. The infile.out File Partitioned Into Four Output Files ................................................................. 290
10-6. ASCII-Hex Object Format................................................................................................ 298
10-7. Intel Hexadecimal Object Format ....................................................................................... 299
10-8. Motorola-S Format ........................................................................................................ 300
10-9. Extended Tektronix Object Format ..................................................................................... 301
10-10. TI-Tagged Object Format ................................................................................................ 302
10-11. TI-TXT Object Format .................................................................................................... 303
List of Tables
4-1. TMS320C6000 Assembler Options ...................................................................................... 42
4-2. C6000 Processor Symbolic Constants .................................................................................. 57
4-3. CPU Control Registers .................................................................................................... 57
4-4. Operators Used in Expressions (Precedence) ........................................................................ 62
4-5. Built-In Mathematical Functions .......................................................................................... 65
4-6. Symbol Attributes........................................................................................................... 73
5-1. Directives that Control Section Use ...................................................................................... 75
5-2. Directives that Gather Sections into Common Groups ................................................................ 75
5-3. Directives that Affect Unused Section Elimination ..................................................................... 75
5-4. Directives that Initialize Values (Data and Memory) ................................................................... 75
5-5. Directives that Perform Alignment and Reserve Space ............................................................... 76
5-6. Directives that Format the Output Listing ............................................................................... 76
5-7. Directives that Reference Other Files ................................................................................... 77
5-8. Directives that Affect Symbol Linkage and Visibility ................................................................... 77
5-9. Directives that Control Dynamic Symbol Visibility ..................................................................... 77
5-10. Directives that Enable Conditional Assembly ........................................................................... 77
5-11. Directives that Define Union or Structure Types ....................................................................... 78
5-12. Directives that Define Symbols ........................................................................................... 78
5-13. Directives that Create or Affect Macros ................................................................................. 78
5-14. Directives that Control Diagnostics ...................................................................................... 79
5-15. Directives that Perform Assembly Source Debug ...................................................................... 79
5-16. Directives that Perform Miscellaneous Functions ...................................................................... 79
6-1. Substitution Symbol Functions and Return Values................................................................... 160
6-2. Creating Macros .......................................................................................................... 170
6-3. Manipulating Substitution Symbols ..................................................................................... 170
6-4. Conditional Assembly .................................................................................................... 170
6-5. Producing Assembly-Time Messages .................................................................................. 170
6-6. Formatting the Listing .................................................................................................... 170
8-1. Basic Options Summary ................................................................................................. 182
8-2. File Search Path Options Summary .................................................................................... 182
8-3. Command File Preprocessing Options Summary .................................................................... 182
8-4. Diagnostic Options Summary ........................................................................................... 182
8-5. Linker Output Options Summary........................................................................................ 183
8-6. Symbol Management Options Summary .............................................................................. 183
8-7. Run-Time Environment Options Summary ............................................................................ 183
8-8. Link-Time Optimization Options Summary ............................................................................ 184
8-9. Dynamic Linking Options Summary .................................................................................... 184
8-10. Miscellaneous Options Summary ....................................................................................... 184
8-11. Predefined C6000 Macro Names ....................................................................................... 189
8-12. Groups of Operators Used in Expressions (Precedence) ........................................................... 233
8-13. Compiler Options For Dynamic Linking ................................................................................ 270
8-14. Linker Options For Dynamic Linking ................................................................................... 271
10-1. Basic Hex Conversion Utility Options .................................................................................. 281
10-2. Options for Specifying Hex Conversion Formats ..................................................................... 298
A-1. Symbolic Debugging Directives ......................................................................................... 313
D-1. Revision History ........................................................................................................... 328
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 <stdio.h>
main()
{ printf("hello world\n");
}
• In 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 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:
• 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:
• In assembler syntax statements, The leftmost character position, 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.
• Some directives can have a varying number of parameters. For example, the .byte directive can have
multiple parameters. This syntax is shown as [, ..., parameter].
• The TMS320C64x+ devices are referred to as C64x+. The TMS320C6600 devices are referred to as
C6600. The TMS320C6740 devices are referred to as C6740.
• Other symbols and abbreviations used throughout this document include the following:
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
The TMS320C6000™ is supported by a set of software development tools, which includes an optimizing
C/C++ compiler, an assembly optimizer, an assembler, a linker, and assorted utilities. This chapter
provides an overview of these tools.
The TMS320C6000 is supported by the following assembly language development tools:
• Assembler
• Archiver
• Linker
• Library information archiver
• 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
TMS320C6000, refer to the books listed in Related Documentation From Texas Instruments.
In addition, the following utilities are provided to help examine or manage the content of a given object file:
• The object file display utility prints the contents of object files and object libraries in either human
readable or XML formats. See Section 9.1.
• The disassembler decodes the machine code from object modules to show the assembly instructions
that it represents. See Section 9.2.
• The name utility prints a list of symbol names for objects and functions defined or referenced in an
object file or object archive. See Section 9.3.
• The strip utility removes symbol table and debugging information from object files and object libraries.
See Section 9.4.
The assembler creates object modules from assembly code, and the linker creates executable object files
from object modules. These executable object files can be executed by a TMS320C6000 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.
The assembler and linker allow you to create, name, and link other kinds of sections. The .text, .data, and
.bss sections are archetypes for how sections are handled.
There are two basic types of sections:
Initialized sections contain data or code. The .text and .data sections are initialized; user-
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; user-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 placement. 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 in a portion of the memory map that contains ROM. For
information on section placement, see the "Specifying Where to Allocate Sections in Memory" section of
the TMS320C6000 Optimizing Compiler User's Guide .
Figure 2-1 shows the relationship between sections in an object file and a hypothetical target memory.
.bss RAM
.data EEPROM
.text
ROM
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.4.6.
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 (see Section 4.9). 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; this option is represented by the
value 1. The value must be a 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 specifies the user-named section in which to reserve space. See Section 2.4.3.
Initialized section directives (.text, .data, and .sect) change which section is considered the current section
(see Section 2.4.2). However, the .bss and .usect directives do not change the current section; they simply
escape from the current section temporarily. Immediately after a .bss or .usect directive, the assembler
resumes assembling into whatever the current section was before the directive. The .bss and .usect
directives can appear anywhere in an initialized section without affecting its contents. For an example, see
Section 2.4.7.
The .usect directive can also be used to create uninitialized subsections. See Section 2.4.6 for more
information on creating subsections.
The .nearcommon and .farcommon directives are similar to directives that create uninitialized data
sections, except that common symbols are created, instead.
.text
.data
.sect "section name"
The .sect directive can also be used to create initialized subsections. See Section 2.4.6, for more
information on creating subsections.
2.4.6 Subsections
A subsection is created by creating a section with a colon in its name. Subsections are logical subdivisions
of larger sections. Subsections are themselves sections and can be manipulated by the assembler and
linker.
The assembler has no concept of subsections; to the assembler, the colon in the name is not special. The
subsection .text:rts would be considered completely unrelated to its parent section .text, and the
assembler will not combine subsections with their parent sections.
Subsections are used to keep parts of a section as distinct sections so that they can be separately
manipulated. For instance, by placing each function and object in a uniquely-named subsection, the linker
gets a finer-grained view of the section for memory placement and unused-function elimination.
By default, when the linker sees a SECTION directive in the linker command file like ".text", it will gather
.text and all subsections of .text into one large output section named ".text". You can instead use the
SECTION directive to control the subsection independently. See Section 8.5.5.1 for an example.
You can create subsections in the same way you create other user-named sections: by using the .sect or
.usect directive.
The syntaxes for a subsection name are:
A subsection is identified by the base section name followed by a colon and the name of the subsection.
The subsection name may not contain any spaces.
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 4.11 for more information on interpreting the fields in a source listing.
4 00000000 .data
5 00000000 00000011 coeff .word 011h,022h
00000004 00000022
18 00000000 .text
19 00000000 00800528 sum: MVK 10,A1
20 00000004 021085E0 ZERO A4
21
22 00000008 01003664 aloop: LDW *A0++,A2
23 0000000c 00004000 NOP 3
24 00000010 0087E1A0 SUB A1,1,A1
25 00000014 021041E0 ADD A2,A4,A4
26 00000018 80000112 [A1] B aloop
27 0000001c 00008000 NOP 5
28
29 00000020 0200007C- STW A4, *+B14(var1)
33 0000000c .data
34 0000000c 000000AA ivals .word 0aah, 0bbh, 0cch
00000010 000000BB
00000014 000000CC
43 00000024 .text
44 00000024 01003664 xmult: LDW *A0++,A2
45 00000028 00006000 NOP 4
46 0000002c 020C4480 MPYHL A2,A3,A4
47 00000030 02800028- MVKL var2,A5
48 00000034 02800068- MVKH var2,A5
49 00000038 02140274 STW A4,*A5
As Figure 2-3 shows, the file in Figure 2-2 creates five sections:
newvars is a user-named section created with the .usect directive; it contains eight bytes in
memory.
The second column shows the object code that is assembled into these sections; the first column shows
the source statements that generated the object code.
19 00800528 .text
20 021085E0
22 01003664
23 00004000
24 0087E1A0
25 021041E0
26 80000112
27 00008000
29 0200007C-
44 01003664
45 00006000
46 020C4480
47 02800028-
48 02800068-
49 02140274
5 00000011 .data
5 00000022
14 00001234
34 000000AA
34 000000BB
34 000000CC
54 00000000’ vectors
54 00000024’
No data— .bss
9 44 bytes
10 reserved
No data— newvars
38 8 bytes
39 reserved
In Figure 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 user-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 user-named sections at the end. The memory map shows the combined
sections to be placed into memory.
2.6 Symbols
An object file contains a symbol table that stores information about external symbols in the object file. The
linker uses this table when it performs relocation. See Section 2.7.
An object file symbol is a named 32-bit integer value, usually representing an address. A symbol can
represent such things as the starting address of a function, variable, or section.
An object file symbol can also represent an absolute integer, such as the size of the stack. To the linker,
this integer is an unsigned value, but the integer may be treated as signed or unsigned depending on how
it is used. The range of legal values for an absolute integer is 0 to 2^32-1 for unsigned treatment and
-2^31 to 2^31-1 for signed treatment.
Symbols can be bound as global symbols, local symbols, or weak symbols. The linker handles symbols
differently based on their binding. For example, the linker does not allow multiple global definitions of a
symbol, but local symbols can be defined in multiple object files (but only once per object file). The linker
does not resolve references to local symbols in different object files, but it does resolve references to
global symbols in any other object file.
A global symbol is defined in the same manner as any other symbol; that is, it appears as a label or is
defined by a directive, such as .set, .equ, .bss, or .usect. If a global symbol is defined more than once, the
linker issues a multiple-definition error. (The assembler can provide a similar multiple-definition error for
local symbols.)
A weak symbol is 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. Weak symbols are similar to global symbols, except that if
one object file contains a weak symbol, and another object file contains a global symbol with the same
name, the global symbol is used to resolve references. A weak reference may be unresolved at link time,
in which case the address is treated as 0. Therefore, for weak references, application code must test to
make sure &var is not zero before attempting to read the contents. See Section 2.6.2 for more about weak
symbols.
See Section 4.8 for information about assembler symbols.
.def The symbol is defined in the current file and may be 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 assembler chooses either .def or .ref as
appropriate for each symbol.
q: B B3
NOP 4
MVK 1, B1
x: MV A0,A1
MVKL y,B3
MVKH y,B3
B z
NOP 5
In this example, the .def definition of x says that it is an external symbol defined in this file and that other
files can reference x. The .ref definition of y says that it is an undefined symbol that is defined in another
file. The .global definition of z says that it is defined in some file and available in this file. The .global
definition of q says that it is defined in this file and that other files can reference q.
28 Introduction to Object Modules SPRUI03B – May 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
www.ti.com Symbols
The assembler places x, y, z, and q in the object file's symbol table. When the file is linked with other
object files, the entries for x and q resolve references to x and q in other files. The entries for y and z
cause the linker to look through the symbol tables of other files for y's and z's definitions.
The linker attempts to 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.
An error also occurs if the same symbol is defined more than once.
Assemble the source file that defines weak symbols, and include the resulting object file in the link. The
"ext_addr_sym" in this example is available as a weak absolute symbol in a final link. It is a candidate for
removal if the symbol is not referenced elsewhere in the application. See .weak directive.
Using the Linker Command File: To define a weak symbol in a linker command file, use the "weak"
operator in an assignment expression to designate that the symbol as eligible for removal from the output
file's symbol table if it is not referenced. In a linker command file, an assignment expression outside a
MEMORY or SECTIONS directive can be used to define a weak linker-defined absolute symbol. For
example, you can define "ext_addr_sym" as follows:
weak(ext_addr_sym) = 0x12345678;
If the linker command file is used to perform the final link, then "ext_addr_sym" is presented to the linker
as a weak absolute symbol; it will not be included in the resulting output file if the symbol is not
referenced. See Section 8.6.2.
If there are multiple definitions of the same absolute symbol, the linker uses certain rules to determine
which definition takes precedence. Some definitions may have weak binding and others may have strong
binding. "Strong" in this context means that the symbol has not been given a weak binding by either of the
two methods described above. Some definitions may come from an input object file (that is, using
assembly directives) and others may come from an assignment statement in a linker command file. The
linker uses the following guidelines to determine which definition is used when resolving references to a
symbol:
• A strongly bound symbol always takes precedence over a weakly bound symbol.
• If two symbols are both strongly bound or both weakly bound, a symbol defined in a linker command
file takes precedence over a symbol defined in an input object file.
• If two symbols are both strongly bound and both are defined in an input object file, the linker provides a
symbol redefinition error and halts the link process.
1 .global X
2 00000000 00000012! Z: B X ; Uses an external relocation
3 00000004 0180082A' MVKL Y,B3 ; Uses an internal relocation
4 00000008 0180006A' MVKH Y,B3 ; Uses an internal relocation
5 0000000C 00004000 NOP 3
6
7 00000010 0001E000 Y: IDLE
8 00000014 00000212 B Y
9 00000018 00008000 NOP 5
In Example 2-1, both symbols X and Y are relocatable. Y is defined in the .text section of this module; X is
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. 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 0x7100. Suppose also that the .text
section is relocated to begin at address 0x7200; Y now has a relocated value of 0x7210. The linker uses
the two relocation entries to patch the two references in the object code:
Relocations are symbol-relative rather than section-relative. This means that the relocation in Example 2-1
generated for 'Y' would refer to the symbol 'Y' and resolve the value for 'Y' in the opcode based on where
the definition of 'Y' ends up.
Even after a program is written, compiled, and linked into an executable object file, there are still many
tasks that need to be performed before the program does its job. The program must be loaded onto the
target, memory and registers must be initialized, and the program must be set to running.
Some of these tasks need to be built into the program itself. Bootstrapping is the process of a program
performing some of its own initialization. Many of the necessary tasks are handled for you by the compiler
and linker, but if you need more control over these tasks, it helps to understand how the pieces are
expected to fit together.
This chapter will introduce you to the concepts involved in program loading, initialization, and startup.
This chapter does not cover dynamic loading. See Chapter 14 of The C6000 Embedded Application
Binary Interface Application Report (SPRAB89) for information about dynamic loaders.
This chapter currently provides examples for the C6000 device family. Refer to your device documentation
for various device-specific aspects of bootstrapping.
3.1 Loading............................................................................................................. 33
3.2 Entry Point ........................................................................................................ 35
3.3 Run-Time Initialization ........................................................................................ 35
3.4 Arguments to main ............................................................................................. 38
3.5 Run-Time Relocation .......................................................................................... 38
3.6 Additional Information ........................................................................................ 38
3.1 Loading
A program needs to be placed into the target device's memory before it may be executed. Loading is the
process of preparing a program for execution by initializing device memory with the program's code and
data. A loader might be another program on the device, an external agent (for example, a debugger), or
the device might initialize itself after power-on, which is known as bootstrap loading, or bootloading.
The loader is responsible for constructing the load image in memory before the program starts. The load
image is the program's code and data in memory before execution. What exactly constitutes loading
depends on the environment, such as whether an operating system is present. This section describes
several loading schemes for bare-metal devices. This section is not exhaustive.
A program may be loaded in the following ways:
• A debugger running on a connected host workstation. In a typical embedded development setup,
the device is subordinate to a host running a debugger such as Code Composer Studio (CCS). The
device is connected with a communication channel such as a JTAG interface. CCS reads the program
and writes the load image directly to target memory through the communications interface.
• Another program running on the device. The running program can create the load image and
transfer control to the loaded program. If an operating system is present, it may have the ability to load
and run programs.
• "Burning" the load image onto an EPROM module. The hex converter (hex6x) can assist with this
by converting the executable object file into a format suitable for input to an EPROM programmer. The
EPROM is placed onto the device itself and becomes a part of the device's memory. See Chapter 10
for details.
• Bootstrap loading from a dedicated peripheral, such as an I2C peripheral. The device may require
a small program called a bootloader to perform the loading from the peripheral. The hex converter can
assist in creating a bootloader.
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 the first reference of the symbol is encountered at run time;
this does not happen automatically simply because you specify a separate run address. For examples that
specify load and run addresses, see Section 8.5.6.1.
For an example that illustrates how to move a block of code at run time, see Example 8-10. To create a
symbol that lets you refer to the load-time address, rather than the run-time address, see the .label
directive. To use copy tables to copy objects from load-space to run-space at boot time, see Section 8.8.
ELF format executable object files contain segments. See Section 2.3 for information about sections and
segments.
The primary bootloader is typically very small and copies a limited amount of memory from a dedicated
location in ROM to a dedicated location in RAM. (Some bootloaders support copying the program from an
I/O peripheral.) After the copy is completed, it transfers control to the program.
3.3.1 _c_int00
The function _c_int00 is the startup routine (also called the boot routine) for C/C++ programs. It performs
all the steps necessary for a C/C++ program to initialize itself.
The name _c_int00 means that it is the interrupt handler for interrupt number 0, RESET, and that it sets
up the C environment. Its name need not be exactly _c_int00, but the linker sets _c_int00 as the entry
point for C programs by default. The compiler's run-time-support library provides a default implementation
of _c_int00.
The startup routine is responsible for performing the following actions:
1. Set up the stack by initializing SP
2. Set up the data page pointer DP (for architectures that have one)
3. Set configuration registers
4. Process the .cinit table to autoinitialize global variables (when using the --rom_model option)
5. Process the .pinit table to construct global C++ objects.
6. Call the function main with appropriate arguments
7. Call exit when main returns
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
non-volatile memory and copied to fast memory each time the program is reset.
Figure 3-2 illustrates autoinitialization at run time. Use this method in any system where your application
runs from code burned into slow memory or needs to survive a reset.
cint Initialization
.cinit
Loader tables
section
(EXT_MEM)
Boot
routine
.bss
section
(D_MEM)
.cinit Loader
.bss
3.3.3.1 BINIT
The BINIT (boot-time initialization) copy table is special in that the target will automatically perform the
copying at auto-initialization time. Refer to Section 8.8.4.2 for more about the BINIT copy table name. The
BINIT copy table is copied immediately before .cinit processing.
3.3.3.2 CINIT
EABI .cinit tables are special kinds of copy tables. Refer to Section 3.3.2.1 for more about using the .cinit
section with the ROM model and Section 3.3.2.2 for more using it with the RAM model.
Assembler Description
The TMS320C6000 assembler translates assembly language source files into machine language object
files. These files are object modules, which are discussed in Chapter 2. Source files can contain the
following assembly language elements:
cl6x 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 invokes 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.
.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 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 C6X_A_DIR environment variable
4. Any directories named with the C6X_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 4.5.1) or the C6X_A_DIR environment variable (described
in Section 4.5.2). The C6X_C_DIR environment variable is discussed in the TMS320C6000 Optimizing
Compiler User's Guide.
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
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"
UNIX: /tools/files/copy.asm
Windows: c:\tools\files\copy.asm
You could set up the search path with the commands shown below:
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.
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 C6X_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:
set C6X_A_DIR=c:\first path\to\tools;d:\second path\to\tools
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 "copy1.asm"
.copy "copy2.asm"
You could set up the search path with the commands shown below:
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 C6X_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:
A label can only be associated with the first instruction in an execute packet (a group of instructions that is
to be executed in parallel).
Following are examples of source statements:
two .set 2 ; Symbol Two = 2
Label: MVK two,A2 ; Move 2 into register A2
.word 016h ; Initialize a word with 016h
There is no limit on characters per source statement. Each statement is one logical line of the input file.
Use a backslash (\) to indicate continuation of the same instruction/directive across multiple lines.
Follow these guidelines:
• All statements must begin with a label, a blank, an asterisk, or a semicolon.
• Labels are optional for most statements; if used, they must begin in column 1.
• One or more space or tab characters must separate each field.
• 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.
• In a conditional instruction, the condition register must be surrounded by square brackets.
• The functional unit specifier is optional. If you do not specify the functional unit, the assembler assigns
a legal functional unit based on the mnemonic field and the other instructions in the execute packet.
NOTE: A mnemonic cannot begin in column 1 or it will be interpreted as a label. Mnemonic opcodes
and assembler directive names without the . prefix are valid label names. Remember to
always use whitespace before the mnemonic, or the assembler will think the identifier is a
new label definition.
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.
Replace nnn with a string of decimal digits. You can precede nnn with a + or a -. You must specify a
decimal point. For example, 3.e5 is valid, but 3e5 is not valid. The exponent indicates a power of 10.
These are examples of valid floating-point literals:
3.0
3.14
3.
-0.314e13
+314.59e-2
The assembler syntax does not support all C89-style float literals nor C99-style hexadecimal constants,
but the $strtod built-in mathematical function supports both. If you want to specify a floating-point literal
using one of those formats, use $strtod. For example:
$strtod(".3")
$strtod("0x1.234p-5")
You cannot directly use NaN, Inf, or -Inf as floating-point literals. Instead, use $strtod to express these
values. The "NaN" and "Inf" strings are handled case-insensitively. See Section 4.10.1 for built-in
functions.
$strtod("NaN")
$strtod("Inf")
4.8.1 Identifiers
Identifiers are names used as labels, registers, symbols, and substitution symbols. An identifier is a string
of alphanumeric characters, the dollar sign, and underscores (A-Z, a-z, 0-9, $, and _). The first character
in an identifier cannot be a number, and identifiers cannot contain embedded blanks. The identifiers you
define are case sensitive; for example, the assembler recognizes ABC, Abc, and abc as three distinct
identifiers.
4.8.2 Labels
An identifier used as a label becomes an assembler symbol, which represent an address in the program.
Labels within a file must be unique.
NOTE: A mnemonic cannot begin in column 1 or it will be interpreted as a label. Mnemonic opcodes
and assembler directive names without the . prefix are valid label names. Remember to
always use whitespace before the mnemonic, or the assembler will think the identifier is a
new label definition.
Symbols derived from labels can also be used as the operands of .bss, .global, .ref, or .def directives.
.global label1
This is an example of code that declares and uses a local label legally:
$1:
SUB A1,1,A1
[A1] B $1
SUBC A3,A0,A3
NOP 4
$1 SUB A2,1,A2
[A2] B $1
MPY A3,A3,A3
NOP 4
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.
****************************************************************
** First definition of local label mylab **
****************************************************************
nop
mylab? nop
B mylab?
nop 5
****************************************************************
** Include file has second definition of mylab **
****************************************************************
.copy "a.inc"
****************************************************************
** Third definition of mylab, reset upon exit from .include **
****************************************************************
mylab? nop
B mylab?
nop 5
****************************************************************
** Fourth definition of mylab in macro, macros use different **
** namespace to avoid conflicts **
****************************************************************
mymac .macro
mylab? nop
B mylab?
nop 5
.endm
****************************************************************
** Macro invocation **
****************************************************************
mymac
****************************************************************
** Reference to third definition of mylab. Definition is not **
** reset by macro invocation. **
****************************************************************
B mylab?
nop 5
****************************************************************
** Changing section, allowing fifth definition of mylab **
****************************************************************
.sect "Sect_One"
nop
mylab? .word 0
nop
nop
B mylab?
nop 5
****************************************************************
** The .newblock directive allows sixth definition of mylab **
****************************************************************
.newblock
mylab? .word 0
nop
nop
B mylab?
nop 5
For more information about using labels in macros see Section 6.6.
You can also use the .set directive to assign symbolic constants for other symbols, such as register
names. In this case, the symbolic constant becomes a synonym for the register:
sym .set B1
MVK 10,sym
The following example shows how the .set directive can be used with the .struct, .tag. and .endstruct
directives. It creates the symbolic constants K, maxbuf, item, value, delta, and i_len.
K .set 1024 ; constant definitions
maxbuf .set 2*K
The assembler also has many predefined symbolic constants; these are discussed in Section 4.8.6.
cl6x --asm_define=name[=value]
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 quotation marks, do one of the following:
• For Windows, use --asm_define= name ="\" value \"". For example, --asm_define=car="\"sedan\""
• 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 with assembly
directives and instructions as if it had been defined with the .set directive. For example, on the command
line you enter:
cl6x --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 4-3 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 these
directives:
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.
4.8.7 Registers
The names of C6000 registers are predefined symbols, including A0-A15 and B0-B15; and A16-31 and
B16-31.
In addition, control register names are predefined symbols.
Register symbols and aliases can be entered as all uppercase or all lowercase characters.
Control register symbols can be entered in all upper-case or all lower-case characters. For example, CSR
can also be entered as csr.
See the "Register Conventions" section of the TMS320C6000 Optimizing Compiler User's Guide for
details about the registers and their uses.
Rn+1:Rn
A1:A0 B1:B0
A3:A2 B3:B2
A5:A4 B5:B4
A7:A6 B7:B6
A9:A8 B9:B8
A11:A10 B11:B10
A13:A12 B13:B12
A15:A14 B15:B14
A17:A16 B17:B16
A19:A18 B19:B18
A21:A20 B21:B20
A23:A22 B23:B22
A25:A24 B25:B24
A27:A26 B27:B26
A29:A30 B29:B30
A31:A32 B31:B32
For details on using register pairs in linear assembly, see the TMS320C6000 Optimizing Compiler User's
Guide.
For more information on functional units, including which assembly instructions require which functional
type, see the TMS320C64x/C64x+ DSP CPU and Instruction Set Reference Guide, TMS320C66x CPU
and Instruction Set Reference Guide, or TMS320C6740 DSP CPU and Instruction Set Reference Guide.
Rn+3:Rn+2:Rn+1:Rn or Rn+3::Rn
For details on using register quads in C6600 linear assembly, see the TMS320C6000 Optimizing Compiler
User's Guide.
For more information on functional units, including which assembly instructions require which functional
type, see the TMS320C66x CPU and Instruction Set Reference Guide.
When you are using macros, substitution symbols are important because macro parameters are actually
substitution symbols that are assigned a macro argument. The following code shows how substitution
symbols are used in macros:
MAC .macro src1, src2, dst ; Multiply/Accumulate macro
MPY src1, src2, src2
NOP
ADD src2, dst, dst
.endm
* MAC macro invocation
MAC A0,A1,A2
4.9 Expressions
Nearly all values and operands in assembly language are expressions, which may be any of the following:
• a literal constant
• a register
• a register pair
• a memory reference
• a symbol
• a built-in function invocation
• a mathematical or logical operation on one or more expressions
This section defines several types of expressions that are referred to throughout this document. Some
instruction operands accept limited types of expressions. For example, the .if directive requires its operand
be an absolute constant expression with an integer value. Absolute in the context of assembly code
means that the value of the expression must be known at assembly time.
A constant expression is any expression that does not in any way refer to a register or memory reference.
An immediate operand will usually not accept a register or memory reference. It must be given a constant
expression. Constant expressions may be any of the following:
• a literal constant
• an address constant expression
• a symbol whose value is a constant expression
• a built-in function invocation on a constant expression
• a mathematical or logical operation on one or more constant expressions
An address constant expression is a special case of a constant expression. Some immediate operands
that require an address value can accept a symbol plus an addend; for example, some branch
instructions. The symbol must have a value that is an address, and it may be an external symbol. The
addend must be an absolute constant expression with an integer value. For example, a valid address
constant expression is "array+4".
A constant expression may be absolute or relocatable. Absolute means known at assembly time.
Relocatable means constant, but not known until link time. External symbols are relocatable, even if they
refer to a symbol defined in the same module.
An absolute constant expression may not refer to any external symbols anywhere in the expression. In
other words, an absolute constant expression may be any of the following:
• a literal constant
• an absolute address constant expression
• a symbol whose value is an absolute constant expression
• a built-in function invocation whose arguments are all absolute constant expressions
• a mathematical or logical operation on one or more absolute constant expressions
A relocatable constant expression refers to at least one external symbol. Such expressions may contain at
most one external symbol. A relocatable constant expression may be any of the following:
• an external symbol
• a relocatable address constant expression
• a symbol whose value is a relocatable constant expression
• a built-in function invocation with any arguments that are relocatable constant expressions
• a mathematical or logical operation on one or more expressions, at least one of which is a relocatable
constant expression
In some cases, the value of a relocatable address expression may be known at assembly time. For
example, a relative displacement branch may branch to a label defined in the same section.
Table 4-4 lists the operators that can be used in expressions, according to precedence group.
The assembler checks for overflow and underflow conditions when arithmetic operations are performed
during assembly. It issues a warning (the "value truncated" message) whenever an overflow or underflow
occurs. The assembler does not check for overflow or underflow in multiplication.
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.
This sequence of instructions is also referred to as far DP-relative addressing. The LDW instruction uses a
scaled version of DP-relative indexed addressing. Similar to the $DPR_WORD(sym) operator, the
$DPR_BYTE(sym) operator is provided to facilitate far DP-relative addressing of 8-bit data objects:
MVKL $DPR_BYTE(xyz),A0 ; load (xyz - static_base) into A0
MVKH $DPR_BYTE(xyz),A0
LDB *+DP[A0],A1 ; load *xyz into A1
The $DPR_HWORD(sym) operator is provided to facilitate far DP-relative addressing of 16-bit data
objects:
MVKL $DPR_HWORD(xyz),A0 ; load (xyz - static_base)/2 into A0
MVKH $DPR_HWORD(xyz),A0
LDH *+DP[A0],A1 ; load *xyz into A1
If the data being accessed is within range of the anticipated value of the DP (assuming the static base is
loaded into the DP before the MVK instructions are used), then a more efficient way to access the data
can be to use MVK instructions. For example, the compiler can compute the address of an 8-bit data
object in the .bss section:
MVK $DPR_BYTE(_char_X),A4 ; load (_char_X - static_base) into A4
ADD DP,A4,A4 ; compute address of _char_X
Similarly, the compiler can compute the address of a 16-bit data object that is defined in the .bss section:
MVK $DPR_HWORD(_short_X),A4 ; load (_short_X - static_base)/2 into A4
ADD DP,A4,A4 ; compute address of _short_X
It can also compute a 32-bit data object that is defined in the .bss section:
MVK $DPR_WORD(_int_X),A4 ; load (_int_X - static_base)/4 into A4
ADD DP,A4,A4 ; compute address of _int_X
The actual semantics of the $GOT(sym) operator is to return the DP- relative offset of the GOT entry for
the referenced symbol (xyz above).
While $DPR_GOT(sym) is semantically similar to the $GOT(sym) operator, it is used when the GOT is not
accessible using DP-relative addressing mode (offset is not within signed 15-bit range of the static base
address that is loaded into the data pointer register (DP)). The DP-relative offset to the GOT entry is then
loaded into an index register using a MVKL/MVKH instruction sequence, and the GOT entry is then
accessed via DP-relative indexed addressing to load the address of the referenced symbol:
MVKL $DPR_GOT(xyz),A0 ; load DP-relative offset of
MVKH $DPR_GOT(xyz),A0 ; GOT entry for xyz into A0
LDW *+DP[A0],A1 ; get address of xyz via GOT entry
LDW *A1,A2 ; load xyz into A2
4.10.2.3 $PCR_OFFSET(x,y)
The $PCR_OFFSET(x,y) operator can be applied in the source operand of a MVKL, MVKH, or ADDK
instruction to compute a PC-relative offset to be loaded into (in the case of MVKL/MVKH) or added to (in
the case of ADDK) a register.
This operator is used in the context of compiler-generated code under the Linux ABI (using --linux
compiler option). It helps the compiler to generate position-independent code by accessing a symbol that
is defined in the same RO segment using PC-relative addressing.
For example, if there is to be a call to a function defined in the same file, but you would like to avoid
generating a dynamic relocation that accesses the symbol that represents the destination of the call, then
you can use the $PCR_OFFSET operator as follows:
dest:
<code>
...
make_pcr_call:
MVC PCE1, B0 ; set up PC reference point in B0
MVKL $PCR_OFFSET(dest, make_pcr_call), B1 ; compute dest - make_pcr_call
MVKH $PCR_OFFSET(dest, make_pcr_call), B1 ; and load it into B1
ADD B0,B1,B0 ; compute dest address into B0 register
B B0 ; call dest indirectly through B0
...
The above code sequence is position independent. No matter what address 'dest' is placed at load time,
the call to 'dest' will still work since it is independent of the actual address of 'dest'. However, the call does
have to maintain its position relative to the definition of 'dest'.
Also in the above sequence, the compiler creates a coupling between the MVC instruction and the
'make_pcr_call' label. The 'make_pcr_call' label must be associated with the address of the MVC
instruction so that when the $PCR_OFFSET(dest, make_pcr_call) operator is applied, the 'make_pcr_call'
symbol becomes a representative for the PC reference point. This means that the result of 'dest -
make_pcr_call' becomes the PC-relative offset which when added to the PC reference point in B0 gives
the address of 'dest'.
The relocation that is generated for the $PCR_OFFSET() operator is handled during the static link step in
which a dynamic module is built. This static relocation can then be discarded and no dynamic relocation
will be needed to resolve the call to 'dest' in the above example.
Example 4-4. Generating a Switch Table With Offset Switch Case Labels
.asg A15, FP
.asg B14, DP
.asg B15, SP
.sect ".text"
.clink
.global myfunc
;******************************************************************************
;* FUNCTION NAME: myfunc *
;******************************************************************************
myfunc:
;** --------------------------------------------------------------------------*
B .S1 $C$L10
|| SUB .L2X A4,10,B5
|| STW .D2T2 B3,*SP--(16)
CMPGTU .L2 B5,7,B0
|| STW .D2T1 A4,*+SP(12)
|| MV .S2X A4,B4
[ B0] BNOP .S1 $C$L9,3
; BRANCH OCCURS {$C$L10} ; |6|
;** --------------------------------------------------------------------------*
$C$L1:
<case 0 code>
...
;** --------------------------------------------------------------------------*
$C$L2:
<case 1 code>
...
;** --------------------------------------------------------------------------*
$C$L3:
<case 2 code>
...
;** --------------------------------------------------------------------------*
$C$L4:
<case 3 code>
...
;** --------------------------------------------------------------------------*
$C$L5:
<case 4 code>
...
;** --------------------------------------------------------------------------*
Example 4-4. Generating a Switch Table With Offset Switch Case Labels (continued)
$C$L6:
<case 5 code>
...
;** --------------------------------------------------------------------------*
$C$L7:
<case 6 code>
...
;** --------------------------------------------------------------------------*
$C$L8:
<case 7 code>
...
;** --------------------------------------------------------------------------*
$C$L9:
<default case code>
...
;** --------------------------------------------------------------------------*
$C$L10:
NOP 2
; BRANCHCC OCCURS {$C$L9} {-9} ;
;** --------------------------------------------------------------------------*
SUB .L2 B4,10,B5 ; Norm switch value -> switch table index
|| ADDKPC .S2 $C$SW1,B4,0 ; Load address of switch table to B4
LDW .D2T2 *+B4[B5],B5 ; Load PC-relative offset from switch table
NOP 4
ADD .L2 B5,B4,B4 ; Combine to get case label into B5
BNOP .S2 B4,5 ; Branch to case label
; BRANCH OCCURS {B4} ;
Example 4-4 mixes data into the code section. Compression is disabled for the code section that contains
the $LABEL_DIFF() operator, since the label difference must resolve to a constant value during assembly.
2 ** Global variables
10 .copy mpy32.inc
A 1 mpy32 .macro A,B
A 2
A 5
A 7
A 9
A 11
A 13 .endm
11
15 00000000 .text
16 00000000 _func
17 00000000 0200006C- LDW *+B14(var1),A4
18 00000004 0000016E- LDW *+B14(var2),B0
19 00000008 00006000 NOP 4
20 0000000c mpy32 A4,B0
1
21 00000024 000C6362 B B3
22 00000028 00008000 NOP 5
23 * end _func
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 .ref directive). Example 4-5 shows the cvar.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 4-
6 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:
cl6x --symdebug:dwarf cvars.c addfive.asm --run_linker --library=lnk.cmd --library=rts6600.lib
--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.
typedef struct
{
int m1;
int m2;
} X;
X svar = { 1, 2 };
;--------------------------------------------------------------------------------------
; Tell the assembler we're referencing variable "_svar", which is defined in
; another file (cvars.c).
;--------------------------------------------------------------------------------------
.ref _svar
;--------------------------------------------------------------------------------------
; addfive() - Add five to the second data member of _svar
;--------------------------------------------------------------------------------------
.text
.global addfive
addfive: .asmfunc
LDW .D2T2 *+B14(_svar+4),B4 ; load svar.m2 into B4
RET .S2 B3 ; return from function
NOP 3 ; delay slots 1-3
ADD .D2 5,B4,B4 ; add 5 to B4 (delay slot 4)
STW .D2T2 B4,*+B14(_svar+4) ; store B4 back into svar.m2 (delay slot 5)
.endasmfunc
.BIG_ENDIAN 00000000 0
.LITTLE_ENDIAN 00000001 0
.TMS320C6400_PLUS 00000001 0
.TMS320C6600 00000000 0
.TMS320C6740 00000001 0
_func 00000000' 18
var1 00000000- 4 17
var2 00000004- 5 18
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 4-6 lists these
characters and names.
Definition (DEFN) 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.
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
• Specify libraries from which the assembler can obtain macros
• Examine symbolic debugging information
This chapter is divided into two parts: the first part (Section 5.1 through Section 5.11) describes the
directives according to function, and the second part (Section 5.12) is an alphabetical reference.
Table 5-4. Directives that Initialize Values (Data and Memory) (continued)
Mnemonic and Syntax Description See
.double value1[, ... , valuen] 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 value1[, ... , valuen] Initializes one or more 32-bit, IEEE single-precision, floating-point .float topic
constants
.half value1[, ... , valuen] Initializes one or more 16-bit integers (halfword) .half topic
.int value1[, ... , valuen] Initializes one or more 32-bit integers .int topic
.long value1[, ... , valuen] Initializes one or more 32-bit integers .long topic
.short value1[, ... , valuen] Initializes one or more 16-bit integers (halfword) .short topic
.string {expr1|"string1"}[,... , {exprn|"stringn"}] Initializes one or more text strings .string topic
.ubyte value1[, ... , valuen] Initializes one or more successive unsigned bytes in the current .ubyte topic
section
.uchar value1[, ... , valuen] Initializes one or more successive unsigned bytes in the current .uchar topic
section
.uhalf value1[, ... , valuen] Initializes one or more unsigned 16-bit integers (halfword) .uhalf topic
.uint value1[, ... , valuen] Initializes one or more unsigned 32-bit integers .uint topic
.ulong value1[, ... , valuen] Initializes one or more unsigned 32-bit integers .long topic
.ushort value1[, ... , valuen] Initializes one or more unsigned 16-bit integers (halfword) .short topic
.uword value1[, ... , valuen] Initializes one or more unsigned 32-bit integers .uword topic
.word value1[, ... , valuen] Initializes one or more 32-bit integers .word topic
In addition to the assembly directives that you can use in your code, the C/C++ 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
• The .battr directive is used to encode build attributes for the object file. For more information about
build attributes generated and used by the C6000 Code Generation Tools, please see The C6000
Embedded Application Binary Interface application report (SPRAB89).
• The .bound directive is used internally.
• The .comdat directive is used internally.
• The .compiler_opts directive indicates that the assembly code was produced by the compiler, and
which build model options were used for this file.
• The .tls directive is used internally.
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 or data into the current
section.
00000004 00000002
6 00000008 00000003 .word 3,4
0000000c 00000004
7
8 **************************************************
9 * Start assembling into the .data section *
10 **************************************************
11 00000000 .data
12 00000000 00000009 .word 9, 10
00000004 0000000A
13 00000008 0000000B .word 11, 12
0000000c 0000000C
14
15 **************************************************
16 * Start assembling into a named, *
17 * initialized section, var_defs *
18 **************************************************
19 00000000 .sect "var_defs"
20 00000000 00000011 .word 17, 18
00000004 00000012
21
22 **************************************************
23 * Resume assembling into the .data section *
24 **************************************************
25 00000010 .data
26 00000010 0000000D .word 13, 14
00000014 0000000E
27 00000000 .bss sym, 19 ; Reserve space in .bss
28 00000018 0000000F .word 15, 16 ; Still in .data
0000001c 00000010
29
30 **************************************************
31 * Resume assembling into the .text section *
32 **************************************************
33 00000010 .text
34 00000010 00000005 .word 5, 6
00000014 00000006
35 00000000 usym .usect "xy", 20 ; Reserve space in xy
36 00000018 00000007 .word 7, 8 ; Still in .text
0000001c 00000008
Figure 5-1 shows how fields are packed into a word. Using the following assembled code, notice that
the SPC does not change (the fields are packed into the same word):
1 00000000 00000003 .field 3,4
2 00000000 00000083 .field 8,5
3 00000000 00002083 .field 16,7
• 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 or more 16-bit values into consecutive 16-bit fields
(halfwords) in the current section. These 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. These 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.
• The .ubyte, .uchar, .uhalf, .uint, .ulong, .ushort, and .uword directives are provided as unsigned
versions of their respective signed directives. These directives are used primarily by the C/C++
compiler to support unsigned types in C/C++.
Figure 5-2 compares the .byte, .half, .word, and .string directives using the following assembled code:
1 00000000 000000AB .byte 0ABh
2 .align 4
3 00000004 0000CDEF .half 0CDEFh
4 00000008 89ABCDEF .word 089ABCDEFh
5 0000000c 00000068 .string "help"
0000000d 00000065
0000000e 0000006C
0000000f 00000070
• The .bes and .space directives reserve a specified number of bytes in the current section. The
assembler fills these reserved bytes with 0s.
– When you use a label with .space, it points to the first byte that contains reserved bits.
– When you use a label with .bes, it points to the last byte that contains reserved bits.
Figure 5-4 shows how the .space and .bes directives work for the following assembled code:
1
2 00000000 00000100 .word 100h, 200h
00000004 00000200
3 00000008 Res_1: .space 17
4 0000001c 0000000F .word 15
5 00000033 Res_2: .bes 20
6 00000034 000000BA .byte 0BAh
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.
Res_1 = 08h
17 bytes
reserved
20 bytes
reserved
Res_2 = 33h
• 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.
D turns off the listing of certain directives (same effect as .drnolist).
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).
O turns on listing (performs .list).
R resets the B, H, L, M, T, and W directives (turns off the limits of B, H, L, 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 --asm_listing_cross_reference option (see Section 4.3).
• 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 listing. 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.
• The .if/.elseif/.else/.endif directives tell the assembler to conditionally assemble a block of code
according to the evaluation of an expression.
.if condition marks the beginning of a conditional block and assembles code
if the .if condition is true.
[.elseif condition] marks a block of code to be assembled if the .if condition is
false and the .elseif condition is true.
.else marks a block of code to be assembled if the .if condition 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 [count] marks the beginning of a repeatable block of code. The optional
expression evaluates to the loop count.
.break [end condition] tells the assembler to assemble repeatedly when the .break end
condition 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 operators, see Section 4.9.2.
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 11. For .struct and .union, element offset calculation is left up to the
assembler, so the layout may be different than .cstruct and .cunion.
Description The .align directive aligns the section program counter (SPC) on the next boundary,
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 size in bytes must
equal a power of 2; the value must be between 1 and 32,768, inclusive. 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
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 00000004 .byte 4
2 .align 2
3 00000002 00000045 .string "Errorcnt"
00000003 00000072
00000004 00000072
00000005 0000006F
00000006 00000072
00000007 00000063
00000008 0000006E
00000009 00000074
4 .align
5 00000008 0003746E .field 3,3
6 00000008 002B746E .field 5,4
7 .align 2
8 0000000c 00000003 .field 3,3
9 .align 8
10 00000010 00000005 .field 5,4
11 .align
12 00000011 00000004 .byte 4
Description 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 11 for more information about using C/C++ headers in assembly source.
The .eval directive performs arithmetic on substitution symbols, which are stored in the
substitution symbol table. This directive evaluates the 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 expression is a well-defined alphanumeric expression in which all symbols have
been previously defined in the current source module, so that the result is an
absolute expression.
• 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.
Example This example shows how .asg and .eval can be used.
1 .sslist ; show expanded substitution symbols
2
3 .asg *+B14(100), GLOB100
4 .asg *+B15(4), ARG0
5
6 00000000 003B22E4 LDW GLOB100,A0
# LDW *+B14(100),A0
7 00000004 00BC22E4 LDW ARG0,A1
# LDW *+B15(4),A1
8 00000008 00006000 NOP 4
9 0000000c 010401E0 ADD A0,A1,A2
10
11 .asg 0,x
12 .loop 5
13 .word 100*x
14 .eval x+1,x
15 .endloop
1 00000010 00000000 .word 100*x
# .word 100*0
1 .eval x+1,x
# .eval 0+1,x
1 00000014 00000064 .word 100*x
# .word 100*1
1 .eval x+1,x
# .eval 1+1,x
1 00000018 000000C8 .word 100*x
# .word 100*2
1 .eval x+1,x
# .eval 2+1,x
1 0000001c 0000012C .word 100*x
# .word 100*3
1 .eval x+1,x
# .eval 3+1,x
1 00000020 00000190 .word 100*x
# .word 100*4
1 .eval x+1,x
# .eval 4+1,x
Description 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 symbol is a label that must appear in the label field.
The .asmfunc directive has an optional parameter, stack_usage, which indicates that the
function may use up 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 $
Example This example generates debug information for the user_func section.
1 00000000 .sect ".text"
2 .global userfunc
3 .global _printf
4
5 userfunc: .asmfunc stack_usage(16)
6 00000000 00000010! CALL .S1 _printf
7 00000004 01BC94F6 STW .D2T2 B3,*B15--(16)
8 00000008 01800E2A' MVKL .S2 RL0,B3
9 0000000c 01800028+ MVKL .S1 SL1+0,A3
10 00000010 01800068+ MVKH .S1 SL1+0,A3
11
12 00000014 01BC22F5 STW .D2T1 A3,*+B15(4)
13 00000018 0180006A' || MVKH .S2 RL0,B3
14
15 0000001c 01BC92E6 RL0: LDW .D2T2 *++B15(16),B3
16 00000020 020008C0 ZERO .D1 A4
17 00000024 00004000 NOP 3
18 00000028 000C0362 RET .S2 B3
19 0000002c 00008000 NOP 5
20 .endasmfunc
21
22 00000000 .sect ".const"
23 00000000 00000048 SL1: .string "Hello World!",10,0
00000001 00000065
00000002 0000006C
00000003 0000006C
00000004 0000006F
00000005 00000020
00000006 00000057
00000007 0000006F
00000008 00000072
00000009 0000006C
0000000a 00000064
0000000b 00000021
0000000c 0000000A
0000000d 00000000
Description The .bits directive places one or more values into consecutive bits of the current section.
The .bits directive is similar to the .field directive (see .field topic ). However, the .bits
directive does not allow you to specify the number of bits to fill or increment the SPC.
Description The .bss directive reserves space for variables in the .bss section. This directive is
usually used to allocate space in RAM.
• The symbol is a required parameter. It defines a symbol that points to the first
location 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 constant
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. This must be set to a power of 2. If the
SPC is already aligned to the specified boundary, it is not incremented.
• The bank offset is an optional parameter that ensures that the space allocated 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.
For more information about sections, see Chapter 2.
Example In this example, the .bss directive allocates space for a variable, array. The symbol array
points to 100 bytes of uninitialized space (at .bss SPC = 0). Symbols declared with the
.bss directive can be referenced in the same manner as other symbols and can also be
declared global.
1 *******************************************
2 ** Start assembling into .text section. **
3 *******************************************
4 00000000 .text
5 00000000 008001A0 MV A0,A1
6
7 *******************************************
8 ** Allocate 100 bytes in .bss. **
9 *******************************************
10 00000000 .bss array,100
11
12 *******************************************
13 ** Still in .text **
14 *******************************************
15 00000004 010401A0 MV A1,A2
16
17 *******************************************
18 ** Declare external .bss symbol **
19 *******************************************
20 .global array
Description The .byte, .ubyte, .char, and .uchar directives place one or more values into
consecutive bytes of the current section. A value can be one of the following:
• An expression that the assembler evaluates and treats as an 8-bit signed number
• A character 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.
With little-endian ordering, 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.
Example 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 0h, 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 0000000A STRX .byte 10,-1,"abc",'a'
00000001 000000FF
00000002 00000061
00000003 00000062
00000004 00000063
00000005 00000061
2 00000006 00000008 STRY .char 8,-3,"def",'b'
Description 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:
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 %}, is
treated as C/C++ source and processed. Ordinary assembler processing then resumes
on the line following the closing %}.
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 #defines.
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 11 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"
Source file:
.cdecls C,LIST,"myheader.h"
Listing File:
1 .cdecls C,LIST,"myheader.h"
A 1 ; ------------------------------------------
A 2 ; Assembly Generated from C/C++ Source Code
A 3 ; ------------------------------------------
A 4
A 5 ; =========== MACRO DEFINITIONS ===========
A 6 .define "10",WANT_ID
A 7 .define """John\n""",NAME
A 8
A 9 ; =========== TYPE DEFINITIONS ===========
A 10 status_enum .enum
A 11 00000001 OK .emember 1
A 12 00000100 FAILED .emember 256
A 13 00000000 RUNNING .emember 0
A 14 .endenum
A 15
A 16 myCstruct .struct 0,4
17 ; struct size=(8 bytes|64 bits), alignment=4
A 18 00000000 member_a .field 32
19 ; 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)
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_enum.OK
6 00000010 00000100 failval: .int status_enum.FAILED
7 .if $defined(WANT_ID)
8 00000014 0000004A id .cstring NAME
00000015 0000006F
00000016 00000068
00000017 0000006E
00000018 0000000A
00000019 00000000
9 .endif
Description The .common directive creates a common symbol in a common block, rather than
placing the variable in a memory section.
This directive is used by the compiler when the --common option is enabled (the default),
which causes uninitialized file scope variables to be emitted as common symbols. The
benefit of common symbols is that generated code can remove unused variables that
would otherwise increase the size of the .bss section. (Uninitialized variables of a size
larger than 32 bytes are separately optimized through placement in separate subsections
that can be omitted from a link.) This optimization happens for C/C++ code by default
unless you use the --common=off compiler option.
• The symbol is a required parameter. It defines a name for the symbol created by this
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 section used for common symbols. There is no
default size.
• A structure tag can be used in place of a size to specify a structure created with the
.struct directive. Either a size or a structure tag is required for this argument.
• The alignment is an optional parameter that ensures that the space allocated to the
symbol occurs on the specified boundary. The boundary must be set to a power of 2
between 20 and 215, inclusive. If the SPC is already aligned at the specified boundary,
it is not incremented.
Common symbols are symbols that are placed in the symbol table of an ELF object file.
They represent an uninitialized variable. Common symbols do not reference a section.
(In contrast, initialized variables need to reference a section that contains the initialized
data.) The value of a common symbol is its required alignment; it has no address and
stores no address. While symbols for an uninitialized common block can appear in
executable object files, common symbols may only appear in relocatable object files.
Common symbols are preferred over weak symbols. See the section on the "Symbol
Table" in the System V ABI specification for more about common symbols.
When object files containing common symbols are linked, space is reserved in an
uninitialized section for each common symbol. A symbol is created in place of the
common symbol to refer to its reserved location.
Description 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 C6X_A_DIR environment variable
4. Any directories specified by the C6X_C_DIR environment variable
For more information about the --include_path option and C6X_A_DIR, see Section 4.5.
For more information about C6X_C_DIR, see the TMS320C6000 Optimizing Compiler
User's 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.
Example 1 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 0ABCDh, 56q
** Back in original file .copy "word.asm"
Listing file:
1 00000000 .space 29
2 .copy "byte.asm"
A 1 ** In byte.asm
A 2 0000001d 00000020 .byte 32,1+ 'A'
0000001e 00000042
A 3 .copy "word.asm"
B 1 ** In word.asm
B 2 00000020 0000ABCD .word 0ABCDh, 56q
00000024 0000002E
A 4 ** Back in byte.asm
A 5 00000028 0000006A .byte 67h + 3q
3
4 ** Back in original file
5 00000029 00000064 .string "done"
0000002a 0000006F
0000002b 0000006E
0000002c 00000065
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 0ABCDh, 56q
.include
** Back in original file "word2.asm"
** Back in byte2.asm
.string "done"
.byte 67h + 3q
Listing file:
1 00000000 .space 29
2 .include "byte2.asm"
3
4 ** Back in original file
5 00000029 00000064 .string "done"
0000002a 0000006F
0000002b 0000006E
0000002c 00000065
Description 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 label, 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 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. The 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 expr is an optional expression indicating the beginning offset of the structure.
The default starting point for a structure is 0.
• The exprn/N 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 memn/N 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.
Example This example illustrates a structure in C that will be accessed in assembly code.
struct1 .struct
i0 .int ; bytes 0-3
s0 .short ; bytes 4-5
struct1len .endstruct ; size 6, alignment 4
struct2 .struct
st1 .tag struct1 ; bytes 0-5
s1 .short ; bytes 6-7
endstruct2 .endstruct ; size 8, alignment 4
.sect "data1"
.word struct1.i0 ; 0
.word struct1.s0 ; 4
.word struct1len ; 6
.sect "data2"
.word struct2.st1 ; 0
.word struct2.s1 ; 6
.word endstruct2 ; 8
;
; The .cstruct/.cunion directives calculate 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.
cstruct1 .cstruct
i0 .int ; bytes 0-3
s0 .short ; bytes 4-5
cstruct1len .endstruct ; size 8, alignment 4
cstruct2 .cstruct
st1 .tag cstruct1 ; bytes 0-7
s1 .short ; bytes 8-9
cendstruct2 .endstruct ; size 12, alignment 4
.sect "data3"
.word cstruct1.i0, struct1.i0 ; 0
.word cstruct1.s0, struct1.s0 ; 4
.word cstruct1len, struct1len ; 8
.sect "data4"
.word cstruct2.st1, struct2.st1 ; 0
.word cstruct2.s1, struct2.s1 ; 8
.word cendstruct2, endstruct2 ; 12
Syntax .data
Description The .data directive sets .data as the current section; the lines that follow will be
assembled into the .data 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.
1 ***********************************************
2 ** Reserve space in .data **
3 ***********************************************
4 00000000 .data
5 00000000 .space 0CCh
6
7 ***********************************************
8 ** Assemble into .text **
9 ***********************************************
10 00000000 .text
11 00000000 00800358 ABS A0,A1
12
13 ***********************************************
14 ** Assemble into .data **
15 ***********************************************
16 000000cc table: .data
17 000000cc FFFFFFFF .word -1
18 000000d0 000000FF .byte 0FFh
19
20 ***********************************************
21 ** Assemble into .text **
22 ***********************************************
23 00000004 .text
24 00000004 008001A0 MV A0,A1
25
26 ***********************************************
27 ** Resume assembling into the .data section **
28 ***********************************************
29 000000d1 .data
30 000000d4 00000000 coeff .word 00h,0ah,0bh
000000d8 0000000A
000000dc 0000000B
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 an
absolute constant expression with an arithmetic type or a symbol equated to an absolute
constant expression with an arithmetic type. 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.
The 64-bit value is stored in the format shown in Figure 5-5.
S E E E E E E E E E E E MMMMMMMMMM MMMMMMMMMM
31 20 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.
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.
By default, the assembler acts as if the .drlist directive had been specified.
Example This example shows how .drnolist inhibits the listing of the specified directives.
Source file:
.length 65
.width 85
.asg 0, x
.loop 2
.eval x+1, x
.endloop
.drnolist
.length 55
.width 95
.asg 1, x
.loop 3
.eval x+1, x
.endloop
Listing file:
3 .asg 0, x
4 .loop 2
5 .eval x+1, x
6 .endloop
1 .eval 0+1, x
1 .eval 1+1, x
7
8 .drnolist
12 .loop 3
13 .eval x+1, x
14 .endloop
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:
.word 0
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 directive 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 This example sends the message ERROR -- MISSING PARAMETER to the standard
output device.
Source file:
.global PARAM
MSG_EX .macro parm1
.if $symlen(parm1) = 0
.emsg "ERROR -- MISSING PARAMETER"
.else
MVK parm1, A1
.endif
.endm
MSG_EX PARAM
MSG_EX
Listing file:
1 .global PARAM
2 MSG_EX .macro parm1
3 .if $symlen(parm1) = 0
4 .emsg "ERROR -- MISSING PARAMETER"
5 .else
6 MVK parm1, A1
7 .endif
8 .endm
9
10 00000000 MSG_EX PARAM
1 .if $symlen(parm1) = 0
1 .emsg "ERROR -- MISSING PARAMETER"
1 .else
1 00000000 00800028! MVK PARAM, A1
1 .endif
11
12 00000004 MSG_EX
1 .if $symlen(parm1) = 0
1 .emsg "ERROR -- MISSING PARAMETER"
***** USER ERROR ***** - : ERROR -- MISSING PARAMETER
1 .else
1 MVK parm1, A1
1 .endif
In addition, the following messages are sent to standard output by the assembler:
"t.asm", ERROR! at line 10: [ ***** USER ERROR ***** - ] ERROR --
MISSING PARAMETER
.emsg "ERROR -- MISSING PARAMETER"
Syntax .end
Description 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.
Example This example shows how the .end directive terminates assembly. Any source statements
that follow the .end directive are ignored by the assembler.
Source file:
start: .text
ZERO A0
ZERO A1
ZERO A3
.end
ZERO A4
Listing file:
1 00000000 start: .text
2 00000000 000005E0 ZERO A0
3 00000004 008425E0 ZERO A1
4 00000008 018C65E0 ZERO A3
5 .end
Description The .farcommon and .nearcommon directives create a common symbol in a common
block, rather than placing variables in a section. The .farcommon directive places the
symbol in far memory, and the .nearcommon directive places the symbol in near
memory.
A common symbol cannot be created for a symbol that has a memory bank
specification, for example because the DATA_MEM_BANK pragma was used to align
the variable.
These directives are used by the compiler when the --common option is enabled (the
default), which causes uninitialized file scope variables to be emitted as common
symbols. The benefit of common symbols is that generated code can remove unused
variables that would otherwise increase the size of the .bss section. (Uninitialized
variables of a size larger than 32 bytes are separately optimized through placement in
separate subsections that can be omitted from a link.) This optimization happens for
C/C++ code by default unless you use the --common=off compiler option.
• The symbol is a required parameter. It defines a name for the symbol created by this
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 section used for common symbols. There is no
default size.
• A structure tag can be used in place of a size to specify a structure created with the
.struct directive. Either a size or a structure tag is required for this argument.
• The alignment is an optional parameter that ensures that the space allocated to the
symbol occurs on the specified boundary. This boundary must be set to a power of 2.
If the SPC is already aligned to the specified boundary, it is not incremented.
Syntax .fclist
.fcnolist
Description 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.
Example This example shows the assembly language and listing files for code with and without
the conditional blocks listed.
Source file:
a .set 0
b .set 1
.fclist ; list false conditional blocks
.if a
MVK 5,A0
.else
MVK 0,A0
.endif
.fcnolist ; do not list false conditional blocks
.if a
MVK 5,A0
.else
MVK 0,A0
.endif
Listing file:
1 00000000 a .set 0
2 00000001 b .set 1
3 .fclist ; list false conditional blocks
4 .if a
5 MVK 5,A0
6 .else
7 00000000 00000028 MVK 0,A0
8 .endif
9 .fcnolist ; do not list false conditional blocks
13 00000004 00000028 MVK 0,A0
Description 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. The default 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:
"t.asm", WARNING! at line 1: [W0001] Value truncated to 1
.field 3, 1
Successive .field directives pack values into the specified number of bits starting at the
current 32-bit location. Fields are packed starting at the least significant bit (bit 0),
moving toward the most significant bit (bit 31) as more fields are added. If the assembler
encounters a field size that does not fit in the current 32-bit word, it fills the remaining
bits of the current byte with 0s, increments the SPC to the next word boundary, and
begins packing fields into the next word.
The .field directive is similar to the .bits directive (see the .bits topic). However, the .bits
directive does not allow you to specify the number of bits in the field and does not
automatically increment the SPC when a word boundary is reached.
Use the .align directive to force the next .field directive to begin packing 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.
Example 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.
1 ************************************
2 ** Initialize a 24-bit field. **
3 ************************************
4 00000000 00BBCCDD .field 0BBCCDDh, 24
5
6 ************************************
7 ** Initialize a 5-bit field **
8 ************************************
9 00000000 0ABBCCDD .field 0Ah, 5
10
11 ***********************************
12 ** Initialize a 4-bit field **
13 ** in a new word. **
14 ************************************
15 00000004 0000000C .field 0Ch, 4
16
17 ************************************
18 ** Initialize a 3-bit field **
19 ************************************
20 00000004 0000001C x: .field 01h, 3
21
22 ************************************
23 ** Initialize a 32-bit field **
24 ** relocatable field in the **
25 ** next word **
26 ************************************
27 00000008 00000004' .field x
Figure 5-6 shows how the directives in this example affect memory.
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 an
absolute constant expression with an arithmetic type or a symbol equated to an absolute
constant expression with an arithmetic type. Each constant is converted to a floating-
point value in IEEE single-precision 32-bit format.
With big-endian ordering, the 32-bit value is stored exponent byte first, most significant
byte of fraction second, and least significant byte of fraction third, in the format shown in
Figure 5-7.
S E E E E E E E E MMMMMMMMMMMMM MMMMMMMMMM
31 23 0
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.
Description 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 directive 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. If a global symbol is
defined more than once, the linker issues a multiple-definition error. (The assembler can
provide a similar multiple-definition error for local symbols.) 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:
• If the 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.
Example This example shows four files. The file1.lst and file2.lst refer to each other for all symbols
used; file3.lst and file4.lst are similarly related.
The file1.lst and file3.lst 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.lst uses the .global directive to identify these global symbols; file3.lst uses .ref and
.def to identify the symbols.
The file2.lst and file4.lst 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.lst
1 ; Global symbol defined in this file
2 .global INIT
3 ; Global symbols defined in file2.lst
4 .global X, Y, Z
5 00000000 INIT:
6 00000000 00902058 ADD.L1 0x01,A4,A1
7 00000004 00000000! .word X
8 ; .
9 ; .
10 ; .
11 .end
file2.lst
1 ; Global symbols defined in this file
2 .global X, Y, Z
3 ; Global symbol defined in file1.lst
4 .global INIT
5 00000001 X: .set 1
6 00000002 Y: .set 2
7 00000003 Z: .set 3
8 00000000 00000000! .word INIT
9 ; .
10 ; .
11 ; .
12 .end
file3.lst
1 ; Global symbol defined in this file
2 .def INIT
3 ; Global symbols defined in file4.lst
4 .ref X, Y, Z
5 00000000 INIT:
6 00000000 00902058 ADD.L1 0x01,A4,A1
7 00000004 00000000! .word X
8 ; .
9 ; .
10 ; .
11 .end
file4.lst
1 ; Global symbols defined in this file
2 .def X, Y, Z
3 ; Global symbol defined in file3.lst
4 .ref INIT
5 00000001 X: .set 1
6 00000002 Y: .set 2
7 00000003 Z: .set 3
8 00000000 00000000! .word INIT
9 ; .
10 ; .
11 ; .
12 .end
Description Three directives instruct the assembler to make certain sections members of an ELF
group section (see the 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:
Duplicate COMDAT (common data) groups are allowed in multiple modules; the linker
keeps only one. Creating such duplicate groups is useful for late instantiation of C++
templates and for providing debugging information.
The .gmember directive designates section name as a member of the group.
The .endgroup directive ends the group declaration.
Description The .half, .uhalf, .short, and .ushort directives place one or more values into
consecutive halfwords in the current section. Each value is placed in a 2-byte memory
location by itself. A value can be either:
• An expression that the assembler evaluates and treats as a 16-bit signed or unsigned
number
• A character 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 0s.
The assembler truncates values greater than 16 bits.
If you use a label with .half, .short, .uhalf, or .ushort; 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, .short, .uhalf, or .ushort 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.
Example 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 100h * 16
2 00001000 0000000A .half 10, -1, "abc", 'a'
00001002 0000FFFF
00001004 00000061
00001006 00000062
00001008 00000063
0000100a 00000061
3 0000100c 00000008 STRN .short 8, -3, "def", 'b'
0000100e 0000FFFD
00001010 00000064
00001012 00000065
00001014 00000066
00001016 00000062
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 symbolname to STV_PROTECTED.
See Section 8.12 for an explanation of symbol visibility.
Theses directives are commonly used in the context of dynamic linking. For more about
dynamic linking, see Chapter 14 of The C6000 Embedded Application Binary Interface
Application Report (SPRAB89).
Description The .int, .unint, .long, .ulong, .word, and .uword 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
• A character 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 32-bit field,
which is padded with 0s.
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.
Example 1 This example uses the .int directive to initialize words. Notice that the symbol SYMPTR
puts the symbol's address in the object code and generates a relocatable reference
(indicated by the - character appended to the object word).
1 00000000 .space 73h
2 00000000 .bss PAGE, 128
3 00000080 .bss SYMPTR, 3
4 00000074 003C12E4 INST: LDW.D2 *++B15[0],A0
5 00000078 0000000A .int 10, SYMPTR, -1, 35 + 'a', INST
0000007c 00000080-
00000080 FFFFFFFF
00000084 00000084
00000088 00000074'
Example 2 This example initializes two 32-bit fields and defines DAT1 to point to the first location.
The contents of the resulting 32-bit fields are FFFABCDh and 141h.
1 00000000 FFFFABCD DAT1: .long 0FFFFABCDh,'A'+100h
00000004 00000141
Example 3 This example initializes five words. The symbol WordX points to the first word.
1 00000000 00000C80 ;WordX .word 3200,1+'AB',-'AF',0F410h,'A'
00000004 00004242
00000008 FFFFB9BF
0000000c 0000F410
00000010 00000041
Description 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.
See Section 3.5 for more information about run-time relocation.
The .label directive creates a special label that refers to the load-time address. This
function is useful primarily to designate where the section was loaded for purposes of
the code that relocates the section.
See Section 8.5.6 for more information about assigning run-time and load-time
addresses in the linker.
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 specifying 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.
********************************************
** Page length = 65 lines **
** Page width = 85 characters **
********************************************
.length 65
.width 85
********************************************
** Page length = 55 lines **
** Page width = 100 characters **
********************************************
.length 55
.width 100
Syntax .list
.nolist
Description 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 4.3), the assembler ignores the .list directive.
Example This example shows how the .list and .nolist directives turn the output listing on and off.
The .nolist, the table: .data through .byte lines, and the .list directives do not appear in
the listing file. Also, the line counter is incremented even when source statements are
not listed.
Source file:
.data
.space 0CCh
.text
ABS A0,A1
.nolist
table: .data
.word -1
.byte 0FFh
.list
.text
MV A0,A1
.data
coeff .word 00h,0ah,0bh
Listing file:
1 00000000 .data
2 00000000 .space 0CCh
3 00000000 .text
4 00000000 00800358 ABS A0,A1
5
13
14 00000004 .text
15 00000004 008001A0 MV A0,A1
16 000000d1 .data
17 000000d4 00000000 coeff .word 00h,0ah,0bh
000000d8 0000000A
000000dc 0000000B
Example 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 0,x
2 COEF .loop
3 .word x*100
4 .eval x+1, x
5 .break x = 6
6 .endloop
1 00000000 00000000 .word 0*100
1 .eval 0+1, x
1 .break 1 = 6
1 00000004 00000064 .word 1*100
1 .eval 1+1, x
1 .break 2 = 6
1 00000008 000000C8 .word 2*100
1 .eval 2+1, x
1 .break 3 = 6
1 0000000c 0000012C .word 3*100
1 .eval 3+1, x
1 .break 4 = 6
1 00000010 00000190 .word 4*100
1 .eval 4+1, x
1 .break 5 = 6
1 00000014 000001F4 .word 5*100
1 .eval 5+1, x
1 .break 6 = 6
Description The .macro and .endm directives are used to define 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, 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.
Description The .map directive is used by the compiler when the input is linear assembly. The
compiler tries to keep your symbolic names for registers defined with .reg by creating
substitution symbols with .map.
The .map directive is similar to .asg, but uses a forward slash instead of a comma; and
allows single quote characters in the symbolic names. For example, this linear assembly
input:
The .clearmap directive is used by the compiler to undefine all current .map substitution
symbols.
See the TMS320C6000 Optimizing Compiler User's Guide for details on using the .map
directive in linear assembly code.
Example The .map directive is similar to .asg, but uses a forward slash instead of a comma; and
allows single quote characters in the symbolic names. For example, this linear assembly
input:
fn: .cproc a, b, c
.reg x, y, z
ADD a, b, z
ADD z, c, z
.return z
.endproc
Description 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 must 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 C6X_A_DIR environment variable
4. Any directories specified by the C6X_C_DIR environment variable
See Section 4.5 for more information about the --include_path option.
A .mlib directive causes the assembler to open the library specified by filename and
create a table of the library's contents. The assembler stores names of individual library
members in the opcode table as library entries. This redefines any existing opcodes or
macros with the same name. If one of these macros is called, the assembler extracts the
library entry and loads it into the macro table. The assembler expands the library entry
as it does other macros, but it does not place the source code in the listing. Only macros
called from the library are extracted, and they are extracted only once.
See Chapter 6 for more information on macros and macro libraries.
Example The code creates a macro library that defines two macros, inc1.asm and dec1.asm. The
file inc1.asm contains the definition of inc1 and dec1.asm contains the definition of dec1.
inc1.asm dec1.asm
* Macro for incrementing * Macro for decrementing
inc1 .macro A dec1 .macro A
ADD A,1,A SUB A,1,A
.endm .endm
Now you can use the .mlib directive to reference the macro library and define the
inc1.asm and dec1.asm macros:
1 .mlib "mac.lib"
2
3 * Macro Call
4 00000000 inc1 A0
1 00000000 000021A0 ADD A0,1,A0
5
6 * Macro Call
7 00000004 dec1 B0
1 00000004 0003E1A2 SUB B0,1,B0
Syntax .mlist
.mnolist
Description 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 6 for more information on macros and macro libraries. See the
.loop/.break/.endloop topic for information on conditional blocks.
Example 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 .macro P1, P2, P3
2 .string ":p1:", ":p2:", ":p3:"
3 .endm
4
5 00000000 STR_3 "as", "I", "am"
1 00000000 0000003A .string ":p1:", ":p2:", ":p3:"
00000001 00000070
00000002 00000031
00000003 0000003A
00000004 0000003A
00000005 00000070
00000006 00000032
00000007 0000003A
00000008 0000003A
00000009 00000070
0000000a 00000033
0000000b 0000003A
6 .mnolist
7 0000000c STR_3 "as", "I", "am"
8 .mlist
9 00000018 STR_3 "as", "I", "am"
1 00000018 0000003A .string ":p1:", ":p2:", ":p3:"
00000019 00000070
0000001a 00000031
0000001b 0000003A
0000001c 0000003A
0000001d 00000070
0000001e 00000032
0000001f 0000003A
00000020 0000003A
00000021 00000070
00000022 00000033
00000023 0000003A
Syntax .newblock
Description 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, and cannot be used in expressions. 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 4.8.3 for more information on the use of local labels.
Example This example shows how the local label $1 is declared, reset, and then declared again.
1 .global table1, table2
2
3 00000000 00000028! MVKL table1,A0
4 00000004 00000068! MVKH table1,A0
5 00000008 008031A9 MVK 99, A1
6 0000000c 010848C0 || ZERO A2
7
8 00000010 80000212 $1:[A1] B $1
9 00000014 01003674 STW A2, *A0++
10 00000018 0087E1A0 SUB A1,1,A1
11 0000001c 00004000 NOP 3
12
13 .newblock ; undefine $1
14
15 00000020 00000028! MVKL table2,A0
16 00000024 00000068! MVKH table2,A0
17 00000028 008031A9 MVK 99, A1
18 0000002c 010829C0 || SUB A2,1,A2
19
20 00000030 80000212 $1:[A1] B $1
21 00000034 01003674 STW A2, *A0++
22 00000038 0087E1A0 SUB A1,1,A1
23 0000003c 00004000 NOP 3
Syntax .nocmp
Description The .nocmp directive instructs the compiler to not utilize 16-bit instructions for the code
section .nocmp appears in. The .nocmp directive can appear anywhere in the section.
Example In the example, the section one is not compressed, whereas section two is compressed.
.sect "one"
LDW *A4, A5
LDW *B4, A5
.nocmp
NOP 4
ADD A4, A5, A6
ADD B4, B5, B6
NOP
...
.sect "two"
ADD A4, A5, A6
NOP
NOP
...
Description The .noremark directive suppresses the assembler remark identified by num. A remark
is an informational assembler message that is less severe than a warning.
This directive is equivalent to using the -ar[num] assembler option.
The .remark directive re-enables the remark(s) previously suppressed.
Example This example uses .noremark to turn off remark #5001 and then .remark to turn it back
on again.
Partial source file:
SPLOOP 1
SPMASK
|| CMPYSP .M2 B9:B8,B19:B18,B7:B6:B5:B4
SPKERNEL 1,0
|| DADDSP .S2 B27:B26,B7:B6,B27:B26
NOP 5
.noremark 5001
SPLOOP 1
SPMASK
|| CMPYSP .M2 B9:B8,B19:B18,B7:B6:B5:B4
SPKERNEL 1,0
|| DADDSP .S2 B27:B26,B7:B6,B27:B26
NOP 5
.remark 5001
SPLOOP 1
SPMASK
|| CMPYSP .M2 B9:B8,B19:B18,B7:B6:B5:B4
SPKERNEL 1,0
|| DADDSP .S2 B27:B26,B7:B6,B27:B26
NOP 5
15 .noremark 5001
16
17 00000012 0c66 SPLOOP 1
18
19 00000014 00030001 SPMASK
20 00000018 12490f02 || CMPYSP .M2 B9:B8,B19:B18,B7:B6:B5:B4
21
22 00000020 08034001 SPKERNEL 1,0
23 00000024 1d1b4b22 || DADDSP .S2 B27:B26,B7:B6,B27:B26
24
25 00000028 8c6e NOP 5
26
27 .remark 5001
28
29 0000002a 0c66 SPLOOP 1
"sploopex.asm", REMARK at line 29: [R5001] SDSCM00012367 potentially triggered
by this
execute packet sequence. SPLOOP must be
30
31 0000002c 00030001 SPMASK
32 00000030 12490f02 || CMPYSP .M2 B9:B8,B19:B18,B7:B6:B5:B4
33
34 00000034 08034001 SPKERNEL 1,0
35 00000038 1d1b4b22 || DADDSP .S2 B27:B26,B7:B6,B27:B26
36
37 00000040 00008000 NOP 5
Description 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.
D turns off the listing of certain directives (same effect as .drnolist).
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).
O turns on listing (performs .list).
R resets any B, H, L, M, T, and W (turns off the limits of B, H, L, 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 --
asm_listing_cross_reference option (see Section 4.3).
Example This example shows how to limit the listings of the .byte, .char, .int, long, .word, and
.string directives to one line each.
1 ****************************************
2 ** Limit the listing of .byte, .char, **
3 ** .int, .word, and .string **
4 ** directives to 1 line each. **
5 ****************************************
6 .option B, W, T
7 00000000 000000BD .byte -'C', 0B0h, 5
8 00000003 000000BC .char -'D', 0C0h, 6
9 00000008 0000000A .int 10, 35 + 'a', "abc"
10 0000001c AABBCCDD .long 0AABBCCDDh, 536 + 'A'
11 00000024 000015AA .word 5546, 78h
12 0000002c 00000052 .string "Registers"
13
14 ****************************************
15 ** Reset the listing options. **
16 ****************************************
17 .option R
18 00000035 000000BD .byte -'C', 0B0h, 5
00000036 000000B0
00000037 00000005
19 00000038 000000BC .char -'D', 0C0h, 6
00000039 000000C0
0000003a 00000006
20 0000003c 0000000A .int 10, 35 + 'a', "abc"
00000040 00000084
00000044 00000061
00000048 00000062
0000004c 00000063
21 00000050 AABBCCDD .long 0AABBCCDDh, 536 + 'A'
00000054 00000259
22 00000058 000015AA .word 5546, 78h
0000005c 00000078
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 (generic)
.title "**** Page Directive Example ****"
; .
; .
; .
.page
Listing file:
TMS320C6000 Assembler Version x.xx Day Time Year
Copyright (c) 1996-2011 Texas Instruments Incorporated
**** Page Directive Example **** PAGE 1
2 ; .
3 ; .
4 ; .
TMS320C6000 Assembler Version x.xx Day Time Year
Copyright (c) 1996-2011 Texas Instruments Incorporated
**** Page Directive Example **** PAGE 2
No Errors, No Warnings
Description 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.
The .retainrefs directive indicates that any sections that refer to the current or specified
section are not eligible for removal via conditional linking. For example, applications may
use an .intvecs section to set up interrupt vectors. The .intvecs section is eligible for
removal during conditional linking by default. You can force the .intvecs section and any
sections that reference it to be retained by applying the .retain and .retainrefs directives
to the .intvecs section.
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 linker assumes that all sections by default are eligible for removal via conditional
linking. (However, the linker does automatically retain the .reset section.) The .retain
directive is useful for overriding this default conditional linking behavior for 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.
Example 1 This example of an interrupt function that has a .retain directive applied to it.
.sect ".text:interrupts:retain"
.retain
.global _int_func1
;******************************************************************************
;* FUNCTION NAME: int_func1 *
;******************************************************************************
_int_func1:
STW .D2 FP,*SP++(-88) ; [B_D] |31|
STW .D2 B3,*SP(80) ; [B_D] |31|
STW .D2 A4,*SP(24) ; [B_D] |31|
STW .D2 B2,*SP(84) ; [B_D] |31|
STW .D2 B9,*SP(76) ; [B_D] |31|
STW .D2 B8,*SP(72) ; [B_D] |31|
STW .D2 B7,*SP(68) ; [B_D] |31|
STW .D2 B6,*SP(64) ; [B_D] |31|
STW .D2 B5,*SP(60) ; [B_D] |31|
STW .D2 B4,*SP(56) ; [B_D] |31|
STW .D2 B1,*SP(52) ; [B_D] |31|
STW .D2 B0,*SP(48) ; [B_D] |31|
STW .D2 A7,*SP(36) ; [B_D] |31|
STW .D2 A6,*SP(32) ; [B_D] |31|
STW .D2 A5,*SP(28) ; [B_D] |31|
...
Description The .sect directive defines a named section that can be used like the default .text and
.data sections. The .sect directive sets section name to be the current section; the lines
that follow are assembled into the section name 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. See Chapter 2 for more information about sections.
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 conflicting 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
Example This example defines two special-purpose sections, Sym_Defs and Vars, and assembles
code into them.
1 **********************************************
2 ** Begin assembling into .text section. **
3 **********************************************
4 00000000 .text
5 00000000 000005E0 ZERO A0
6 00000004 008425E0 ZERO A1
7
8 **********************************************
9 ** Begin assembling into vars section. **
10 **********************************************
11 00000000 .sect "vars"
12 00000000 4048F5C3 pi .float 3.14
13 00000004 000007D0 max .int 2000
14 00000008 00000001 min .int 1
15
16 **********************************************
17 ** Resume assembling into .text section. **
18 **********************************************
19 00000008 .text
20 00000008 010000A8 MVK 1,A2
21 0000000c 018000A8 MVK 1,A3
22
23 **********************************************
24 ** Resume assembling into vars section. **
25 **********************************************
26 0000000c .sect "vars"
27 0000000c 00000019 count .short 25
Description The .set and .equ directives equate a constant value to a .set/.equ 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 symbol is a label that must appear in the label field.
• The value must be a well-defined expression, that is, 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.
Example This example shows how symbols can be assigned with .set and .equ.
1 **********************************************
2 ** Equate symbol AUX_R1 to register A1 **
3 ** and use it instead of the register. **
4 **********************************************
5 00000001 AUX_R1 .set A1
6 00000000 00B802D4 STH AUX_R1,*+B14
7
8 **********************************************
9 ** Set symbol index to an integer expr. **
10 ** and use it as an immediate operand. **
11 **********************************************
12 00000035 INDEX .equ 100/2 +3
13 00000004 01001AD0 ADDK INDEX, A2
14
15 **********************************************
16 ** Set symbol SYMTAB to a relocatable expr. **
17 ** and use it as a relocatable operand. **
18 **********************************************
19 00000008 0000000A LABEL .word 10
20 00000009' SYMTAB .set LABEL + 1
21
22 **********************************************
23 ** Set symbol NSYMS equal to the symbol **
24 ** INDEX and use it as you would INDEX. **
25 **********************************************
26 00000035 NSYMS .set INDEX
27 0000000c 00000035 .word NSYMS
Description The .space and .bes directives reserve the number of bytes given by size in bytes in the
current section and fill them with 0s. The section program counter is incremented to
point to the word following the reserved space.
When you use a 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 last 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 ** Reserve 0F0 bytes (60 words in .text section). **
7 *****************************************************
8 00000000 .space 0F0h
9 000000f0 00000100 .word 100h, 200h
000000f4 00000200
10 *****************************************************
11 ** Begin assembling into the .data section. **
12 *****************************************************
13 00000000 .data
14 00000000 00000049 .string "In .data"
00000001 0000006E
00000002 00000020
00000003 0000002E
00000004 00000064
00000005 00000061
00000006 00000074
00000007 00000061
15 *****************************************************
16 ** Reserve 100 bytes in the .data section; **
17 ** RES_1 points to the first word **
18 ** that contains reserved bytes. **
19 *****************************************************
20 00000008 RES_1: .space 100
21 0000006c 0000000F .word 15
22 00000070 00000008" .word RES_1
23 *****************************************************
24 ** Reserve 20 bytes in the .data section; **
25 ** RES_2 points to the last word **
26 ** that contains reserved bytes. **
27 *****************************************************
28 00000087 RES_2: .bes 20
29 00000088 00000036 .word 36h
30 0000008c 00000087" .word RES_2
Syntax .sslist
.ssnolist
Description 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 expanded substitution symbols.
Example 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 00000000 .bss x,4
2 00000004 .bss y,4
3 00000008 .bss z,4
4
5 addm .macro src1,src2,dst
6 LDW *+B14(:src1:), A0
7 LDW *+B14(:src2:), A1
8 NOP 4
9 ADD A0,A1,A0
10 STW A0,*+B14(:dst:)
11 .endm
12
13 00000000 addm x,y,z
1 00000000 0000006C- LDW *+B14(x), A0
1 00000004 0080016C- LDW *+B14(y), A1
1 00000008 00006000 NOP 4
1 0000000c 000401E0 ADD A0,A1,A0
1 00000010 0000027C- STW A0,*+B14(z)
14
15 .sslist
16 00000014 addm x,y,z
1 00000014 0000006C- LDW *+B14(:src1:), A0
# LDW *+B14(x), A0
1 00000018 0080016C- LDW *+B14(:src2:), A1
# LDW *+B14(y), A1
1 0000001c 00006000 NOP 4
1 00000020 000401E0 ADD A0,A1,A0
1 00000024 0000027C- STW A0,*+B14(:dst:)
# STW A0,*+B14(z)
17
Description 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:
• An expression that the assembler evaluates and treats as an 8-bit signed number.
• A character 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 \b \f \n \r \t \v
\<octal>).
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.
Example In this example, 8-bit values are placed into consecutive bytes in the current section.
The label Str_Ptr has the value 0h, which is the location of the first initialized byte.
1 00000000 00000041 Str_Ptr: .string "ABCD"
00000001 00000042
00000002 00000043
00000003 00000044
2 00000004 00000041 .string 41h, 42h, 43h, 44h
00000005 00000042
00000006 00000043
00000007 00000044
3 00000008 00000041 .string "Austin", "Houston"
00000009 00000075
0000000a 00000073
0000000b 00000074
0000000c 00000069
0000000d 0000006E
0000000e 00000048
0000000f 0000006F
00000010 00000075
00000011 00000073
00000012 00000074
00000013 0000006F
00000014 0000006E
4 00000015 00000030 .string 36 + 12
Description 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 label, 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 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. The stag is optional for .struct, but is required for .tag.
• The expr is an optional expression indicating the beginning offset of the structure.
The default starting point for a structure is 0.
• The memn/N 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 element is 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 exprn/N 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 structure.
The following examples show various uses of the .struct, .tag, and .endstruct directives.
Example 1 1 real_rec .struct ; stag
2 00000000 nom .int ; member1 = 0
3 00000004 den .int ; member2 = 1
4 00000008 real_len .endstruct ; real_len = 2
5
6 00000000 0080016C- LDW *+B14(real+real_rec.den), A1
7 ; access structure
8
9 00000000 .bss real, real_len ; allocate mem rec
10
Description These directives are used to affect symbol linkage and visibility.
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 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. Instead of
including a weak symbol in the output file's symbol table by default (as it would for a
global symbol), the linker only includes a weak symbol in the output of a "final" link if the
symbol is required to resolve an otherwise unresolved reference. See Section 2.6.2 for
details about how weak symbols are handled by the linker.
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. If a global symbol is
defined more than once, the linker issues a multiple-definition error. (The assembler can
provide a similar multiple-definition error for local symbols.) 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 in either of the following ways:
• If the symbol is not defined in the current module (which includes macro, copy, and
include files), use the .weak directive to tell 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, use the .symdepend directive to
declare that the symbol and its definition can be used externally by other modules.
These types of references are resolved at link time.
For example, use the .weak and .set directives in combination as shown in the following
example, which defines a weak absolute symbol "ext_addr_sym":
.weak ext_addr_sym
ext_addr_sym .set 0x12345678
If you assemble such assembly source and include the resulting object file in the link, the
"ext_addr_sym" in this example is available as a weak absolute symbol in a final link. It
is a candidate for removal if the symbol is not referenced elsewhere in the application.
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:
1 ; default tab size
2 00000000 00000000 NOP
3 00000004 00000000 NOP
4 00000008 00000000 NOP
5 .tab4
7 0000000c 00000000 NOP
8 00000010 00000000 NOP
9 00000014 00000000 NOP
10 .tab 16
12 00000018 00000000 NOP
13 0000001c 00000000 NOP
14 00000020 00000000 NOP
Syntax .text
Description The .text sets .text as the current section. Lines that follow this directive will be
assembled 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.
The .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.
Example This example assembles code into the .text and .data sections.
1 ******************************************
2 ** Begin assembling into .data section. **
3 ******************************************
4 00000000 .data
5 00000000 00000005 .byte 5,6
00000001 00000006
6
7 ******************************************
8 ** Begin assembling into .text section. **
9 ******************************************
10 00000000 .text
11 00000000 00000001 .byte 1
12 00000001 00000002 .byte 2,3
00000002 00000003
13
14 ******************************************
15 ** Resume assembling into .data section.**
16 ******************************************
17 00000002 .data
18 00000002 00000007 .byte 7,8
00000003 00000008
19
20 ******************************************
21 ** Resume assembling into .text section.**
22 ******************************************
23 00000003 .text
24 00000003 00000004 .byte 4
Description 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. If you want a title on the first page, the
first source statement must contain a .title directive.
Example In this example, one title is printed on the first page and a different title is printed on
succeeding pages.
Source file:
.title "**** Fast Fourier Transforms ****"
; .
; .
; .
.title "**** Floating-Point Routines ****"
.page
Listing file:
TMS320C6000 Assembler Version x.xx Day Time Year
Copyright (c) 1996-2011 Texas Instruments Incorporated
**** Fast Fourier Transforms **** PAGE 1
2 ; .
3 ; .
4 ; .
TMS320C6000 Assembler Version x.xx Day Time Year
Copyright (c) 1996-2011 Texas Instruments Incorporated
**** Floating-Point Routines **** PAGE 2
No Errors, No Warnings
Description 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 repeatedly.
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 label, 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 expr is 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 memn/N 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, and .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 exprn/N 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.
Example 2 1
2 ; utag
3 0000 x .long ; member1 = long
4 0000 y .float ; member2 = float
5 0000 z .word ; member3 = word
6 0002 size_u .endunion ; real_len = 2
7
Syntax symbol .usect "section name", size in bytes[, alignment[, bank offset] ]
Description 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. This boundary must be set to a power of 2.
• The bank offset is an optional parameter that ensures that the space allocated 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) tell the assembler to pause
assembling into the current section and 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.
Example 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.
Figure 5-8 shows how this example reserves space in two uninitialized sections, var1
and var2.
1 ***************************************************
2 ** Assemble into .text section **
3 ***************************************************
4 00000000 .text
5 00000000 008001A0 MV A0,A1
6
7 ***************************************************
8 ** Reserve 2 bytes in var1. **
9 ***************************************************
10 00000000 ptr .usect "var1",2
11 00000004 0100004C- LDH *+B14(ptr),A2 ; still in .text
12
13 ***************************************************
14 ** Reserve 100 bytes in var1 **
15 ***************************************************
16 00000002 array .usect "var1",100
17 00000008 01800128- MVK array,A3 ; still in .text
18 0000000c 01800068- MVKH array,A3
19
20 ***************************************************
21 ** Reserve 50 bytes in var1 **
22 ***************************************************
23 00000066 dflag .usect "var1",50
24 00000010 02003328- MVK dflag,A4
25 00000014 02000068- MVKH dflag,A4
26
27 ***************************************************
28 ** Reserve 100 bytes in var1 **
29 ***************************************************
30 00000000 vec .usect "var2",100
31 00000018 0000002A- MVK vec,B0 ; still in .text
32 0000001c 0000006A- MVKH vec,B0
array
100 bytes
100 bytes
Description 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.
See Section 4.8.10 for more information on substitution symbols.
These directives can be used to remove from the assembly environment any C/C++
macros that may cause a problem. See Chapter 11 for more information about using
C/C++ headers in assembly source.
Description 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 Section 4.8.10 for more information on substitution symbols .See Chapter 6 for
information on macros.
The TMS320C6000 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
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 1, are optional substitution symbols that appear as operands for the .macro directive.
parameter n Parameters are discussed in Section 6.3.
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 6.7 for more information
about macro comments.
Example 6-1 shows the definition, call, and expansion of a macro.
Macro definition: The following code defines a macro, sadd4, with four parameters:
1 sadd4 .macro r1,r2,r3,r4
2 !
3 ! sadd4 r1, r2 ,r3, r4
4 ! r1 = r1 + r2 + r3 + r4 (saturated)
5 !
6 SADD r1,r2,r1
7 SADD r1,r3,r1
8 SADD r1,r4,r1
9 .endm
Macro call: The following code calls the sadd4 macro with four arguments:
10
11 00000000 sadd4 A0,A1,A2,A3
Macro expansion: The following code shows the substitution of the macro definition for the macro call. The
assembler substitutes A0, A1, A2, and A3 for the r1, r2, r3, and r4 parameters of sadd4.
1 00000000 00040278 SADD A0,A1,A0
1 00000004 00080278 SADD A0,A2,A0
1 00000008 000C0278 SADD A0,A3,A0
Macro definition:
Parms .macro a,b,c
; a = :a:
; b = :b:
; c = :c:
.endm
Parms """string""",x,y
; a = "string"
; b = x
; c = y
.asg 1,counter
.loop 100
.word counter
.eval counter + 1,counter
.endloop
In Example 6-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 Assign a Substitution Symbol for more information about the .asg and .eval assembler directives.
.var item
.loop
.break ($ismember(item, list) = 0)
STW item,*B15--[1]
.endloop
.endm
pushx A0,A1,A2,A3
: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 6-7 shows how the forced substitution operator is used.
force .macro x
.loop 8
PORT:x: .set x*4
.eval x+1, x
.endloop
.endm
.global portbase
force
PORT0 .set 0
PORT1 .set 4
.
.
.
PORT7 .set 28
storex .macro x
.var tmp
.asg :x(1):, tmp
.if $symcmp(tmp,"A") == 0
STW x,*A15--(4)
.elseif $symcmp(tmp,"B") == 0
STW x,*A15--(4)
.elseif $iscons(x)
MVK x,A0
STW A0,*A15--(4)
.else
.emsg "Bad Macro Parameter"
.endif
.endm
storex 10h
storex A15
.asg 0,pos
.asg "ar1 ar2 ar3 ar4",regs
substr 1,"ar2",regs,pos
.word pos
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 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 the same way it expands other macros. See Section 6.1 for how
the assembler expands macros. You can control the listing of library entry expansions with the .mlist
directive. For information about the .mlist directive, see Section 6.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 7.1.
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:
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 loop is broken, the assembler continues with the code
after the .endloop directive. For more information, see Section 5.7.
Example 6-10, Example 6-11, and Example 6-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.
.asg 1,x
.loop
.eval x+1,x
.endloop
.asg 1,x
.loop
.eval x+1,x
.endloop
Example 6‑12. Built-In Substitution Symbol Functions in a Conditional Assembly Code Block
.if k = 0
MPY src1, src2, src2
NOP
ADD src2, sum, sum
.else
MPY src1,src2,src2
MVK k,src1
MPY src1,src2,src2
NOP
ADD src2,sum,sum
.endif
.endm
MACK3 A0,A1,A3,0
MACK3 A0,A1,A3,100
label ?
Example 6-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 4.3).
.TMS320C60 00000001 0
.tms320C60 00000001 0
l$1$ 00000014' 12 12
.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 comments 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 6-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 6-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 the A1 register . The fact
macro accomplishes this by calling fact1, which calls itself recursively.
.fcnolist
fact1 .macro n
.if n == 1
MVK globcnt, A1 ; Leave the answer in the A1 register.
.else
.eval 1, temp ; Compute the decrement of symbol n.
.eval globcnt*temp, globcnt ; Multiply to get a new result.
fact1 temp ; Recursive call.
.endif
.endm
fact .macro n
.if ! $iscons(n) ; Test that input is a constant.
.emsg "Parm not a constant"
.else
.var temp
.asg n, globcnt
.endif
.endm
Archiver Description
The TMS320C6000 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 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.
Example 7-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.
Using the library information archiver, you can create an index library called mylib.lib from the above
libraries:
libinfo6x -o mylib.lib mylib_6600_be.lib mylib_6600_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 of the library to use. If the --issue_remarks option is specified before the
--run_linker option, the linker reports which library was chosen.
• Example 1 (ISA 64plus, little endian):
cl6x -mv64plus --endian=little --issue_remarks main.c -z -l lnk.cmd ./mylib.lib
<Linking>
remark: linking in "mylib_64plus_le.lib" in place of "mylib.lib"
• Example 2 (ISA 6600, big endian):
cl6x -mv6600 --endian=big --issue_remarks main.c -z -l lnk.cmd ./mylib.lib
<Linking>
remark: linking in "mylib_6600_be.lib" in place of "mylib.lib"
The indexed object file libraries have an additional .libinfo extension in the archiver listing. The
__TI_$$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 member, 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.
7.5.4 Requirements
You must follow these requirements to use library index files:
• At least one application object file must appear on the linker command line before the index library.
• 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.
Linker Description
The TMS320C6000 linker creates a static executable or dynamic object module by combining object
modules. This chapter describes the linker options, directives, and statements used to create static
executables and dynamic object modules. Object libraries, command files, and other key concepts are
discussed as well.
The concept of sections is basic to linker operation; Chapter 2 includes a detailed discussion of sections.
cl6x --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 linker command file.
(Options are discussed in Section 8.4.)
filename 1, filename n can be object files, linker 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.
SECTIONS
{
.fast_code: { *.obj(*fast*) } > FAST_MEM
.vectors : { vectors.obj(.vector:part1:*) > 0xFFFFFF00
.str_code : { rts*.lib<str*.obj>(.text) } > S1ROM
}
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 output module called a.out:
cl6x --run_linker --relocatable file1.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 8.9.)
8.4.4 Allocate Memory for Use by the Loader to Pass Arguments (--arg_size Option)
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 the number of bytes to be allocated in target memory for command-line arguments.
By default, the linker creates the __c_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_args__ 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 TMS320C6000
Optimizing Compiler User's Guide for information about the loader.
--diag_error=num Categorize the diagnostic identified by num as an error. To find 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 diagnostics.
--diag_remark=num Categorize the diagnostic identified by num as a remark. To find 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 Suppress the diagnostic identified by num. To find 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.
--diag_warning=num Categorize the diagnostic identified by num as a warning. To find 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 Display 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 TMS320C6000 Optimizing Compiler User's Guide
for more information on understanding diagnostic messages.
--emit_warnings_as_ Treat all warnings as errors. This option cannot be used with the --
errors no_warnings option. The --diag_remark option takes precedence over this
option. This option takes precedence over the --diag_warning option.
--issue_remarks Issue remarks (nonserious warnings), which are suppressed by default.
--no_warnings Suppress warning diagnostics (errors are still issued).
--set_error_limit=num Set 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 Provide verbose diagnostics that display the original source with line-wrap
and indicate the position of the error in the source line
8.4.10 Linker Command File Preprocessing (--disable_pp, --define and --undefine Options)
The linker preprocesses linker 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:
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:
cl6x --define=FOO=1 main.c --run_linker --define=BAR=2 lnk.cmd
The linker sees only the --define for BAR; the compiler only sees 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
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 <brackets>), in the directory of the current file
2. In the list of directories specified with --Iibrary options or environment variables (see Section 8.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 provides the built-in macro definitions listed in Table 8-11. The availability of these macros
within the linker is determined by the command-line options used, not the build attributes of the files being
linked. If these macros are not set as expected, confirm that your project's command line uses the correct
compiler option settings.
The address is the location of the minimum addressable unit where the error is to be injected. A
symbol+offset can be used to specify the location of the error to be injected with a signed offset from that
symbol. The page number is needed to make the location non-ambiguous if the address occurs on
multiple memory pages. The bitmask is a mask of the bits to flip; its width should be the width of an
addressable unit.
For example, the following command line flips the least-significant bit in the byte at the address 0x100,
making it inconsistent with the ECC parity bits for that byte:
cl6x test.c --ecc:data_error=0x100,0x01 -z -o test.out
The following command flips two bits in the third byte of the code for main():
cl6x test.c --ecc:data_error=main+2,0x42 -z -o test.out
The --ecc:ecc_error option injects errors into the ECC parity bits that correspond to the specified
location. Note that the ecc_error option can therefore only specify locations inside ECC input ranges,
whereas the data_error option can also specify errors in the ECC output memory ranges. The syntax is:
--ecc:ecc_error=(symbol+offset|address)[,page],bitmask
The parameters for this option are the same as for --ecc:data_error, except that the bitmask must be
exactly 8 bits. Mirrored copies of the affected ECC byte will also contain the same injected error.
An error injected into an ECC byte with --ecc:ecc_error may cause errors to be detected at run time in any
of the 8 data bytes covered by that ECC byte.
For example, the following command flips every bit in the ECC byte that contains the parity information for
the byte at 0x200:
cl6x test.c --ecc:ecc_error=0x200,0xff -z -o test.out
The linker disallows injecting errors into memory ranges that are neither an ECC range nor the input range
for an ECC range. The compiler can only inject errors into initialized sections.
See Section 8.6.1 for information about referring to linker symbols in C/C++ code.
The linker creates the .sysmem section only if there is a .sysmem section in an input file.
The linker also creates a global symbol __TI_SYSMEM_SIZE and assigns it a value equal to the size of
the heap. The default size is 1K bytes. See Section 8.6.1 for information about referring to linker symbols
in C/C++ code. For more about C/C++ linking, see Section 8.10.
8.4.16 Alter the Library Search Algorithm (--library Option, --search_path Option, and
C6X_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. If
this library defines symbols that are referenced in the file file1.obj, this is how you link the files:
cl6x --run_linker file1.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 -l. The syntax for this option is:
--library=[pathname] filename
The filename is the name of an archive, an object file, or linker 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 8.5.5.5.
You can augment the linker's directory search algorithm by using the --search_path linker option or the
C6X_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 --Iibrary option on the command line or in a command file.
2. It searches directories named with C6X_C_DIR.
3. If C6X_C_DIR is not set, it searches directories named with the assembler's C6X_A_DIR environment
variable.
4. It searches the current directory.
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 linker 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 C6X_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 C6X_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 ld and ld2
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:
The environment variable remains set until you reboot the system or reset the variable by entering:
The assembler uses an environment variable named C6X_A_DIR to name alternate directories that
contain copy/include files or macro libraries. If C6X_C_DIR is not set, the linker searches for object
libraries in the directories named with C6X_A_DIR. For information about C6X_A_DIR, see Section 4.5.2.
For more information about object libraries, see Section 8.6.3.
8.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).
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:
cl6x --run_linker --library=a.lib --library=b.lib --library=a.lib
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
lib1 defines B
lib2 defines A, B; obj defining A references B
% cl6x --run_linker objfile lib1 lib2
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 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 rts6600_elf.lib
without providing a full replacement for rts6600_elf.lib. Using --priority and linking your new library before
rts6600_elf.lib guarantees that all references to malloc and free resolve to the new library.
The --priority option is intended to support linking programs with SYS/BIOS where situations like the one
illustrated above occur.
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
For more information about the MEMORY directive, see Section 8.5.4.
• A table showing the linked addresses of each output section and the input sections that make up the
output sections (section placement map). This table has the following columns; this information is
generated on the basis of the information in the SECTIONS directive in the linker 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 8.5.5.
• A table showing each external symbol and its address sorted by symbol name.
• A table showing each external symbol and its address sorted by symbol address.
The following example links file1.obj and file2.obj and creates a map file called map.out:
cl6x --run_linker file1.obj file2.obj --map_file=map.out
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.
The load_addr and sym_defs attributes 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).
You can use the sym_defs filter to include information sorted on a file by file basis. You may find it useful
to replace the sym_name, sym_dp, 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_dp,nosym_runaddr,sym_defs
By default, information about global symbols defined in an application are included in tables sorted by
name, data page, and run address. If you use the --mapfile_contents=sym_defs option, static variables
are also listed.
The --no_demangle option disables the demangling of symbol names in diagnostics. For example:
-[ f1.c ]-
#include "header.h"
...
-[ f2.c ]-
#include "header.h"
...
When these files are compiled for debugging, both f1.obj and f2.obj have symbolic debugging entries to
describe type XYZ. For the final output file, only one set of these entries is necessary. The linker
eliminates the duplicate entries automatically.
--preferred_order=function specification
Refer to the TMS320C6000 Optimizing Compiler User's Guide for details on the program cache layout
tool, which is impacted by --preferred_option.
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 the stack size is different.
When the linker defines the .stack section, it also defines a global symbol, __TI_STACK_SIZE, and
assigns it a value equal to the size of the section. The default software stack size is 1K bytes. See
Section 8.6.1 for information about referring to linker symbols in C/C++ code.
If the foo function is placed out-of-range from 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 C6000, 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.
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 8.5.10.7).
These operators allow you to define symbols to represent the load-time start address and size inside the
linker 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.
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) }
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.
See Section 8.6.1 for information about referring to linker symbols in C/C++ code.
If you do not use --undef_sym, this member is not included, because there is no explicit reference to it in
file1.obj or file2.obj.
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 8-1 shows a sample linker command file called link.cmd.
The sample file in Example 8-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:
cl6x --run_linker link.cmd
You can place other parameters on the command line when you use a command file:
cl6x --run_linker --relocatable link.cmd c.obj d.obj
The linker processes the command file as soon as it encounters 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.lst that contains
filenames and another file called dir.cmd that contains linker directives, you could enter:
cl6x --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 last 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 8-2 shows a sample command file that contains
linker directives.
For more information, see Section 8.5.4 for the MEMORY directive, and Section 8.5.5 for the SECTIONS
directive.
In addition, any section names used by the TI tools are reserved from being used as the prefix for other
names, unless the section will be a subsection of the section name used by the TI tools. For example,
section names may not begin with .debug.
Now assume that the app_data.lib object library resides in a sub-directory called "lib" relative to where you
are building the application. In order to gain access to app_data.lib from the build command-line, you can
use a combination of the –i and –l options to set up a directory search path which the linker can use to
find the app_data.lib library:
%> cl6x <compile options/files> -z -i ./lib -l app_data.lib mylnk.cmd <link options/files>
The –i option adds the lib sub-directory to the directory search path and the –l option instructs the linker to
look through the directories in the directory search path to find the app_data.lib library. However, if you do
not update the reference to app_data.lib in mylnk.cmd, the linker will fail to find the app_data.lib library and
generate a "file not found" error. The reason is that when the linker encounters the reference to
app_data.lib inside the SECTIONS directive, there is no –l option preceding the reference. Therefore, the
linker tries to open app_data.lib in the current working directory.
In essence, the linker has a few different ways of opening files:
• If there is a path specified, the linker will look for the file in the specified location. For an absolute path,
the linker will try to open the file in the specified directory. For a relative path, the linker will follow the
specified path starting from the current working directory and try to open the file at that location.
• If there is no path specified, the linker will try to open the file in the current working directory.
• If a –l option precedes the file reference, then the linker will try to find and open the referenced file in
one of the directories in the directory search path. The directory search path is set up via –i options
and environment variables (like C_DIR and C6X_C_DIR).
As long as a file is referenced in a consistent manner on the command line and throughout any applicable
LCFs, the linker will be able to find and open your object files and libraries.
Returning to the earlier example, you can insert a –l option in front of the reference to app_data.lib in
mylnk.cmd to ensure that the linker will find and open the app_data.lib library when the application is built:
SECTIONS
{
...
.coeffs: { -l app_data.lib<app_coeffs.obj>(.data) } > DDR
...
}
Another benefit to using the –l option when referencing a file from within an LCF is that if the location of
the referenced file changes, you can modify the directory search path to incorporate the new location of
the file (using –i option on the command line, for example) without having to modify the LCF.
/********************************************************/
/* Sample command file with MEMORY directive */
/********************************************************/
file1.obj file2.obj /* Input files */
--output_file=prog.out /* Options */
#define BUFFER 0
MEMORY
{
FAST_MEM (RX): origin = 0x00000000 length = 0x00001000 + BUFFER
SLOW_MEM (RW): origin = end(FAST_MEM) length = 0x00001800 - size(FAST_MEM)
EXT_MEM (RX): origin = 0x10000000 length = size(FAST_MEM)
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.
I 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 a 32-bit integer constant expression, which can be decimal, octal, or
hexadecimal.
length specifies the length of a memory range; enter as length, len, or l. The value, specified in
bytes, is a 32-bit integer constant expression, 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 an 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. (See Section 8.5.9.3 for
virtual filling of memory ranges when using Error Correcting Code (ECC).)
The following example specifies a memory range with the R and W attributes and a fill constant of
0FFFFFFFFh:
MEMORY
{
RFILE (RW) : o = 0x00000020, l = 0x00001000, f = 0xFFFFFFFF
}
You normally use the MEMORY directive in conjunction with the SECTIONS directive to control placement
of output sections. For more information about the SECTIONS directive, see Section 8.5.5.
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.
/********************************************************/
/* Sample command file with MEMORY directive */
/********************************************************/
file1.obj file2.obj /* Input files */
--output_file=prog.out /* Options */
#define ORIGIN 0x00000000
#define BUFFER 0x00000200
#define CACHE 0x0001000
MEMORY
{
FAST_MEM (RX): origin = ORIGIN + 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
SECTIONS
{
name : [property [, property] [, property] . . . ]
name : [property [, property] [, property] . . . ]
name : [property [, property] [, property] . . . ]
}
Each section specification, beginning with name, defines an output section. (An output section is a section
in the output file.) Section names can refer to sections, subsections, or archive library members. (See
Section 8.5.5.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. See Section 3.5,
Section 3.1.1, and Section 8.5.6.
Syntax: load = allocation or
> allocation
• Run allocation defines where in memory the section is to be run.
Syntax: run = allocation or
run > allocation
• Input sections defines the input sections (object files) that constitute the output section. See
Section 8.5.5.3.
Syntax: { input_sections }
• Section type defines flags for special section types. See Section 8.5.8.
Syntax: type = COPY or
type = DSECT or
type = NOLOAD
• Fill value defines the value used to fill uninitialized holes. See Section 8.5.11.
Syntax: fill = value
/**************************************************/
/* Sample command file with SECTIONS directive */
/**************************************************/
file1.obj file2.obj /* Input files */
--output_file=prog.out /* Options */
SECTIONS
{
.text: load = EXT_MEM, run = 0x00000800
.const: load = FAST_MEM
.bss: load = SLOW_MEM
.vectors: load = 0x00000000
{
t1.obj(.intvec1)
t2.obj(.intvec2)
endvec = .;
}
.data:alpha: align = 16
.data:beta: align = 16
}
Figure 8-2 shows the output sections defined by the SECTIONS directive in Example 8-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 8-3.
0x00001000
SLOW_MEM
.bss - Allocated in SLOW_MEM The .bss section combines the .bss sections from
file1.obj and file2.obj.
For the load (usually the only) allocation, use a greater-than sign and omit the load keyword:
.text: > SLOW_MEM
.text: {...} > SLOW_MEM
.text: > 0x4000
If more than one parameter is used, you can string them together as follows:
.text: > 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 8.5.5.3.
Additional information about controlling the order in which code and data are placed in memory is provided
in the FAQ topic on section placement.
8.5.5.2.1 Binding
You can set the 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.
SECTIONS
{
.text : > SLOW_MEM
.data : > FAST_MEM ALIGN(128)
.bss : > FAST_MEM
}
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
{
.text: > (X) /* .text --> executable memory */
.data: > (RI) /* .data --> read or init memory */
.bss : > (RW) /* .bss --> read or write memory */
}
In this example, the .text output section can be linked into either the 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 I 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 0. If a section must start on a specific
address, use binding instead of named memory.
The HIGH specifier used on the .stack section placement 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 8-6 illustrates a portion of a map file that shows where the
given sections are allocated within RAM for a typical program.
As shown in Example 8-6 , the .bss and .sysmem sections are allocated at the lower addresses of RAM
(0x0200 - 0x0590) and the .stack section is allocated at address 0x08c0, even though lower addresses
are available.
Without using the HIGH specifier, the linker allocation would result in the code shown in Example 8-7
The HIGH specifier is ignored if it is used with specific address binding or automatic section splitting (>>
operator).
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 block 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.
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 = 0xffffffff {} > 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 0xffff
The size of .mytext has been bumped to a multiple of 8 bytes and the padding created by the linker has
been filled with 0xff.
The fill value specified in the linker command file is interpreted as a 16-bit constant. If you specify this
code:
.mytext: palign(8), fill = 0xff {} > PMEM
The fill value assumed by the linker is 0x00ff, and .mytext will then have the following contents:
addr content
---- -------
0000 0x1234
0002 0x1234
0004 0x1234
0006 0x00ff
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:
.mytext: palign(power2) {} > 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
------- ---------- ----- -----
.mytext 0x00010080 0x80 128
SECTIONS
{
.text:
.data:
.bss:
}
In Example 8-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. If the filename is hyphenated (or contains special characters), enclose it
within quotes:
SECTIONS
{
.text : /* Build .text output section */
{
f1.obj(.text) /* Link .text section from f1.obj */
f2.obj(sec1) /* Link sec1 section from f2.obj */
"f3-new.obj" /* Link ALL sections from f3-new.obj */
f4.obj"(.text,sec2) /* Link .text and sec2 from f4.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 8-8 are actually a shorthand method for the following:
SECTIONS
{
.text: { *(.text) }
.data: { *(.data) }
.bss: { *(.bss) }
}
The specification *(.text) means the unallocated .text sections from all input files. This format is useful if:
• You want the output section to contain all input sections that have a specified name, but the output
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.
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.
Each input section acts as a prefix and gathers longer-named sections. For example, the pattern *(.data)
matches .dataspecial. This mechanism enables the use of subsections, which are described in the
following section.
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)} /* france, germany */
therest: {*(europe)} /* spain, italy, malta */
}
This SECTIONS specification allocates the input sections as indicated in the comments:
SECTIONS {
islands: {*(europe:south:malta)
*(europe:north:iceland)} /* malta, iceland */
europe:north:finland : {} /* finland */
europe:north : {} /* norway, sweden */
europe:central : {} /* germany, denmark */
europe:central:france: {} /* france */
SECTIONS
{
boot > BOOT1
{
--library=rtsXX.lib<boot.obj> (.text)
--library=rtsXX.lib<exit.obj strcpy.obj> (.text)
}
In Example 8-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 < and > 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 8-9 is optional when listing specific archive members inside <
>. Using < > implies that you are referring to a library.
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 the .text sections from rts6600_elf.lib into the
.rtstest section:
SECTIONS
{
.rtstest { --library=rts6600_elf.lib(.text) } > RAM
}
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 section
that grows beyond the available space of the memory range in which it is originally allocated. Instead of
modifying the linker command file, you can let the linker move the section into one of the other areas.
In this example, the >> 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.
The | operator is used to specify the list of multiple memory ranges.
You can also use the >> 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: { f1.obj(.text) } load = 0x4000
.text: { *(.text) } >> 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.obj(.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 >> operator can also be used to split an output section among all memory ranges that match a
specified attribute combination. For example:
MEMORY
{
P_MEM1 (RWX) : origin = 0x1000, length = 0x2000
P_MEM2 (RWI) : origin = 0x4000, length = 0x1000
}
SECTIONS
{
.text: { *(.text) } >> (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) } >> P_MEM1 | P_MEM2}
}
Use the load keyword for the load address and the run keyword for the run address.
See Section 3.5 for an overview on run-time relocation.
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. (The TABLE operator instructs the linker to
produce a copy table; see Section 8.8.4.1.)
The following example uses parentheses, but has effects that are identical to the previous example:
.data: load = (SLOW_MEM align 32), run = FAST_MEM
The following example aligns FAST_MEM to 32 bits for run allocations and aligns all load allocations to 16
bits:
.data: run = FAST_MEM, align 32, load = align 16
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.
.dbss: load = FAST_MEM
.bss: run = FAST_MEM
.bss: > FAST_MEM
Example 8-10. Moving a Function from Slow to Fast Memory at Run Time
.sect ".fir"
.align 4
.label fir_src
fir
; insert code here
.label fir_end
.text
MVKL fir_src, A4
MVKH fir_src, A4
MVKL fir_end, A5
MVKH fir_end, A5
MVKL fir, A6
MVKH fir, A6
SUB A5, A4, A1
loop:
[!A1] B done
LDW *A4+ +, B3
NOP 4
; branch occurs
STW B3, *A6+ +
SUB A1, 4, A1
B loop
NOP 5
; branch occurs
done:
B fir
NOP 5
; call occurs
SECTIONS
{
.text: load = FAST_MEM
.fir: load = SLOW_MEM, run FAST_MEM
}
.text
fir (relocated
to run here)
0x00001000
0x10000000
SLOW_MEM
0x10001000
0xFFFFFFFF
See Section 8.6.1 for information about referring to linker symbols in C/C++ code.
SECTIONS
{
.text /* Normal output section */
.bss /* Normal output section */
GROUP 0x00001000 : /* Specify a group of sections */
{
.data /* First section in the group */
term_rec /* Allocated immediately after .data */
}
}
You can use binding, alignment, or named memory to allocate a GROUP in the same manner as a single
output section. In the preceding example, the GROUP is bound to address 0x1000. This means that .data
is allocated at 0x1000, and term_rec follows it in memory.
SECTIONS
{
.text: load = SLOW_MEM
UNION: run = FAST_MEM
{
.bss:part1: { file1.obj(.bss) }
.bss:part2: { file2.obj(.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 8-14.
Figure 8-4. Memory Allocation Shown in Example 8-13 and Example 8-14
.bss:part3 .bss:part3
SLOW_MEM SLOW_MEM
.text 2 (load)
Since the .text sections contain raw data, they cannot load 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.
SECTIONS
{
GROUP 0x1000 : run = FAST_MEM
{
UNION:
{
mysect1: load = SLOW_MEM
mysect2: load = SLOW_MEM
}
UNION:
{
mysect3: load = SLOW_MEM
mysect4: load = SLOW_MEM
}
}
}
• 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
{
.text1:
UNION:
{
.text2:
.text3:
}
}
}
The load allocator given for the group does not uniquely specify the load allocation for the elements
within the union: .text2 and .text3. In this case, the linker issues a diagnostic message to request that
these load allocations be specified explicitly.
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(table1)
.pinit :{}load=D_MEM, table(table1)
}run=P_MEM
The "ECC" specifier attached to the ECC memory ranges indicates the data memory range that the ECC
range covers. The ECC specifier supports the following parameters:
input_range = <memory The data memory range covered by this ECC data range. Required.
range>
algorithm = <ECC algorithm The name of an ECC algorithm defined later in the command file using
name> the ECC directive. Optional if only one algorithm is defined. (See
Section 8.5.9.2.)
fill = true | false Whether to generate ECC data for holes in the initialized data of the input
range. The default is "true". Using fill=false produces behavior similar to
the nowECC tool. The input range can be filled normally or using a virtual
fill (see Section 8.5.9.3).
For example:
MEMORY {
FLASH0 : origin=0x00000020 length=0x17FFE0
ECC_FLA0 : origin=0xf0400004 length=0x02FFFC ECC={ input_range=FLASH0
algorithm=F021 }
}
algorithm_name Specify the name you would like to use for referencing the algorithm.
address_mask = <32-bit This mask determines which bits of the address of each 64-bit piece of
mask> memory are used in the calculation of the ECC byte for that memory.
Default is 0xffffffff, so that all bits of the address are used. (Note that the
ECC algorithm itself ignores the lowest bits, which are always zero for a
correctly-aligned input block.)
parity_mask = <8-bit mask> This mask determines which ECC bits encode even parity and which bits
encode odd parity. Default is 0, meaning that all bits encode even parity.
mirroring = F021 | F035 This setting determines the order of the ECC bytes and their duplication
pattern for redundancy. Default is F021.
The vfill specifier is functionally equivalent to omitting a fill specifier, except that it allows ECC data to be
generated for areas of the input memory range that remain uninitialized. This has the benefit of reducing
the size of the resulting object file.
The vfill specifier has no effect other than in ECC data generation. It cannot be specified along with a fill
specifier, since that would introduce ambiguity.
If fill is specified in the ECC specifier, but vfill is not specified, vfill defaults to 0xff.
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 8.5.10.3. Assignment statements
must terminate with a semicolon.
The linker processes assignment statements after it allocates all the output sections. Therefore, if an
expression contains a symbol, the address used for that symbol 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 = Table1; /* Assign cur_tab to one of the tables */
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 8.5.11.
The following symbols are defined only for C/C++ support when the --ram_model or --rom_model option is
used.
See Section 8.6.1 for information about referring to linker symbols in C/C++ code.
8.5.10.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 linker command file. Then execute a sequence of instructions (the copying
code in Example 8-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 in Example 8-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.
LOAD_START( sym ) Defines sym with the load-time start address of related allocation unit
START( sym )
LOAD_END( sym ) Defines sym with the load-time end address of related allocation unit
END( sym )
LOAD_SIZE( sym ) Defines sym with the load-time size of related allocation unit
SIZE( sym )
RUN_START( sym ) Defines sym with the run-time start address of related allocation unit
RUN_END( sym ) Defines sym with the run-time end address of related allocation unit
RUN_SIZE(sym ) Defines sym with the run-time size of related allocation unit
These 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.
SPRUI03B – May 2017 Linker Description 235
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
Linker Command Files www.ti.com
These symbols defined by the linker can be accessed at runtime using the _symval operator, which is
essentially a cast operation. For example, suppose your linker command file contains the following:
.text: RUN_START(text_run_start), RUN_SIZE(text_run_size) { *(.text) }
See Section 8.6.1 for more information about referring to linker symbols in C/C++ code.
This can be rewritten using the START and END operators as follows:
outsect:
{
s1.obj(.text) { END(end_of_s1) }
s2.obj(.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 for braces { } to enclose the
operator list. The operators in the list are applied to the input item that occurs immediately before the list.
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.
8.5.10.7.3 GROUPs
Here is another use of the START and SIZE operators in the context of a GROUP specification:
GROUP
{
outsect1: { ... }
outsect2: { ... }
} 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.
8.5.10.7.4 UNIONs
The RUN_SIZE and LOAD_SIZE 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)
{
.text1: load = ROM, SIZE(text1_size) { f1.obj(.text) }
.text2: load = 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.
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, expressions, and
syntaxes of assignment statements are described in Section 8.5.10.
The following example uses assignment statements to create holes in output sections:
SECTIONS
{
outsect:
{
file1.obj(.text)
. += 0x0100 /* Create a hole with size 0x0100 */
file2.obj(.text)
. = align(16); /* Create a hole to align the SPC */
file3.obj(.text)
}
}
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. In this case, the linker treats the uninitialized section as a hole and
supplies data for it. The following example illustrates this method:
SECTIONS
{
outsect:
{
file1.obj(.text)
file1.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.
Filling Sections
NOTE: Because filling a section (even with 0s) 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.
Suppose your linker command file defines the following linker symbol:
func_sym=printf+100;
Linker symbols that represent a data address: In C code, declare the variable as an extern variable.
Then, refer to the value of the linker symbol using the & operator. Because the variable is at a valid data
address, we know that a data pointer can represent the value.
Suppose your linker command file defines the following linker symbols:
data_sym=.data+100;
xyz=12345
myvar = &xyz;
Linker symbols for an arbitrary address: In C code, declare this as an extern symbol. The type does
not matter. If you are using GCC extensions, declare it as "extern void". If you are not using GCC
extensions, declare it as "extern char". Then, refer to the value of the linker symbol mySymbol as
_symval(&mySymbol). You must use the _symval operator, which is equivalent to a cast, because the 32-
bit value of the linker symbol could be wider than a data pointer. The compiler treats _symval(&mySymbol)
in a special way that can represent all 32 bits, even when pointers are 16 bits. Targets that have 32-bit
pointers can usually use &mySymbol instead of the _symval operator. However, the portable way to
access such linker symbols across TI targets is to use _symval(&mySymbol).
Suppose your linker command file defines the following linker symbol:
abs_sym=0x12345678;
When the linker command file is used to perform the final link, then "ext_addr_sym" is presented to the
linker as a weak absolute symbol; it will not be included in the resulting output file if the symbol is not
referenced.
See Section 2.6.2 for details about how weak symbols are handled by the linker.
If you enter:
cl6x --run_linker f1.obj f2.obj liba.lib libc.lib
then:
• Member 1 of liba.lib satisfies the f1.obj and f2.obj references to clrscr because the library is searched
and the definition of clrscr is found.
• Member 0 of libc.lib satisfies the reference to origin.
• Member 3 of liba.lib satisfies the reference to fillclr.
If, however, you enter:
cl6x --run_linker f1.obj f2.obj libc.lib liba.lib
then the references to clrscr 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 8.4.32.) The next example creates an undefined
symbol rout1 in the linker's global symbol table:
cl6x --run_linker --undef_sym=rout1 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 8.5.5.
Section 8.4.16 describes methods for specifying directories that contain object libraries.
MEMORY
{
RAM : origin = 0x00000001, length = 0xFFFFFFFE
}
SECTIONS
{
.text : ALIGN(32) {} > RAM
.const : ALIGN(8) {} > RAM
.data : ALIGN(8) {} > RAM
.bss : ALIGN(8) {} > RAM
.cinit : ALIGN(4) {} > RAM ; cflag option only
.pinit : ALIGN(4) {} > RAM ; cflag option only
.stack : ALIGN(8) {} > RAM ; cflag option only
.far : ALIGN(8) {} > RAM ; cflag option only
.sysmem: ALIGN(8) {} > RAM ; cflag option only
.switch: ALIGN(4) {} > RAM ; cflag option only
.cio : ALIGN(4) {} > RAM ; cflag option only
}
Also see Section 2.5.1 for information about default memory allocation.
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 this default allocation. Instead, allocation
is performed according to the rules specified by the SECTIONS directive and the general algorithm
described next in Section 8.7.1.
If an output section is formed as a result of a SECTIONS directive, this definition completely determines
the section's contents. (See Section 8.5.5 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 SECTIONS 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.obj 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 8.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 8-16. (See
Section 8.5.4 for more information on configuring memory.)
In this example, the LOAD_START(), RUN_START(), and SIZE() operators instruct the linker to create
three symbols:
Symbol Description
_flash_code_ld_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 8.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 linker 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 8.5.10.7.
SECTIONS
{
...
UNION
{
GROUP
{
.task1: { task1.obj(.text) }
.task2: { task2.obj(.text) }
GROUP
{
.task3: { task3.obj(.text) }
.task4: { task4.obj(.text) }
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.
SECTIONS
{
...
UNION
{
GROUP
{
.task1: { task1.obj(.text) }
.task2: { task2.obj(.text) }
GROUP
{
.task3: { task3.obj(.text) }
.task4: { task4.obj(.text) }
} run = RAM
...
}
Using the SECTIONS directive from Example 8-18 in the linker command file, the linker generates two
copy tables named: _task12_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 need not worry about the creation or maintenance of a copy table. You can
reference 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.
For this example, the linker creates a copy table that can be accessed through a special linker-generated
symbol, __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 linker 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.
SECTIONS
{
UNION
{
.first: { a1.obj(.text), b1.obj(.text), c1.obj(.text) }
load = EMEM, run = PMEM, table(BINIT), table(_first_ctbl)
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.
Example 8-20. Controlling the Placement of the Linker-Generated Copy Table Sections
SECTIONS
{
UNION
{
.first: { a1.obj(.text), b1.obj(.text), c1.obj(.text) }
load = EMEM, run = PMEM, table(BINIT), table(_first_ctbl)
For the linker command file in Example 8-20, 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.
SECTIONS
{
UNION
{
.task1to3: { *(.task1), *(.task2), *(.task3) }
load >> LMEM1 | LMEM2 | LMEM4, table(_task13_ctbl)
GROUP
{
.task4: { *(.task4) }
.task5: { *(.task5) }
.task6: { *(.task6) }
.task7: { *(.task7) }
} run = PMEM
...
.ovly: > LMEM4
}
#include <cpy_tbl.h>
main()
{
...
copy_in(&task13_ctbl);
task1();
task2();
task3();
...
copy_in(&task47_ctbl);
task4();
task5();
task6();
task7();
...
}
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.
The 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.
8.8.5 Compression
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.
• The table() operator accepts an optional compression parameter. The syntax is: .
table( name , 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.
– lzss. Compress data using Lempel-Ziv-Storer-Szymanski 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.
You cannot compress the decompression routines or any member of a GROUP containing .cinit.
In Figure 8-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.
The output object file has one output section named .task1 which has different load and run addresses.
This is possible because the load space and run space have identical data when the section is not
compressed.
If the linker compresses the .task1 section then the load space data and the run space data are different.
The linker creates the following two sections:
• .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.
The linker allocates load space for the .task1.load input section in the memory area that was specified for
load placement for the .task1 section. There is only a single load section to represent the load placement
of .task1 - .task1.load. If the .task1 data had not been compressed, there would be two allocations for the
.task1 input section: one for its load placement and another for its run placement.
The first 8 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 8-6.
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 __TI_decompress_rle().
The data following the 8-bit index is compressed using run length encoded (RLE) format. C6000 uses a
simple run length encoding that can be decompressed using the following algorithm:
1. Read the first byte, Delimiter (D).
2. Read the next byte (B).
3. If B != D, copy B to the output buffer and go to step 2.
4. Read the next byte (L).
(a) If L == 0, then length is either a 16-bit or 24-bit value, or we’ve reached the end of the data, read
next byte (L).
(i) If L == 0, length is a 24-bit value or the end of the data is reached, read next byte (L).
(i) If L == 0, the end of the data is reached, go to step 7.
(ii) Else L <<= 16, read next two bytes into lower 16 bits of L to complete 24-bit value for L.
(ii) Else L <<= 8, read next byte into lower 8 bits of L to complete 16-bit value for L.
(b) Else if L > 0 and L < 4, copy D to the output buffer L times. Go to step 2.
(c) Else, length is 8-bit value (L).
5. Read the next byte (C); C is the repeat character.
6. Write C to the output buffer L times; go to step 2.
7. End of processing.
The C6000 run-time support library has a routine __TI_decompress_rle24() 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.
The data following the 8-bit index is compressed using LZSS compression. The C6000 run-time-support
library has the routine __TI_decompress_lzss() 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.
/****************************************************************************/
/* cpy_tbl.h */
/* */
/* Copyright (c) 2011 Texas Instruments Incorporated */
/* */
/* Specification of copy table data structures which can be automatically */
/* generated by the linker (using the table() operator in the LCF). */
/* */
/****************************************************************************/
/****************************************************************************/
/* Copy Record Data Structure */
/****************************************************************************/
typedef struct copy_record
{
unsigned int load_addr;
unsigned int run_addr;
unsigned int size;
} COPY_RECORD;
/****************************************************************************/
/* Copy Table Data Structure */
/****************************************************************************/
typedef struct copy_table
{
unsigned short rec_size;
unsigned short num_recs;
COPY_RECORD recs[1];
} COPY_TABLE;
/****************************************************************************/
/* Prototype for general purpose copy routine. */
/****************************************************************************/
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 */
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 object 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_RECORDs in the table. For instance, in
the BINIT example in Section 8.8.4.2, 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>,
<run address of .first>,
<size of .first> },
{ <load address of .extra>,
<run address of .extra>,
<size of .extra> } };
/****************************************************************************/
/* cpy_tbl.c */
/* */
/* Copyright (c) 2011 Texas Instruments Incorporated */
/* */
/* General purpose copy routine. Given the address of a link-generated */
/* COPY_TABLE data structure, effect the copy of all object components */
/* that are designated for copy via the corresponding LCF table() operator. */
/* */
/****************************************************************************/
#include <cpy_tbl.h>
#include <string.h>
/****************************************************************************/
/* COPY_IN() */
/****************************************************************************/
void copy_in(COPY_TABLE *tp)
{
unsigned short I;
if (crp.size)
{
/*------------------------------------------------------------------*/
/* Copy record has a non-zero size so the data is not compressed. */
/* Just copy the data. */
/*------------------------------------------------------------------*/
memcpy(rn_addr, ld_addr, crp.size);
}
Step 1: Link the file file1.com; use the --relocatable option to retain relocation information in the
output file tempout1.out.
cl6x --run_linker --relocatable --output_file=tempout1 file1.com
file1.com contains:
SECTIONS
{
ss1: {
f1.obj
f2.obj
.
.
.
fn.obj
}
}
Step 2: Link the file file2.com; use the --relocatable option to retain relocation information in the
output file tempout2.out.
cl6x --run_linker --relocatable --output_file=tempout2 file2.com
file2.com contains:
SECTIONS
{
ss2: {
g1.obj
g2.obj
.
.
.
gn.obj
}
}
Step 3: Link tempout1.out and tempout2.out.
cl6x --run_linker --map_file=final.map --
output_file=final.out tempout1.out tempout2.out
Example 8-25 shows the linker command file for this example. Example 8-26 shows the map file.
/****************************************************************************/
/*** Specify Linker Options ***/
/****************************************************************************/
-c
--heap 0x3000
--stack 0x6000
--args 0x1000
-u filter_table_A
-u filter_table_B
/****************************************************************************/
/*** Specify the Input Files ***/
/****************************************************************************/
demo.obj
tables.obj
filter.obj
lex.obj
/****************************************************************************/
/*** Specify Runtime Support Library to be linked in ***/
/****************************************************************************/
-l libc.a
/****************************************************************************/
/*** Specify the Memory Configuration ***/
/****************************************************************************/
MEMORY
{
PMEM: o = 00000020h l = 0020ffe0h
EXT0: o = 00400000h l = 01000000h
EXT1: o = 01400000h l = 00400000h
EXT2: o = 02000000h l = 01000000h
EXT3: o = 03000000h l = 01000000h
BMEM: o = 80000000h l = 02000000h
}
/****************************************************************************/
/* Specify the Output Sections ***/
/****************************************************************************/
SECTIONS
{
.text : > PMEM
UNION
{
.tableA: { tables.obj(.tableA) } load > BMEM, table(tableA_cpy)
.tableB: { tables.obj(.tableB) } load > BMEM, table(tableB_cpy)
} RUN = EXT1, RUN_START(filter_matrix)
GROUP
{
.neardata:
.rodata:
.bss:
} > EXT2
MEMORY CONFIGURATION
output attributes/
section page origin length input sections
-------- ---- ---------- ---------- ----------------
.text 0 00000020 00008060
00000020 000005c0 rts6740_elf.lib : divd.obj (.text:__c6xabi_divd)
000005e0 000005c0 : _printfi.obj (.text:_getarg_diouxp)
00000ba0 000005a0 : _printfi.obj (.text:_setfield)
00001140 00000460 : _printfi.obj (.text:__TI_printfi)
000015a0 00000380 : fputs.obj (.text:fputs)
...
.neardata
* 0 02000000 0000001c UNINITIALIZED
02000000 0000001c lex.obj (.neardata)
...
address name
------- ----
00007fc0 C$$EXIT
00007700 C$$IO$$
000071c0 HOSTclose
00005d20 HOSTlseek
...
00008080 __TI_table_tableA_cpy
00008090 __TI_table_tableB_cpy
...
[121 symbols]
DSP Memory
Application Tasks
Drivers
RTOS
(DSPBIOS)
DSP
In this scenario, the DSP application is a single static executable file that contains: the RTOS, any
required driver functions, and all tasks that the application needs to carry out. All of the addresses in the
static executable are bound at link-time, they cannot be relocated at load-time. Execution of the DSP
application will proceed from the application's entry point.
DSP Memory
If we convert the earlier RTOS example into a dynamic system, the RTOS part of the system is still built
like an executable and is assumed to be loaded by traditional means (bootstrap loader) and set running on
the DSP by a host application.
Application tasks can be built as dynamic libraries that can then be loaded by the dynamic loader and
linked against the RTOS that is already loaded and running on the DSP. In this scenario, the RTOS is a
dynamic executable and is also sometimes referred to as the base image. The dynamic library is
dynamically linked against the RTOS base image at load time.
In Figure 8-8, the dynamic loader is running on a General Purpose Processor (GPP) and is able to interact
with the user to load and unload dynamic library components onto the DSP as needed. Another scenario
is to load the dynamic loader as part of the RTOS base image executable:
DSP Memory
RTOS
(DSPBIOS)
DSP
An example of this scenario is the reference implementation of the C6000 dynamic loader. It is written to
be built and run as a dynamic executable base image itself. It contains an interactive user interface which
allows the user to identify their own base image, load and link dynamic libraries against that base image,
and then execute a function that is defined in the dynamic library. For more details about the reference
implementation of the dynamic loader, please see the Dynamic Loader wiki article at
http://processors.wiki.ti.com/index.php/C6000_Dynamic_Loader.
#include <stdio.h>
__declspec(dllexport) int start();
int start()
{
printf("Hello World\n");
return 0;
}
• Then build a dynamic library called hello.dll:
cl6x -mv6400+ hello.c -z --import=printf --dynamic=lib -o hello.dll
dl6x.6x -e start
• Now, load the dynamic loader using a loader that supports C6000 ELF executable object files. Then
start the dynamic loader running. When using the reference implementation of the dynamic loader
(RIDL), you will see the RIDL prompt come up and then you need to issue the following commands:
RIDL> base_image dl6x.6x
RIDL> load hello.dll
RIDL> execute
You should see the "Hello World" message displayed and then control will return to the RIDL prompt.
To terminate the dynamic loader you can enter the exit command from the RIDL prompt.
For more details, see the Dynamic Loader wiki article
(http://processors.wiki.ti.com/index.php/C6000_Dynamic_Loader).
• --import_helper_functions
The compiler generates calls to functions that are defined in the run-time-support library. For example,
to perform unsigned long division in user code, the compiler generates a call to __c6xabi_divul. Since
there is no declaration and you do not call these functions directly, the __declspec() annotation cannot
be used. This prevents you from importing such functions from the run-time-support library that is built
as a dynamic library. To address this issue, the compiler supports the --import_helper_functions option.
When specified on the compiler command line, for each run-time-support function that is called by the
compiler, that function symbol will be imported.
ofd6x 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 and can appear anywhere on the command line following the command.
Precede each option with a hyphen.
-cg Prints function stack usage and callee information in XML
format. While the XML output may be accessed by a
developer, this option was primarily designed to be used
by tools such as Code Composer Studio to display an
application’s worst case stack usage.
--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 ofd6x --dwarf_display=help.
-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", ofd6x 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 attributes can be
obtained by invoking ofd6x --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.
The TMS320C6000 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
file (for example, when using debuggers and loaders).
The hex conversion utility can produce these output file formats:
• ASCII-Hex, supporting 32-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
10.1 The Hex Conversion Utility's Role in the Software Development Flow .................... 280
10.2 Invoking the Hex Conversion Utility .................................................................... 281
10.3 Understanding Memory Widths .......................................................................... 284
10.4 The ROMS Directive .......................................................................................... 288
10.5 The SECTIONS Directive ................................................................................... 292
10.6 The Load Image Format (--load_image Option) ..................................................... 293
10.7 Excluding a Specified Section ............................................................................ 294
10.8 Assigning Output Filenames .............................................................................. 294
10.9 Image Mode and the --fill Option ......................................................................... 295
10.10 Controlling the ROM Device Address................................................................. 296
10.11 Control Hex Conversion Utility Diagnostics ........................................................ 297
10.12 Description of the Object Formats ..................................................................... 298
10.1 The Hex Conversion Utility's Role in the Software Development Flow
Figure 10-1 highlights the role of the hex conversion utility in the software development process.
Figure 10-1. The Hex Conversion Utility in the TMS320C6000 Software Development Flow
In addition to regular command line information, you can use the hex conversion utility ROMS and
SECTIONS directives in a command file.
10.2.1 Invoking the Hex Conversion Utility From the Command Line
To invoke the hex conversion utility, enter:
To invoke the utility and use the options you defined in a command file, enter:
hex6x 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:
hex6x 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 boot.
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:
hex6x 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 */
ROMS
{
ROW1: origin=0x00000000 len=0x4000 romwidth=8
files={ appl.u0 appl.u1 app1.u2 appl.u3 }
ROW2: origin=0x00004000 len=0x4000 romwidth=8
files={ app1.u4 appl.u5 appl.u6 appl.u7 }
}
SECTIONS
{ .text, .data, .cinit, .sect1, .vectors, .const:
}
Output file(s)
Figure 10-3 demonstrates how the memory width is related to object file data.
Source file
.word 0 A A B B CCDD h
.word 011223344h
AA BB CC DD
11 22 33 44
A A B B CCDD CCDD DD
11223344 AABB CC
44
33
22
11
You can change ROM width (except for TI-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 10.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, the utility simply writes
multibyte fields into the file. The --romwidth option is ignored for the TI-TXT and TI-Tagged formats.
Figure 10-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
A A B B C C D D 1 1 2 2 3 3 4 4
31 0
Source file
.word 0 A A B B CCDD h
.word 011223344h
AA BB CC DD
11 22 33 44
Output files
--romwidth=8
--outfile=file.b0 DD 4 4
--outfile=file.b1 CC 3 3
--outfile=file.b2 BB 2 2
--outfile=file.b3 AA 1 1
Data after
phase II --romwidth=16
of hex6x
--outfile=file.wrd CCDD A A B B 3 3 4 4 1 1 2 2
--romwidth=8
--outfile=file.b0 DD B B 4 4 22
--outfile=file.b1 CC A A 3 3 11
--romwidth=8
--outfile=file.byt DDCC B B A A 4 4 3 3 2 2 1 1
ROMS
{
romname : [origin=value,] [length=value,] [romwidth=value,]
[memwidth=value,] [fill=value]
[files={ filename 1, filename 2, ...}]
romname : [origin=value,] [length=value,] [romwidth=value,]
[memwidth=value,] [fill=value]
[files={ filename 1, filename 2, ...}]
...
}
length specifies the length of a memory range as the physical length of the ROM device. It
can be entered as length, len, or l. The value must be a decimal, octal, or hexadecimal
constant. If you omit the length, it defaults to the length of the entire address space.
romwidth specifies the physical ROM width of the range in bits (see Section 10.3.3). Any value
you specify here overrides the --romwidth option. The value must be a decimal, octal,
or hexadecimal constant that is a power of 2 greater than or equal to 8.
memwidth specifies the memory width of the range in bits (see Section 10.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 10.5.)
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 10.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 least significant to most significant output
file, where the bits of the memory word are numbered from right to left. The number of
file names must equal the number of output files that the range generates. To calculate
the number of output files, see Section 10.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.
• 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.
infile.out
--image
--memwidth 16
ROMS
{
EPROM1: org = 0x00004000, len = 0x2000, romwidth = 8
files = { rom4000.b0, rom4000.b1}
Figure 10-5. The infile.out File Partitioned Into Four Output Files
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 10-2 is a segment of the
map file resulting from the example in Example 10-1.
Example 10-2. Map File Output From Example 10-1 Showing Memory Ranges
-----------------------------------------------------
00004000..00005fff Page=0 Width=8 "EPROM1"
-----------------------------------------------------
OUTPUT FILES: rom4000.b0 [b0..b7]
rom4000.b1 [b8..b15]
CONTENTS: 00004000..0000487f .text
00004880..00005b7f FILL = 00000000
00005b80..00005fff .data
-----------------------------------------------------
00006000..00007fff Page=0 Width=8 "EPROM2"
-----------------------------------------------------
OUTPUT FILES: rom6000.b0 [b0..b7]
rom6000.b1 [b8..b15]
CONTENTS: 00006000..0000633f .data
00006340..000066ff FILL = ff00ff00
00006700..00007c7f .table
00007c80..00007fff FILL = ff00ff00
EPROM1 defines the address range from 0x00004000 through 0x00005FFF with the following sections:
The rest of the range is filled with 0h (the default fill value), converted into two output files:
• rom4000.b0 contains bits 0 through 7
• rom4000.b1 contains bits 8 through 15
EPROM2 defines the address range from 0x00006000 through 0x00007FFF with the following sections:
The rest of the range is filled with 0xFF00FF00 (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
Use the SECTIONS directive in a command file. (See Section 10.2.2.) The general syntax is:
SECTIONS
{
oname(sname)[:] [paddr=value]
oname(sname)[:] [paddr= boot]
oname(sname)[:] [boot]
...
}
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 }
a for ASCII-Hex
i for Intel
m for Motorola-S
t for TI-Tagged
x 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 0 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 a.i0, a.i1, a.i2, a.i3.
If you include the following ROMS directive when you invoke the hex conversion utility, you would have
eight output files:
ROMS
{
range1: o = 0x00001000 l = 0x1000
range2: o = 0x00002000 l = 0x1000
}
Step 1: Define the ranges of target memory with a ROMS directive. See Section 10.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.
Depending on whether or not you are using the boot loader, the hex conversion utility output file
controlling mechanisms are different.
Non-boot loader mode. The address field of the hex conversion utility output file is controlled by the
following mechanisms 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 the section in the
address specified by paddr.
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.
Boot-Loader Mode. When the boot loader is used, the hex conversion utility places the different sections
that are in the boot table into consecutive memory locations. Each section becomes a boot table block
whose destination address is equal to the linker-assigned section load address.
In a boot table, the address field of the hex conversion utility output file is not related to the section load
addresses assigned by the linker. The address fields of the boot table are simply offsets to the beginning
of the table. The section load addresses assigned by the linker will be encoded into the boot table along
with the size of the section and the data contained within the section. These addresses will be used to
store the data into memory during the boot load process.
The beginning of the boot table defaults to the linked load address of the first bootable section in the input
file, unless you use one of the following mechanisms, listed here from low to high priority. Higher priority
mechanisms override the values set by low priority options in an overlapping range.
1. The ROM origin specified in the ROMS directive. The hex conversion utility places the boot table at
the origin of the first memory range in a ROMS directive.
2. The --bootorg option. The hex conversion utility places the boot table at the address specified by the
--bootorg option if you select boot loading from memory.
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 TI-Tagged format, which supports a 16-bit width only.
^B $AXXXXXXXX,
XX XX XX XX XX XX XX XX XX XX. . .^C
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.
Record type00, the data record, 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 0h, 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 10-7 illustrates the Intel hexadecimal object format.
Data
records
:00000001FF
Checksum
Byte Record End-of-file
count type record
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 10-8 illustrates the Motorola-S object format.
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
% 1 Data type is Tektronix format
Block length 2 Number of characters in the record, minus the %
Block type 1 6 = data record
8 = termination record
Checksum 2 A 2-digit hex sum modulo 256 of all values in the record except the % and the
checksum itself.
The load address in the data record specifies where the object code will be located. The first digit
specifies the address length; this is always 8. The remaining characters of the data record contain the
object code, two characters per byte.
Figure 10-9 illustrates the Tektronix object format.
Header %15621810000000202020202020
character
Load address: 10000000h
Block type: 6 Length of
(data) load address
Figure 10-10 illustrates the tag characters and fields in TI-Tagged object format.
Data
BFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFFBFFFF7F245F 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 2s 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 ( : ).
Item Description
@ADDR Hexadecimal start address of a section
DATAn Hexadecimal data byte
q End-of-file termination character
@ADDR1
Data
DATA01 DATA02 ........ DATA16
bytes DATA17 DATA32 ........ DATA32
DATAm ........ DATAn
Section @ADDR2
start DATA01 .................... DATAn Data
q bytes
End-of-line
character
@F000
31 40 00 03 B2 40 80 5A 20 01 D2 D3 22 00 D2 E3
21 00 3F 40 E8 FD 1F 83 FE 23 F9 3F
@FFFE
00 F0
Q
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.
304 Sharing C/C++ Header Files With Assembly Source SPRUI03B – May 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
www.ti.com Overview of the .cdecls Directive
.cdecls C,NOLIST
%{
#ifndef ASMTEST
#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 C/C++ 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.
11.2.1 Comments
Comments are consumed entirely at the C level, and do not appear in the resulting converted assembly
file.
SPRUI03B – May 2017 Sharing C/C++ Header Files With Assembly Source 305
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
Notes on C/C++ Conversions www.ti.com
11.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.
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)
306 Sharing C/C++ Header Files With Assembly Source SPRUI03B – May 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
www.ti.com Notes on C/C++ Conversions
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 11.2.11 for
suggestions on how to use C/C++ macro strings.
Macros are converted using the .define directive (see Section 11.4.2), which functions similarly to the .asg
assembler directive. The exception is that .define disallows redefinitions of register symbols and
mnemonics 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 11.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.
11.2.10 Enumerations
Enumeration members are converted to .enum elements in assembly. For example:
enum state { ACTIVE=0x10, SLEEPING=0x01, INTERRUPT=0x100, POWEROFF, LAST};
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.
11.2.11 C Strings
Because C string escapes such as \n and \t are not converted to hex characters 0x0A and 0x09 until their
use in a string 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, I,
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 11.4.7 for the .cstring directive syntax.)
SPRUI03B – May 2017 Sharing C/C++ Header Files With Assembly Source 307
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
Notes on C/C++ Conversions www.ti.com
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 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
308 Sharing C/C++ Header Files With Assembly Source SPRUI03B – May 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
www.ti.com Notes on C/C++ Conversions
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);
...
}
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.
SPRUI03B – May 2017 Sharing C/C++ Header Files With Assembly Source 309
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
Notes on C++ Specific Conversions www.ti.com
11.3.3 Templates
No support exists for templates.
ENUM_NAME .enum
MEMBER1 .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.
310 Sharing C/C++ Header Files With Assembly Source SPRUI03B – May 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
www.ti.com Special Assembler Support
SPRUI03B – May 2017 Sharing C/C++ Header Files With Assembly Source 311
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
Appendix A
SPRUI03B – May 2017
The assembler supports several directives that the TMS320C6000 C/C++ compiler uses for symbolic
debugging.
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.
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:
cl6x --symdebug:none --keep_asm input_file
The TMS320C6000 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 linker results.
This appendix enumerates all of the elements that are generated by the linker into the XML link
information file.
Example B-2. Input File List for the hi.out Output File
<input_file_list>
<input_file id="fl-1">
<kind>object</kind>
<file>hi.obj</file>
<name>hi.obj</name>
</input_file>
<input_file id="fl-2">
<path>/tools/lib/</path>
<kind>archive</kind>
<file>rtsxxx.lib</file>
<name>boot.obj</name>
</input_file>
<input_file id="fl-3">
<path>/tools/lib/</path>
<kind>archive</kind>
<file>rtsxxx.lib</file>
<name>exit.obj</name>
</input_file>
<input_file id="fl-4">
<path>/tools/lib/</path>
<kind>archive</kind>
<file>rtsxxx.lib</file>
<name>printf.obj</name>
</input_file>
...
</input_file_list>
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>
<size>0xc0</size>
<input_file_ref idref="fl-4"/>
</object_component>
<object_component id="oc-21">
<name>.data</name>
<load_address>0x80000000</load_address>
<run_address>0x80000000</run_address>
<size>0x0</size>
<input_file_ref idref="fl-4"/>
</object_component>
<object_component id="oc-22">
<name>.bss</name>
<load_address>0x80000000</load_address>
<run_address>0x80000000</run_address>
<size>0x0</size>
<input_file_ref idref="fl-4"/>
</object_component>
Example B-4. Logical Group List for the fl-4 Input File
<logical_group_list>
...
<logical_group id="lg-7">
<name>.text</name>
<load_address>0x20</load_address>
<run_address>0x20</run_address>
<size>0xb240</size>
<contents>
<object_component_ref idref="oc-34"/>
<object_component_ref idref="oc-108"/>
<object_component_ref idref="oc-e2"/>
...
</contents>
</logical_group>
...
<overlay id="lg-b">
<name>UNION_1</name>
<run_address>0xb600</run_address>
<size>0xc0</size>
<contents>
<object_component_ref idref="oc-45"/>
<logical_group_ref idref="lg-8"/>
</contents>
</overlay>
...
<split_section id="lg-12">
<name>.task_scn</name>
<size>0x120</size>
<contents>
<logical_group_ref idref="lg-10"/>
<logical_group_ref idref="lg-11"/>
</contents>
...
</logical_group_list>
<placement_map>
<memory_area>
<name>PMEM</name>
<page_id>0x0</page_id>
<origin>0x20</origin>
<length>0x100000</length>
<used_space>0xb240</used_space>
<unused_space>0xf4dc0</unused_space>
<attributes>RWXI</attributes>
<usage_details>
<allocated_space>
<start_address>0x20</start_address>
<size>0xb240</size>
<logical_group_ref idref="lg-7"/>
</allocated_space>
<available_space>
<start_address>0xb260</start_address>
<size>0xf4dc0</size>
</available_space>
</usage_details>
</memory_area>
...
</placement_map>
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>
<call_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>
<symbol_table>
<symbol>
<name>_c_int00</name>
<value>0xaf80</value>
</symbol>
<symbol>
<name>_main</name>
<value>0xb1e0</value>
</symbol>
<symbol>
<name>_printf</name>
<value>0xac00</value>
</symbol>
...
</symbol_table>
Glossary
C.1 Terminology
ABI — Application binary interface.
absolute address — An address that is permanently assigned to a TMS320C6000 memory location.
absolute constant expression — An expression that does not refer to any external symbols or any
registers or memory reference. The value of the expression must be knowable at assembly time.
address constant expression — A symbol with a value that is an address plus an addend that is an
absolute constant expression with an integer value.
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 — American 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 little endian
binding — A process in which you specify a distinct address for an output section or a symbol.
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.
command file — A file that contains options, filenames, directives, or commands for the linker or hex
conversion utility.
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.
constant expression — An expression that does not in any way refer to a register or memory reference.
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).
DWARF — A standardized debugging data format that was originally designed along with ELF, although it
is independent of the object file format.
EABI — An embedded application binary interface (ABI) that provides standards for file formats, data
types, and more.
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 TMS320C6000 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. See also pipelined-loop
epilog.
executable module — A 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
different program module.
field — For the TMS320C6000, 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.
hole — An area between the input sections that compose an output section that contains no code.
identifier— Names used as labels, registers, and symbols.
immediate operand — An operand whose value must be a constant expression.
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
initializes 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).
literal constant — A value that represents itself. It may also be called a literal or an immediate value.
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 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.
memory reference operand — An operand that refers to a location in memory using a target-specific
syntax.
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.
operand — An argument of an assembly 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. See
also assembly optimizer.
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.
register operand — A special pre-defined symbol that represents a CPU register.
relocatable constant expression— An expression that refers to at least one external symbol, register, or
memory location. The value of the expression is not known until link time.
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 address 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.
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 data 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 name that represents an address or a value.
symbolic constant — A symbol with a value that is an absolute constant expression.
symbolic debugging — The ability of a software tool to retain symbolic information that can be used by a
debugging tool such as an emulator.
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 — A value that is treated as a nonnegative number, regardless of its actual sign.
variable — A symbol representing a quantity that can assume any of a set of values.
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
Revision History
Previous Revisions:
Linker Information about accessing files and libraries from a linker command file has
SPRUI03A Section 8.5.3
Description been added.
Object File A –cg option has been added to the Object File Display utility to display
SPRUI03A Section 9.1
Utilities function stack usage and callee information in XML format.
The C6200, C6400, C6700, and C6700+ variants are not supported in v8.0 and
later versions of the TI Code Generation Tools. This document applies to the
C64x+, C6740, and C6600 variants of the TMS320C6000™ processor series.
SPRUI03 Preface --
Sections of this document that referred to the legacy variants have been
removed or simplified. If you are using a legacy device, please use v7.4 of the
Code Generation Tools and refer to SPRU186 for documentation.
The software simulator for C6000 devices is no longer supported. It was
SPRUI03 -- --
supported only for legacy devices.
The Absolute Lister and Cross-Reference Lister are no longer supported. They
SPRUI03 Introduction Section 1.2
were supported only for legacy devices.
The COFF object file format and the associated STABS debugging format are
no longer supported. The C6000 Code Generation Tools now support only the
Embedded Application Binary Interface (EABI) ABI, which works only with
Object
SPRUI03 Section 2.1 object files that use the ELF object file format and the DWARF debug format.
Modules
Sections of this document that referred to the COFF format have been
removed or simplified. If you want COFF support, please use v7.4 of the Code
Generation Tools and refer to SPRU186 for documentation.
Object You can now define weak symbols using assembly or the linker command file.
SPRUI03 Section 2.6.2
Modules The linker can omit weak symbols if they are not needed to resolve references.
Program
Secondary bootloaders are no longer described. They were used with legacy
SPRUI03 Loading and Section 3.1.2
devices.
Running
SPRUI03 Linker Section 8.4.10 Added a list of the linker's predefined macros.
SPRUI03 Linker Section 8.5.10.7 Information is provided about the _symval operator.
SPRUI03 Linker Section 8.6.1 Added information about referencing linker symbols.
Texas Instruments Incorporated (‘TI”) technical, application or other design advice, services or information, including, but not limited to,
reference designs and materials relating to evaluation modules, (collectively, “TI Resources”) are intended to assist designers who are
developing applications that incorporate TI products; by downloading, accessing or using any particular TI Resource in any way, you
(individually or, if you are acting on behalf of a company, your company) agree to use it solely for this purpose and subject to the terms of
this Notice.
TI’s provision of TI Resources does not expand or otherwise alter TI’s applicable published warranties or warranty disclaimers for TI
products, and no additional obligations or liabilities arise from TI providing such TI Resources. TI reserves the right to make corrections,
enhancements, improvements and other changes to its TI Resources.
You understand and agree that you remain responsible for using your independent analysis, evaluation and judgment in designing your
applications and that you have full and exclusive responsibility to assure the safety of your applications and compliance of your applications
(and of all TI products used in or for your applications) with all applicable regulations, laws and other applicable requirements. You
represent that, with respect to your applications, you have all the necessary expertise to create and implement safeguards that (1)
anticipate dangerous consequences of failures, (2) monitor failures and their consequences, and (3) lessen the likelihood of failures that
might cause harm and take appropriate actions. You agree that prior to using or distributing any applications that include TI products, you
will thoroughly test such applications and the functionality of such TI products as used in such applications. TI has not conducted any
testing other than that specifically described in the published documentation for a particular TI Resource.
You are authorized to use, copy and modify any individual TI Resource only in connection with the development of applications that include
the TI product(s) identified in such TI Resource. NO OTHER LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE TO
ANY OTHER TI INTELLECTUAL PROPERTY RIGHT, AND NO LICENSE TO ANY TECHNOLOGY OR INTELLECTUAL PROPERTY
RIGHT OF TI OR ANY THIRD PARTY IS GRANTED HEREIN, including but not limited to any patent right, copyright, mask work right, or
other intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information
regarding or referencing third-party products or services does not constitute a license to use such products or services, or a warranty or
endorsement thereof. Use of TI Resources 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.
TI RESOURCES ARE PROVIDED “AS IS” AND WITH ALL FAULTS. TI DISCLAIMS ALL OTHER WARRANTIES OR
REPRESENTATIONS, EXPRESS OR IMPLIED, REGARDING TI RESOURCES OR USE THEREOF, INCLUDING BUT NOT LIMITED TO
ACCURACY OR COMPLETENESS, TITLE, ANY EPIDEMIC FAILURE WARRANTY AND ANY IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL
PROPERTY RIGHTS.
TI SHALL NOT BE LIABLE FOR AND SHALL NOT DEFEND OR INDEMNIFY YOU AGAINST ANY CLAIM, INCLUDING BUT NOT
LIMITED TO ANY INFRINGEMENT CLAIM THAT RELATES TO OR IS BASED ON ANY COMBINATION OF PRODUCTS EVEN IF
DESCRIBED IN TI RESOURCES OR OTHERWISE. IN NO EVENT SHALL TI BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL,
COLLATERAL, INDIRECT, PUNITIVE, INCIDENTAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES IN CONNECTION WITH OR
ARISING OUT OF TI RESOURCES OR USE THEREOF, AND REGARDLESS OF WHETHER TI HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
You agree to fully indemnify TI and its representatives against any damages, costs, losses, and/or liabilities arising out of your non-
compliance with the terms and provisions of this Notice.
This Notice applies to TI Resources. Additional terms apply to the use and purchase of certain types of materials, TI products and services.
These include; without limitation, TI’s standard terms for semiconductor products http://www.ti.com/sc/docs/stdterms.htm), evaluation
modules, and samples (http://www.ti.com/sc/docs/sampterms.htm).
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2017, Texas Instruments Incorporated