Assembly Language Tools
Assembly Language Tools
Assembly Language Tools
v21.6.0.LTS
User’s Guide
Table of Contents
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 3
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Table of Contents www.ti.com
4 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Table of Contents
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 5
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Table of Contents www.ti.com
6 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Table of Contents
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 7
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Table of Contents www.ti.com
List of Figures
Figure 1-1. TMS320C28x Software Development Flow............................................................................................................ 16
Figure 2-1. Partitioning Memory Into Logical Blocks................................................................................................................. 21
Figure 2-2. Using Sections Directives Example.........................................................................................................................26
Figure 2-3. Object Code Generated by the File in Figure 2-2 ...................................................................................................27
Figure 2-4. Combining Input Sections to Form an Executable Object Module.......................................................................... 28
Figure 3-1. Bootloading Sequence (Simplified)......................................................................................................................... 37
Figure 3-2. Bootloading Sequence with Secondary Bootloader................................................................................................ 38
Figure 3-3. Autoinitialization at Run Time.................................................................................................................................. 42
Figure 3-4. Initialization at Load Time........................................................................................................................................43
Figure 4-1. The Assembler in the TMS320C28x Software Development Flow......................................................................... 47
Figure 4-2. Example Assembler Listing..................................................................................................................................... 70
Figure 5-1. The .field Directive...................................................................................................................................................84
Figure 5-2. Initialization Directives.............................................................................................................................................85
Figure 5-3. The .align Directive..................................................................................................................................................86
Figure 5-4. The .space and .bes Directives............................................................................................................................... 87
Figure 5-5. The .field Directive................................................................................................................................................. 114
Figure 5-6. Single-Precision Floating-Point Format................................................................................................................. 115
Figure 5-7. The .usect Directive...............................................................................................................................................153
Figure 7-1. The Archiver in the TMS320C28x Software Development Flow........................................................................... 172
Figure 8-1. The Linker in the TMS320C28x Software Development Flow...............................................................................178
Figure 8-2. Memory Map Defined in The MEMORY Directive ................................................................................................ 205
Figure 8-3. Section Placement Defined by The SECTIONS Directive ....................................................................................208
Figure 8-4. Run-Time Execution of Moving a Function from Slow to Fast Memory at Run Time ........................................... 222
Figure 8-5. Memory Allocation Shown in The UNION Statement and Separate Load Addresses for UNION Sections .........224
Figure 8-6. Overlay Pages Defined in Example 8-5 and Example 8-6 ................................................................................... 229
Figure 8-7. Compressed Copy Table....................................................................................................................................... 251
Figure 8-8. Handler Table........................................................................................................................................................ 252
Figure 8-9. CRC_TABLE Conceptual Model............................................................................................................................260
8 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Table of Contents
List of Tables
Table 4-1. TMS320C28x Assembler Options.............................................................................................................................48
Table 4-2. C28x Processor Symbolic Constants........................................................................................................................61
Table 4-3. CPU and CPU Control Registers.............................................................................................................................. 62
Table 4-4. FPU and FPU Control Registers...............................................................................................................................62
Table 4-5. VCU Registers.......................................................................................................................................................... 62
Table 4-6. Operators Used in Expressions (Precedence)..........................................................................................................64
Table 4-7. Built-In Mathematical Functions................................................................................................................................66
Table 4-8. Symbol Attributes......................................................................................................................................................72
Table 4-9. Smart Encoding for Efficiency................................................................................................................................... 73
Table 4-10. Smart Encoding Intuitively...................................................................................................................................... 73
Table 4-11. Instructions That Avoid Smart Encoding................................................................................................................. 74
Table 5-1. Directives that Control Section Use.......................................................................................................................... 78
Table 5-2. Directives that Gather Sections into Common Groups............................................................................................. 78
Table 5-3. Directives that Affect Unused Section Elimination.................................................................................................... 78
Table 5-4. Directives that Initialize Values (Data and Memory)..................................................................................................78
Table 5-5. Directives that Perform Alignment and Reserve Space............................................................................................79
Table 5-6. Directives that Format the Output Listing..................................................................................................................79
Table 5-7. Directives that Reference Other Files....................................................................................................................... 80
Table 5-8. Directives that Affect Symbol Linkage and Visibility..................................................................................................80
Table 5-9. Directives that Define Symbols at Assembly Time ...................................................................................................80
Table 5-10. Directives that Enable Conditional Assembly......................................................................................................... 80
Table 5-11. Directives that Define Union or Structure Types..................................................................................................... 81
Table 5-12. Directives that Create or Affect Macros.................................................................................................................. 81
Table 5-13. Directives that Control Diagnostics......................................................................................................................... 81
Table 5-14. Directives that Perform Assembly Source Debug...................................................................................................81
Table 5-15. Directives that Are Used by the Absolute Lister......................................................................................................81
Table 5-16. Directives that Perform Miscellaneous Functions................................................................................................... 81
Table 6-1. Substitution Symbol Functions and Return Values................................................................................................. 160
Table 6-2. Creating Macros......................................................................................................................................................169
Table 6-3. Manipulating Substitution Symbols......................................................................................................................... 169
Table 6-4. Conditional Assembly............................................................................................................................................. 169
Table 6-5. Producing Assembly-Time Messages.....................................................................................................................169
Table 6-6. Formatting the Listing............................................................................................................................................. 169
Table 8-1. Basic Options Summary......................................................................................................................................... 180
Table 8-2. File Search Path Options Summary........................................................................................................................180
Table 8-3. Command File Preprocessing Options Summary...................................................................................................180
Table 8-4. Diagnostic Options Summary................................................................................................................................. 180
Table 8-5. Linker Output Options Summary.............................................................................................................................181
Table 8-6. Symbol Management Options Summary................................................................................................................ 181
Table 8-7. Run-Time Environment Options Summary............................................................................................................. 181
Table 8-8. Link-Time Optimization Options Summary..............................................................................................................181
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 9
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Table of Contents www.ti.com
10 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Read This First
Preface
Read This First
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 11
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Read This First www.ti.com
Notational Conventions
This document uses the following conventions:
• Program listings, program examples, and interactive displays are shown in a special typeface .
Interactive displays use a bold version of the special typeface to distinguish commands that you enter from
items that the system displays (such as prompts, command output, error messages, etc.).
Here is a sample of C code:
#include <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:
cl2000 [options] [filenames] [--run_linker [link_options] [object files]]
• 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:
cl2000 --run_linker {--rom_model | --ram_model} filenames
• 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.
symbol .usect "section name", size in bytes[, alignment]
• Some directives can have a varying number of parameters. For example, the .byte directive can have
multiple parameters. This syntax is shown as [, ..., parameter].
.byte parameter1[, ... , parametern]
12 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Read This First
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 13
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Read This First www.ti.com
14 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Introduction to the Software Development Tools
Chapter 1
Introduction to the Software Development Tools
The TMS320C28x™ is supported by a set of software development tools, which includes an optimizing C/C++
compiler, an assembler, a linker, and assorted utilities. This chapter provides an overview of these tools.
The TMS320C28x is supported by the following assembly language development tools:
• Assembler
• Archiver
• Linker
• Library information archiver
• Absolute lister
• Cross-reference lister
• Object file display utility
• Disassembler
• Name utility
• Strip utility
• Hex conversion utility
This chapter shows how these tools fit into the general software tools development flow and gives a brief
description of each tool. For convenience, it also summarizes the C/C++ compiler and debugging tools. For
detailed information on the compiler and debugger, and for complete descriptions of the TMS320C28x, refer to
the books listed in Related Documentation From Texas Instruments.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 15
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Introduction to the Software Development Tools www.ti.com
C
source
files
Macro C2xx
source C/C++
compiler assembler
files source
Assembler Transition
Archiver
source assistant
Macro Assembler
library Assembler
source
Object Library-build
Archiver files utility
Debugging
tools
Library of Run-time-
object support
files Linker library
Post-link
optimizer
Executable
object file
Hex-conversion
utility
16 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Introduction to the Software Development Tools
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 17
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Introduction to the Software Development Tools www.ti.com
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 11.1.
• The disassembler decodes the machine code from object modules to show the assembly instructions that it
represents. See Section 11.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 11.3.
• The strip utility removes symbol table and debugging information from object files and object libraries. See
Section 11.4.
18 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Introduction to Object Modules
Chapter 2
Introduction to Object Modules
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 TMS320C28x 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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 19
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Introduction to Object Modules www.ti.com
Note that the .data section is used mainly for EABI. For COFF, the compiler generates .cinit sections that are
used to initialize the .ebss section. The assembler can be used to place initialized data in the .data section for
both COFF and EABI.
The assembler and linker allow you to create, name, and link other kinds of sections. The .text, .data, and .ebss
or .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 .ebss or .bss section is uninitialized;
user-named sections created with the .usect assembler directive are also uninitialized.
1 Some targets allow content other than text, such as constants, in .text sections.
20 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Introduction to Object Modules
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 TMS320C28x Optimizing C/C++
Compiler User's Guide.
Figure 2-1 shows the relationship between sections in an object file and a hypothetical target memory. (This
figure shows COFF sections. For EABI, the .ebss section would be .bss.) ROM may be EEPROM, FLASH or
some other type of physical memory in an actual system.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 21
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Introduction to Object Modules www.ti.com
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.
Note
If you do not use a section directive, the assembler assembles everything into the .text section.
symbol points to the first word reserved by this invocation of the .usect directive. The symbol corresponds to the name of
the variable for which you are reserving space. It can be referenced by any other section and can also be declared
as a global symbol (with the .global directive).
size in words is an absolute expression (see Section 4.9). The .usect directive reserves size in words words in section name. You
must specify a size; there is no default value.
blocking flag is an optional parameter. If you specify a value greater than 0 for this parameter, the assembler allocates size in
words contiguously. This means the allocated space does not cross a page boundary unless its size is greater than
a page, in which case the allocated space starts a page boundary. By default, the compiler causes this flag to be set
to 0 so that DP load optimization is used. The compiler provides the "blocked" and "noblocked" variable attributes
for controlling blocking on a per-variable basis. For examples of DP load optimization, see the Tools Insider blog in
TI's E2E community.
alignment flag is an optional parameter. It causes the assembler to allocate the specified size in words on long word boundaries.
The resulting alignment will be on a boundary that is 2 to the power of the specified alignment flag. For example, an
alignment flag of 5 gives an alignment of 2**5, which is 32 words.
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.4). 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 .common directive (EABI only) is similar to directives that create uninitialized data sections, except that
common symbols are created by the linker instead.
2.4.2 Initialized Sections
Initialized sections contain executable code or initialized data. The contents of these sections are stored in
the object file and placed in TMS320C28x memory when the program is loaded. Each initialized section is
independently relocatable and may reference symbols that are defined in other sections. The linker automatically
resolves these references. The following directives tell the assembler to place code or data into a section. The
syntaxes for these directives are:
22 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Introduction to Object Modules
.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.3 User-Named Sections
User-named sections are sections that you create. You can use them like the default .text, .data, and .ebss
or .bss sections, but each section with a distinct name is kept distinct during assembly.
For example, repeated use of the .text directive builds up a single .text section in the object file. This .text section
is allocated in memory as a single unit. Suppose there is a portion of executable code (perhaps an initialization
routine) that you want the linker to place in a different location than the rest of .text. If you assemble this segment
of code into a user-named section, it is assembled separately from .text, and you can use the linker to allocate it
into memory separately. You can also assemble initialized data that is separate from the .data section, and you
can reserve space for uninitialized variables that is separate from the .ebss or .bss section.
These directives let you create user-named sections:
• The .usect directive creates uninitialized sections that are used like the .ebss or .bss section. These sections
reserve space in RAM for variables.
• The .sect directive creates initialized sections, like the default .text and .data sections, that can contain code
or data. The .sect directive creates user-named sections with relocatable addresses.
The syntaxes for these directives are:
symbol .usect " section name ", size in words[,blocking flag[,alignment flag ] ]
.sect " section name "
When using COFF, you can create up to 32,767 distinct named sections. When using EABI, the maximum
number of sections is 232-1 (4294967295).
The section name parameter is the name of the section. For the .usect and .sect directives, a section name can
refer to a subsection; see Section 2.4.6 for details.
Each time you invoke one of these directives with a new name, you create a new user-named section. Each
time you invoke one of these directives with a name that was already used, the assembler resumes assembling
code or data (or reserves space) into the section with that name. You cannot use the same names with different
directives. That is, you cannot create a section with the .usect directive and then try to use the same section
with .sect .
2.4.4 Current Section
The assembler adds code or data to one section at a time. The section the assembler is currently filling is the
current section. The .text, .data, and .sect directives change which section is considered the current section.
When the assembler encounters one of these directives, it stops assembling into the current section (acting as
an implied end of current section command). The assembler sets the designated section as the current section
and assembles subsequent code into the designated section until it encounters another .text, .data, or .sect
directive.
If one of these directives sets the current section to a section that already has code or data in it from earlier in
the file, the assembler resumes adding to the end of that section. The assembler generates only one contiguous
section for each given section name. This section is formed by concatenating all of the code or data which was
placed in that section.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 23
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Introduction to Object Modules www.ti.com
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.
You can create two types of subsections:
• Initialized subsections are created using the .sect directive. See Section 2.4.2.
• Uninitialized subsections are created using the .usect directive. See Section 2.4.1.
Subsections are placed in the same manner as sections. See Section 8.5.5 for information on the SECTIONS
directive.
24 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Introduction to Object Modules
See Section 4.12 for more information on interpreting the fields in a source listing.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 25
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Introduction to Object Modules www.ti.com
26 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Introduction to Object Modules
As Figure 2-3 shows, the example code in Figure 2-2 creates four sections:
.text contains twelve 16-bit words of object code.
.data contains seven 16-bit words of initialized data.
.bss reserves ten 16-bit words in memory.
newvars is a user-named section created with the .usect directive; it contains eight 16-bit words 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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 27
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Introduction to Object Modules www.ti.com
It is not always necessary to use linker directives. If you do not use them, the linker uses the target processor's
default placement algorithm described in Section 8.7. When you do use linker directives, you must specify them
in a linker command file.
Refer to the following sections for more information about linker command files and linker directives:
• Section 8.5, Linker Command Files
• Section 8.5.4, The MEMORY Directive
• Section 8.5.5, The SECTIONS Directive
• Section 8.7, Default Placement Algorithm
2.5.1 Combining Input Sections
Figure 2-4 provides a simplified example of the process of linking two files together.
Note that this is a simplified example, so it does not show all the sections that will be created or the actual
sequence of the sections. See Section 8.7 for the actual default memory placement map for TMS320C28x. (The
following figure shows sections used by COFF. For EABI, change the .ebss section to .bss.)
In Figure 2-4, file1.obj and file2.obj have been assembled to be used as linker input. Each contains
the .text, .data, and .ebss 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
28 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Introduction to Object Modules
section from file2.obj to form one .text section, then combines the two .data sections and the two .ebss sections,
and finally places the user-named sections at the end. The memory map shows the combined sections to be
placed into memory.
2.5.2 Placing Sections
Figure 2-4 illustrates the linker's default method for combining sections. Sometimes you may not want to use
the default setup. For example, you may not want all of the .text sections to be combined into a single .text
section. Or you may want a user-named section placed where the .data section would normally be allocated.
Most memory maps contain various types of memory (RAM, ROM, EEPROM, FLASH, etc.) in varying amounts;
you may want to place a section in a specific type of memory.
For further explanation of section placement within the memory map, see the discussions in Section 8.5.4 and
Section 8.5.5. See Section 8.7 for the actual default memory allocation map for TMS320C28x.
2.6 Symbols
An object file contains a symbol table that stores information about 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
things like the start address of a function, variable, section, or an absolute integer (such as the size of the stack).
Symbols are defined in assembly by adding a label or a directive such as .set .equ .bss, or .usect.
Symbols have a binding, which is similar to the C concept of linkage. Both COFF and ELF file formats may
contain symbols bound locally and globally. ELF also binds symbols as weak symbols.
• Global symbols are visible to the entire program. The linker does not allow more than one global definition
of a particular symbol; it issues a multiple-definition error if a global symbol is defined more than once. (The
assembler can provide a similar multiple-definition error for local symbols.) A reference to a global symbol
from any object file refers to the one and only allowed global definition of that symbol. Assembly code must
explicitly make a symbol global by adding a .def, .ref, or .global directive. (See Section 2.6.1.)
• Local symbols are visible only within one object file; each object file that uses a symbol needs its own local
definition. References to local symbols in an object file are entirely unrelated to local symbols of the same
name in another object file. By default, a symbol is local. (See Section 2.6.2.)
• Weak symbols (EABI only) are symbols that may be used but not defined in the current module. They
may or may not be defined in another module. A weak symbol is intended to be overridden by a strong
(non-weak) global symbol definition of the same name in another object file. If a strong definition is available,
the weak symbol is replaced by the strong symbol. If no definition is available (that is, if the weak symbol
is unresolved), no error is generated, but the weak variable's address is considered to be null (0). For
this reason, application code that accesses a weak variable must check that its address is not zero before
attempting to access the variable. (See Section 2.6.3.)
Absolute symbols are symbols with a numeric value. They may be constants. To the linker, such symbols are
unsigned, 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.
In general, common symbols (see .common directive) are preferred over weak symbols.
See Section 4.8 for information about assembler symbols.
2.6.1 Global (External) Symbols
Global symbols are symbols that are either accessed in the current module but defined in another (an external
symbol) or defined in the current module and accessed in another. Such symbols are visible across object
modules. You must use the .def, .ref, or .global directive to identify a symbol as external:
.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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 29
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Introduction to Object Modules www.ti.com
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.
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.
2.6.2 Local Symbols
Local symbols are visible within a single object file. Each object file may have its own local definition for a
particular symbol. References to local symbols in an object file are entirely unrelated to local symbols of the
same name in another object file.
By default, a symbol is local.
2.6.3 Weak Symbols
Weak symbols are symbols that may or may not be defined.
Note
Weak symbols are supported only in EABI mode.
The linker processes symbols that are defined with a "weak" binding differently from symbols that are defined
with global binding. Instead of including a weak symbol in the object file's symbol table (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.
This allows the linker to minimize the number of symbols it includes in the output file's symbol table by omitting
those that are not needed to resolve references. Reducing the size of the output file's symbol table reduces the
time required to link, especially if there are a large number of pre-loaded symbols to link against. This feature is
particularly helpful for OpenCL applications.
You can define a weak symbol using either the .weak assembly directive or the weak operator in the linker
command file.
• Using Assembly: To define a weak symbol in an input object file, the source file can be written in assembly.
Use the .weak and .set directives in combination as shown in the following example, which defines a weak
symbol "ext_addr_sym":
.weak ext_addr_sym
ext_addr_sym .set 0x12345678
30 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Introduction to Object Modules
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 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 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 symbol; it will not be included in the resulting output file if the symbol is not referenced. See Section
8.6.2.
• Using C/C++ code: See information about the WEAK pragma and weak GCC-style variable attribute in the
TMS320C28x Optimizing C/C++ Compiler User's Guide.
If there are multiple definitions of the same 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.
2.6.4 The Symbol Table
The assembler generates entries with global (external) binding in the symbol table for each of the following:
• Each .ref, .def, or .global directive (see Section 2.6.1)
• The beginning of each section
The assembler generates entries with local binding for each locally-available function.
For informational purposes, there are also entries in the symbol table for each symbol in a program.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 31
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Introduction to Object Modules www.ti.com
Note
Expression Cannot Be Larger Than Space Reserved
If the value of an expression is larger, in bits, than the space reserved for it, you will receive an error
message from the linker.
Each section in an object module has a table of relocation entries. The table contains one relocation entry for
each relocatable reference in the section. The linker usually removes relocation entries after it uses them. This
prevents the output file from being relocated again (if it is relinked or when it is loaded). A file that contains no
relocation entries is an absolute file (all its addresses are absolute addresses, which are addresses known at
assembly time). If you want the linker to retain relocation entries, invoke the linker with the --relocatable option
(see Section 8.4.3.2).
In the example in Section 2.7, 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 4 (relative to address 0 in
the .text section). The assembler generates two relocation entries: one for X and one for Y. The reference to X
is an external reference (indicated by the ! character in the listing). The reference to Y is to an internally defined
relocatable symbol (indicated by the ' character in the listing).
32 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Introduction to Object Modules
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 0x7204. The linker uses the two relocation
entries to patch the two references in the object code:
0080' LC Y becomes 0080'
0004 7204
28A1! MOV AR1,#X becomes 28A1!
0000 7100
Sometimes an expression contains more than one relocatable symbol, or cannot be evaluated at assembly time.
In this case, the assembler encodes the entire expression in the object file. After determining the addresses of
the symbols, the linker computes the value of the expression as shown in the following example.
1 .global sym1, sym2
2
3 00000000 FF20% MOV ACC, #(sym2-sym1)
00000001 0000
The symbols sym1 and sym2 are both externally defined. Therefore, the assembler cannot evaluate the
expression sym2 - sym1, so it encodes the expression in the object file. The '%' listing character indicates a
relocation expression. Suppose the linker relocates sym2 to 300h and sym1 to 200h. Then the linker computes
the value of the expression to be 300h - 200h = 100h. Thus the MOV instruction is patched to:
00000000 FF20 MOV ACC, #(sym2-sym1)
00000001 0100
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 33
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Introduction to Object Modules www.ti.com
34 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Program Loading and Running
Chapter 3
Program Loading and Running
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.
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........................................................................................................................................................................36
3.2 Entry Point...................................................................................................................................................................40
3.3 Run-Time Initialization............................................................................................................................................... 41
3.4 Arguments to main.....................................................................................................................................................44
3.5 Run-Time Relocation..................................................................................................................................................44
3.6 Additional Information............................................................................................................................................... 44
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 35
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Program Loading and Running www.ti.com
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. Additionally, with the COFF RAM model, the loader is
responsible for parsing the .cinit section and performing the initializations encoded therein at load time.
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.
• "Burning" the load image onto an EPROM module. The hex converter (hex2000) 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 12 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.
• 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.
3.1.1 Load and Run Addresses
Consider an embedded device for which the program's load image is burned onto EPROM/ROM. Variable data
in the program must be writable, and so must be located in writable memory, typically RAM. However, RAM is
volatile, meaning it will lose its contents when the power goes out. If this data must have an initial value, that
initial value must be stored somewhere else in the load image, or it would be lost when power is cycled. The
initial value must be copied from the non-volatile ROM to its run-time location in RAM before it is used. See
Section 8.8 for ways this is done.
The load address is the location of an object in the load image.
The run address is the location of the object as it exists during program execution.
An object is a chunk of memory. It represents a section, segment, function, or data.
The load and run addresses for an object may be the same. This is commonly the case for program code
and read-only data, such as the .econst section. In this case, the program can read the data directly from the
load address. Sections that have no initial value, such as the .ebss section, do not have load data and are
considered to have load and run addresses that are the same. If you specify different load and run addresses for
an uninitialized section, the linker provides a warning and ignores the load address.
The load and run addresses for an object may be different. This is commonly the case for writable data, such as
the .data section. The .data section's starting contents are placed in ROM and copied to RAM. This often occurs
during program startup, but depending on the needs of the object, it may be deferred to sometime later in the
program as described in Section 3.5.
Symbols in assembly code and object files almost always refer to the run address. When you look at an address
in the program, you are almost always looking at the run address. The load address is rarely used for anything
but initialization.
The load and run addresses for a section are controlled by the linker command file and are recorded in the
object file metadata.
36 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Program Loading and Running
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 Moving a Function from Slow
to Fast Memory at Run Time. 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. COFF format executable object files contain sections.
3.1.2 Bootstrap Loading
The details of bootstrap loading (bootloading) vary a great deal between devices. Not every device supports
every bootloading mode, and using the bootloader is optional. This section discusses various bootloading
schemes to help you understand how they work. Refer to your device's data sheet to see which bootloading
schemes are available and how to use them.
A typical embedded system uses bootloading to initialize the device. The program code and data may be stored
in ROM or FLASH memory. At power-on, an on-chip bootloader (the primary bootloader) built into the device
hardware starts automatically.
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.
For many programs, the primary bootloader is not capable of loading the entire program, so these programs
supply a more capable secondary bootloader. The primary bootloader loads the secondary bootloader and
transfers control to it. Then, the secondary bootloader loads the rest of the program and transfers control to it.
There can be any number of layers of bootloaders, each loading a more capable bootloader to which it transfers
control.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 37
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Program Loading and Running www.ti.com
38 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Program Loading and Running
The boot table is target-specific. For C6000, the format of the boot table is simple. A header record contains
a 4-byte field that indicates where the boot loader should branch after it has completed copying data. After the
header, each section that is to be included in the boot table has the following contents:
• 4-byte field containing the size of the section
• 4-byte field containing the destination address for the copy
• the raw data
• 0 to 3 bytes of trailing padding to make the next field aligned to 4 bytes
More than one section can be entered; a termination block containing an all-zero 4-byte field follows the last
section.
See Section 12.11.2 for details about the boot table format.
3.1.2.5 Bootloader Routine
The bootloader routine is a normal function, except that it executes before the C environment is set up. For this
reason, it can't use the C stack, and it can't call any functions that have yet to be loaded!
The following sample code is for C6000 and is from Creating a Second-Level Bootloader for FLASH Bootloading
on TMS320C6000 Platform With Code Composer Studio (SPRA999).
Example 3-1. Sample Secondary Bootloader Routine
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 39
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Program Loading and Running www.ti.com
|| mvkh EMIF_CE2_V,B4
stw B4,*A4
;****************************************************************
; *EMIF_CE3 = EMIF_CE3_V (setup for 32−bit async)
;****************************************************************
|| mvkl EMIF_CE3,A4
|| mvkl EMIF_CE3_V,B4 ;
mvkh EMIF_CE3,A4
|| mvkh EMIF_CE3_V,B4
stw B4,*A4
;****************************************************************
; *EMIF_SDRAMCTL = EMIF_SDRAMCTL_V
;****************************************************************
|| mvkl EMIF_SDRAMCTL,A4
|| mvkl EMIF_SDRAMCTL_V,B4 ;
mvkh EMIF_SDRAMCTL,A4
|| mvkh EMIF_SDRAMCTL_V,B4
stw B4,*A4
;****************************************************************
; *EMIF_SDRAMTIM = EMIF_SDRAMTIM_V
;****************************************************************
|| mvkl EMIF_SDRAMTIM,A4
|| mvkl EMIF_SDRAMTIM_V,B4 ;
mvkh EMIF_SDRAMTIM,A4
|| mvkh EMIF_SDRAMTIM_V,B4
stw B4,*A4
;****************************************************************
; *EMIF_SDRAMEXT = EMIF_SDRAMEXT_V
;****************************************************************
|| mvkl EMIF_SDRAMEXT,A4
|| mvkl EMIF_SDRAMEXT_V,B4 ;
mvkh EMIF_SDRAMEXT,A4
|| mvkh EMIF_SDRAMEXT_V,B4
stw B4,*A4
;****************************************************************************
; copy sections
;****************************************************************************
mvkl COPY_TABLE, a3 ; load table pointer
mvkh COPY_TABLE, a3
ldw *a3++, b1 ; Load entry point
copy_section_top:
ldw *a3++, b0 ; byte count
ldw *a3++, a4 ; ram start address
nop 3
[!b0] b copy_done ; have we copied all sections?
nop 5
copy_loop:
ldb *a3++,b5
sub b0,1,b0 ; decrement counter
[ b0] b copy_loop ; setup branch if not done
[!b0] b copy_section_top
zero a1
[!b0] and 3,a3,a1
stb b5,*a4++
[!b0] and −4,a3,a5 ; round address up to next multiple of 4
[ a1] add 4,a5,a3 ; round address up to next multiple of 4
;****************************************************************************
; jump to entry point
;****************************************************************************
copy_done:
b .S2 b1
nop 5
40 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Program Loading and Running
The object file has an entry point field. For a C/C++ program, the linker will fill in _c_int00 by default. You can
select a custom entry point; see Section 8.4.13. The device itself cannot read the entry point field from the object
file, so it has to be encoded in the program somewhere.
• If you are using a bootloader, the boot table includes an entry point field. When it finishes running, the
bootloader branches to the entry point.
• If you are using an interrupt vector, the entry point is installed as the RESET interrupt handler. When RESET
is applied, the startup routine will be invoked.
• If you are using a hosted debugger, such as CCS, the debugger may explicitly set the program counter (PC)
to the value of the entry point.
3.3 Run-Time Initialization
After the load image is in place, the program can run. The subsections that follow describe bootstrap initialization
of a C/C++ program. An assembly-only program may not need to perform all of these steps.
3.3.1 The _c_int00 Function
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 status and configuration registers
2. Set up the stack
3. Process the .cinit run-time initialization table to autoinitialize global variables (when using the --rom_model
option)
4. Call all global object constructors in .init_array (for EABI) .pinit (for COFF)
5. Call the function main
6. Call exit when main returns
3.3.2 RAM Model vs. ROM Model
Choose a startup model based on the needs of your application. The ROM model performs more work during the
boot routine. The RAM model performs more work while loading the application.
If your application is likely to need frequent RESETs or is a standalone application, the ROM model may be a
better choice, because the boot routine will have all the data it needs to initialize RAM variables. However, for a
system with an operating system, it may be better to use the RAM model.
In the COFF RAM model, the loader is first responsible for processing the .cinit section. The .cinit section is a
NOLOAD section, which means it does not get allocated to target memory. Instead, the loader is responsible for
parsing the .cinit section and performing the initializations encoded therein at load time.
In both the COFF ROM and EABI ROM models, the C boot routine copies data from the .cinit section to the
run-time location of the variables to be initialized.
In the EABI RAM model, no .cinit records are generated at startup.
3.3.2.1 Autoinitializing Variables at Run Time (--rom_model)
Autoinitializing variables at run time is the default method of autoinitialization. To use this method, invoke the
linker with the --rom_model option.
The ROM model allows initialization data to be stored in slow non-volatile memory and copied to fast memory
each time the program is reset. Use this method if your application runs from code burned into slow memory or
needs to survive a reset.
For the ROM model with EABI, the .cinit section is loaded into memory along with all the other initialized
sections. The linker defines a special symbol called __TI_CINIT_Base that points to the beginning of the
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 41
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Program Loading and Running www.ti.com
initialization tables in memory. When the program begins running, the C boot routine copies data from the tables
(pointed to by .cinit) into the run-time location of the variables.
For the ROM model with COFF, 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 .ebss or user-defined section.
Figure 3-3 illustrates autoinitialization at run time for the COFF ABI using the ROM model.
42 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Program Loading and Running
Note
Loader
A loader is not included as part of the TMS320C28x C/C++ compiler tools. Use Code Composer
Studio as a loader.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 43
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Program Loading and Running www.ti.com
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 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.
COFF .cinit tables can be used to provide copy table functionality. See Section 8.8 for more information.
3.4 Arguments to main
Some programs expect arguments to main (argc, argv) to be valid. Normally this isn't possible for an embedded
program, but the TI runtime does provide a way to do it. The user must allocate an .args section of an
appropriate size using the --args linker option. It is the responsibility of the loader to populate the .args section. It
is not specified how the loader determines which arguments to pass to the target. The format of the arguments is
the same as an array of pointers to char on the target.
See Section 8.4.4 for information about allocating memory for argument passing.
3.5 Run-Time Relocation
At times you may want to load code into one area of memory and move it to another area before running it.
For example, you may have performance-critical code in an external-memory-based system. The code must be
loaded into external memory, but it would run faster in internal memory. Because internal memory is limited, you
might swap in different speed-critical functions at different times.
The linker provides a way to handle this. Using the SECTIONS directive, you can optionally direct the linker
to allocate a section twice: first to set its load address and again to set its run address. Use the load keyword
for the load address and the run keyword for the run address. See Section 3.1.1 for more about load and run
addresses. If a section is assigned two addresses at link time, 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.
If you provide only one allocation (either load or run) for a section, the section is allocated only once and loads
and runs at the same address. If you provide both allocations, the section is actually allocated as if it were two
separate sections. The two sections are the same size if the load section is not compressed.
Uninitialized sections (such as .ebss or .bss) are not loaded, so the only significant address is the run address.
The linker allocates uninitialized sections only once; if you specify both run and load addresses, the linker warns
you and ignores the load address.
For a complete description of run-time relocation, see Section 8.5.6.
3.6 Additional Information
See the following sections and documents for additional information:
Section 8.4.4, "Allocate Memory for Use by the Loader to Pass Arguments (--arg_size Option)"
Section 8.4.13, "Define an Entry Point (--entry_point Option)"
Section 8.5.6.1 ,"Specifying Load and Run Addresses"
Section 8.8, "Linker-Generated Copy Tables"
Section 8.11.1, "Run-Time Initialization"
Chapter 12, "Hex Conversion Utility Description"
"Run-Time Initialization" and "System Initialization" sections in the TMS320C28x Optimizing C/C++ Compiler
User's Guide
44 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
Chapter 4
Assembler Description
The TMS320C28x 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:
Assembler directives described in Chapter 5
Macro directives described in Chapter 6
Assembly language instructions described in the TMS320C28x DSP CPU and Instruction Set Reference Guide.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 45
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
46 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
C
source
files
Macro C2xx
source C/C++
compiler assembler
files source
Assembler Transition
Archiver
source assistant
Macro Assembler
library Assembler
source
Object Library-build
Archiver files utility
Debugging
tools
Library of Run-time-
object support
files Linker library
Post-link
optimizer
Executable
object file
Hex-conversion
utility
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 47
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
cl2000 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.
48 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
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
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 49
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
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 C2000_A_DIR environment variable
4. Any directories named with the C2000_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 C2000_A_DIR environment variable (described in
Section 4.5.2). The C2000_C_DIR environment variable is discussed in the TMS320C28x Optimizing C/C++
Compiler User's Guide.
4.5.1 Using the --include_path Assembler Option
The --include_path assembler option names an alternate directory that contains copy/include files or macro
libraries. The format of the --include_path option is as follows:
cl2000 --include_path= pathname source filename [other options]
There is no limit to the number of --include_path options per invocation; each --include_path option names
one pathname. In assembly source, you can use the .copy, .include, or .mlib directive without specifying 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"
You could set up the search path with the commands shown below:
Operating System Enter
UNIX (Bourne shell) cl2000 --include_path=/tools/files source.asm
Windows cl2000 --include_path=c:\tools\files source.asm
The assembler first searches for copy.asm in the current directory because source.asm is in the current
directory. Then the assembler searches in the directory named with the --include_path option.
50 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
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 C28X_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 C28X_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:
Operating System Enter
UNIX (Bourne shell) C2000_A_DIR="/dsys"; export C2000_A_DIR
cl2000 --include_path=/tools/files source.asm
Windows C2000_A_DIR=c:\dsys
cl2000 --include_path=c:\tools\files source.asm
The assembler first searches for copy1.asm and copy2.asm in the current directory because source.asm is in
the current directory. Then the assembler searches in the directory named with the --include_path option and
finds copy1.asm. Finally, the assembler searches the directory named with C2000_A_DIR and finds copy2.asm.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 51
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
The environment variable remains set until you reboot the system or reset the variable by entering one of these
commands:
Operating System Enter
UNIX (Bourne shell) unset C2000_A_DIR
Windows set C2000_A_DIR=
The C28x assembler reads an unlimited number of characters per line. Source statements that extend beyond
400 characters in length (including comments) are truncated in the listing file.
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.
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.
52 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
A label on a line by itself is a valid statement. When a label appears on a line by itself, it points to the instruction
on the next line (the SPC is not incremented):
1 000000 Here:
2 000000 0003 .word 3
If you do not use a label, the character in column 1 must be a blank, an asterisk, or a semicolon.
4.6.2 Mnemonic Field
The mnemonic field follows the label field. The mnemonic field cannot start in column 1; if it does, it is interpreted
as a label. The mnemonic field can begin with pipe symbols (||) when the previous instruction is a RPT. Pipe
symbols that follow a RPT instruction indicate instructions that are repeated. For example:
RPT
|| Inst2 This instruction is repeated.
In the case of C28x with FPU support, the mnemonic field can begin with pipe symbols to indicate instructions
that are to be executed in parallel. For example, in the instance given below, Inst1 and Inst2 are FPU instructions
that execute in parallel:
Instr1
|| Instr2
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 53
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
54 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 55
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
56 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
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.
$strtod("NaN")
$strtod("Inf")
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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 57
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
Symbols derived from labels can also be used as the operands of .bss, .global, .ref, or .def directives.
.global label1
label2: NOP
ADD AR1, label1
SB label2, UNC
This is an example of code that declares and uses a local label legally:
$1:
ADDB AL, #-7
B $1, GEQ
.newblock ; undefine $1 to use it again.
$1 MOV T, AL
MPYB ACC, T, #7
CMP AL, #1000
B $1, LT
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.
58 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
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.
Example 4-2. Local Labels of the Form name?
****************************************************************
** First definition of local label mylab **
****************************************************************
nop
mylab? nop
B mylab?, UNC
****************************************************************
** Include file has second definition of mylab **
****************************************************************
.copy "a.inc"
****************************************************************
** Third definition of mylab, reset upon exit from .include **
****************************************************************
mylab? nop
B mylab?, UNC
****************************************************************
** Fourth definition of mylab in macro, macros use different **
** namespace to avoid conflicts **
****************************************************************
mymac .macro
mylab? nop
B mylab?, UNC
.endm
****************************************************************
** Macro invocation **
****************************************************************
mymac
****************************************************************
** Reference to third definition of mylab. Definition is not **
** reset by macro invocation. **
****************************************************************
B mylab?, UNC
****************************************************************
** Changing section, allowing fifth definition of mylab **
****************************************************************
.sect "Sect_One"
nop
mylab? .word 0
nop
nop
B mylab?, UNC
****************************************************************
** The .newblock directive allows sixth definition of mylab **
****************************************************************
.newblock
mylab? .word 0
nop
nop
B mylab?, UNC
For more information about using labels in macros see Section 6.6.
4.8.4 Symbolic Constants
A symbolic constant is a symbol with a value that is an absolute constant expression (see Section
4.9). By using symbolic constants, you can assign meaningful names to constant expressions. The .set
and .struct/.tag/.endstruct directives enable you to set symbolic constants (see Define Assembly-Time Constant).
Once defined, symbolic constants cannot be redefined.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 59
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
If you use the .set directive to assign a value to a symbol , the symbol becomes a symbolic constant and may be
used where a constant expression is expected. For example:
shift3 .set 3
MOV AR1, #shift3
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:
myReg .set AR1
MOV myReg, #3
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
item .struct ; item structure definition
value .int ; value offset = 0
delta .int ; delta offset = 4
i_len .endstruct ; item size = 8
The assembler also has many predefined symbolic constants; these are discussed in Section 4.8.6.
4.8.5 Defining Symbolic Constants (--asm_define Option)
The --asm_define option equates a constant value or a string with a symbol. The symbol can then be used in
place of a value in assembly source. The format of the --asm_define option is as follows:
cl2000 --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:
cl2000 --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.
In assembler source, you can test the symbol defined with the --asm_define option with these directives:
Type of Test Directive Usage
Existence .if $isdefed(" name ")
Nonexistence .if $isdefed(" name ") = 0
Equal to value .if name = value
Not equal to value .if name != value
60 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
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.
Example 4-3. Using Symbolic Constants Defined on Command Line
4.8.7 Registers
The names of C28x registers are predefined symbols.
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, IER can
also be entered as ier.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 61
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
See the "Register Conventions" section of the TMS320C28x Optimizing C/C++ Compiler User's Guide for details
about the registers and their uses.
Table 4-3. CPU and CPU Control Registers
Register Description
ACC/AH, AL Accumulator/accumulator high, accumulator low
DBGIER Debug interrupt enable register
DP Data page pointer
IER Interrupt enable register
IFR Interrupt flag pointer
P/PH, PL Product register/product high, product low
PC Program counter
RPC Return program counter
ST0 Status register 0
ST1 Status register 1
SP Stack pointer register
TH Multiplicant high register; an alias of T register
XAR0/AR0H, AR0 Auxiliary register 0/auxiliary 0 high, auxiliary 0 low
XAR1/AR1H, AR1 Auxiliary register 1/auxiliary 1 high, auxiliary 1 low
XAR2/AR2H, AR2 Auxiliary register 2/auxiliary 2 high, auxiliary 2 low
XAR3/AR3H, AR3 Auxiliary register 3/auxiliary 3 high, auxiliary 3 low
XAR4/AR4H, AR4 Auxiliary register 4/auxiliary 4 high, auxiliary 4 low
XAR5/AR5H, AR5 Auxiliary register 5/auxiliary 5 high, auxiliary 5 low
XAR6/AR6H, AR6 Auxiliary register 6/auxiliary 6 high, auxiliary 6 low
XAR7/AR7H, AR7 Auxiliary register 7/auxiliary 7 high, auxiliary 7 low
XT/T, TL Multiplicand register/Multiplicant high, multiplicant low
62 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
assembler encounters a substitution symbol, its string value is substituted for the symbol name. Unlike symbolic
constants, substitution symbols can be redefined.
A string can be assigned to a substitution symbol anywhere within a program; for example:
.asg "AR1", myReg ;register AR1
.asg "*+XAR2 [2]", ARG1 ;first arg
.asg "*+XAR2 [1]", ARG2 ;second arg
When you are using macros, substitution symbols are important because macro parameters are actually
substitution symbols that are assigned a macro argument. The following code shows how substitution symbols
are used in macros:
add2 .macro A, B ; add2 macro definition
MOV AL, A
ADD AL, B
.endm
*add2 invocation
add2 LOC1, LOC2 ;add "LOC1" argument to a
;second argument "LOC2".
MOV AL,LOC1
ADD AL,LOC2
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 63
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
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. For ELF, 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.
4.9.1 Mathematical and Logical Operators
The operands of a mathematical or logical operator must be well-defined expressions. That is, you must use the
correct number of operands and the operation must make sense. For example, you cannot take the XOR of a
floating-point value. In addition, well-defined expressions contain only symbols or assembly-time constants that
have been defined before they occur in the directive's expression.
Three main factors influence the order of expression evaluation:
Parentheses Expressions enclosed in parentheses are always evaluated first.
8 / (4 / 2) = 4, but 8 / 4 / 2 = 1
You cannot substitute braces ( { } ) or brackets ( [ ] ) for parentheses.
Precedence groups Operators, listed in Table 4-6, are divided into nine precedence groups. When parentheses do not determine
the order of expression evaluation, the highest precedence operation is evaluated first.
8 + 4 / 2 = 10 (4 / 2 is evaluated first)
Left-to-right evaluation When parentheses and precedence groups do not determine the order of expression evaluation, the
expressions are evaluated from left to right, except for Group 1, which is evaluated from right to left.
8 / 4*2 = 4, but 8 / (4*2) = 1
Table 4-6 lists the operators that can be used in expressions, according to precedence group.
Table 4-6. Operators Used in Expressions (Precedence)
Group(1) Operator Description(2)
1 + Unary plus
- Unary minus
~ 1s complement
! Logical NOT
2 * Multiplication
/ Division
% Modulo
3 + Addition
- Subtraction
4 << Shift left
>> Shift right
5 < Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
64 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
(1) Group 1 operators are evaluated right to left. All other operators are evaluated left to right.
(2) Unary + and - have higher precedence than the binary forms.
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.
4.9.2 Relational Operators and Conditional Expressions
The assembler supports relational operators that can be used in any expression; they are especially useful for
conditional assembly. Relational operators include the following:
= Equal to != Not equal to
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.
4.9.3 Well-Defined Expressions
Some assembler directives, such as .if, require well-defined absolute constant expressions as operands. Well-
defined expressions contain only symbols or assembly-time constants that have been defined before they occur
in the directive's expression. In addition, they must use the correct number of operands and the operation must
make sense. The evaluation of a well-defined expression must be unambiguous.
This is an example of a well-defined expression:
1000h+X
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 65
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
66 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 67
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
68 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
The following example shows compiled code with a .sect directive for a CLA function and a .usect directive
to identify the function scratchpad frame. This .usect directive identifies the function frame as part of
the .scratchpad section and allows the compiler to use overlays when possible. Overlaid function frames use
the same physical memory, thereby reducing memory utilization. It is recommended that assembly code follow
the ".scratchpad:" naming convention to reduce memory requirements.
.sect "Cla1Prog:_Cla1Task2"
.align 2
__cla_Cla1Task2_sp .usect ".scratchpad:Cla1Prog:_Cla1Task2",14,0,1
.global _Cla1Task2
;***************************************************************
;* FNAME: _Cla1Task2 FR SIZE: 14 *
;* *
;* FUNCTION ENVIRONMENT *
;* *
;* FUNCTION PROPERTIES *
;* 14 Auto, 12 SOE *
;***************************************************************
_Cla1Task2:
[ ... ]
If the CLA function in the example above were a CLA2 background task, the .usect directive would instead
identify the scratchpad frame as ".scratchpad:background:Cla1Prog:_Cla1Task2".
See the "CLA Compiler" chapter in the TMS320C28x Optimizing C/C++ Compiler User's Guide for more details.
4.12 Source Listings
A source listing shows source statements and the object code they produce. To obtain a listing file, invoke the
assembler with the --asm_listing option (see Section 4.3).
Two banner lines, a blank line, and a title line are at the top of each source listing page. Any title supplied by
the .title directive is printed on the title line. A page number is printed to the right of the title. If you do not use
the .title directive, the name of the source file is printed. The assembler inserts a blank line below the title line.
Each line in the source file produces at least one line in the listing file. This line shows a source statement
number, an SPC value, the object code assembled, and the source statement. Figure 4-2 shows these in an
actual listing file.
Field 1: Source Statement Number
Line number
The source statement number is a decimal number. The assembler numbers source lines as it encounters them
in the source file; some statements increment the line counter but are not listed. (For example, .title statements
and statements following a .nolist are not listed.) The difference between two consecutive source line numbers
indicates the number of intervening statements in the source file that are not listed.
Include file letter
A letter preceding the line number indicates the line is assembled from the include file designated by the letter.
Nesting level number
A number preceding the line number indicates the nesting level of macro expansions or loop blocks.
Field 2: Section Program Counter
This field contains the SPC value, which is hexadecimal. All sections (.text, .data, .bss, .ebss, and named
sections) maintain separate SPCs. Some directives do not affect the SPC and leave this field blank.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 69
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
70 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
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). The C example that follows shows the cvar.c program that defines a variable, svar, as the structure
type X. The svar variable is then referenced in the addfive.asm assembly program that follows, 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:
cl2000 -symdebug:dwarf cvars.c addfive.asm --run_linker --library=lnk.cmd
--library=rts2800_ml.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.
Viewing Assembly Variables as C Types C Program
typedef struct {
int m1;
int m2;
} X;
X svar = { 1, 2 };
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 71
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
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. The following table 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.
72 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
The assembler also intuitively changes instruction formats during smart encoding. For example, to push the
accumulator value to the stack, you use MOV *SP++, ACC. Since it would be intuitive to use PUSH ACC for
this operation, the assembler accepts PUSH ACC and through smart encoding, changes it to MOV *SP++, ACC.
Table 4-10 shows a list of instructions recognized during intuitive smart encoding and what the instruction is
changed to.
Table 4-10. Smart Encoding Intuitively
This instruction... Is encoded as...
MOV P, #0 MPY P, T, #0
SUB loc, #16BitSigned ADD loc, #-16BitSigned
ADDB SP, #-7Bit SUBB SP, #7Bit
ADDB aux, #-7Bit SUBB aux, #7Bit
SUBB AX, #8BitSigned ADDB AX, #-8BitSigned
PUSH IER MOV *SP++, IER
POP IER MOV IER, *--SP
PUSH ACC MOV *SP++, ACC
POP ACC MOV ACC, *--SP
PUSH XARn MOV *SP++, XARn
POP XARn MOV XARn, *--SP
PUSH #16Bit MOV *SP++, #16Bit
MPY ACC, T, #8Bit MPYB ACC, T, #8Bit
In some cases, you might want a 2-word instruction even when there is an equivalent 1-word instruction
available. In such cases, smart encoding for efficiency could be a problem. Therefore, the equivalent instructions
in Table 4-11 are provided; these instructions will not be optimized.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 73
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
74 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Description
• Pipeline Conflict:
Two instructions write the same register in the same cycle.
Assembler Response:
The assembler generates an error message and aborts.
• Pipeline Conflict:
Instructions FRACF32, I16TOF32, UI16TOF32, F32TOI32, and/or F32TOUI32 are present in the delay slot of
a specific type of MOV32 instruction that moves a value from a CPU register or memory location to an FPU
register.
Assembler Response:
The assembler gives an error message and aborts, as the hardware is not able to correctly execute this
sequence.
• Pipeline Conflict:
Parallel operations have the same destination register.
Assembler Response:
The assembler gives a warning.
• Pipeline Conflict:
A read/write happens in the delay slot of a write of the same register.
Assembler Response:
The assembler gives a warning.
• Pipeline Conflict:
A SAVE operation happens in the delay slot of a pipeline operation.
Assembler Response:
The assembler gives a warning.
• Pipeline Conflict:
A RESTORE operation happens in the delay slot of a pipeline operation.
Assembler Response:
The assembler gives a warning.
• Pipeline Conflict:
A SETFLG instruction tries to modify the LUF or LVF flag while certain instructions that modify LUF/LVF (such
as ADDF32, SUBF32, EINVF32, EISQRTF32 etc) have pending writes.
Assembler Response:
The assembler does not check for which instructions have pending writes; on encountering a SETFLG when
any write is pending, the assembler issues a detailed warning, asking you to ensure that the SETFLG is not
in the delay slot of the specified instructions.
For the actual timing of each FPU instruction, and pipeline modeling, please refer to the TMS320C28x Floating
Point Unit and Instruction Set Reference Guide. Timing information for VCU instructions can be found in the
TMS320x28xx, 28xxx DSP Peripherals Reference Guide.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 75
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Description www.ti.com
76 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
Chapter 5
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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 77
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
Note
Labels and Comments Are Not Shown in Syntaxes
Most source statements that contain a directive can also contain a label and a comment. Labels begin
in the first column (only labels and comments can appear in the first column), and comments must be
preceded by a semicolon, or an asterisk if the comment is the only element in the line. To improve
readability, labels and comments are not shown as part of the directive syntax here. See the detailed
description of each directive for using labels with directives.
78 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
Table 5-4. Directives that Initialize Values (Data and Memory) (continued)
Mnemonic and Syntax Description See
.float value1[, ... , valuen] Initializes one or more 32-bit, IEEE single-precision, floating-point .float topic
constants
.int value1[, ... , valuen] Initializes one or more 16-bit integers .int topic
.long value1[, ... , valuen] Initializes one or more 32-bit integers .long topic
.pstring {expr1|" string1 "}[,... , {exprn|" stringn "}] Places 8-bit characters from a character string into the current .pstring topic
section.
.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
.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
.uword value1[, ... , valuen] Initializes one or more unsigned 16-bit integers .uword topic
.word value1[, ... , valuen] Initializes one or more 16-bit integers .word topic
.xfloat value1[, ... , valuen] Places the 32-bit floating-point representation of one or more .xfloat topic
floating-point constants into the current section
.xldouble value1[, ... , valuen] Places the 64-bit floating-point representation of one or more .xfloat topic
floating-point double constants into the current section
.xlong value1[, ... , valuen] Places one or more 32-bit values into consecutive words in the .xlong topic
current section
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 79
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
80 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 81
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
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 Appendix A.1
• The .compiler_opts directive indicates that the assembly code was produced by the compiler, and which
build model options were used for this file.
5.2 Directives that Define Sections
These directives associate portions of an assembly language program with the appropriate sections:
• The .bss directive reserves space in the .bss section for uninitialized variables.
• The .clink directive enables conditional linking by telling the linker to leave the named section out of the final
object module output of the linker if there are no references found to any symbol in the section. The .clink
directive can be applied to initialized sections. (COFF only)
• The .data directive identifies portions of code in the .data section. The .data section usually contains
initialized data.
• The .retain directive can be used to indicate that the current or specified section must be included in the
linked output. Thus even if no other sections included in the link reference the current or specified section, it
is still included in the link. (EABI only)
• The .retainrefs directive can be used to force sections that refer to the specified section. This is useful in the
case of interrupt vectors. (EABI only)
• The .sect directive defines an initialized named section and associates subsequent code or data with that
section. A section defined with .sect can contain code or data.
• The .text directive identifies portions of code in the .text section. The .text section usually contains executable
code.
• The .usect directive reserves space in an uninitialized named section. The .usect directive is similar to
the .bss directive, but it allows you to reserve space separately from the .bss section.
Chapter 2 discusses these sections in detail.
Example 5-1 shows how you can use sections directives to associate code and data with the proper sections.
This is an output listing; column 1 shows line numbers, and column 2 shows the SPC values. (Each section has
its own program counter, or SPC.) When code is first placed in a section, its SPC equals 0. When you resume
assembling into a section after other code is assembled, the section's SPC resumes counting as if there had
been no intervening code.
The directives in Example 5-1 perform the following tasks:
.text initializes words with the values 1, 2, 3, 4, 5, 6, 7, and 8.
.data initializes words with the values 9, 10, 11, 12, 13, 14, 15, and 16.
var_defs initializes words with the values 17 and 18.
.usect reserves 19 words
xy reserves 20 words.
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.
82 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
1 ***************************************************
2 * Start assembling into the .text section *
3 ***************************************************
4 000000 .text
5 000000 0001 .word 1, 2
000001 0002
6 000002 0003 .word 3, 4
000003 0004
7
8 ***************************************************
9 * Start assembling into the .data section *
10 ***************************************************
11 000000 .data
12 000000 0009 .word 9, 10
000001 000A
13 000002 000B .word 11, 12
000003 000C
14
15 ***************************************************
16 * Start assembling into a named, *
17 * initialized section, var_defs *
18 ***************************************************
19 000000 .sect "var_defs"
20 000000 0011 .word 17, 18
000001 0012
21
22 ***************************************************
23 * Resume assembling into the .data section *
24 ***************************************************
25 000004 .data
26 000004 000D .word 13, 14
000005 000E
27 000000 sym .usect ".ebss", 19 ; Reserve space in .ebss
28 000006 000F .word 15, 16 ; Still in .data
000007 0010
29
30 ***************************************************
31 * Resume assembling into the .text section *
32 ***************************************************
33 000004 .text
34 000004 0005 .word 5, 6
000005 0006
35 000000 usym .usect "xy", 20 ; Reserve space in xy
36 000006 0007 .word 7, 8 ; Still in .text
37 000007 0008
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 83
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
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 000000 0003 .field 3, 3
2 000000 0008 .field 8, 6
3 000000 0010 .field 16, 5
15 2 1 0
0 1 1 .field 3, 3
3 bits
15 8 7 6 5 4 3
0 0 1 0 0 0 0 1 1 .field 8, 6
6 bits
15 13 12 11 10 9
1 0 0 0 0 0 0 1 0 0 0 0 1 1 .field 16, 5
5 bits
Figure 5-1. The .field Directive
• The .float and .xfloat directives calculate the single-precision (32-bit) IEEE floating-point representation of a
single floating-point value and store it in a word in the current section that is aligned to a word boundary.
• The .int and .word directives place one or more 16-bit values into consecutive 16-bit fields (words) in the
current section. The .int and .word directives automatically align to a word boundary.
• The .long and .xlong directives place one or more 32-bit values into consecutive 32-bit fields (words) in the
current section. The .long directive automatically aligns to a word boundary.
• The .xldouble directive calculates the double-precision (64-bit) IEEE floating-point representation of a double
floating-point value and stores it into consecutive 32-bit fields (words) in the current section that is aligned to
a word boundary. Note that the .double directive is not a synonym and is not recommended.
• The .string , .cstring, and .pstring 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 16-bit word of the current section. The .cstring directive adds a NUL character needed by C;
the .string directive does not add a NUL character. With the .pstring directive, the data is packed so that each
word contains two 8-bit bytes.
• The .ubyte, .uchar, .uint, .ulong, 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++.
Note
Directives that Initialize Constants When Used in a .struct/.endstruct Sequence
The .bits, .byte, .char, .int, .long, .word, .ubyte, .uchar, .uint, .ulong, .uword, .string, .pstring, .float, .xflo
at, .xldouble, and .field directives do not initialize memory when they are part of a .struct/ .endstruct
sequence; rather, they define a member’s size. For more information, see the .struct/.endstruct
directives.
84 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
Figure 5-2 compares the .byte, .word, .long, and .string directives using the following assembled code:
1 000000 00AB .byte 0ABh
2 000001 CDEF .word 0CDEFh
3 000002 CDEF .long 089ABCDEFh
000003 89AB
4 000004 0068 .string "help"
000005 0065
000006 006C
000007 0070
1 0 0 A B .byte 0ABh
2 C D E F .word 0CDEFh
3 C D E F .long 089ABCDEFh
4 8 9 A B
5 0 0 68 .string “help”
h
6 0 0 65
e
7 0 0 6C
l
8 0 0 70
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 85
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
80h
Current
SPC = 88h 64 word New SPC = C0h
after assembling
.align directive
C0h
86 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
• The .bes and .space directives reserve a specified number of bits in the current section. The assembler fills
these reserved bits with 0s.
– When you use a label with .space, it points to the first word that contains reserved bits.
– When you use a label with .bes, it points to the last word that contains reserved bits.
• Figure 5-4 shows how the .space and .bes directives work for the following assembled code:
1
2
3 000000 0100 .word 100h, 200h
000001 0200
4 000002 Res_1 .space 17
5 000004 000F .word 15
6 000006 Res_2 .bes 20
7 000007 00BA .byte 0BAh
Res_1 points to the first word in the space reserved by .space. Res_2 points to the last word in the space
reserved by .bes.
Res_1 = 02h
17 bits
reserved
20 bits
reserved
Res_2 = 06h
• The source code listing includes false conditional blocks that do not generate code. The .fclist and .fcnolist
directives turn this listing on and off. You can use the .fclist directive to list false conditional blocks exactly as
they appear in the source code. You can use the .fcnolist directive to list only the conditional blocks that are
actually assembled.
• The .length directive controls the page length of the listing file. You can use this directive to adjust listings for
various output devices.
• The .list and .nolist directives turn the output listing on and off. You can use the .nolist directive to prevent
the assembler from printing selected source statements in the listing file. Use the .list directive to turn the
listing on again.
• The source code listing includes macro expansions and loop blocks. The .mlist and .mnolist directives turn
this listing on and off. You can use the .mlist directive to print all macro expansions and loop blocks to the
listing, and the .mnolist directive to suppress this listing.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 87
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
• 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.
R resets the B, L, M, T, and W directives (turns off the limits of B, L, T, and W).
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).
88 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.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 tells the assembler to assemble repeatedly when the .break end condition is false and to go to the code
condition] 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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 89
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
• The .define directive assigns a character string to a substitution symbol. The value is stored in the
substitution symbol table. When the assembler encounters a substitution symbol, it replaces the symbol
with its character string value. Substitution symbols created with .define cannot be redefined.
• The .eval directive evaluates a well-defined expression, translates the results into a character string, and
assigns the character string to a substitution symbol. This directive is most useful for manipulating counters:
.asg 1 , x ; x = 1
.loop ; Begin conditional loop.
.byte x*10h ; Store value into current section.
.break x = 4 ; Break loop if x = 4.
.eval x+1, x ; Increment x by 1.
.endloop ; End conditional loop.
• The .set directive sets a constant value to a symbol. The symbol is stored in the symbol table and cannot be
redefined; for example:
• The .unasg directive turns off substitution symbol assignment made with .asg.
• The .undefine directive turns off substitution symbol assignment made with .define.
• The .var directive allows you to use substitution symbols as local variables within a macro.
5.11 Miscellaneous Directives
These directives enable miscellaneous functions or features:
• The .asmfunc and .endasmfunc directives mark function boundaries. These directives are used with the
compiler --symdebug:dwarf (-g) option to generate debug information for assembly functions.
• The .cdecls directive enables programmers in mixed assembly and C/C++ environments to share C headers
containing declarations and prototypes between C and assembly code.
• The .end directive terminates assembly. If you use the .end directive, it should be the last source statement of
a program. This directive has the same effect as an end-of-file character.
• The .group, .gmember, and .endgroup directives define an ELF group section to be shared by several
sections. (EABI only)
• The .newblock directive resets local labels. Local labels are symbols of the form $n, where n is a decimal
digit, or of the form NAME?, where you specify NAME. They are defined when they appear in the label field.
Local labels are temporary labels that can be used as operands for jump instructions. The .newblock directive
limits the scope of local labels by resetting them after they are used. See Section 4.8.3 for information on
local labels.
• The .sblock directive designates sections for blocking.
These three directives enable you to define your own error and warning messages:
• The .emsg directive sends error messages to the standard output device. The .emsg directive generates
errors in the same manner as the assembler, incrementing the error count and preventing the assembler from
producing an object file.
• The .mmsg directive sends assembly-time messages to the standard output device. The .mmsg directive
functions in the same manner as the .emsg and .wmsg directives but does not set the error count or the
warning count. It does not affect the creation of the object file.
• The .wmsg directive sends warning messages to the standard output device. The .wmsg directive functions
in the same manner as the .emsg directive but increments the warning count rather than the error count. It
does not affect the creation of the object file.
For more information about using the error and warning directives in macros, see Section 6.7.
90 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
Description The .align directive aligns the section program counter (SPC) on the next boundary,
depending on the size in words parameter. The size can be any power of 2 , although only
certain values are useful for alignment. An operand of 64 aligns the SPC on the next page
boundary, and this is the default if no size in words is given. The assembler assembles
words containing null values (0) up to the next size in words boundary:
1 aligns SPC to word boundary
2 aligns SPC to long word/even boundary
64 aligns SPC to page boundary
Example This example shows several types of alignment, including .align 2, .align 4, and a
default .align.
1 000000 0004 .byte 4
2 .align 2
3 000002 0045 .string "Errorcnt"
000003 0072
000004 0072
000005 006F
000006 0072
000007 0063
000008 006E
000009 0074
4 .align
5 000040 0003 .field 3,3
6 000040 002B .field 5,4
7 .align 2
8 000042 0003 .field 3,3
9 .align 8
10 000048 0005 .field 5,4
11 .align
12 000080 0004 .byte 4
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 91
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.asg/.define/.eval
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 13 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.
92 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
Example This example shows how .asg and .eval can be used.
1 .sslist
2 .asg XAR6, FP
3 00000000 0964 ADD ACC, #100
4 00000001 7786 NOP *FP++
# NOP *XAR6++
5 00000002 7786 NOP *XAR6++
6
7 .asg 0, x
8 .loop 5
9 .eval x+1, x
10 .word x
11 .endloop
1 .eval x+1, x
# .eval 0+1, x
1 00000003 0001 .word x
# .word 1
1 .eval x+1, x
# .eval 1+1, x
1 00000004 0002 .word x
# .word 2
1 .eval x+1, x
# .eval 2+1, x
1 00000005 0003 .word x
# .word 3
1 .eval x+1, x
# .eval 3+1, x
1 00000006 0004 .word x
# .word 4
1 .eval x+1, x
# .eval 4+1, x
1 00000007 0005 .word x
# .word 5
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 93
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.asmfunc/.endasmfunc
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 In this example the assembly source generates debug information for the userfunc
section.
1 00000000 .sect ".text"
2 .global userfunc
3 .global _printf
4
5 userfunc: .asmfunc
6 00000000 FE02 ADDB SP,#2
00000002 0000
8 00000003 7640! LCR #_printf
00000004 0000
9 00000005 9A00 MOVB AL,#0
10 00000006 FE82 SUBB SP,#2
11 00000007 0006 LRETR
12 .endasmfunc
13
14 00000000 .sect ".econst"
15 00000000 0048 SL1: .string "Hello World!",10,0
00000001 0065
00000002 006C
00000003 006C
00000004 006F
00000005 0020
00000006 0057
00000007 006F
00000008 0072
00000009 006C
0000000a 0064
0000000b 0021
0000000c 000A
0000000d 0000
94 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.bits
Initialize Bits
Description The .bits directive places a value 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 force the value to be aligned to a field boundary. If the .bits directive is
followed by a different space-creating directive, the SPC is aligned to an appropriate value
for the directive that follows.
This directive has two operands:
• The value is a required parameter; it is an expression that is evaluated and placed in
the current section at the current location. 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 value. The default size is 16 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, .bits 3,1 causes the assembler to truncate the value 3 to 1; the
assembler also prints the message:
*** WARNING! line 21: W0001: Field value truncated to 1
.bits 3, 1
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 95
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.bss
Description The .bss directive reserves space for variables in the .bss section. This directive is
usually used to allocate space in RAM.
This directive is similar to the .usect directive (see .usect topic); 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.
Note
This directive is supported only in EABI mode.
• 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 words is a required parameter; it must be an absolute constant expression.
The assembler allocates size words in the .bss section. There is no default size.
• The blocking flag is an optional parameter. If you specify a value greater than 0 for this
parameter, the assembler allocates size in words contiguously. This means that the
allocated space does not cross a page boundary unless its size is greater than a page,
in which case the object starts on a page boundary.
• 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.
For more information about sections, see Chapter 2.
96 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.byte/.ubyte/.char/.uchar
Initialize Byte
Description The .byte, .ubyte, .char, and .uchar directives place one or more values into consecutive
words of the current section. Each byte is placed in a word by itself; the eight MSBs are
filled with 0s. 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.
Values are not packed or sign-extended; each byte occupies the eight least significant bits
of a full 16-bit word. 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 words in
memory. The label STRX has the value 100h, which is the location of the first initialized
word.
1 000000 .space 100h * 16
2 000100 000A STRX .byte 10, -1, "abc", 'a'
000101 00FF
000102 0061
000103 0062
000104 0063
000105 0061
3 000106 000A .char 10, -1, "abc", 'a'
000107 00FF
000108 0061
000109 0062
00010a 0063
00010b 0061
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 97
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.cdecls
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:
C Treat the code in the .cdecls block as C source code (default).
CPP Treat the code in the .cdecls block as C++ source code. This is the opposite
of the C option.
NOLIST Do not include the converted assembly code in any listing file generated for
the containing assembly file (default).
LIST Include the converted assembly code in any listing file generated for the
containing assembly file. This is the opposite of the NOLIST option.
NOWARN Do not emit warnings on STDERR about C/C++ constructs that cannot be
converted while parsing the .cdecls source block (default).
WARN Generate warnings on STDERR about C/C++ constructs that cannot be
converted while parsing the .cdecls source block. This is the opposite of the
NOWARN option.
In the single-line format, the options are followed by one or more filenames to include.
The filenames and options are separated by commas. Each file listed acts as if #include
"filename" was specified in the multiple-line format.
In the multiple-line format, the line following .cdecls must contain the opening .cdecls
block indicator %{. Everything after the %{, up to the closing block indicator %}, 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.
98 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
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 13 for more information on setting up and using the .cdecls directive with C
header files.
Example In this example, the .cdecls directive is used call the C header.h file.
C header file:
#define WANT_ID 10
#define NAME "John\n"
extern int a_variable;
extern float cvt_integer(int src);
struct myCstruct { int member_a; float member_b; };
enum status_enum { OK = 1, FAILED = 256, RUNNING = 0 };
Source file:
.cdecls C,LIST,"myheader.h"
size: .int $sizeof(myCstruct)
aoffset: .int myCstruct.member_a
boffset: .int myCstruct.member_b
okvalue: .int status_enum.OK
failval: .int status_enum.FAILED
.if $defined(WANT_ID)
id .cstring NAME
.endif
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 99
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
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 "1",_OPTIMIZE_FOR_SPACE
A 7 .define "1",__ASM_HEADER__
A 8 .define "1",__edg_front_end__
A 9 .define "5001000",__COMPILER_VERSION__
A 10 .define "0",__TI_STRICT_ANSI_MODE__
A 11 .define """14:53:42""",__TIME__
A 12 .define """I""",__TI_COMPILER_VERSION_QUAL__
A 13 .define "unsigned long",__SIZE_T_TYPE__
A 14 .define "long",__PTRDIFF_T_TYPE__
A 15 .define "1",__TMS320C2000__
A 16 .define "1",_TMS320C28X
A 17 .define "1",_TMS320C2000
A 18 .define "1",__TMS320C28X__
A 19 .define "1",__STDC__
A 20 .define "1",__signed_chars__
A 21 .define "0",__GNUC_MINOR__
A 22 .define "1",_TMS320C28XX
A 23 .define "5001000",__TI_COMPILER_VERSION__
A 24 .define "1",__TMS320C28XX__
A 25 .define "1",__little_endian__
A 26 .define "199409L",__STDC_VERSION__
A 27 .define """EDG gcc 3.0 mode""",__VERSION__
A 28 .define """John\n""",NAME
A 29 .define "unsigned int",__WCHAR_T_TYPE__
A 30 .define "1",__TI_RUNTIME_RTS__
A 31 .define "3",__GNUC__
A 32 .define "10",WANT_ID
A 33 .define """Sep 7 2007""",__DATE__
A 34 .define "7250",__TI_COMPILER_VERSION_QUAL_ID__
A 35
A 36 ; =========== TYPE DEFINITIONS ===========
A 37 status_enum .enum
A 38 0001 OK .emember 1
A 39 0100 FAILED .emember 256
A 40 0000 RUNNING .emember 0
A 41 .endenum
A 42
A 43 myCstruct .struct 0,2 ; struct size=(4 bytes|64
bits), alignment=2
A 44 0000 member_a .field 16 ; int member_a - offset 0
bytes, size (1 bytes|16 bits)
A 45 0001 .field 16 ; padding
A 46 0002 member_b .field 32 ; float member_b-offset 2
bytes, size (2 bytes|32 bits)
A 47 0004 .endstruct ; final size=(4 bytes|64 bits)
A 48
A 49 ; =========== EXTERNAL FUNCTIONS ===========
A 50 .global _cvt_integer
A 51
A 52 ; =========== EXTERNAL VARIABLES ===========
A 53 .global _a_variable
2 00000000 0004 size: .int $sizeof(myCstruct)
3 00000001 0000 aoffset: .int myCstruct.member_a
4 00000002 0002 boffset: .int myCstruct.member_b
5 00000003 0001 okvalue: .int status_enum.OK
6 00000004 0100 failval: .int status_enum.FAILED
7 .if $defined(WANT_ID)
8 00000005 004A id .cstring NAME
00000006 006F
00000007 0068
00000008 006E
00000009 000A
0000000a 0000
9 .endif
100 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.clink
Description The .clink directive enables conditional linking by telling the linker to leave a section out
of the final object module output of the linker if there are no references found to any
symbol in that section. The .clink directive can be applied to initialized sections.
Note
The .clink directive is supported only for the COFF ABI. It is ignored when used
in EABI mode.
The .clink directive applies to the current initialized section. It tells the linker to leave the
section out of the final object module output of the linker if there are no references found
in a linked section to any symbol defined in the specified section.
The .clink directive is useful only with the COFF object file format. Under the COFF ABI
model, the linker assumes that all sections are ineligible for removal via conditional linking
by default. If you want to make a section eligible for removal, you must apply a .clink
directive to it. In contrast, under the ELF EABI model, the linker assumes that all sections
are eligible for removal via conditional linking. Therefore, the .clink directive has no effect
under EABI.
A section in which the entry point of a C program is defined cannot be marked as a
conditionally linked section.
Example In this example, the Vars and Counts sections are set for conditional linking.
1 000000 .sect "Vars"
2 ; Vars section is conditionally linked
3 .clink
4
5 000000 001A X: .long 01Ah
000001 0000
6 000002 001A Y: .word 01Ah
7 000003 001A Z: .word 01Ah
8 ; Counts section is conditionally linked
9 .clink
10
11 000004 001A XCount: .word 01Ah
12 000005 001A YCount: .word 01Ah
13 000006 001A ZCount: .word 01Ah
14 ; By default, .text in unconditionally linked
15 000000 .text
16
17 000000 97C6 MOV *XAR6, AH
18 ; These references to symbol X cause the Vars
19 ; section to be linked into the COFF output
20 000001 8500+ MOV ACC, @X
21 000002 3100 MOV P, #0
22 000003 0FAB CMPL ACC, P
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 101
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.common
Description The .common directive creates a common symbol in a common block, rather than placing
the variable in a memory section.
Note
This directive is supported only when using EABI mode.
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.)
• 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 (.common) for each common symbol. A symbol is created in place
of the common symbol to refer to its reserved location.
102 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.copy/.include
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 C2000_A_DIR environment variable
4. Any directories specified by the C2000_C_DIR environment variable
For more information about the --include_path option and C2000_A_DIR, see Section
4.5. For more information about C2000_C_DIR, see the TMS320C28x Optimizing C/C++
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"
.string "done" ** Back in byte.asm
.byte 67h + 3q
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 103
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
Listing file:
1 000000 .space 29
2 .copy "byte.asm"
1 ** In byte.asm
2 000002 0005 byte 5
3 .copy "word.asm"
1 ** In word.asm
2 000003 ABCD .word 0ABCDh
4 * Back in byte.asm
5 000004 0006 .byte 6
3
4 **Back in original file
5 000005 646F .string "done"
000006 6E65
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
** Back in original file .include "word2.asm"
.string "done" ** Back in byte2.asm
.byte 67h + 3q
Listing file:
1 000000 .space 29
2 .include "byte2.asm"
3
4 ** Back in original file
5 000007 0064 .string "done"
000008 006F
000009 006E
00000a 0065
104 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.cstruct/.cunion/.endstruct/.endunion/.tag
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, .string, .pstring, .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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 105
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
Example This example illustrates a structure in C that will be accessed in assembly code.
;typedef struct MYSTR1
;{ long l0; /* offset 0 */
; short s0; /* offset 2 */
;} MYSTR1; /* size 4, alignment 2 */
;typedef struct MYSTR2
;{ MYSTR1 m1; /* offset 0 */
; short s1; /* offset 4 */
;} MYSTR2; /* size 6, alignment 2 */
;
; The structure will get the following offsets once the C compiler lays out the
structure
; elements according to C standard rules:
;
; offsetof(MYSTR1, l0) = 0
; offsetof(MYSTR1, s0) = 2
; sizeof(MYSTR1) = 4
;
; offsetof(MYSTR2, m1) = 0
; offsetof(MYSTR2, s1) = 4
; sizeof(MYSTR2) = 6
;
; Attempts to replicate this structure in assembly using .struct/.union
directives will not
; create the correct offsets because the assembler tries to use the most
compact arrangement:
MYSTR1.struct
l0.long ; bytes 0 and 1
s0.short ; byte 2
M1_LEN .endstruct ; size 4, alignment 2
MYSTR2.struct
m1.tag MYSTR1 ; bytes 0-3
s1.short ; byte 4
M2_LEN .endstruct ; size 6, alignment 2
.sect "data1"
.word MYSTR1.l0
.word MYSTR1.s0
.word M1_LEN
.sect "data2"
.word MYSTR2.m1
.word MYSTR2.s1
.word M2_LEN
; The .cstruct/.cunion directives calculate offsets the same as the C compiler.
The resulting
; assembly structure can be used to access elements of the C structure. Compare
differences
; in the offsets of those structures defined via .struct above and the offsets
for C code.
CMYSTR1 .cstruct
l0 .long
s0 .short
MC1_LEN .endstruct
CMYSTR2 .cstruct
m1 .tag CMYSTR1
s1 .short
MC2_LEN .endstruct
.sect "data3"
.word CMYSTR1.l0, MYSTR1.l0
.word CMYSTR1.s0, MYSTR1.s0
.word MC1_LEN, M1_LEN
.sect "data4"
.word CMYSTR2.m1, MYSTR2.m1
.word CMYSTR2.s1, MYSTR2.s1
.word MC2_LEN, M2_LEN
106 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.data
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 000000 .data
5 000000 .space 0CCh
6 *******************************************
7 ** Assemble into .text. **
8 *******************************************
9 000000 .text
10 0000 INDEX .set 0
11 000000 9A00 MOV AL,#INDEX
12 *******************************************
13 ** Assemble into .data. **
14 *******************************************
15 00000c Table: .data
16 00000d FFFF .word -1 ; Assemble 16-bit constant
into .data.
17 00000e 00FF .byte 0FFh ; Assemble 8-bit constant
into .data.
18 *******************************************
19 ** Assemble into .text. **
20 *******************************************
21 000001 .text
22 000001 08A9" ADD AL,Table
000002 000C
23 *******************************************
24 ** Resume assembling into the .data **
25 ** section at address 0Fh. **
26 *******************************************
27 00000f .data
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 107
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.drlist/.drnolist
Syntax .drlist
.drnolist
Description Two directives enable you to control the printing of assembler directives to the listing file:
The .drlist directive enables the printing of all directives to the listing file.
The .drnolist directive suppresses the printing of the following directives to the listing file.
The .drnolist directive has no affect within macros.
• .asg • .fcnolist • .ssnolist
• .break • .mlist • .var
• .emsg • .mmsg • .wmsg
• .eval • .mnolist
• .fclist • .sslist
By default, the assembler acts as if the .drlist directive had been specified.
Example This example shows how .drnolist inhibits the listing of the specified directives.
Source file:
.asg 0, x
.loop 2
.eval x+1, x
.endloop
.drnolist
.asg 1, x
.loop 3
.eval x+1, x
.endloop
Listing file:
1 .asg 0, x
2 .loop 2
3 .eval x+1, x
4 .endloop
1 .eval 0+1, x
1 .eval 1+1, x
5
6 .drnolist
7
9 .loop 3
10 .eval x+1, x
11 .endloop
108 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.elfsym
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(value) syntax is
used for each type.
Note
This directive is supported for EABI mode only.
SYM_SIZE indicates the allocation size (in bytes) of the symbol indicated by name.
The SYM_PRESERVE and SYM_UPDATE types indicate how a symbol should be
handled during a warm start. These types are supported only if the executable is compiled
for Live Firmware Update (LFU). See the .preserve topic for examples that use these
types.
Example This example shows the use of the ELF symbol information directive.
.sect ".examp"
.align 4
.elfsym ex_sym, SYM_SIZE(4)
ex_sym:
.word 0
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 109
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.emsg/.mmsg/.wmsg
Define Messages
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
ADD AL, @parm1
.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 ADD AL, @parm1
7 .endif
8 .endm
9
10 000000 MSG_EX PARAM
1 .if $symlen(parm1) = 0
1 .emsg "ERROR -- MISSING PARAMETER"
1 .else
1 000000 9400! ADD AL, @PARAM
1 .endif
11
12 000001 MSG_EX
1 .if $symlen(parm1) = 0
1 .emsg "ERROR -- MISSING PARAMETER"
***** USER ERROR ***** - : ERROR -- MISSING PARAMETER
1 .else
1 ADD AL, @parm1
110 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
1 .endif
1 Error, No Warnings
In addition, the following messages are sent to standard output by the assembler:
*** ERROR! line 12: ***** USER ERROR ***** - : ERROR -- MISSING PARAMETER
.emsg "ERROR -- MISSING PARAMETER" ]]
1 Assembly Error, No Assembly Warnings
Errors in source - Assembler Aborted
.end
End Assembly
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.
Note
Ending a Macro
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: .space 300
TEMP .set 15
LOC1 .usect ".ebss", 48h
ABS ACC
ADD ACC, #TEMP
MOV @LOC1, ACC
.end
.byte 4
.word CCCh
Listing file:
1 000000 START: .space 300
2 000F TEMP .set 15
3 000000 LOC1 .usect ".ebss", 48h
4 000013 FF56 ABS ACC
5 000014 090F ADD ACC, #TEMP
6 000015 9600- MOV @LOC1, ACC
7 .end
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 111
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.fclist/.fcnolist
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:
AAA .set 1
BBB .set 0
.fclist
.if AAA
ADD ACC, #1024
.else
ADD ACC, #1024*4
.endif
.fcnolist
.if AAA
ADD ACC, #1024
.else
ADD ACC, #1024*10
.endif
Listing file:
1 0001 AAA .set 1
2 0000 BBB .set 0
3 .fclist
4
5 .if AAA
6 000000 FF10 ADD ACC, #1024
000001 0400
7 .else
8 ADD ACC, #1024*4
9 .endif
10
11 .fcnolist
12
14 000002 FF10 ADD ACC, #1024
000003 0400
112 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.field
Initialize Field
Description The .field directive initializes a multiple-bit field within a single word (16 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 value from 1 to 32, which is the number of bits in the
field. The default size is 16 bits. If you specify a size of 16 or more bits, the field starts
on a word boundary. 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 and print this message:
*** WARNING! line 21: W0001: Field value truncated to 1
.field 3, 1
Successive .field directives pack values into the specified number of bits starting at the
current word. Fields are packed starting at the least significant part of the word, moving
toward the most significant part as more fields are added. If the assembler encounters
a field size that does not fit into the current word, it writes out the word, increments the
SPC, and begins packing fields into the next word. You can use the .align directive with an
operand of 1 to force the next .field directive to begin packing into a new word.
The .field directive is similar to the .bits directive (see the .bits topic). However, the .bits
directive does not force alignment to a field boundary 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 word 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 14-bit field. **
3 ************************************
4 000000 0ABC .field 0ABCh, 14
5
6 ************************************************
7 ** Initialize a 5-bit field in a new word. **
8 ************************************************
9 000001 000A L_F: .field 0Ah, 5
10
11 ************************************************
12 ** Initialize a 4-bit field in the same word. **
13 ************************************************
14 000001 018A X: .field 0Ch, 4
15 ************************************************
16 ** Relocatable field in the next 2 words. **
17 ************************************************
18 000002 0001' .field X
19 ************************************
20 ** Initialize a 32-bit field **
21 ************************************
22 000003 4321 .field 04321h, 32
000004 0000
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 113
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
Figure 5-5 shows how the directives in this example affect memory.
Word Code
15 13 0
(a) 0 0 0 1 0 1 0 1 0 1 1 1 1 0 0 .field 0ABCh, 14
14-bit field
1 0 1 0 1 0
5-bit field
4-bit field
(d) 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 .field x
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5 0 1 0 0 0 0 1 1 0 0 1 0 0 0 0 0
114 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.float/.xfloat/.xldouble
Description The .float and .xfloat directives place 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.
The .float directive aligns the floating-point constants on the long-word boundary, while
the .xfloat directive does not.
The 32-bit value is stored exponent byte first, least significant word of fraction second,
and most significant word of fraction third, in the format shown in Figure 5-6.
The .xldouble directive places the IEEE double-precision floating-point representation of
a double floating-point constant into two words 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 double value in IEEE double-precision 64-bit format. The 64-bit value is
stored exponent byte first, least significant word of fraction second, and most significant
word of fraction third.
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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 115
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.global/.def/.ref
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.
116 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
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 000000 INIT:
6 000000 0956 ADD ACC, #56h
7
8 000001 0000! .word X
9 ; .
10 ; .
11 ; .
12 .end
file2.lst
1 ; Global symbols defined in this file
2 .global X, Y, Z
3 ; Global symbol defined in file1.lst
4 .global INIT
5 0001 X: .set 1
6 0002 Y: .set 2
7 0003 Z: .set 3
8 000000 0000! .word INIT
9 ; .
10 ; .
11 ; .
12 .end
file3.lst
1 ; Global symbol defined in this file
2 .def INIT
3 ; Global symbols defined in file4.lst
4 .ref X, Y, Z
5 000000 INIT:
6 000000 0956 ADD ACC, #56h
7
8 000001 0000! .word X
9 ; .
10 ; .
11 ; .
12 .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 0001 X: .set 1
6 0002 Y: .set 2
7 0003 Z: .set 3
8 000000 0000! .word INIT
9 ; .
10 ; .
11 ; .
12 .end
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 117
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.group/.gmember/.endgroup
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).
Note
These directives are supported for EABI mode only.
The .group directive begins the group declaration. The group_section_name designates
the name of the group section. The group_type designates the type of the group. The
following types are supported:
0x0 Regular ELF group
0x1 COMDAT ELF group
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.
118 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.if/.elseif/.else/.endif
Description The .if directive marks the beginning of a conditional block. The condition is required.
• If the expression evaluates to true (nonzero), the assembler assembles the code that
follows the expression (up to a .elseif, .else, or .endif).
• If the expression evaluates to false (0), the assembler assembles code that follows
a .elseif (if present), .else (if present), or .endif (if no .elseif or .else is present).
The .elseif directive identifies a block of code to be assembled when the .if expression
is false (0) and the .elseif expression is true (nonzero). When the .elseif expression is
false, the assembler continues to the next .elseif (if present), .else (if present), or .endif (if
no .elseif or .else is present). The .elseif is optional in a conditional block, and more than
one .elseif can be used. If an expression is false and there is no .elseif, the assembler
continues with the code that follows a .else (if present) or a .endif.
The .else directive identifies code the assembler assembles when the .if expression and
all .elseif expressions are false (0). The .else directive is optional; if an expression is
false and there is no .else statement, the assembler continues with the code that follows
the .endif. The .elseif and .else directives can be used in the same conditional block.
The .endif directive terminates a conditional block.
See Section 4.9.2 for information about relational operators.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 119
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.int/.unint/.word/.uword
Description The .int, .unint, .word, and .uword directives place one or more values into consecutive
words in the current section. Each value is placed in a 16-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 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.
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 2 In this example, the .word directive is used to initialize words. The symbol WORDX points
to the first word that is reserved.
1 000000 0C80 WORDX: .word 3200, 1 + 'AB', -0AFh, 'X'
000001 4242
000002 FF51
000003 0058
120 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.label
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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 121
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.length/.width
Description Two directives allow you to control the size of the output listing file.
The .length directive sets the page length of the output listing file. It affects the current
and following pages. You can reset the page length with another .length directive.
• Default length: 60 lines. If you do not use the .length directive or if you use the .length
directive without specifying the page length, the output listing length defaults to 60
lines.
• Minimum length: 1 line
• Maximum length: 32 767 lines
The .width directive sets the page width of the output listing file. It affects the next line
assembled and the lines following. You can reset the page width with another .width
directive.
• Default width: 132 characters. If you do not use the .width directive or if you use
the .width directive without 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
122 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.list/.nolist
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 .copy directive inserts source statements from another file.
The first time .copy is encountered, the assembler lists the copied source lines in the
listing file. The second time .copy is encountered, the assembler does not list the copied
source lines, because a .nolist directive was assembled. The .nolist, the second .copy,
and the .list directives do not appear in the listing file. Also the line counter is incremented,
even when source statements are not listed.
Source file:
copy.asm copy2.asm
(source file) (copy file)
.copy "copy2.asm" ** In copy2.asm
** Back in original file .word 32, 1 + 'A'
NOP
.nolist
.copy "copy2.asm"
.list
** Back in original file
.string "done"
Listing file:
1 .copy "copy2.asm"
1 *In copy2.asm (copy file)
2 000000 0020 .word 32, 1 + 'A'
000001 0042
2 * Back in original file
3 000002 7700 NOP
7 * Back in original file
8 000005 0044 .string "Done"
000006 006F
000007 006E
000008 0065
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 123
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.long/.ulong/.xlong
Description The .long, .ulong, and .xlong directives place one or more 32-bit values into consecutive
words in the current section. The most significant word is stored first. The .long directive
aligns the result on the long-word boundary, while .xlong does not.
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 .long in a .struct/.endstruct sequence, .long defines a member's size; it
does not initialize memory. See the .struct/.endstruct/.tag topic.
Example This example shows how the .long and .xlong directives initialize double words.
1 000000 ABCD DAT1: .long 0ABCDh, 'A' + 100h, 'g', 'o'
000001 0000
000002 0141
000003 0000
000004 0067
000005 0000
000006 006F
000007 0000
2 000008 0000' .xlong DAT1, 0AABBCCDDh
000009 0000
00000a CCDD
00000b AABB
3 00000c DAT2:
124 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.loop/.endloop/.break
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 000000 0000 .word 0*100
1 .eval 0+1, x
1 .break 1 = 6
1 000001 0064 .word 1*100
1 .eval 1+1, x
1 .break 2 = 6
1 000002 00C8 .word 2*100
1 .eval 2+1, x
1 .break 3 = 6
1 000003 012C .word 3*100
1 .eval 3+1, x
1 .break 4 = 6
1 000004 0190 .word 4*100
1 .eval 4+1, x
1 .break 5 = 6
1 000005 01F4 .word 5*100
1 .eval 5+1, x
1 .break 6 = 6
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 125
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.macro/.endm
Define Macro
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.
126 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.mlib
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 C2000_A_DIR environment variable
4. Any directories specified by the C2000_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 specified library and create a table of
the library's contents. The assembler stores names of 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 with other macros, but it does
not place the source code in the listing. Only macros from the library are extracted, and
they are extracted only once. See Chapter 6 for details.
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.
Macro for incrementing: inc1.asm Macro for decrementing: dec1.asm
inc1 .macro A dec1 .macro A
ADD A, #1 SUB A, #1
.endm .endm
Use the archiver with a command line like the following to create a macro library:
ar2000 -a mac inc1.asm dec1.asm
Use .mlib to reference the macro library. Define inc1.asm and dec1.asm as macros:
1 .mlib "mac.lib"
2
3 * Macro call
4 000000 inc1 AL
1 000000 9C01 ADD AL,#1
5
6 * Macro call
7 000001 dec1 AR1
1 000001 08A9 SUB AR1,#1
000002 FFFF
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 127
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.mlist/.mnolist
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.
128 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 129
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.newblock
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 .ref ADDRA, ADDRB, ADDRC
2 0076 B .set 76h
3
4 00000000 F800! MOV DP, #ADDRA
5
6 00000001 8500! LABEL1: MOV ACC, @ADDRA
7 00000002 1976 SUB ACC, #B
8 00000003 6403 B $1, LT
9 00000004 9600! MOV @ADDRB, ACC
10 00000005 6F02 B $2, UNC
11
12 00000006 8500! $1 MOV ACC, @ADDRA
13 00000007 8100! $2 ADD ACC, @ADDRC
14 .newblock ; Undefine $1 to use again.
15
16 00000008 6402 B $1, LT
17 00000009 9600! MOV @ADDRC, ACC
18 0000000a 7700 $1 NOP
130 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.option
Description The .option directive selects options for the assembler output listing. The options must
be separated by commas; each option selects a listing feature. Options are not case
sensitive. These are valid options:
A turns on listing of all directives, data, 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).
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, L, M, T, and W (turns off the limits of B, 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 symbol listing. You can also obtain this listing by invoking the
assembler with the --asm_listing_cross_reference option (see Section 4.3).
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 131
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
Example This example shows how to limit the listings of the .byte, long, .word, and .string directives
to one line each.
1 *****************************************************
2 ** Limit listing of specified directive to 1 line. **
3 *****************************************************
4 .option B, W, L, T
5 000000 00BD .byte -'C', 0B0h, 5
6 000004 CCDD .long 0AABBCCDDh, 536 + 'A'
7 000008 15AA .word 5546, 78h
8 00000a 0045 .string "Extended Registers"
9 *****************************************************
10 ** Reset the listing options. **
11 *****************************************************
12 .option R
13 00001c 00BD .byte -'C', 0B0h, 5
00001d 00B0
00001e 0005
14 000020 CCDD .long 0AABBCCDDh, 536 + 'A'
000021 AABB
000022 0259
000023 0000
15 000024 15AA .word 5546, 78h
000025 0078
16 000026 0045 .string "Extended Registers"
000027 0078
000028 0074
000029 0065
00002a 006E
00002b 0064
00002c 0065
00002d 0064
00002e 0020
00002f 0052
000030 0065
000031 0067
000032 0069
000033 0073
000034 0074
000035 0065
000036 0072
000037 0073
132 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.page
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:
TMS320C000 COFF Assembler Version x.xx Day Time Year
Copyright (c) 1996-2011 Texas Instruments Incorporated
**** Page Directive Example **** PAGE 1
2 ; .
3 ; .
4 ; .
TMS320C2000 COFF Assembler Version x.xx Day Time Year
Copyright (c) 1996-2011 Texas Instruments Incorporated
**** Page Directive Example **** PAGE 2
No Errors, No Warnings
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 133
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.preserve
Description The .preserve directive causes a symbol's address and value to be preserved during a
warm start. This directive must be used in the asm header block.
The executable must be in ELF format and compiled for Live Firmware Update
(LFU), which provides a "warm start" capability. For information about using LFU, see
the TMS320C28x Optimizing C/C++ Compiler User's Guide (SPRU514) and the Live
Firmware Update Reference Design with C2000 MCUs (TIDUEY4) design guide.
Global and static variables may be preserved, updated, or allowed to move handled in the
following ways during a warm start:
• Preserve: The values stored for such symbols are retained from before the warm start.
The addresses of such symbols are unchanged from the addresses in the reference
ELF image.
• Update (Reinitialize): The values stored for these symbols are re-initialized during a
warm start. The addresses of such symbols may change compared to the addresses in
the reference ELF image.
• No special handling: The values of these symbols are not retained or re-initialized.
These symbols may be allocated at any memory address during a warm start.
Preserve a Symbol Follow these conventions to specify the "preserve" behavior:
• Create a .global specification for the symbol.
• Create a section for each preserved symbol as a subsection of .TI.bound, If
the .TI.bound sections are contiguous in memory, the linker can coalesce them into a
single output section, which reduces the number of CINIT records required to initialize
them.
• Use an .elfsym directive to specify the SYM_PRESERVE attribute to indicate this
behavior.
• Use an .sblock directive to indicate that the .TI.bound: subsection created for this
symbol should be blocked.
The following example preserves the address of var0 when a warm start occurs:
Update (Reinitialize) No special directive is required to specify the "update" behavior for a symbol. The
a Symbol following conventions are required to specify a symbol should be updated,
• Create a .global specification for the symbol.
• Create a section for the symbol as a subsection of .TI.update. This section defaults to
copy compression (that is, no decompression is required during a warm start), which
reduces the LFU image switchover time.
• Use an .elfsym directive to specify the SYM_UPDATE attribute to indicate this
behavior.
134 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
The following example causes the var1 symbol to be re-initialized (updated) when a
warm start occurs:
.global ||var1||
.sect “.TI.update:var1”, RW
.elfsym ||var0||, SYM_UPDATE(1)
Symbol Not This behavior occurs only if the --lfu_default=none compiler option is used and a
Preserved or global or static variable is not placed in a special output section. Create such symbols
Reinitialized using the .global directive. For example:
.global ||var2||
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 135
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.retain / .retainrefs
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.
Note
The .retain and .retainrefs directives are supported only for EABI. They are
ignored when used with the COFF ABI.
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.
Under the COFF ABI model, the linker assumes that all sections are not eligible for
removal via conditional linking by default. So under the COFF ABI mode, the .retain
directive does not have any real effect on the section.
136 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.sblock
Description The .sblock directive designates sections for blocking. Blocking is an address alignment
mechanism similar to page alignment, but weaker. A blocked section does not cross a
page boundary (64 words) if it is smaller than a page, and it starts on a page boundary if it
is larger than a page. The section names may optionally be enclosed in quotation marks.
Example This example designates the .text and .data sections for blocking.
1 ****************************************
2 ** Specify blocking for the .text **
3 ** and .data sections. **
4 ****************************************
5 .sblock .text, .data
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 137
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.sect
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.
If you are using EABI, 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 ** Begin assembling into .text section. **
2 000000 .text
3 000000 FF20 MOV ACC, #78h ; Assembled into .text
000001 0078
4 000002 0936 ADD ACC, #36h ; Assembled into .text
5
6 ** Begin assembling into Sym_Defs section. **
7 000000 .sect "Sym_Defs"
8 000000 CCCD .float 0. ; Assembled into Sym_Defs
000001 3D4C
9 000002 00AA X: .word 0AAh ; Assembled into Sym_Defs
10 000003 FF10 ADD ACC, #X ; Assembled into Sym_Defs
000004 0002+
11
12 ** Begin assembling into Vars section. **
13 000000 .sect "Vars"
14 0010 WORD_LEN .set 16
15 0020 DWORD_LEN .set WORD_LEN * 2
16 0008 BYTE_LEN .set WORD_LEN / 2
17 0053 STR .set 53h
18
19 ** Resume assembling into .text section. **
20 000003 .text
21 000003 0942 ADD ACC, #42h ; Assembled into .text
22 000004 0003 .byte 3, 4 ; Assembled into .text
000005 0004
23
24 ** Resume assembling into Vars section. **
25 000000 .sect "Vars"
26 000000 000D .field 13, WORD_LEN
27 000001 000A .field 0Ah, BYTE_LEN
28 000002 0008 .field 10q, DWORD_LEN
000003 0000
29
138 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.set
Description The .set directive equates a constant value to a .set 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 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 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 .
1 **********************************************
2 ** Equate symbol AUX_R1 to register AR1 **
3 ** and use it instead of the register. **
4 **********************************************
5 0001 AUX_R1 .set AR1
6 000000 28C1 MOV *AUX_R1, #56h
000001 0056
7
8 **********************************************
9 ** Set symbol index to an integer expr. **
10 ** and use it as an immediate operand. **
11 **********************************************
12 0035 INDEX .set 100/2 +3
13 000002 0935 ADD ACC, #INDEX
14
15 **********************************************
16 ** Set symbol SYMTAB to a relocatable expr. **
17 ** and use it as a relocatable operand. **
18 **********************************************
19 000003 000A LABEL .word 10
20 0004' 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 0035 NSYMS .set INDEX
27 000004 0035 .word NSYMS
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 139
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.space/.bes
Reserve Space
Description The .space and .bes directives reserve the number of bits given by size in bits 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 word reserved. When
you use a label with the .bes directive, it points to the last reserved.
Example This example shows how memory is reserved with the .space and .bes directives .
1 *********************************************
2 ** Begin assembling into .text section. **
3 *********************************************
4 000000 .text
5 *********************************************
6 ** Reserve 0F0 bits (15 words in the **
7 ** .text section. **
8 *********************************************
9 000000 .space 0F0h
10 00000f 0100 .word 100h, 200h
000010 0200
11 *********************************************
12 ** Begin assembling into .data section. **
13 *********************************************
14 000000 .data
15 000000 0049 .string "In .data"
000001 006E
000002 0020
000003 002E
000004 0064
000005 0061
000006 0074
000007 0061
16 *********************************************
17 ** Reserve 100 bits in the .data section; **
18 ** RES_1 points to the first word that **
19 ** contains reserved bits. **
20 *********************************************
21 000008 RES_1: .space 100
22 00000f 000F .word 15
23 *********************************************
24 ** Reserve 20 bits in the .data section; **
25 ** RES_2 points to the last word that **
26 ** contains reserved bits. **
27 *********************************************
28 000011 RES_2: .bes 20
29 000012 0036 .word 36h
30 000013 0011" .word RES_
140 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.sslist/.ssnolist
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 ADDRX .usect ".ebss", 1
2 00000001 ADDRY .usect ".ebss", 1
3 00000002 ADDRA .usect ".ebss", 1
4 00000003 ADDRB .usect ".ebss", 1
5
6 ADD2 .macro parm1, parm2
7 MOV ACC, @parm1
8 ADD ACC, @parm2
9 MOV @parm2, ACC
10 .endm
11
12 00000000 ADD2 ADDRX, ADDRY
1 00000000 8500- MOV ACC, @ADDRX
1 00000001 8101- ADD ACC, @ADDRY
1 00000002 9601- MOV @ADDRY, ACC
13
14 .sslist
15 00000003 ADD2 ADDRA, ADDRB
1 00000003 8502- MOV ACC, @parm1
# MOV ACC, @ADDRA
1 00000004 8103- ADD ACC, @parm2
# ADD ACC, @ADDRB
1 00000005 9603- MOV @parm2, AC
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 141
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.string/.cstring/.pstring
Initialize Text
Syntax .string {expr1 | " string1 "} [, ... , {exprn | " stringn "} ]
.cstring {expr1 | " string1 "} [, ... , {exprn | " stringn "} ]
.pstring {expr1 | " string1 "} [, ... , {exprn | " stringn "} ]
Description The .string , .cstring, and .pstring directives place 8-bit characters from a character
string into the current section. With the .string directive, each 8-bit character has its own
16-bit word, but with the .pstring directive, the data is packed so that each word contains
two 8-bit bytes. The expr or string can be one of the following:
• An expression that the assembler evaluates and treats as an 16-bit signed number.
• A character string enclosed in double quotes. Each character in a string represents a
separate byte. 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>).
With .pstring, values are packed into words starting with the most significant byte of the
word. Any unused space is padded with null bytes.
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 word that is initialized.
When you use .string , .cstring, and .pstring 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 words in the current section.
1 000000 0041 Str_Ptr: .string "ABCD"
000001 0042
000002 0043
000003 0044
2
3 000004 0041 .string 41h, 42h, 43h, 44h
000005 0042
000006 0043
000007 0044
4
5 000008 4175 .pstring "Austin", "Houston"
000009 7374
00000a 696E
00000b 486F
00000c 7573
00000d 746F
00000e 6E00
6
7 00000f 0030 .string 36 + 12
142 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.struct/.endstruct/.tag
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, .string, .pstring, .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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 143
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
Note
Directives that Can Appear in a .struct/.endstruct Sequence
The only directives that can appear in a .struct/.endstruct sequence are
element descriptors, conditional assembly directives, and the .align directive,
which aligns the member offsets on word boundaries. Empty structures are
illegal.
The following examples show various uses of the .struct, .tag, and .endstruct directives.
Example 1
REAL_REC .struct ; stag
NOM .int ; member1 = 0
DEN .int ; member2 = 1
REAL_LEN .endstruct ; real_len = 4
ADD ACC, @(REAL + REAL_REC.DEN) ;access structure element
REAL .usect ".ebss", REAL_LEN ; allocate mem rec
Example 2
CPLX_REC .struct
REALI .tag REAL_REC ; stag
IMAGI .tag REAL_REC ; member1 = 0
CPLX_LEN .endstruct ; rec_len = 4
COMPLEX .tag CPLX_REC ; assign structure attrib
ADD ACC, COMPLEX.REALI ; access structure
ADD ACC, COMPLEX.IMAGI
COMPLEX .usect ".ebss", CPLX_LEN ; allocate space
Example 3
.struct ; no stag puts mems into
X .int ; global symbol table
Y .int ;create 3 dim templates
Z .int
.endstruct
Example 4
BIT_REC .struct ; stag
STREAM .string 64
BIT7 .field 7 ; bits1 = 64
BIT9 .field 9 ; bits2 = 64
BIT10 .field 10 ; bits3 = 65
X_INT .int ; x_int = 67
BIT_LEN .endstruct ; length = 68
BITS .tag BIT_REC
ADD AC, @BITS.BIT7 ; move into acc
AND ACC, #007Fh ; mask off garbage bits
BITS .usect ".ebss", BIT_REC
144 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.symdepend
Description 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.
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 .symdepend directive creates a symbol table entry only if the module actually uses
the symbol. The .weak directive, in contrast, always creates a symbol table entry for a
symbol, whether the module uses the symbol or not (see .weak topic).
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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 145
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.tab
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 000000 7700 NOP
3 000001 7700 NOP
4 000002 7700 NOP
5
7 000003 7700 NOP
8 000004 7700 NOP
9 000005 7700 NOP
10
12 000006 7700 NOP
13 000007 7700 NOP
14 000008 7700 NOP
146 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.text
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. The .data section contains
integer constants and the .text section contains character strings.
1 ******************************************
2 ** Begin assembling into .data section. **
3 ******************************************
4 000000 .data
5 000000 000A .byte 0Ah, 0Bh
000001 000B
6
7 ******************************************
8 ** Begin assembling into .text section. **
9 ******************************************
10 000000 .text
11 000000 0041 START: .string "A", "B", "C"
000001 0042
000002 0043
12 000003 0058 END: .string "X", "Y", "Z"
000004 0059
000005 005A
13
14 000006 8100' ADD ACC, @START
15 000007 8103' ADD ACC, @END
16
17 ******************************************
18 ** Resume assembling into .data section.**
19 ******************************************
20 000002 .data
21 000002 000C .byte 0Ch, 0Dh
000003 000D
22 ******************************************
23 ** Resume assembling into .text section.**
24 ******************************************
25 000008 .text
26 000008 0051 .string "Quit"
000009 0075
00000a 0069
00000b 0074
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 147
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.title
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:
TMS320C2000 COFF Assembler Version x.xx Day Time Year
Copyright (c) 1996-2011 Texas Instruments Incorporated
**** Fast Fourier Transforms **** PAGE 1
2 ; .
3 ; .
4 ; .
TMS320C2000 COFF Assembler Version x.xx Day Time Year
Copyright (c) 1996-2011 Texas Instruments Incorporated
**** Floating-Point Routines **** PAGE 2
No Errors, No Warnings
148 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
.unasg/.undefine
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.8 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 13 for more information about using
C/C++ headers in assembly source.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 149
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.union/.endunion/ .tag
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, .xldouble, .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.
150 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
Note
Directives that Can Appear in a .union/.endunion Sequence
The only directives that can appear in a .union/.endunion sequence are
element descriptors, structure and union tags, and conditional assembly
directives. Empty structures are illegal.
Example 1
1
2 .global employid
3 xample .union ; utag
4 0000 ival .int ; member1 = int
5 0000 fval .float ; member2 = float
6 0000 sval .string ; member3 = string
7 0002 real_len .endunion
8
9 00000000 employid .usect ".ebss", real_len ; allocate memory
10
11 employid .tag xample ; name an instance
12
13 00000000 08A1- ADD AR1, #employid.ival
00000001 0000
Example 2
1
2 .union ; utag
3 0000 x .long ; member 1= long
4 0000 y .float ; member 2 = float
5 0000 z .int ; member 3 = int
6 0002 size_u .endunion ; size_u = 2
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 151
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.usect
Syntax symbol .usect " section name ", size in words[, blocking flag[, alignment] ]
Description The .usect directive reserves space for variables in an uninitialized, named section. This
directive is similar to the .bss directive (see .bss topic); 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 words is an expression that defines the number of words that are reserved
in section name.
• The blocking flag is an optional parameter. If you specify a value greater than 0 for this
parameter, the assembler allocates size in words contiguously. This means that the
allocated space does not cross a page boundary (64 words) unless its size is greater
than a page, in which case the allocated space starts on a page boundary. By default,
the compiler causes this flag to be set to 0 so that DP load optimization is used.
The compiler provides the "blocked" and "noblocked" variable attributes for controlling
blocking on a per-variable basis. For examples of DP load optimization, see the Tools
Insider blog in TI's E2E community.
• The alignment is an optional parameter . It causes the assembler to allocate the
specified size in words on long word boundaries. The resulting alignment will be on a
boundary that is 2 to the power of the specified alignment parameter. For example, an
alignment parameter of 5 gives an alignment of 2**5, which is 32 words.
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 word reserved in the var1 section. The symbol
array points to the first word in a block of 100 words reserved in var1, and dflag points
to the first word in a block of 50 words in var1. The symbol vec points to the first word
reserved in the var2 section.
152 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Assembler Directives
Figure 5-7 shows how this example reserves space in two uninitialized sections, var1 and
var2.
1 *******************************************
2 ** Assemble into .text section. **
3 *******************************************
4 000000 .text
5 000000 9A03 MOV AL, #03h
6
7 *******************************************
8 ** Reserve 1 word in var1. **
9 *******************************************
10 000000 ptr .usect "var1", 1
11
12 *******************************************
13 ** Reserve 100 words in var1. **
14 *******************************************
15 000001 array .usect "var1", 100
16
17 000001 9C03 ADD AL, #03h ; Still in .text
18
19 *******************************************
20 ** Reserve 50 words in var1. **
21 *******************************************
22 000065 dflag .usect "var1", 50
23
24 000002 08A9 ADD AL, #dflag ; Still in .text
000003 0065-
25
26 *******************************************
27 ** Reserve 100 words in var2. **
28 *******************************************
29 000000 vec .usect "var2", 100
30
31 000004 08A9 ADD AL, #vec ; Still in .text
000005 0000-
32
33 *******************************************
34 ** Declare an external .usect symbol **
35 *******************************************
36 .global array
array
100 words
100 words
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 153
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Assembler Directives www.ti.com
.var
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.8 for more information on substitution symbols .See Chapter 6 for
information on macros.
.weak
Description 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.3 for
details about how weak symbols are handled by the linker.
Note
The .weak directive is supported for EABI mode only.
The .weak directive is equivalent to the .ref directive, except that the reference has weak
linkage.
The .weak directive always creates a symbol table entry for a symbol, whether the module
uses the symbol or not. The .symdepend directive, in contrast, creates an symbol table
entry only if the module actually uses the symbol (see .symdepend topic).
If a 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.
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.
154 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Macro Language Description
Chapter 6
Macro Language Description
The TMS320C28x 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
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 155
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Macro Language Description www.ti.com
156 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Macro Language Description
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. Parameters are discussed in
parameter n 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.
The following example shows the definition, call, and expansion of a macro.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 157
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Macro Language Description www.ti.com
158 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Macro Language Description
The .asg Directive shows character strings being assigned to substitution symbols.
The .asg Directive
.asg "A4", RETVAL ; return value
In The .eval Directive, 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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 159
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Macro Language Description www.ti.com
(1) For more information about predefined register names, see Section 4.8.6.
160 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Macro Language Description
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.
Using the Forced Substitution Operator shows how the forced substitution operator is used.
Using the Forced Substitution Operator
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
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 161
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Macro Language Description www.ti.com
In this method, expression1 represents the substring's starting position, and expression2 represents the
substring's length. You can specify exactly where to begin subscripting and the exact length of the resulting
character string. The index of substring characters begins with 1, not 0.
The following examples show substitution symbol functions with subscripts. In the first example, subscripted
substitution symbols redefine the STW instruction so that it handles immediates. In the second example, the
subscripted substitution symbol is used to find a substring strg1 beginning at position start in the string strg2.
The position of the substring strg1 is assigned to the substitution symbol pos.
Using Subscripted Substitution Symbols to Redefine an Instruction
ADDX .macro ABC
.var TMP
.asg :ABC(1): , TMP
.if $symcmp(TMP, "#") = 0
ADD ACC, ABC
.else
.emsg "Bad Macro Parameter"
.endif
.endm
162 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Macro Language Description
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.
6.5 Using Conditional Assembly in Macros
The conditional assembly directives are .if/.elseif/.else/.endif and .loop/ .break/.endloop. They can be nested
within each other up to 32 levels deep. The format of a conditional block is:
.if well-defined expression
[.elseif well-defined expression]
[.else]
.endif
The .elseif and .else directives are optional in conditional assembly. The .elseif directive can be used more than
once within a conditional assembly code block. When .elseif and .else are omitted and when the .if expression is
false (0), the assembler continues to the code following the .endif directive. See Assemble Conditional Blocks for
more information on the .if/ .elseif/.else/.endif directives.
The .loop/.break/.endloop directives enable you to assemble a code block repeatedly. The format of a
repeatable block is:
.loop [well-defined expression]
[.break [well-defined expression]]
.endloop
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 163
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Macro Language Description www.ti.com
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.
The .loop/.break/.endloop Directives, Nested Conditional Assembly Directives, and Built-In Substitution Symbol
Functions in a Conditional Assembly Code Block show the .loop/.break/ .endloop directives, properly nested
conditional assembly directives, and built-in substitution symbol functions used in a conditional assembly code
block.
The .loop/.break/.endloop Directives
.asg 1,x
.loop
.break (x == 10) ; if x == 10, quit loop/break with expression
.eval x+1,x
.endloop
164 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Macro Language Description
Unique Labels in a Macro 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).
Unique Labels in a Macro
1
2 min .macro x, y, z
3
4 MOV z, y
5 CMP x, y
6 B l?,GT
7 MOV z, x
8 l?
9 .endm
10
11 00000000 min AH, AL, PH
1
1 00000000 2FA9 MOV PH, AL
1 00000001 55A9 CMP AH, AL
1 00000002 6202 B l?,GT
1 00000003 2FA8 MOV PH, AH
1 l?
12
LABEL VALUE DEFN REF
.TMS320C2800 000001 0
.TMS320C2800_FPU32 000000 0
__TI_ASSEMBLER_VERSION_QUAL_ID__ 001c52 0
__TI_ASSEMBLER_VERSION_QUAL__ 000049 0
__TI_ASSEMBLER_VERSION__ 4c4f28 0
l$1$ 000004' 12 11
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 165
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Macro Language Description www.ti.com
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.
Producing Messages in a Macro 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.
Producing Messages in a Macro
1 testparam .macro x, y
2 !
3 ! This macro checks for the correct number of parameters.
4 ! It generates an error message if x and y are not present.
5 !
6 ! The first line tests for proper input.
7 !
8 .if ($symlen(x) == 0)
9 .emsg "ERROR --missing parameter in call to TEST"
10 .mexit
11 .else
12 MOV ACC, #2
13 MOV AL, #1
14 ADD ACC, @AL
15 .endif
16 .endm
17
18 000000 testparam 1, 2
1 .if ($symlen(x) == 0)
1 .emsg "ERROR --missing parameter in call to TEST"
1 .mexit
1 .else
1 000000 FF20 MOV ACC, #2
000001 0002
1 000002 9A01 MOV AL, #1
1 000003 A0A9 ADD ACC, @AL
1 .endif
166 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Macro Language Description
.mlist expands macros and .loop/.endloop blocks. The .mlist directive prints all code encountered in those blocks.
.mnolist suppresses the listing of macro expansions and .loop/ .endloop blocks.
.fclist causes the assembler to include in the listing file all conditional blocks that do not generate code (false conditional
blocks). Conditional blocks appear in the listing exactly as they appear in the source code.
.fcnolist suppresses the listing of false conditional blocks. Only the code in conditional blocks that actually assemble
appears in the listing. The .if, .elseif, .else, and .endif directives do not appear in the listing.
For false conditional block listing, .fclist is the default.
• Substitution symbol expansion listing
.sslist expands substitution symbols in the listing. This is useful for debugging the expansion of substitution symbols. The
expanded line appears below the actual source line.
.ssnolist turns off substitution symbol expansion in the listing.
For substitution symbol expansion listing, .ssnolist is the default.
• Directive listing
.drlist causes the assembler to print to the listing file all directive lines.
.drnolist suppresses the printing of certain directives in the listing file. These directives
are .asg, .eval, .var, .sslist, .mlist, .fclist, .ssnolist, .mnolist, .fcnolist, .emsg, .wmsg, .mmsg, .length, .width,
and .break.
For directive listing, .drlist is the default.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 167
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Macro Language Description www.ti.com
Using Recursive Macros 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 A register. The fact
macro accomplishes this by calling fact1, which calls itself recursively.
Using Recursive Macros
1 .fcnolist
2
3 fact .macro N, LOC
4
5 .if N < 2
6 MOV @LOC, #1
7 .else
8 MOV @LOC, #N
9
10
11 .eval N-1, N
12 fact1
13
14 .endif
15 .endm
16
17 fact1 .macro
18 .if N > 1
19 MOV @T, @LOC
20 MPYB @P, @T, #N
21 MOV @LOC, @P
22 MOV ACC, @LOC
23 .eval N - 1, N
24 fact1
25
26 .endif
27 .endm
168 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Macro Language Description
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 169
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Macro Language Description www.ti.com
170 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Archiver Description
Chapter 7
Archiver Description
The TMS320C28x 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 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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 171
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Archiver Description www.ti.com
C
source
files
Macro C2xx
source C/C++
compiler assembler
files source
Assembler Transition
Archiver
source assistant
Macro Assembler
library Assembler
source
Object Library-build
Archiver files process
Debugging
tools
Library of Run-time-
object support
files Linker library
Post-link
optimizer
Executable
object file
Hex-conversion
utility
172 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Archiver Description
Note
Naming Library Members
It is possible (but not desirable) for a library to contain several members with the same name. If you
attempt to delete, replace, or extract a member whose name is the same as another library member,
the archiver deletes, replaces, or extracts the first library member with that name.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 173
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Archiver Description www.ti.com
• You can print a table of contents of function.lib with the -t command, enter:
ar2000 -t function
Because this example does not specify an extension for the libname, the archiver adds the files to the library
called function.lib. If function.lib does not exist, the archiver creates it. (The -s option tells the archiver to list
the global symbols that are defined in the library.)
• If you want to modify a library member, you can extract it, edit it, and replace it. In this example, assume there
is a library named macros.lib that contains the members push.asm, pop.asm, and swap.asm.
ar2000 -x macros push.asm
The archiver makes a copy of push.asm and places it in the current directory; it does not remove push.asm
from the library. Now you can edit the extracted file. To replace the copy of push.asm in the library with the
edited copy, enter:
ar2000 -r macros push.asm
• If you want to use a command file, specify the command filename after the -@ command. For example:
ar2000 [email protected]
174 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Archiver Description
Archiver Command File 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.
Archiver Command File
; Command file to replace members of the
; modules library with updated files
; Use r command and u option:
ru
; Specify library name:
modules.lib
; List filenames to be replaced if updated:
align.asm
bss.asm
data.asm
text.asm
sect.asm
clink.asm
copy.asm
double.asm
drnolist.asm
emsg.asm
end.asm
options changes the default behavior of the library information archiver. These options are:
--output libname specifies the name of the index library to create or update. This option is required.
--update updates any existing information in the index library specified with the --output option
instead of creating a new index.
libnames names individual object file libraries to be manipulated. When you enter a libname, you must enter a complete
filename including extension, if applicable.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 175
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Archiver Description www.ti.com
Using the library information archiver, you can create an index library called mylib.lib from the above libraries:
libinfo2000 --output mylib.lib mylib_2800.lib mylib_2800_fpu32.lib mylib_2800_ml.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:
cl2000 --issue_remarks main.c -z -l lnk.cmd ./mylib.lib
<Linking>
remark: linking in "mylib_2800.lib" in place of "mylib.lib"
176 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
Chapter 8
Linker Description
The TMS320C28x linker creates executable modules by combining object modules. This chapter describes the
linker options, directives, and statements used to create executable modules. Object libraries, command 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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 177
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
Macro C2xx
source C/C++
compiler assembler
files source
Assembler Transition
Archiver
source assistant
Macro Assembler
library Assembler
source
Object Library-build
Archiver files utility
Debugging
tools
Library of Run-time-
object support
files Linker library
Post-link
optimizer
Executable
object file
Hex-conversion
utility
178 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
cl2000 --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 extensions for input files
are .c.obj (for C source files) and .cpp.obj (for C++ source files). 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.
Note
The default file extensions for object files created by the compiler have been changed. Object files
generated from C source files have the .c.obj extension. Object files generated from C++ source
files have the .cpp.obj extension. Object files generated from assembly source files still have the .obj
extension.
• Put filenames and options in a linker command file. Filenames that are specified inside a linker command file
must begin with a letter. For example, assume the file linker.cmd contains the following lines:
--output_file=link.out file1.c.obj file2.c.obj
Now you can invoke the linker from the command line; specify the command filename as an input file:
cl2000 --run_linker linker.cmd
When you use a command file, you can also specify other options and files on the command line. For
example, you could enter:
cl2000 --run_linker --map_file=link.map linker.cmd file3.c.obj
The linker reads and processes a command file as soon as it encounters the filename on the command line,
so it links the files in this order: file1.c.obj, file2.c.obj, and file3.c.obj. This example creates an output file
called link.out and a map file called link.map.
For information on invoking the linker for C/C++ files, see Section 8.11.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 179
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
180 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 181
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
(1) For more information, refer to the Post-Link Optimizer chapter in the TMS320C28x Optimizing C /C++ Compiler v6.0 User's Guide.
182 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
The linker supports two options (--absolute_exe and --relocatable) that allow you to produce an absolute or a
relocatable output module. The linker also supports a third option (-ar) that allows you to produce an executable,
relocatable output module.
When the linker encounters a file that contains no relocation or symbol table information, it issues a warning
message (but continues executing). Relinking an absolute file can be successful only if each input file contains
no information that needs to be relocated (that is, each file has no unresolved references and is bound to the
same virtual address that it was bound to when the linker created it).
8.4.3.1 Producing an Absolute Output Module (--absolute_exe option)
If you use --absolute_exe without the --relocatable option, the linker produces an absolute, executable output
module. Absolute files contain no relocation information. Executable files contain the following:
• Special symbols defined by the linker (see Section 8.5.11.4)
• An header that describes information such as the program entry point (optional in COFF)
• No unresolved references
The following example links file1.c.obj and file2.c.obj and creates an absolute output module called a.out:
cl2000 --run_linker --absolute_exe file1.c.obj file2.c.obj
Note
The --absolute_exe and --relocatable Options
If you do not use the --absolute_exe or the --relocatable option, the linker acts as if you specified
--absolute_exe.
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.10.)
8.4.3.3 Producing an Executable, Relocatable Output Module (-ar Option)
If you invoke the linker with both the --absolute_exe and --relocatable options, the linker produces an executable,
relocatable object module. The output file contains the special linker symbols, an optional header, and all
resolved symbol references; however, the relocation information is retained.
This example links file1.c.obj and file2.c.obj to create an executable, relocatable output module called xr.out:
cl2000 --run_linker -ar file1.c.obj file2.c.obj --output_file=xr.out
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
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 183
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
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 TMS320C28x Optimizing C/C++ Compiler
User's Guide for information about the loader.
8.4.5 Compression (--cinit_compression and --copy_compression Option)
By default, the linker does not compress copy table (Section 3.3.3 and Section 8.8) source data sections. The
--cinit_compression and --copy_compression options specify compression through the linker. These options are
supported only when you use EABI by specifying the --abi=eabi option. They are not supported for COFF object
modules.
The --cinit_compression option specifies the compression type the linker applies to the C autoinitialization copy
table source data sections. The default is lzss.
Overlays can be managed by using linker-generated copy tables. To save ROM space the linker can
compress the data copied by the copy tables. The compressed data is decompressed during copy. The
--copy_compression option controls the compression of the copy data tables.
The syntax for the options are:
--cinit_compression[=compression_kind]
--copy_compression[=compression_kind]
The compression_kind can be one of the following types:
• off. Don't compress the data.
• rle. Compress data using Run Length Encoding .
• lzss. Compress data using Lempel-Ziv-Storer-Szymanski compression (the default if no compression_kind is
specified).
See Section 8.8.5 for more information about compression.
8.4.6 Compress DWARF Information (--compress_dwarf Option)
The --compress_dwarf option aggressively reduces the size of DWARF information by eliminating duplicate
information from input object files.
For COFF files, this is the default behavior, and can be disabled for COFF with the legacy --no_sym_merge
option.
With EABI, the default is to use DWARF 4, which merges types efficiently. Such merging can be made slightly
more efficient using the --compress_dwarf option. (See the ELF specification for information on COMDAT groups
and type merging.)
8.4.7 Control Linker Diagnostics
The linker honors certain C/C++ compiler options to control linker-generated diagnostics. The diagnostic options
must be specified before the --run_linker option.
--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.
184 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
--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 TMS320C28x Optimizing C/C++ Compiler User's
Guide for more information on understanding diagnostic messages.
--emit_references:file [=filename] Emits a file containing section information. The information includes section size, symbols defined, and
references to symbols. This information allows you to determine why each section is included in the
linked application. The output file is a simple ASCII text file. The filename is used as the base name of
a file created. For example, --emit_references:file=myfile generates a file named myfile.txt in the current
directory.
--emit_warnings_as_ Treat all warnings as errors. This option cannot be used with the --no_warnings option. The
errors --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
Note
This option is supported for COFF mode only.
The --disable_clink option disables removal of unreferenced sections in COFF object modules. Only sections
marked as candidates for removal with the .clink assembler directive are affected by conditional linking. See
Conditionally Leave Section Out of Object Module Output for details on setting up conditional linking using
the .clink directive.
The --disable_clink option is not used with EABI.
8.4.10 Do Not Remove Unused Sections (--unused_section_elimination Option)
Note
This option applies when using EABI mode only. It is ignored when using COFF mode.
To minimize the footprint, the ELF linker does not include sections that are not needed to resolve any references
in the final executable. Use --unused_section_elimination=off to disable this optimization. The linker default
behavior is equivalent to --unused_section_elimination=on.
8.4.11 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:
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 185
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
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:
cl2000 --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
#include "incfile.cmd" /* sees GLOBAL and LOCAL */
nestfile.cmd /* only sees GLOBAL */
Two cautions apply to the use of --define and --undefine in command files. First, they have global effect as
mentioned above. Second, since they are not actually preprocessing directives themselves, they are subject to
macro substitution, probably with unintended consequences. This effect can be defeated by quoting the symbol
name. For example:
--define MYSYM=123
--undefine MYSYM /* expands to --undefine 123 (!) */
--undefine "MYSYM" /* ahh, that's better */
The linker uses the same search paths to find #include files as it does to find libraries. That is, #include files are
searched in the following places:
1. If the #include file name is in quotes (rather than <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.17)
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-10. 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.
Table 8-10. Predefined C28x Macro Names
Macro Name Description
__DATE__ Expands to the compilation date in the form mmm dd yyyy
__FILE__ Expands to the current source filename
__TI_COMPILER_VERSION__ Defined to a 7-9 digit integer, depending on if X has 1, 2, or 3 digits. The number does not
contain a decimal. For example, version 3.2.1 is represented as 3002001. The leading zeros
are dropped to prevent the number being interpreted as an octal.
__TI_EABI__ Defined to 1 if EABI is enabled; otherwise, it is undefined.
__TIME__ Expands to the compilation time in the form "hh:mm:ss"
__TMS320C2000__ Defined for all C2000 processors
__TMS320C28XX__ Defined if target is C28x
__TMS320C28XX_CLA__ Defined to 1 if and --cla_support is used; otherwise it is undefined.
__TMS320C28XX_CLA0__ Defined to 1 if --cla_support=cla0 is used; otherwise it is undefined.
186 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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:
cl2000 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():
cl2000 test.c --ecc:data_error=main+2,0x42 -z -o test.out
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 187
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
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:
cl2000 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.
8.4.13 Define an Entry Point (--entry_point Option)
The memory address at which a program begins executing is called the entry point. When a loader loads a
program into target memory, the program counter (PC) must be initialized to the entry point; the PC then points
to the beginning of the program.
The linker can assign one of four values to the entry point. These values are listed below in the order in which
the linker tries to use them. If you use one of the first three values, it must be an external symbol in the symbol
table.
• The value specified by the --entry_point option. The syntax is:
--entry_point= global_symbol
where global_symbol defines the entry point and must be defined as an external symbol of the input files.
The external symbol name of C or C++ objects may be different than the name as declared in the source
language; refer to the TMS320C28x Optimizing C/C++ Compiler User's Guide.
• The value of symbol _c_int00 (if present). The _c_int00 symbol must be the entry point if you are linking code
produced by the C compiler.
• The value of symbol _main (if present)
• 0 (default value)
This example links file1.c.obj and file2.c.obj. The symbol begin is the entry point; begin must be defined as
external in file1 or file2.
cl2000 --run_linker --entry_point=begin file1.c.obj file2.c.obj
See Section 8.6.1 for information about referring to linker symbols in C/C++ code.
8.4.14 Set Default Fill Value (--fill_value Option)
The --fill_value option fills the holes formed within output sections. The syntax for the option is:
--fill_value= value
The argument value is a 32-bit constant (up to eight hexadecimal digits). If you do not use --fill_value, the linker
uses 0 as the default fill value.
This example fills holes with the hexadecimal value ABCDABCD:
cl2000 --run_linker --fill_value=0xABCDABCD file1.c.obj file2.c.obj
188 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
The linker creates the .esysmem section only if there is a .esysmem section in an input file.
The linker also creates a global symbol, __SYSMEM_SIZE (for COFF) or __TI_SYSMEM_SIZE (for EABI), and
assigns it a value equal to the size of the heap. The default size is 1K words. 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.11.
8.4.16 Hiding Symbols
Symbol hiding prevents the symbol from being listed in the output file's symbol table. While localization is used
to prevent name space clashes in a link unit (see Section 8.4.18), symbol hiding is used to obscure symbols
which should not be visible outside a link unit. Such symbol’s names appear only as empty strings or “no name”
in object file readers. The linker supports symbol hiding through the --hide and --unhide options.
The syntax for these options are:
--hide=' pattern '
--unhide=' pattern '
The pattern is a "glob" (a string with optional ? or * wildcards). Use ? to match a single character. Use * to match
zero or more characters.
The --hide option hides global symbols with a linkname matching the pattern. It hides symbols matching the
pattern by changing the name to an empty string. A global symbol that is hidden is also localized.
The --unhide option reveals (un-hides) global symbols that match the pattern that are hidden by the --hide
option. The --unhide option excludes symbols that match pattern from symbol hiding provided the pattern defined
by --unhide is more restrictive than the pattern defined by --hide.
These options have the following properties:
• The --hide and --unhide options can be specified more than once on the command line.
• The order of --hide and --unhide has no significance.
• A symbol is matched by only one pattern defined by either --hide or --unhide.
• A symbol is matched by the most restrictive pattern. Pattern A is considered more restrictive than Pattern B, if
Pattern A matches a narrower set than Pattern B.
• It is an error if a symbol matches patterns from --hide and --unhide and one does not supersede the other.
Pattern A supersedes pattern B if A can match everything B can and more. If Pattern A supersedes Pattern
B, then Pattern B is said to more restrictive than Pattern A.
• These options affect final and partial linking.
In map files these symbols are listed under the Hidden Symbols heading.
8.4.17 Alter the Library Search Algorithm (--library, --search_path, and C2000_C_DIR )
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.c.obj, this is how you link the files:
cl2000 --run_linker file1.c.obj object.lib
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 189
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
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, 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 adjust the linker's directory search algorithm using the --search_path linker option or the C2000_C_DIR
environment variable. The linker searches for object libraries and command files in this order:
1. Search 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. Search directories named with C2000_C_DIR.
3. If C2000_C_DIR is not set, search directories named with the C2000_A_DIR environment variable.
4. Search the current directory.
8.4.17.1 Name an Alternate Library Directory (--search_path Option)
The --search_path option names an alternate directory that contains input files. The --search_path option's short
form is - I . The syntax for this option is:
--search_path= pathname
The pathname names a directory that contains input files.
When the linker searches for files named with the --library option, it searches through directories named with --
search_path first. Each --search_path option specifies only one directory, but you can use several --search_path
options per invocation. If you use the --search_path option to name an alternate directory, it must precede any
--library option on the command line or in a command file.
For example, assume that there are two archive libraries called r.lib and lib2.lib that reside in ld and ld2
directories. The table below shows the directories that r.lib and lib2.lib reside in, how to set environment variable,
and how to use both libraries during a link. Select the row for your operating system:
Operating System Enter
UNIX (Bourne shell) cl2000 --run_linker f1.c.obj f2.c.obj --search_path=/ld
--search_path=/ld2 --library=r.lib --library=lib2.lib
Windows cl2000 --run_linker f1.c.obj f2.c.obj --search_path=\ld
--search_path=\ld2 --library=r.lib --library=lib2.lib
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.
190 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
• 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 C2000_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 C2000_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:
Operating System Invocation Command
UNIX (Bourne shell) C2000_C_DIR="/ld ;/ld2"; export C2000_C_DIR;
cl2000 --run_linker f1.c.obj f2.c.obj --library=r.lib --library=lib2.lib
Windows C2000_C_DIR=\ld;\ld2
cl2000 --run linker f1.c.obj f2.c.obj --library=r.lib --library=lib2.lib
The environment variable remains set until you reboot the system or reset the variable by entering:
Operating System Enter
UNIX (Bourne shell) unset C2000_C_DIR
Windows set C2000_C_DIR=
The assembler uses an environment variable named C2000_A_DIR to name alternate directories that contain
copy/include files or macro libraries. If C2000_C_DIR is not set, the linker searches for object libraries in
the directories named with C2000_A_DIR. For information about C2000_A_DIR, see Section 4.5.2. For more
information about object libraries, see Section 8.6.3.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 191
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
8.4.17.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:
cl2000 --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
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 rts2800_ml.lib without
providing a full replacement for rts2800_ml.lib. Using --priority and linking your new library before rts2800_ml.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.
8.4.18 Change Symbol Localization
Symbol localization changes symbol linkage from global to local (static). This is used to obscure global symbols
that should not be widely visible, but must be global because they are accessed by several modules in the
library. The linker supports symbol localization through the --localize and --globalize linker options.
The syntax for these options are:
--localize=' pattern '
--globalize=' pattern '
The pattern is a "glob" (a string with optional ? or * wildcards). Use ? to match a single character. Use * to match
zero or more characters.
192 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
The --localize option changes the symbol linkage to local for symbols matching the pattern.
The --globalize option changes the symbol linkage to global for symbols matching the pattern. The --globalize
option only affects symbols that are localized by the --localize option. The --globalize option excludes symbols
that match the pattern from symbol localization, provided the pattern defined by --globalize is more restrictive
than the pattern defined by --localize.
See Section 8.4.2 for information about using C/C++ identifiers in linker options such as --localize and
--globalize.
These options have the following properties:
• The --localize and --globalize options can be specified more than once on the command line.
• The order of --localize and --globalize options has no significance.
• A symbol is matched by only one pattern defined by either --localize or --globalize.
• A symbol is matched by the most restrictive pattern. Pattern A is considered more restrictive than Pattern B, if
Pattern A matches a narrower set than Pattern B.
• It is an error if a symbol matches patterns from --localize and --globalize and if one does not supersede other.
Pattern A supersedes pattern B if A can match everything B can, and some more. If Pattern A supersedes
Pattern B, then Pattern B is said to more restrictive than Pattern A.
• These options affect final and partial linking.
In map files these symbols are listed under the Localized Symbols heading.
8.4.18.1 Make All Global Symbols Static (--make_static Option)
The --make_static option makes all global symbols static. Static symbols are not visible to externally linked
modules. By making global symbols static, global symbols are essentially hidden. This allows external symbols
with the same name (in different files) to be treated as unique.
The --make_static option effectively nullifies all .global assembler directives. All symbols become local to the
module in which they are defined, so no external references are possible. For example, assume file1.c.obj and
file2.c.obj both define global symbols called EXT. By using the --make_static option, you can link these files
without conflict. The symbol EXT defined in file1.c.obj is treated separately from the symbol EXT defined in
file2.c.obj.
cl2000 --run_linker --make_static file1.c.obj file2.c.obj
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
8.4.19 Create a Map File (--map_file Option)
The syntax for the --map_file option is:
--map_file= filename
The linker map describes:
• Memory configuration
• Input and output section allocation
• Linker-generated copy tables
• The addresses of external symbols after they have been relocated
• Hidden and localized symbols
The map file contains the name of the output module and the entry point; it can also contain up to three tables:
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 193
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
• A table shows the new memory configuration if the MEMORY directive specifies any non-default
configuration. The table has the following columns, which are generated from the MEMORY directive in
the linker command file. For information about the MEMORY directive, see Section 8.5.4.
– Name. This is the name of the memory range specified with the MEMORY directive.
– Origin. This specifies the starting address of a memory range.
– Length. This specifies the length of a memory range.
– Unused. This specifies the total amount of unused (available) memory in that memory area.
– Attributes. This specifies one to four attributes associated with the named range:
R specifies that the memory can be read.
• 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.c.obj and file2.c.obj and creates a map file called map.out:
cl2000 --run_linker file1.c.obj file2.c.obj --map_file=map.out
194 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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.
8.4.21 Disable Name Demangling (--no_demangle)
By default, the linker uses demangled symbol names in diagnostics. For example:
undefined symbol first referenced in file
ANewClass::getValue() test.cpp.obj
The --no_demangle option instead shows the linkname for symbols in diagnostics. For example:
undefined symbol first referenced in file
_ZN9ANewClass8getValueEv test.cpp.obj
For information on referencing symbol names, see the "Object File Symbol Naming Conventions (Linknames)"
section in the TMS320C28x Optimizing C/C++ Compiler User's Guide.
For information specifically about C++ symbol naming, see the "C++ Name Demangler" chapter in the
TMS320C28x Optimizing C/C++ Compiler User's Guide.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 195
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
When these files are compiled for debugging, both f1.c.obj and f2.c.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.
Use the COFF only --no_sym_merge option if you want the linker to keep such duplicate entries in COFF object
files. Using the --no_sym_merge option has the effect of the linker running faster and using less host memory
during linking, but the resulting executable file may be very large due to duplicated debug information.
8.4.23 Strip Symbolic Information (--no_symtable Option)
The --no_symtable option creates a smaller output module by omitting symbol table information and line number
entries. The --no_sym_table option is useful for production applications when you do not want to disclose
symbolic information to the consumer.
This example links file1.c.obj and file2.c.obj and creates an output module, stripped of line numbers and symbol
table information, named nosym.out:
cl2000 --run_linker --output_file=nosym.out --no_symtable file1.c.obj file2.c.obj
Note
Stripping Symbolic Information
The --no_symtable option is deprecated. To remove symbol table information, use the strip2000 utility
as described in Section 11.4.
196 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
Refer to the TMS320C28x Optimizing C/C++ Compiler User's Guide for details on the program cache layout tool,
which is impacted by --preferred_option.
8.4.26 C Language Options (--ram_model and --rom_model Options)
The --ram_model and --rom_model options cause the linker to use linking conventions that are required by the C
compiler. Both options inform the linker that the program is a C program and requires a boot routine.
• The --ram_model option tells the linker to initialize variables at load time.
• The --rom_model option tells the linker to autoinitialize variables at run time.
If you use a linker command line that does not compile any C/C++ files, you must use either the --rom_model or
--ram_model option. If your command line fails to include one of these options when it is required, you will see
"warning: no suitable entry-point found; setting to 0".
If you use a single command line to both compile and link, the --rom_model option is the default. If used, the
--rom_model or --ram_model option must follow the --run_linker option.
For more information, see Section 8.11, Section 3.3.2.1, and Section 3.3.2.2.
8.4.27 Retain Discarded Sections (--retain Option)
Note
The --retain option is used only with EABI mode. It is ignored when linking in COFF mode.
When --unused_section_elimination is on, the ELF linker does not include a section in the final link if it is not
needed in the executable to resolve references. The --retain option tells the linker to retain a list of sections that
would otherwise not be retained. This option accepts the wildcards '*' and '?'. When wildcards are used, the
argument should be in quotes. The syntax for this option is:
--retain=sym_or_scn_spec
The --retain option take one of the following forms:
• --retain= symbol_spec
Specifying the symbol format retains sections that define symbol_spec. For example, this code retains
sections that define symbols that start with init:
--retain='init*'
You can specify --retain='*(*)' to retain all sections from all input files. However, this does not prevent sections
from library members from being optimized out.
• --retain= ar_spec<mem_spec, [mem_spec, ...>(scn_spec[, scn_spec, ...]
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 197
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
Specifying the archive format retains sections matching one or more scn_spec from members matching one
or more mem_spec from archive files matching ar_spec. For example, this code retains the .text sections
from printf.c.obj in the rts2800_ml_eabi.lib library:
--retain=rts2800_ml_eabi.lib<printf.c.obj>(.text)
If the library is specified with the --library option (--library=rts2800_ml_eabi.lib) the library search path is used
to search for the library. You cannot specify '*<*>(*)'.
8.4.28 Create an Absolute Listing File (--run_abs Option)
The --run_abs option produces an output file for each file linked. These files are named with the input filenames
and an extension of .abs. Header files, however, do not generate a corresponding .abs file.
8.4.29 Scan All Libraries for Duplicate Symbol Definitions (--scan_libraries)
The --scan_libraries option scans all libraries during a link looking for duplicate symbol definitions to those
symbols that are actually included in the link. The scan does not consider absolute symbols or symbols defined
in COMDAT sections. The --scan_libraries option helps determine those symbols that were actually chosen by
the linker over other existing definitions of the same symbol in a library.
The library scanning feature can be used to check against unintended resolution of a symbol reference to a
definition when multiple definitions are available in the libraries.
8.4.30 Define Stack Size (--stack_size Option)
The TMS320C28x C/C++ compiler uses an uninitialized section, .stack, to allocate space for the run-time stack.
You can set the size of this section in words at link time with the --stack_size option. The syntax for the
--stack_size option is:
--stack_size= size
The size must be a constant and is in words. This example defines a 4K word stack:
cl2000 --run_linker --stack_size=0x1000 /* defines a 4K heap (.stack section)*/
If you specified a different stack size in an input section, the input section stack size is ignored. Any symbols
defined in the input section remain valid; only the stack size is different.
When the linker defines the .stack section, it also defines a global symbol, __STACK_SIZE (for COFF) or
__TI_STACK_SIZE (for EABI) , and assigns it a value equal to the size of the section. The default software stack
size is 1K words. See Section 8.6.1 for information about referring to linker symbols in C/C++ code.
8.4.31 Enforce Strict Compatibility (--strict_compatibility Option)
The linker performs more conservative and rigorous compatibility checking of input object files when you specify
the --strict_compatibility option. Using this option guards against additional potential compatibility issues, but
may signal false compatibility errors when linking in object files built with an older toolset, or with object files built
with another compiler vendor's toolset. To avoid issues with legacy libraries, the --strict_compatibility option is
turned off by default.
8.4.32 Mapping of Symbols (--symbol_map Option)
Symbol mapping allows a symbol reference to be resolved by a symbol with a different name, which allows
functions to be overridden with alternate definitions. This can be used to patch in alternate implementations to
provide patches (bug fixes) or alternate functionality. The syntax for the --symbol_map option is:
--symbol_map= refname=defname
For example, the following code makes the linker resolve any references to foo by the definition foo_patch:
--symbol_map='foo=foo_patch'
198 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
The --symbol_map option is supported even if --opt_level=4 was used when compiling.
8.4.33 Introduce an Unresolved Symbol (--undef_sym Option)
The --undef_sym option introduces the linkname for an unresolved symbol into the linker's symbol table. This
forces the linker to search a library and include the member that defines the symbol. The linker must encounter
the --undef_sym option before it links in the member that defines the symbol. The syntax for the --undef_sym
option is:
--undef_sym= symbol
For example, suppose a library named rts2800_ml.lib contains a member that defines the symbol symtab; none
of the object files being linked reference symtab. However, suppose you plan to relink the output module and
you want to include the library member that defines symtab in this link. Using the --undef_sym option as shown
below forces the linker to search rts2800_ml.lib for the member that defines symtab and to link in the member.
cl2000 --run_linker --undef_sym=symtab file1.c.obj file2.c.obj rts2800_ml.lib
If you do not use --undef_sym, this member is not included, because there is no explicit reference to it in
file1.c.obj or file2.c.obj.
8.4.34 Display a Message When an Undefined Output Section Is Created (--warn_sections)
In a linker command file, you can set up a SECTIONS directive that describes how input sections are
combined into output sections. However, if the linker encounters one or more input sections that do not have a
corresponding output section defined in the SECTIONS directive, the linker combines input sections that have
the same name into an output section with that name. By default, the linker does not display a message to tell
you that this occurred.
Use the --warn_sections option to cause the linker to display a message when it creates a new output section.
For more information about the SECTIONS directive, see Section 8.5.5. For more information about the default
actions of the linker, see Section 8.7.
8.4.35 Generate XML Link Information File (--xml_link_info Option)
The linker supports the generation of an XML link information file through the --xml_link_info=file option. This
option causes the linker to generate a well-formed XML file containing detailed information about the result of
a link. The information included in this file includes all of the information that is currently produced in a linker
generated map file. See Appendix B for specifics on the contents of the generated XML file.
8.4.36 Zero Initialization (--zero_init Option)
The C and C++ standards require that global and static variables that are not explicitly initialized must be set to
0 before program execution. The C/C++ compiler supports preinitialization of uninitialized variables by default. To
turn this off, specify the linker option --zero_init=off. COFF ABI does not support zero initialization.
The syntax for the --zero_init option is:
--zero_init[={on|off}]
Zero initialization takes place only if the --rom_model linker option, which causes autoinitialization to occur, is
used. If you use the --ram_model option for linking, the linker does not generate initialization records, and the
loader must handle both data and zero initialization.
Note
Disabling Zero Initialization Not Recommended: In general, disabling zero initialization is not
recommended. If you turn off zero initialization, automatic initialization of uninitialized global and static
objects to zero will not occur. You are then expected to initialize these variables to zero in some other
manner.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 199
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
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.
Linker Command File shows a sample linker command file called link.cmd.
Linker Command File
a.c.obj /* First input filename */
b.c.obj /* Second input filename */
--output_file=prog.out /* Option to specify output file */
--map_file=prog.map /* Option to specify map file */
The sample file in Linker Command File 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:
cl2000 --run_linker link.cmd
You can place other parameters on the command line when you use a command file:
cl2000 --run_linker --relocatable link.cmd x.c.obj y.c.obj
The linker processes the command file as soon as it encounters the filename, so a.c.obj and b.c.obj are linked
into the output module before x.c.obj and y.c.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:
cl2000 --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. Command File With Linker Directives shows a sample command file that
contains linker directives.
200 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
For more information, see Section 8.5.4 for the MEMORY directive, and Section 8.5.5 for the SECTIONS
directive.
8.5.1 Reserved Names in Linker Command Files
The following names (in both uppercase and lowercase) are reserved as keywords for linker directives. Do not
use them as symbol or section names in a command file.
ADDRESS_MASK END LEN o SECTIONS
ALGORITHM f LENGTH ORG SIZE
ALIGN FILL LOAD ORIGIN START
ATTR GROUP LOAD_END PAGE TABLE
BLOCK HAMMING_MASK LOAD_SIZE PALIGN TYPE
COMPRESSION HIGH LOAD_START PARITY_MASK UNION
COPY INPUT_PAGE MEMORY RUN UNORDERED
CRC_TABLE INPUT_RANGE MIRRORING RUN_END VFILL
DSECT l (lowercase L) NOINIT RUN_SIZE
ECC LAST NOLOAD RUN_START
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.
8.5.2 Constants in Linker Command Files
You can specify constants with either of two syntax schemes: the scheme used for specifying decimal, octal, or
hexadecimal constants (but not binary constants) used in the assembler (see Section 4.7) or the scheme used
for integer constants in C syntax.
Examples:
Format Decimal Octal Hexadecimal
Assembler format 32 40q 020h
C format 32 040 0x20
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 201
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
Consider a simple example. Imagine that you have an application that requires a table of constants called
"app_coeffs" to be defined in a memory area called "DDR". Assume also that the "app_coeffs" data object
is defined in a .data section that resides in an object file, app_coeffs.c.obj. The app_coeffs.c.obj file is then
included in the object file library app_data.lib. In your LCF, you can control the placement of the "app_coeffs"
data object as follows:
SECTIONS
{
...
.coeffs: { app_data.lib<app_coeffs.c.obj>(.data) } > DDR
...
}
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:
%> cl2000 <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 ).
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.c.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.
202 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 203
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
PAGE identifies a memory space. You can specify up to 32 767 pages. Usually, PAGE 0 specifies program memory, and
PAGE 1 specifies data memory. Each PAGE represents a completely independent address space. Configured memory
on PAGE 0 can overlap configured memory on PAGE 1 and so on. If you do not specify PAGE for a memory space, the
linker defaults to PAGE 0. If you do not specify PAGE in your allocation (see Section 8.5.5), the linker allocates initialized
sections to PAGE 0 and uninitialized sections to PAGE 1.
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 22-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.10.3 for virtual filling of memory ranges when using Error Correcting Code (ECC).)
LAST optionally specifies a symbol that can be used at run-time to find the address of the last allocated byte in the memory
range. See Section 8.5.11.8.
Note
Filling Memory Ranges: If you specify fill values for large memory ranges, your output file will be
very large because filling a memory range (even with 0s) causes raw data to be generated for all
unallocated blocks of memory in the range.
204 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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.
Figure 8-2 illustrates the memory map shown in The MEMORY Directive
Page 0 Page 1
0x0000 0000 0x0000 0000
0x0000 0060
SCRATCH
0x0000 007F
0x0000 0080
0x0000 0200
RAM1
0x0000 03FF
0x0000 0400
0x0000 0C00
PROG
0x0000 1BFF
0x0000 1C00
0x0000 FFFF 0x0000 FFFF
Note
If no PAGE information is input then PAGE=0.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 205
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
206 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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: { input_sections }
• Section type defines flags for special section types. See Section 8.5.9.
The SECTIONS Directive shows a SECTIONS directive in a sample linker command file. (This example uses
COFF section names.)
The SECTIONS Directive
/**************************************************/
/* Sample command file with SECTIONS directive */
/**************************************************/
file1.c.obj file2.c.obj /* Input files */
--output_file=prog.out /* Options */
SECTIONS
{
.text: load = PROG, PAGE = 0,
run = 0x0200, PAGE = 1
.econst: load = RAM1
.ebss: load = RAM1
.scratch: load = 0x0060, PAGE = 1
{
t1.c.obj(.scratch1)
t2.c.obj(.scratch2)
endscratch = .;
}
.data:alpha: align = 16
.data:beta: align = 16
}
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 207
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
Figure 8-3 shows the output sections defined by the SECTIONS directive in The SECTIONS Directive
(.vectors, .text, .econst, .ebss, .data:alpha, and .data:beta) and shows how these sections are allocated in
memory using the MEMORY directive given in The MEMORY Directive.
208 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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 PAGE 2
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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 209
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
8.5.5.2.2 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
22-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.
Note
Binding is Incompatible With Alignment and Named Memory: You cannot bind a section to an
address if you use alignment or named memory. If you try to do this, the linker issues an error
message.
In this example, the linker places .text into the area called SLOW_MEM. The .data and .ebss 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.
210 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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 */
.ebss: > (RW) /* .ebss --> 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 .ebss 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.
8.5.5.2.4 Controlling Placement Using The HIGH Location Specifier
The linker allocates output sections from low to high addresses within a designated memory range by default.
Alternatively, you can cause the linker to allocate a section from high to low addresses within a memory range
by using the HIGH location specifier in the SECTION directive declaration. You might use the HIGH location
specifier in order to keep RTS code separate from application code, so that small changes in the application do
not cause large changes to the memory map.
For example, given this MEMORY directive:
MEMORY
{
RAM : origin = 0x0200, length = 0x0800
FLASH : origin = 0x1100, length = 0xEEE0
VECTORS : origin = 0xFFE0, length = 0x001E
RESET : origin = 0xFFFE, length = 0x0002
}
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 .ebss and .esysmem sections are allocated into the lower
addresses within RAM. Example 8-1 illustrates a portion of a map file that shows where the given sections are
allocated within RAM for a typical program.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 211
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
As shown in Example 8-1 , the .ebss and .esysmem 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-2
The HIGH specifier is ignored if it is used with specific address binding or automatic section splitting (>>
operator).
Example 8-2. Linker Placement Without HIGH Specifier
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 .ebss so that the entire section is
contained in a single 128-byte page or begins on that boundary:
ebss: 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.
212 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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 = 0xffff {} > PMEM
In this example, the length of the .mytext section is 3 16-bit bytes before the palign operator is applied. The
contents of .mytext are as follows:
addr content
---- -------
0001 0x1234
0002 0x1234
0003 0x1234
After the palign operator is applied, the length of .mytext is 8 bytes, and its contents are as follows:
addr content
---- -------
0001 0x1234
0002 0x1234
0003 0x1234
0004 0xffff
0005 0xffff
0006 0xffff
0007 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
---- -------
0001 0x1234
0002 0x1234
0003 0x1234
0004 0x00ff
0005 0x00ff
0006 0x00ff
0007 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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 213
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
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
In this example, the .text and .cinit sections are allocated to PAGE 0. They are placed anywhere within the
bounds of PAGE 0. The .data section is allocated anywhere within the bounds of PAGE 2. The .ebss or .bss
section is allocated anywhere within the bounds of PAGE 1.
You can use the page method in conjunction with any of the other methods to restrict an allocation to a specific
address space. For example:
.text: load = OVR_MEM PAGE 1
In this example, the .text section is allocated to the named memory range OVR_MEM. There are two named
memory ranges called OVR_MEM, however, so you must specify which one is to be used. By adding PAGE 1,
you specify the use of the OVR_MEM memory range in address space PAGE 1 rather than in address space
PAGE 2. If no PAGE is specified for a section, the linker allocates initialized sections to PAGE 0 and uninitialized
sections to PAGE 1.
8.5.5.3 Specifying Input Sections
An input section specification identifies the sections from input files that are combined to form an output section.
In general, the linker combines input sections by concatenating them in the order in which they are specified.
However, if alignment or blocking is specified for an input section, all of the input sections within the output
section are ordered as follows:
• All aligned sections, from largest to smallest
• All blocked sections, from largest to smallest
• All other sections, from largest to smallest
The size of an output section is the sum of the sizes of the input sections that it comprises.
214 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
Example 8-3 shows the most common type of section specification; note that no input sections are listed.
Example 8-3. The Most Common Method of Specifying Section Contents
SECTIONS
{
.text:
.data:
.ebss:
}
In Example 8-3, 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 .ebss or .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.c.obj(.text) /* Link .text section from f1.c.obj */
f2.c.obj(sec1) /* Link sec1 section from f2.c.obj */
"f3-new.c.obj" /* Link ALL sections from f3-new.c.obj */
f4.c.obj(.text,sec2) /* Link .text and sec2 from f4.c.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.c.obj(sec2).
The specifications in Example 8-3 are actually a shorthand method for the following:
SECTIONS
{
.text: { *(.text) }
.data: { *(.data) }
.ebss: { *(.ebss) }
}
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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 215
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
In this example, the .text output section contains a named section xqt from file abc.c.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.c.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.
8.5.5.4 Using Multi-Level Subsections
Subsections can be identified with the base section name and one or more subsection names separated by
colons. For example, A:B and A:B:C name subsections of the base section A. In certain places in a linker
command file specifying a base name, such as A, selects the section A as well as any subsections of A, such as
A:B or A:C:D.
A name such as A:B can specify a (sub)section of that name as well as any (multi-level) subsections beginning
with that name, such as A:B:C, A:B:OTHER, etc. All subsections of A:B are also subsections of A. A and A:B
are supersections of A:B:C. Among a group of supersections of a subsection, the nearest supersection is the
supersection with the longest name. Thus, among {A, A:B} the nearest supersection of A:B:C:D is A:B. With
multiple levels of subsections, the constraints are the following:
1. When specifying input sections within a file (or library unit) the section name selects an input section of the
same name and any subsections of that name.
2. Input sections that are not explicitly allocated are allocated in an existing output section of the same name
or in the nearest existing supersection of such an output section. An exception to this rule is that during a
partial link (specified by the --relocatable linker option) a subsection is allocated only to an existing output
section of the same name.
3. If no such output section described in 2) is defined, the input section is put in a newly created output
section with the same name as the base name of the input section
Consider linking input sections with the following names:
europe:north:norway europe:central:france europe:south:spain
europe:north:sweden europe:central:germany europe:south:italy
europe:north:finland europe:central:denmark europe:south:malta
europe:north:iceland
216 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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 */
/* (italy, spain) go into a linker-generated output section "europe" */
}
Note
Upward Compatibility of Multi-Level Subsections
Existing linker commands that use the existing single-level subsection features and which do not
contain section names containing multiple colon characters continue to behave as before. However, if
section names in a linker command file or in the input sections supplied to the linker contain multiple
colon characters, some change in behavior could be possible. You should carefully consider the
impact of the rules for multiple levels to see if it affects a particular system link.
SECTIONS
{
boot>BOOT1
{
-l rtsXX.lib<boot.c.obj> (.text)
-l rtsXX.lib<exit.c.obj strcpy.c.obj> (.text)
}
.rts>BOOT2
{
-l rtsXX.lib (.text)
}
.text>RAM
{
* (.text)
}
}
In Example 8-4, the .text sections of boot.c.obj, exit.c.obj, and strcpy.c.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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 217
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
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-4 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 rts2800_ml.lib into the .rtstest section:
SECTIONS
{
.rtstest { -l rts2800_ml.lib(.text) } > RAM
}
Note
SECTIONS Directive Effect on --priority: Specifying a library in a SECTIONS directive causes that
library to be entered in the list of libraries that the linker searches to resolve references. If you use the
--priority option, the first library specified in the command file will be searched first.
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.
8.5.5.7 Automatic Splitting of Output Sections Among Non-Contiguous Memory Ranges
The linker can split output sections among multiple memory ranges for efficient allocation. Use the >> operator to
indicate that an output section can be split, if necessary, into the specified memory ranges:
MEMORY
{
P_MEM1 : origin = 0x2000, length = 0x1000
P_MEM2 : origin = 0x4000, length = 0x1000
P_MEM3 : origin = 0x6000, length = 0x1000
P_MEM4 : origin = 0x8000, length = 0x1000
}
SECTIONS
{
.text: { *(.text) } >> P_MEM1 | P_MEM2 | P_MEM3 | P_MEM4
}
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.
218 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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.c.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}
}
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 219
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
The linker provides a simple way to accomplish this. You can use the SECTIONS directive to direct the linker to
allocate a section twice: once to set its load address and again to set its run address. For example:
.fir: load = SLOW_MEM, run = FAST_MEM
Use the 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.)
8.5.6.1 Specifying Load and Run Addresses
The load address determines where a loader places the raw data for the section. Any references to the section
(such as labels in it) refer to its run address. See Section 3.1.1 for an overview of load and run addresses.
If you provide only one allocation (either load or run) for a section, the section is allocated only once and loads
and runs at the same address. If you provide both allocations, the section is allocated as if it were two sections
of the same size. This means that both allocations occupy space in the memory map and cannot overlay each
other or other sections. (The UNION directive provides a way to overlay sections; see Section 8.5.7.2.)
If either the load or run address has additional parameters, such as alignment or blocking, list them after the
appropriate keyword. Everything related to allocation after the keyword load affects the load address until the
keyword run is seen, after which, everything affects the run address. The load and run allocations are completely
independent, so any qualification of one (such as alignment) has no effect on the other. You can also specify run
first, then load. Use parentheses to improve readability.
The examples that follow specify load and run addresses.
In this example, align applies only to load:
.data: load = SLOW_MEM, align = 32, run = FAST_MEM
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
Uninitialized sections (such as .ebss or .bss) are not loaded, so their only significant address is the run address.
The linker allocates uninitialized sections only once: if you specify both run and load addresses, the linker warns
you and ignores the load address. Otherwise, if you specify only one address, the linker treats it as a run
address, regardless of whether you call it load or run.
This example specifies load and run addresses for an uninitialized section:
.ebss: load = 0x1000, run = FAST_MEM
A warning is issued, load is ignored, and space is allocated in FAST_MEM. All of the following examples have
the same effect. The .ebss section is allocated in FAST_MEM.
.ebss: load = FAST_MEM
.ebss: run = FAST_MEM
.ebss: > FAST_MEM
220 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
Linker Command File for Moving a Function from Slow to Fast Memory at Run Time
/*******************************************************************/
/* PARTIAL LINKER COMMAND FILE FOR FIR EXAMPLE */
/*******************************************************************/
MEMORY
{
PAGE 0 : FAST_MEM : origin = 0x00000800, length = 0x00002400
PAGE 0 : PROG : origin = 0x00002C00, length = 0x0000D200
PAGE 1 : SLOW_MEM : origin = 0x00000800, length = 0x0000F800
}
SECTIONS
{
.text: load = PROG PAGE 0
.fir: load = SLOW_MEM PAGE 1, run = FAST_MEM PAGE 0
}
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 221
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
0x0000 2C00
PROG
.text
0x0000 FE00
Figure 8-4. Run-Time Execution of Moving a Function from Slow to Fast Memory at Run Time
See Section 8.6.1 for information about referring to linker symbols in C/C++ code.
8.5.7 Using GROUP and UNION Statements
Two SECTIONS statements allow you to organize or conserve memory: GROUP and UNION. Grouping sections
causes the linker to allocate them contiguously in memory. Unioning sections causes the linker to allocate them
to the same run address.
8.5.7.1 Grouping Output Sections Together
The SECTIONS directive's GROUP option forces several output sections to be allocated contiguously and in the
order listed, unless the UNORDERED operator is used. For example, assume that a section named term_rec
contains a termination record for a table in the .data section. You can force the linker to allocate .data and
term_rec together:
Allocate Sections Together
SECTIONS
{
.text /* Normal output section */
.ebss /* 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.
Note
You Cannot Specify Addresses for Sections Within a GROUP: When you use the GROUP option,
binding, alignment, or allocation into named memory can be specified for the group only. You cannot
use binding, named memory, or alignment for sections within a group.
The MEMORY directive also allows you to use the GROUP keyword to create logical groups of memory ranges
for use with Cyclic Redundancy Checks (CRC). See Section 8.9.2 for how to compute CRCs over memory
ranges using the GROUP syntax.
222 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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 Separate Load Addresses for UNION Sections.
(There is an exception to this rule when combining an initialized section with uninitialized sections; see Section
8.5.7.3.)
Separate Load Addresses for UNION Sections
UNION run = FAST_MEM
{
.text:part1: load = SLOW_MEM, { file1.c.obj(.text) }
.text:part2: load = SLOW_MEM, { file2.c.obj(.text) }
}
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 223
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
Figure 8-5. Memory Allocation Shown in The UNION Statement and Separate Load Addresses for UNION
Sections
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.
Note
UNION and Overlay Page Are Not the Same
The UNION capability and the overlay page capability (see Section 8.5.8) may sound similar because
they both deal with overlays. They are, in fact, quite different. UNION allows multiple sections to be
overlaid within the same memory space. Overlay pages, on the other hand, define multiple memory
spaces. It is possible to use the page facility to approximate the function of UNION, but this is
cumbersome.
224 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
In this example, the .cinit section is an initialized section. It will be loaded into FAST_MEM at the run address of
the union. In contrast, .bss is an uninitialized section. Its run address will also be that of the union.
8.5.7.4 Nesting UNIONs and GROUPs
The linker allows arbitrary nesting of GROUP and UNION statements with the SECTIONS directive. By nesting
GROUP and UNION statements, you can express hierarchical overlays and groupings of sections. Nesting
GROUP and UNION Statements shows how two overlays can be grouped together.
Nesting GROUP and UNION Statements
SECTIONS
{
GROUP 0x1000 : run = FAST_MEM
{
UNION:
{
mysect1: load = SLOW_MEM
mysect2: load = SLOW_MEM
}
UNION:
{
mysect3: load = SLOW_MEM
mysect4: load = SLOW_MEM
}
}
}
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 225
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
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.
8.5.7.6 Naming UNIONs and GROUPs
You can give a name to a UNION or GROUP by entering the name in parentheses after the declaration. For
example:
GROUP(BSS_SYSMEM_STACK_GROUP)
{
.ebss :{}
.esysmem :{}
.stack :{}
} load=D_MEM, run=D_MEM
The name you defined is used in diagnostics for easy identification of the problem LCF area. For example:
warning: LOAD placement ignored for "BSS_SYSMEM_STACK_GROUP": object is uninitialized
UNION(TEXT_CINIT_UNION)
{
.econst :{}load=D_MEM, table(table1)
.pinit :{}load=D_MEM, table(table1)
}run=P_MEM
warning:table(table1) operator ignored: table(table1) has already been applied to a section
in the "UNION(TEXT_CINIT_UNION)" in which ".pinit" is a descendant
226 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
Note
Overlay Section and Overlay Page Are Not the Same: The UNION capability and the overlay page
capability (see Section 8.5.7.2) sound similar because they both deal with overlays. They are, in fact,
quite different. UNION allows multiple sections to be overlaid within the same memory space. Overlay
pages, on the other hand, define multiple memory spaces. It is possible to use the page facility to
approximate the function of UNION, but it is cumbersome.
MEMORY
{
PAGE 0 : RAM :origin = 0x0800, length = 0x0240
: PROG :origin = 0x2C00, length = 0xD200
PAGE 1 : OVR_MEM :origin = 0x0A00, length = 0x2200
: DATA :origin = 0x2C00, length = 0xD400
PAGE 2 : OVR_MEM :origin = 0x0A00, length = 0x2200
}
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 227
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
SECTIONS
{
UNION : run = RAM
{
S1 : load = OVR_MEM PAGE 1
{
s1_load = 0x00000A00h;
s1_start = .;
f1.c.obj (.text)
f2.c.obj (.text)
s1_length = . - s1_start;
}
S2 : load = OVR_MEM PAGE 2
{
s2_load = 0x00000A00h;
s2_start = .;
f3.c.obj (.text)
f4.c.obj (.text)
s2_length = . - s2_start;
}
}
.text: load = PROG PAGE 0
.data: load = PROG PAGE 0
.ebss: load = DATA PAGE 1
}
The four modules are f1, f2, f3, and f4. Modules f1 and f2 are combined into output section S1, and f3 and f4 are
combined into output section S2. The PAGE specifications for S1 and S2 tell the linker to link these sections into
the corresponding pages. As a result, they are both linked to load address A00h, but in different memory spaces.
When the program is loaded, a loader can configure hardware so that each section is loaded into the appropriate
memory bank.
228 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
Figure 8-6. Overlay Pages Defined in Example 8-5 and Example 8-6
• The DSECT type creates a dummy section with the following characteristics:
– It is not included in the output section memory allocation. It takes up no memory and is not included in the
memory map listing.
– It can overlay other output sections, other DSECTs, and unconfigured memory.
– Global symbols defined in a dummy section are relocated normally. They appear in the output module's
symbol table with the same value they would have if the DSECT had actually been loaded. These symbols
can be referenced by other input sections.
– Undefined external symbols found in a DSECT cause specified archive libraries to be searched.
– The section's contents, relocation information, and line number information are not placed in the output
module.
In the preceding example, none of the sections from f1.c.obj are allocated, but all the symbols are relocated
as though the sections were linked at address 0x2000. The other sections can refer to any of the global
symbols in sec1.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 229
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
• A COPY section is similar to a DSECT section, except that its contents and associated information are written
to the output module. The .cinit section that contains initialization tables for the TMS320C28x C/C++ compiler
has this attribute under the run-time initialization model.
• A NOLOAD section differs from a normal output section in one respect: the section's contents, relocation
information, and line number information are not placed in the output module. The linker allocates space for
the section, and it appears in the memory map listing.
• A NOINIT section is not C auto-initialized by the linker. It is your responsibility to initialize this section as
needed. (EABI only)
8.5.10 Configuring Error Correcting Code (ECC) with the Linker
Error Correcting Codes (ECC) can be generated and placed in separate sections through the linker command
file. ECC uses extra bits to allow errors to be detected and/or corrected by a device. To enable ECC generation,
you must include --ecc=on as a linker option on the command line. By default ECC generation is off, even if the
ECC directive and ECC specifiers are used in the linker command file. This allows you to fully configure ECC in
the linker command file while still being able to quickly turn the code generation on and off via the command line.
The ECC support provided by the linker is compatible with the ECC support in TI Flash memory on various TI
devices. TI Flash memory uses a modified Hamming(72,64) code, which uses 8 parity bits for every 64 bits.
Check the documentation for your Flash memory to see if ECC is supported. (ECC for read-write memory is
handled completely in hardware at run time.)
You can control the details of ECC generation using the ECC specifier in the memory map (Section 8.5.10.1)
and the ECC directive (Section 8.5.10.2).
See Section 8.4.12 for command-line options that introduce bit errors into code that has a corresponding ECC
section or into the ECC parity bits themselves. Use these options to test ECC error handling code.
ECC can be generated during linking. The ECC data is included in the resulting object file, alongside code
and data, as a data section located at the appropriate address. No extra ECC generation step is required after
compilation, and the ECC can be uploaded to the device along with everything else.
8.5.10.1 Using the ECC Specifier in the Memory Map
To generate ECC, add a separate memory range to your memory map to hold ECC data and to indicate which
memory range contains the Flash data that corresponds to this ECC data. If you have multiple memory ranges
for Flash data, you should add a separate ECC memory range for each Flash data range.
The definition of an ECC memory range can also provide parameters for how to generate the ECC data.
The memory map for a device supporting Flash ECC may look something like this:
MEMORY {
VECTORS : origin=0x00000000 length=0x000020
FLASH0 : origin=0x00000020 length=0x17FFE0
FLASH1 : origin=0x00180000 length=0x180000
STACKS : origin=0x08000000 length=0x000500
RAM : origin=0x08000500 length=0x03FB00
ECC_VEC : origin=0xf0400000 length=0x000004 ECC={ input_range=VECTORS }
ECC_FLA0 : origin=0xf0400004 length=0x02FFFC ECC={ input_range=FLASH0 }
ECC_FLA1 : origin=0xf0430000 length=0x030000 ECC={ input_range=FLASH1 }
}
230 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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 = <range> The data memory range covered by this ECC data range. Required.
input_page = <page number> The page number of the input range. Required only if the input range's name is ambiguous.
algorithm = <ECC alg name> The name of an ECC algorithm defined later in the command file using the ECC directive. Optional
if only one algorithm is defined. (See Section 8.5.10.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.10.3).
For example:
MEMORY {
FLASH0 : origin=0x00000020 length=0x17FFE0
ECC_FLA0 : origin=0xf0400004 length=0x02FFFC ECC={ input_range=FLASH0 algorithm=F021 }
}
ECC { F021 : parity_mask = 0xfc
mirroring = F021 }
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 231
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
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.
8.5.11 Assigning Symbols at Link Time
Linker assignment statements allow you to define external (global) symbols and assign values to them at link
time. You can use this feature to initialize a variable or pointer to an allocation-dependent value. See Section
8.6.1 for information about referring to linker symbols in C/C++ code.
8.5.11.1 Syntax of Assignment Statements
The syntax of assignment statements in the linker is similar to that of assignment statements in the C language:
symbol = expression; assigns the value of expression to symbol
symbol += expression; adds the value of expression to symbol
symbol -= expression; subtracts the value of expression from symbol
symbol *= expression; multiplies symbol by expression
symbol /= expression; divides symbol by expression
The symbol should be defined externally. If it is not, the linker defines a new symbol and enters it into the symbol
table. The expression must follow the rules defined in Section 8.5.11.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.c.obj /* Input file */
cur_tab = Table1; /* Assign cur_tab to one of the tables */
232 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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.12.
8.5.11.3 Assignment Expressions
These rules apply to linker expressions:
• Expressions can contain global symbols, constants, and the C language operators listed in Table 8-11.
• All numbers are treated as long (32-bit) integers.
• Constants are identified by the linker in the same way as by the assembler. That is, numbers are recognized
as decimal unless they have a suffix (H or h for hexadecimal and Q or q for octal). C language prefixes
are also recognized (0 for octal and 0x for hex). Hexadecimal constants must begin with a digit. No binary
constants are allowed.
• Symbols within an expression have only the value of the symbol's address. No type-checking is performed.
• Linker expressions can be absolute or relocatable. If an expression contains any relocatable symbols (and 0
or more constants or absolute symbols), it is relocatable. Otherwise, the expression is absolute. If a symbol
is assigned the value of a relocatable expression, it is relocatable; if it is assigned the value of an absolute
expression, it is absolute.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 233
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
The linker supports the C language operators listed in Table 8-11 in order of precedence. Operators in the
same group have the same precedence. Besides the operators listed in Table 8-11, the linker also has an align
operator that allows a symbol to be aligned on an n-byte boundary within an output section (n is a power of 2).
For example, the following expression aligns the SPC within the current section on the next 16-byte boundary.
Because the align operator is a function of the current SPC, it can be used only in the same context as . —that
is, within a SECTIONS directive.
. = align(16);
234 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
The linker automatically defines the following symbols for C/C++ support when the --ram_model or --rom_model
option is used.
__TI_STACK_SIZE is assigned the size of the .stack section. (EABI)
__TI_STACK_END is assigned the end of the .stack section. (EABI)
__TI_SYSMEM_SIZE is assigned the size of the .sysmem section. (EABI)
__STACK_SIZE is assigned the size of the .stack section. (COFF)
__STACK_END is assigned the end of the .stack section. (COFF)
__SYSMEM_SIZE is assigned the size of the .esysmem section. (COFF)
These linker-defined symbols can be accessed in any assembly language module if they are declared with
a .global directive (see Identify Global Symbols).
See Section 8.6.1 for information about referring to linker symbols in C/C++ code.
8.5.11.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 Moving a
Function from Slow to Fast Memory at Run Time) 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 Moving a Function from Slow to Fast Memory at Run Time.
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.
8.5.11.6 Why the Dot Operator Does Not Always Work
The dot operator (.) is used to define symbols at link-time with a particular address inside of an output section. It
is interpreted like a PC. Whatever the current offset within the current section is, that is the value associated with
the dot. Consider an output section specification within a SECTIONS directive:
outsect:
{
s1.c.obj(.text)
end_of_s1 = .;
start_of_s2 = .;
s2.c.obj(.text)
end_of_s2 = .;
}
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 235
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
section. One way to get around this problem is to create a dummy section immediately after the output section in
question. For example:
GROUP
{
outsect:
{
start_of_outsect = .;
...
}
dummy: { size_of_outsect = . - start_of_outsect; }
}
Note
Linker Command File Operator Equivalencies --
LOAD_START() and START() are equivalent, as are LOAD_END()/END() and LOAD_SIZE()/SIZE().
The LOAD names are recommended for clarity.
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.
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.
236 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
This can be rewritten using the START and END operators as follows:
outsect:
{
s1.c.obj(.text) { END(end_of_s1) }
s2.c.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.
8.5.11.7.2 Output Section
The START, END, and SIZE operators can also be associated with an output section. Here is an example:
outsect: START(start_of_outsect), SIZE(size_of_outsect)
{
<list of input items>
}
In this case, the SIZE operator defines size_of_outsect to incorporate any padding that is required in the output
section to conform to any alignment requirements that are imposed.
The syntax for specifying the operators with an output section does not require braces to enclose the operator
list. The operator list is simply included as part of the allocation specification for an output section.
8.5.11.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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 237
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
8.5.11.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.c.obj(.text) }
.text2: load = ROM, SIZE(text2_size) { f2.c.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.
8.5.11.8 LAST Operator
The LAST operator is similar to the START and END operators that were described previously. However, LAST
applies to a memory range rather than to a section. You can use it in a MEMORY directive to define a symbol
that can be used at run-time to learn how much memory was allocated when linking the program. See Section
8.5.4.2 for syntax details.
For example, a memory range might be defined as follows:
D_MEM : org = 0x20000020 len = 0x20000000 LAST(dmem_end)
Your C program can then access this symbol at runtime using the _symval operator. For example:
extern char dmem_end;
printf("End of D_MEM memory is %lx\n", _symval(&dmem_end));
See Section 8.6.1 for more information about referring to linker symbols in C/C++ code.
8.5.12 Creating and Filling Holes
The linker provides you with the ability to create areas within output sections that have nothing linked into them.
These areas are called holes. In special cases, uninitialized sections can also be treated as holes. This section
describes how the linker handles holes and how you can fill holes (and uninitialized sections) with values.
8.5.12.1 Initialized and Uninitialized Sections
There are two rules to remember about the contents of output sections. An output section contains either:
• Raw data for the entire section
• No raw data
A section that has raw data is referred to as initialized. This means that the object file contains the actual
memory image contents of the section. When the section is loaded, this image is loaded into memory at
the section's specified starting address. The .text and .data sections always have raw data if anything was
assembled into them. Named sections defined with the .sect assembler directive also have raw data.
By default, the .ebss or .bss section and sections defined with the .usect directive (see Reserve Uninitialized
Space) have no raw data (they are uninitialized). They occupy space in the memory map but have no actual
contents. Uninitialized sections typically reserve space in fast external memory for variables. In the object file,
an uninitialized section has a normal section header and can have symbols defined in it; no memory image,
however, is stored in the section.
238 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 239
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
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.c.obj(.text)
file1.c.obj(.ebss) /* This becomes a hole */
}
}
Because the .text section has raw data, all of outsect must also contain raw data. Therefore, the
uninitialized .ebss 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.
8.5.12.3 Filling Holes
When a hole exists in an initialized output section, the linker must supply raw data to fill it. The linker fills holes
with a 32-bit fill value that is replicated through memory until it fills the hole. The linker determines the fill value
as follows:
1. If the hole is formed by combining an uninitialized section with an initialized section, you can specify a
fill value for the uninitialized section. Follow the section name with an = sign and a 32-bit constant. For
example:
SECTIONS
{ outsect:
{
file1.c.obj(.text)
file2.c.obj(.ebss)= 0xFF00 /* Fill this hole with 0xFF00 */
}
}
2. You can also specify a fill value for all the holes in an output section by supplying the fill value after the
section definition:
SECTIONS
{ outsect:fill = 0xFF00 /* Fills holes with 0xFF00 */
{
. += 0x0010; /* This creates a hole */
file1.c.obj(.text)
file1.c.obj(.ebss) /* This creates another hole */
}
}
3. If you do not specify an initialization value for a hole, the linker fills the hole with the value specified with
the --fill_value option (see Section 8.4.14). For example, suppose the command file link.cmd contains the
following SECTIONS directive:
SECTIONS { .text: { .= 0x0100; } /* Create a 100 word hole */ }
240 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
Note
Filling Sections
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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 241
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
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
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
242 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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;
Note
Weak symbols are supported only in EABI mode.
In a linker command file, an assignment expression outside a MEMORY or SECTIONS directive can be used to
define a linker-defined symbol. 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. For example, you can define "ext_addr_sym" as follows:
weak(ext_addr_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.3 for details about how weak symbols are handled by the linker.
8.6.3 Resolving Symbols with Object Libraries
An object library is a partitioned archive file that contains object files as members. Usually, a group of related
modules are grouped together into a library. When you specify an object library as linker input, the linker includes
any members of the library that define existing unresolved symbol references. You can use the archiver to build
and maintain libraries. Section 7.1 contains more information about the archiver.
Using object libraries can reduce link time and the size of the executable module. Normally, if an object file that
contains a function is specified at link time, the file is linked whether the function is used or not; however, if that
same function is placed in an archive library, the file is included only if the function is referenced.
The order in which libraries are specified is important, because the linker includes only those members that
resolve symbols that are undefined at the time the library is searched. The same library can be specified as
often as necessary; it is searched each time it is included. Alternatively, you can use the --reread_libs option to
reread libraries until no more references can be resolved (see Section 8.4.17.3). A library has a table that lists all
external symbols defined in the library; the linker searches through the table until it determines that it cannot use
the library to resolve any more references.
The following examples link several files and libraries, using these assumptions:
• Input files f1.c.obj and f2.c.obj both reference an external function named clrscr.
• Input file f1.c.obj references the symbol origin.
• Input file f2.c.obj references the symbol fillclr.
• Member 0 of library libc.lib contains a definition of origin.
• Member 3 of library liba.lib contains a definition of fillclr.
• Member 1 of both libraries defines clrscr.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 243
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
If you enter:
cl2000 --run_linker f1.c.obj f2.c.obj liba.lib libc.lib
then:
• Member 1 of liba.lib satisfies the f1.c.obj and f2.c.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:
cl2000 --run_linker f1.c.obj f2.c.obj libc.lib liba.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.17 describes methods for specifying directories that contain object libraries.
8.7 Default Placement Algorithm
The MEMORY and SECTIONS directives provide flexible methods for building, combining, and allocating
sections. However, any memory locations or sections you choose not to specify must still be handled by the
linker. The linker uses algorithms to build and allocate sections in coordination with any specifications you do
supply.
If you do not use the MEMORY and SECTIONS directives, the linker allocates output sections as though
the memory map and section definitions were as shown in Default Allocation for TMS320C28x Devices were
specified.
Default Allocation for TMS320C28x Devices
MEMORY
{
PAGE 0: PROG: origin = 0x000040 length = 0x3fffc0
PAGE 1: DATA: origin = 0x000000 length = 0x010000
PAGE 1: DATA1: origin = 0x010000 length = 0x3f0000
}
SECTIONS
{
.text: PAGE = 0
.data: PAGE = 0
.cinit: PAGE = 0 /* Used only for C programs */
.ebss: PAGE = 1
}
244 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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.
8.7.1 How the Allocation Algorithm Creates Output Sections
An output section can be formed in one of two ways:
Method 1 As the result of a SECTIONS directive definition
Method 2 By combining input sections with the same name into an output section that is not defined in a SECTIONS directive
If an output section is formed as a result of a SECTIONS directive, this definition completely determines the
section's contents. (See Section 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.c.obj and f2.c.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.34) 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 Default Allocation for TMS320C28x Devices. (See Section 8.5.4
for more information on configuring memory.)
8.7.2 Reducing Memory Fragmentation
The linker's allocation algorithm attempts to minimize memory fragmentation. This allows memory to be used
more efficiently and increases the probability that your program will fit into memory. The algorithm comprises
these steps:
1. Each output section for which you supply a specific binding address is placed in memory at that address.
2. Each output section that is included in a specific, named memory range or that has memory attribute
restrictions is allocated. Each output section is placed into the first available space within the named area,
considering alignment where necessary.
3. Any remaining sections are allocated in the order in which they are defined. Sections not defined in a
SECTIONS directive are allocated in the order in which they are encountered. Each output section is placed
into the first available memory space, considering alignment where necessary.
8.8 Using Linker-Generated Copy Tables
The linker supports extensions to the linker command file syntax that enable the following:
• Make it easier for you to copy objects from load-space to run-space at boot time
• Make it easier for you to manage memory overlays at run time
• Allow you to split GROUPs and output sections that have separate load and run addresses
For an introduction to copy tables and their use, see Section 3.3.3.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 245
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
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.11.7.
246 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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.
8.8.4 Generating Copy Tables With the table() Operator
The linker supports extensions to the linker command file syntax that enable you to do the following:
• Identify any object components that may need to be copied from load space to run space at some point
during the run of an application
• Instruct the linker to automatically generate a copy table that contains (at least) the load address, run
address, and size of the component that needs to be copied
• Instruct the linker to generate a symbol specified by you that provides the address of a linker-generated copy
table. For instance, Using a UNION for Memory Overlay can be written as shown in Produce Address for
Linker Generated Copy Table:
Produce Address for Linker Generated Copy Table
SECTIONS
{
...
UNION
{
GROUP
{
.task1: { task1.c.obj(.text) }
.task2: { task2.c.obj(.text) }
} load = ROM, table(_task12_copy_table)
GROUP
{
.task3: { task3.c.obj(.text) }
.task4: { task4.c.obj(.text) }
} load = ROM, table(_task34_copy_table)
} run = RAM
...
}
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 247
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
Using the SECTIONS directive from Produce Address for Linker Generated Copy Table 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.
8.8.4.1 The table() Operator
You can use the table() operator to instruct the linker to produce a copy table. A table() operator can be
applied to an output section, a GROUP, or a UNION member. The copy table generated for a particular table()
specification can be accessed through a symbol specified by you that is provided as an argument to the table()
operator. The linker creates a symbol with this name and assigns it the address of the copy table as the value of
the symbol. The copy table can then be accessed from the application using the linker-generated symbol.
Each table() specification you apply to members of a given UNION must contain a unique name. If a table()
operator is applied to a GROUP, then none of that GROUP's members may be marked with a table()
specification. The linker detects violations of these rules and reports them as warnings, ignoring each offending
use of the table() specification. The linker does not generate a copy table for erroneous table() operator
specifications.
Copy tables can be generated automatically; see Section 8.8.4. The table operator can be used with
compression; see Section 8.8.5.
8.8.4.2 Boot-Time Copy Tables
The linker supports a special copy table name, BINIT (or binit), that you can use to create a boot-time copy table.
This table is handled before the .cinit section is used to initialize variables at startup. For example, the linker
command file for the boot-loaded application described in Section 8.8.2 can be rewritten as follows:
SECTIONS
{
.flashcode: { app_tasks.c.obj(.text) }
load = FLASH, run = PMEM,
table(BINIT)
...
}
For this example, the linker creates a copy table that can be accessed through a special linker-generated
symbol, __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.
8.8.4.3 Using the table() Operator to Manage Object Components
If you have several pieces of code that need to be managed together, then you can apply the same table()
operator to several different object components. In addition, if you want to manage a particular object component
in multiple ways, you can apply more than one table() operator to it. Consider the linker command file excerpt in
Linker Command File to Manage Object Components:
248 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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.
8.8.4.4 Linker-Generated Copy Table Sections and Symbols
The linker creates and allocates a separate input section for each copy table that it generates. Each copy table
symbol is defined with the address value of the input section that contains the corresponding copy table.
The linker generates a unique name for each overlay copy table input section. For example, table(_first_ctbl)
would place the copy table for the .first section into an input section called .ovly:_first_ctbl. The linker creates a
single input section, .binit, to contain the entire boot-time copy table.
Controlling the Placement of the Linker-Generated Copy Table Sections illustrates how you can control the
placement of the linker-generated copy table sections using the input section names in the linker command file.
Controlling the Placement of the Linker-Generated Copy Table Sections
SECTIONS
{
UNION
{
.first: { a1.c.obj(.text), b1.c.obj(.text), c1.c.obj(.text) }
load = EMEM, run = PMEM, table(BINIT), table(_first_ctbl)
.second: { a2.c.obj(.text), b2.c.obj(.text) }
load = EMEM, run = PMEM, table(_second_ctbl)
}
.extra: load = EMEM, run = PMEM, table(BINIT)
...
.ovly: { } > BMEM
.binit: { } > BMEM
}
For the linker command file in Controlling the Placement of the Linker-Generated Copy Table Sections, 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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 249
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
Split Object Component Driver illustrates a possible driver for such an application.
Split Object Component Driver
#include <cpy_tbl.h>
extern COPY_TABLE task13_ctbl;
extern COPY_TABLE task47_ctbl;
extern void task1(void);
...
extern void task7(void);
main()
{
...
copy_in(&task13_ctbl);
task1();
task2();
task3();
...
copy_in(&task47_ctbl);
task4();
task5();
task6();
task7();
...
}
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.
250 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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.
Copy table compression is supported only when you use EABI object modules by specifying the --abi=eabi
option. This feature is not supported for COFF object modules.
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.
– lzss. Compress data using Lempel-Ziv-Storer-Szymanski compression.
– rle. Compress data using Run Length Encoding.
A table() operator without the compression keyword uses the compression kind specified using the command
line option --copy_compression. If no compression_kind was specified with the command-line option, the default
is LZSS 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.
8.8.5.1 Compressed Copy Table Format
The copy table format is the same irrespective of the compression_kind. The size field of the copy record is
overloaded to support compression. Figure 8-7 illustrates the compressed copy table layout.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 251
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
In Figure 8-7, 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.
8.8.5.2 Compressed Section Representation in the Object File
The linker creates a separate input section to hold the compressed data. Consider the following table() operation
in the linker command file.
SECTIONS
{
.task1: load = ROM, run = RAM, table(_task1_table)
}
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.
Alternatively, consider the following:
SECTIONS
{
.task1: load = ROM, run = RAM, table(_task1_table, compression=rle)
}
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.
8.8.5.3 Compressed Data Layout
For C2000, the unit size is 16-bits, which is the size of an unsigned char type on C2000. For compressed data
sections on C2000, all data is stored in 16-bit units.
The compressed load data has the following layout:
16-bit index Compressed data
The first 16 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-8.
_TI_Handler_Table_Base:
32-bit handler address 1
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().
252 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
The data following the 16-bit index is compressed using run length encoded (RLE) format. C2000 uses a simple
run length encoding that can be decompressed using the following algorithm. See copy_decompress_rle.c for
details.
1. Read the first 16 bits, Delimiter (D).
2. Read the next 16 bits (B).
3. If B != D, copy B to the output buffer and go to step 2.
4. Read the next 16 bits (L).
a. If L == 0, then length is either a 32 bit value or we’ve reached the end of the data, read the next 16 bits
(L).
i. If L == 0, the end of the data is reached. Go to the "end of processing" step.
ii. If L !=0, then L is the most significant 16-bits of the 32-bit run length, L.hi. Read the next 16-bits,
which is L.lo. Concatenate L.hi with L.lo to form the 32-bit run length.
b. Else if L > 0 and L < 4, copy D to the output buffer L times. Go to step 2.
c. Else, length is 16-bit value (L).
5. Read the next 16 bits (C); C is the repeat character.
6. Write C to the output buffer L times; go to step 2.
7. End of processing.
The C2000 run-time support library has a routine __TI_decompress_rle() to decompress data compressed using
RLE. The first argument to this function is the address pointing to the 16 bits after the 16-bit index. The second
argument is the run address from the C auto initialization record.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 253
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
The data following the 8-bit index is compressed using LZSS compression. The C2000 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 16 bits after the 16-bit Index, and the second argument is the run
address from the C auto initialization record.
The decompression algorithm for LZSS is as follows. See copy_decompress_lzss.c for details on the LZSS
algorithm.
1. Read 16 bits, which are the encoding flags (F) marking the start of the next LZSS encoded packet.
2. For each bit (B) in F, starting from the least significant to the most significant bit, do the following:
a. If (B & 0x1), read the next 16 bits and write it to the output buffer. Then advance to the next bit (B) in F
and repeat this step.
b. Else read the next 16-bits into temp (T), length (L) = (T & 0xf) + 2, and offset (O) = (T >> 4).
i. If L == 17, read the next 16-bits (L'); then L += L'.
ii. If O == LZSS end of data (LZSS_EOD), we've reached the end of the data, and the algorithm is
finished.
iii. At position (P) = output buffer - Offset (O) - 1, read L bytes from position P and write them to the
output buffer.
iv. Go to step 2a.
254 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
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 page id
• The run page id
• The load address
• The run address
• The size
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 255
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
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 page id of .first>,
<run page id of .first>,
<load address of .first>,
<run address of .first>,
<size of .first> },
{ <load page id of .extra>,
<run page id of .extra>,
<load address of .extra>,
<run address of .extra>,
<size of .extra> } };
The load (or source) page id and the run (or destination) page id are used to choose which low-level copy
routine is called to move a word of data from the load location to the run location. A page id of 0 indicates that
the specified address is in program memory, and a page id of 1 indicates that the address is in data memory.
The hardware provides special instructions, PREAD and PWRITE, to move code/data into and out of program
memory.
256 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 257
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
The supported CRC algorithms are specified by published standards, including the Powerline Related Intelligent
Metering Evolution (PRIME) standard and IEEE 802.15.4. The Viterbi, Complex Math and CRC Unit (VCU)
module available on some C28x devices provides efficient instructions for CRC calculation using these
algorithms. You might want to take advantage of the VCU module to compute the CRC at run time. For details,
see the VCU module documentation in TMS320x28xx, 28xxx DSP Peripherals Reference Guide (SPRU566).
There are also restrictions which will be enforced by the linker:
• CRC can only be requested at final link time.
• CRC can only be applied to initialized sections.
• CRC can be requested for load addresses only.
• Certain restrictions also apply to CRC table names.
8.9.1.2 Examples
The crc_table() operator is similar in syntax to the table() operator used for copy tables. A few simple examples
of linker command files follow.
Example 8-7. Using crc_table() Operator to Compute the CRC Value for .text Data
SECTIONS
{
...
.section_to_be_verified: {a1.c.obj(.text)} crc_table(_my_crc_table_for_a1)
}
Example 8-7 defines a section named “.section_to_be_verified”, which contains the .text data from the a1.c.obj
file. The crc_table() operator requests that the linker compute the CRC value for the .text data and store that
value in a table named “my_crc_table_for_a1”. This table will contain all the information needed to invoke a user-
supplied CRC calculation routine, and verify that the CRC calculated at run time matches the linker-generated
CRC. The table can be accessed from application code using the symbol my_crc_table_for_a1, which should
be declared of type “extern CRC_TABLE”. This symbol will be defined by the linker. The application code might
resemble the following.
#include "crc_tbl.h"
extern CRC_TABLE my_crc_table_for_a1;
verify_a1_text_contents()
{
...
/* Verify CRC value for .text sections of a1.c.obj. */
if (my_check_CRC(&my_crc_table_for_a1)) puts("OK");
}
...
SECTIONS
{
...
.section_to_be_verified_2: {b1.c.obj(.text)} load=SLOW_MEM, run=FAST_MEM,
crc_table(_my_crc_table_for_b1, algorithm=CRC8_PRIME)
.TI.crctab: > CRCMEM
}
...
258 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
In Example 8-8, the CRC algorithm is specified in the crc_table() operator. The specified algorithm is used to
compute the CRC of the text data from b1.c.obj. The CRC tables generated by the linker are created in the
special section .TI.crctab, which can be placed in the same manner as other sections. In this case, the CRC
table _my_crc_table_for_b1 is created in section .TI.crctab:_my_crc_table_for_b1, and that section is placed in
the CRCMEM memory region.
Example 8-9. Using a Single Table for Multiple Sections
...
SECTIONS
{
.section_to_be_verified_1: {a1.c.obj(.text)}
crc_table(_my_crc_table_for_a1_and_c1)
.section_to_be_verified_3: {c1.c.obj(.text)}
crc_table(_my_crc_table_for_a1_and_c1, algorithm=CRC16_802_15_4)
}
...
In Example 8-9 the same identifier, _my_crc_table_for_a1_and_c1, is specified for both a1.c.obj and c1.c.obj.
The linker creates a single table that contains entries for both text sections. Multiple CRC algorithms can occur in
a single table. In this case, _my_crc_table_for_a1_and_c1 contains an entry for the text data from a1.c.obj using
the default CRC algorithm, and an entry for the text data from c1.c.obj using the CRC16_802_15_4 algorithm.
The order of the entries is unspecified.
Example 8-10. Applying the crc_table() Operator to a GROUP or UNION
...
SECTIONS
{
UNION
{
section1: {} crc_table(table1, algorithm=CRC16_ALT)
section2:
} crc_table(table2, algorithm=CRC32_PRIME)
}
When the crc_table() operator is applied to a GROUP or a UNION, the linker applies the table specification to
the members of the GROUP or UNION.
In Example 8-10 the linker creates two CRC tables, table1 and table2. table1 contains one entry for section1,
using algorithm CRC16_ALT. Because both sections are members of the UNION, table2 contains entries for
section1 and section2, using algorithm CRC32_PRIME. The order of the entries in table2 is unspecified.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 259
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
table_name rec_size=8
The crc_tbl.h header file is included in Example 8-11. This file specifies the C structures created by the
linker to manage CRC information. It also includes the specifications of the supported CRC algorithms. A full
discussion of CRC algorithms is beyond the scope of this document, and the interested reader should consult
the referenced document for a description of the fields shown in the table. The following fields are relevant to this
document.
• Name – text identifier of the algorithm, used by the programmer in the linker command file.
• ID – the numeric identifier of the algorithm, stored by the linker in the crc_alg_ID member of each table entry.
• Order – the number of bits used by the CRC calculation.
• Polynomial – used by the CRC computation engine.
• Initial Value – the initial value given to the CRC computation engine.
In the CRC_TABLE struct, the array recs[1] is dynamically sized by the linker to accommodate the number of
records contained in the table (num_recs). A user-supplied routine to verify CRC values should take a table
name and check the CRC values for all entries in the table. An outline of such a routine is shown in Appendix
C.3.
260 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
/*****************************************************************************/
/* crc_tbl.h */
/* */
/* PRELIMINARY - SUBJECT TO CHANGE */
/* Specification of CRC table data structures which can be automatically */
/* generated by the linker (using the crc_table() operator in the linker */
/* command file). */
/*****************************************************************************/
/* The CRC generator used by the linker is based on concepts from the */
/* document: */
/* "A Painless Guide to CRC Error Detection Algorithms" */
/* */
/* Author : Ross Williams ([email protected].). */
/* Date : 3 June 1993. */
/* Status : Public domain (C code). */
/* */
/* Description : For more information on the Rocksoft^tm Model CRC */
/* Algorithm, see the document titled "A Painless Guide to CRC Error */
/* Detection Algorithms" by Ross Williams ([email protected].). */
/* This document is likely to be in "ftp.adelaide.edu.au/pub/rocksoft" or */
/* at http:www.ross.net/crc/download/crc_v3.txt. */
/* */
/* Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia. */
/*****************************************************************************/
#include <stdint.h> /* For uintXX_t */
/*****************************************************************************/
/* CRC Algorithm Specifiers */
/* */
/* The following specifications, based on the above cited document, are used */
/* by the linker to generate CRC values. */
/* */
/* ID Name Order Polynomial Initial Ref Ref CRC XOR Zero */
/* Value In Out Value Pad */
/*-------------------------------------------------------------------------- */
/* 0, "CRC32_PRIME", 32, 0x04c11db7, 0x00000000, 0, 0, 0x00000000, 1 */
/* 1, "CRC16_802_15_4", 16, 0x00001021, 0x00000000, 0, 0, 0x00000000, 1 */
/* 2, "CRC16_ALT", 16, 0x00008005, 0x00000000, 0, 0, 0x00000000, 1 */
/* 3, "CRC8_PRIME", 8, 0x00000007, 0x00000000, 0, 0, 0x00000000, 1 */
/* */
/* Users should specify the name, such as CRC32_PRIME, in the linker command */
/* file. The resulting CRC_RECORD structure will contain the corresponding */
/* ID value in the crc_alg_ID field. */
/*****************************************************************************/
#define CRC32_PRIME 0 /* Poly = 0x04c11db7 */ /* DEFAULT ALGORITHM */
#define CRC16_802_15_4 1 /* Poly = 0x00001021 */
#define CRC16_ALT 2 /* Poly = 0x00008005 */
#define CRC8_PRIME 3 /* Poly = 0x00000007 */
/*********************************************************/
/* CRC Record Data Structure */
/* NOTE: The list of fields and the size of each field */
/* varies by target and memory model. */
/*********************************************************/
typedef struct crc_record
{
uint16_t crc_alg_ID; /* CRC algorithm ID */
uint16_t page_id; /* page number of data */
uint32_t addr; /* Starting address */
uint32_t size; /* size of data in 16-bit units */
uint32_t crc_value;
} CRC_RECORD;
/*********************************************************/
/* CRC Table Data Structure */
/*********************************************************/
typedef struct crc_table
{
uint16_t rec_size;
uint16_t num_recs;
CRC_RECORD recs[1];
} CRC_TABLE;
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 261
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
This syntax causes the linker to compute a single CRC over both RANGE1 and RANGE2. The CRC is based
on the algorithm specified, taking into account all output sections that have been placed in those ranges. The
result is stored in a table in the format described in Section 8.9.2.6. This table is placed in an output section
called .TI.memcrc, which is accessible through the table name as a linker symbol.
The algorithm argument for crc() may be any algorithm listed in Section 8.9.1.1. The algorithm is required in the
current version, and linking will fail without it. In future releases, the algorithm specification will be optional, and
the default is specified If no algorithm is specified, the default algorithm will be chosen, which is CRC32_PRIME.
Specifying the GROUP name is optional. For example:
MEMORY
{
GROUP
{
RANGE1 :...
RANGE2 :...
} crc(_table_name, algorithm=CRC8_PRIME)
}
When GROUP is used inside a MEMORY block, the syntax options are limited to the functionality described
here and in the subsections that follow. The full functionality described in Section 8.5.7 for GROUP within the
SECTIONS directive is not available within the MEMORY directive.
8.9.2.1 Restrictions when Using the crc() Operator
The crc() operator can only be applied to a GROUP within a MEMORY directive. It cannot be applied to
individual memory ranges in a MEMORY directive or to groups in the SECTIONS directive.
Along with the restrictions described in Section 8.9.1.1, the following additional restrictions apply:
• Memory range groups cannot contain any gaps between the ranges.
• All of the memory ranges must be on the same page.
• Memory ranges that contain sections that would not otherwise be eligible for CRC table generation cannot
have a CRC computed. That is, memory ranges for which a CRC value is generated must correspond only to
load addresses of initialized sections.
• The .TI.memcrc section may not be placed in a range that itself is having a CRC value computed. This would
result in a circular reference; the CRC result would depend upon the result of the CRC. See Section 8.9.2.3
for ways to generate CRCs for most or all of Flash memory without violating this restriction.
262 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
If no VFILL parameter is specified, it defaults to 0x1, which fills everything with ones. Remember to update every
memory range that has a fill value other than 0x1 for CRCs.
8.9.2.3 Generate CRC for Most or All of Flash Memory
If you are trying to generate a CRC value for the entire FLASH memory, place the table in a separate memory
range, which .TI.memcrc will be placed in by default. For example:
MEMORY
{
/* Carve out a section of FLASH to store the CRC result */
CRC_PRELUDE : origin=0x0, length=0x10
GROUP
{
FLASH : origin=0x10, length=0xFFFF
} crc(_flash_crc, algorithm=CRC8_PRIME)
/* Other memory ranges... */
}
SECTION
{
.TI.memcrc > CRC_PRELUDE
}
In the above example, a small section of flash has been cut out of the whole, to allow the .TI.memcrc section to
reside there, while everything else that is eligible for CRC generation is placed in FLASH. This avoids placing the
CRC result in the CRC range.
In some cases, you may want to generate a CRC for all of Flash memory and read back the CRC result via the
linker-generated map file (see Section 8.4.19). However, there is no memory location to place the CRC result for
the memory range covering all of Flash memory. If you place it in Flash, then you violate the rule that the result
cannot be placed within the input range. Thus, if there’s no good place to put the CRC result, you can mark
the .TI.memcrc section as a COPY section like so:
.TI.memcrc : type=COPY
This prevents the CRC result for a memory range from being placed anywhere. Marking .TI.memcrc as a
DSECT section has the same result.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 263
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
MEMORY
{
PAGE 0:
STACK (RW) : origin = 0x008000, length = 0x008000
SMALLROM (R) : origin = 0x000402, length = 0x0003FE
ROMCRC (R) : origin = 0x080000, length = 0x000100
GROUP(FLASH)
{
BIGROM (R) : origin = 0x080100, length = 0x01FF00, VFILL=0x0
} crc(_ext_memrange_crc, algorithm=CRC8_PRIME)
BIGRAM (RW) : origin = 0x100000, length = 0x200000
}
SECTIONS
{
.stack > STACK
.args > BIGRAM
.bss > BIGRAM
.ebss > BIGRAM
.cio > BIGRAM
.data > BIGRAM
264 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
The table header stores the record count and size, as well as the algorithm type and the CRC result. Each table
entry encodes the start address and length of a memory range that was used to compute the CRC.
The following header file excerpt shows the C structures the linker creates to manage the CRC information:
typedef struct memrange_crc_record {
uint16_t page_id; /* page number of data */
uint16_t padding; /* pad for next 32-bit value */
uint32_t addr; /* starting address */
uint32_t size; /* size of data in 16-bit addressable units */
} MEMRANGE_CRC_RECORD;
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 265
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
1 9 16 1 8
2 9 16 1 8
High Memory
266 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
The --rom_model option tells the linker to use special conventions that are defined by the C/C++ environment.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 267
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
Note
Linking the .stack Section: The .stack section must be linked into the low 64K of data memory
(PAGE 1) since the SP is a 16-bit register and cannot access memory locations beyond the first 64K.
268 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 269
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
Linker Command File, demo.cmd shows the linker command file for this example. Output Map File, demo.map
shows the map file.
Linker Command File, demo.cmd
/***************************************************************/
/*** Specify Linker Options ***/
/***************************************************************/
--output_file=demo.out /* Name the output file */
--map_file=demo.map /* Create an output map */
/***************************************************************/
/*** Specify the Input Files ***/
/***************************************************************/
demo.c.obj
fft.c.obj
tables.c.obj
/***************************************************************/
/*** Specify the Memory Configuration ***/
/***************************************************************/
MEMORY
{
PAGE 0: SLOW_MEM (R): origin=0x3f0000 length=0x00ffc0
VECTORS (R): origin=0x3fffc0 length=0x000040
PAGE 1: STACK (RW): origin=0x000040 length=0x0001c0
FAST_MEM_1 (RW): origin=0x000200 length=0x000600
FAST_MEM_2 (RW): origin=0x3ed000 length=0x003000
}
/***************************************************************/
/*** Specify the Output Sections ***/
/***************************************************************/
SECTIONS
{
vectors : { } > VECTORS page=0
.text : load = SLOW_MEM, page = 0 /* link in .text */
.data : fill = 07A1Ch, Load=FAST_MEM_1, page=1
{
tables.c.obj(.data) /* .data input */
fft.c.obj(.data) /* .data input */
. += 100h; /* create hole, fill with 0x07A1C */
}
var_defs : { } > FAST_MEM_2 page=1 /* defs in RAM */
.ebss : page=1, fill=0x0ffff /*.ebss fill and link*/
}
/***************************************************************/
/*** End of Command File ***/
/***************************************************************/
This creates the map file shown in Output Map File, demo.map and an output file called demo.out that can be
run on a TMS320C28x.
270 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Linker Description
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 271
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Linker Description www.ti.com
272 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Absolute Lister Description
Chapter 9
Absolute Lister Description
The TMS320C28x absolute lister is a debugging tool that accepts linked object files as input and creates .abs
files as output. These .abs files can be assembled to produce a listing that shows the absolute addresses of
object code. Manually, this could be a tedious process requiring many operations; however, the absolute lister
utility performs these operations automatically.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 273
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Absolute Lister Description www.ti.com
Assembler
Object
file
Step 2: Link the resulting object file.
Linker
Linked object
file
Step 3: Invoke the absolute lister; use the linked
object file as input. This creates a file with
Absolute an .abs extension.
lister
.abs
file
Step 4: Finally, assemble the .abs file; you must
invoke the assembler with the compiler
Assembler --absolute_listing option.
274 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Absolute Lister Description
The . in the extensions and the space between the option and the extension are optional.
-fs specifies a directory for the output files. For example, to place the .abs file generated by the absolute lister in
C:\ABSDIR use this command:
abs2000 -fs C:\ABSDIR filename.out
If the -fs option is not specified, the absolute lister generates the .abs files in the current directory.
-q (quiet) suppresses the banner and all progress information.
input file names the linked object file. If you do not supply an extension, the absolute lister assumes that the input file has the
default extension .out. If you do not supply an input filename when you invoke the absolute lister, the absolute lister
prompts you for one.
The absolute lister produces an output file for each file that was linked. These files are named with the input
filenames and an extension of .abs. Header files, however, do not generate a corresponding .abs file.
Assemble these files with the --absolute_listing assembler option as follows to create the absolute listing:
cl2000 --absolute_listing filename .abs
The -e options affect both the interpretation of filenames on the command line and the names of the output files.
They should always precede any filename on the command line.
The -e options are useful when the linked object file was created from C files compiled with the debugging
option (--symdebug:dwarf compiler option). When the debugging option is set, the resulting linked object file
contains the name of the source files used to build it. In this case, the absolute lister does not generate a
corresponding .abs file for the C header files. Also, the .abs file corresponding to a C source file uses the
assembly file generated from the C source file rather than the C source file itself.
For example, suppose the C source file hello.csr is compiled with the debugging option set; the debugging option
generates the assembly file hello.s. The hello.csr file includes hello.hsr. Assuming the executable file created is
called hello.out, the following command generates the proper .abs file:
abs2000 -ea s -ec csr -eh hsr hello.out
An .abs file is not created for hello.hsr (the header file), and hello.abs includes the assembly file hello.s, not the
C source file hello.csr.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 275
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Absolute Lister Description www.ti.com
module2.asm
offset .usect ".ebss", 2
.copy globals.def
MOV ACC, #offset
MOV ACC, #array
globals.def
.global dflag
.global array
.global offset
The following steps create absolute listings for the files module1.asm and module2.asm:
Step 1: First, assemble module1.asm and module2.asm:
cl2000 module1
cl2000 module2
This creates two object files called module1.obj and module2.obj.
Step 2: Next, link module1.obj and module2.obj using the following linker command file, called bttest.cmd:
--output_file=bttest.out
--map_file=bttest.map
module1.obj
module2.obj
MEMORY
{
PAGE 0: ROM: origin=2000h length=2000h
PAGE 1: RAM: origin=8000h length=8000h
}
SECTIONS
{
.data: >RAM
.text: >ROM
.ebss: >RAM
}
276 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Absolute Lister Description
.nolist
array .setsym 000008000h
dflag .setsym 000008064h
offset .setsym 000008066h
.data .setsym 000008000h
edata .setsym 000008000h
.text .setsym 000002000h
etext .setsym 000002008h
.usect .setsym 000008000h
end .setsym 000008068h
.setsect ".text",000002000h
.setsect ".data",000008000h
.setsect ".ebss",00008000h
.list
.text
.copy "module1.asm"
module2.abs:
.nolist
array .setsym 000008000h
dflag .setsym 000008064h
offset .setsym 000008066h
.data .setsym 000008000h
edata .setsym 000008000h
.text .setsym 000002000h
etext .setsym 000002008h
.usect .setsym 000008000h
end .setsym 000008068h
.setsect ".text",000002004h
.setsect ".data",000008000h
.setsect ".ebss",00008066h
.list
.text
.copy "module2.asm"
These files contain the following information that the assembler needs for Step 4:
• They contain .setsym directives, which equate values to global symbols. Both files contain global equates for the symbol
dflag. The symbol dflag was defined in the file globals.def, which was included in module1.asm and module2.asm.
• They contain .setsect directives, which define the absolute addresses for sections.
• They contain .copy directives, which defines the assembly language source file to include.
The .setsym and .setsect directives are useful only for creating absolute listings, not normal assembly.
Step 4: Finally, assemble the .abs files created by the absolute lister (remember that you must use the --absolute_listing option
when you invoke the assembler):
cl2000 --absolute_listing module1.abs
cl2000 --absolute_listing module2.abs
This command sequence creates two listing files called module1.lst and module2.lst; no object code is produced. These
listing files are similar to normal listing files; however, the addresses shown are absolute addresses.
The absolute listing files created are module1.lst (see module1.lst ) and module2.lst (see module2.lst).
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 277
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Absolute Lister Description www.ti.com
module1.lst
module1.abs PAGE 1
15 002000 .text
16 .copy "module1.asm"
1 002000 .text
2 008000 array .usect ".ebss",100
3 008064 dflag .usect ".ebss",2
4 .copy globals.def
1 .global dflag
2 .global array
3 .global offset
5 002000 FF20! MOV ACC,#offset
002001 8066
6 002002 FF20- MOV ACC,#dflag
002003 8064
module2.lst
module2.abs PAGE 1
15 002004 .text
16 .copy "module2.asm"
1 008066 offset .usect ".ebss",2
2 .copy globals.def
1 .global dflag
2 .global array
3 .global offset
3 002004 FF20- MOV ACC,#offset
002005 8066
4 002006 FF20! MOV ACC,#array
002007 8000
278 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Cross-Reference Lister Description
Chapter 10
Cross-Reference Lister Description
The TMS320C28x cross-reference lister is a debugging tool. This utility accepts linked object files as input and
produces a cross-reference listing as output. This listing shows symbols, their definitions, and their references in
the linked source files.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 279
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Cross-Reference Lister Description www.ti.com
Linked object
file
Step 3: Invoke the cross-reference lister. The
following section provides the command
Cross-reference syntax for invoking the cross-reference lister
lister utility.
Cross-reference
listing
280 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Cross-Reference Lister Description
options identifies the cross-reference lister options you want to use. Options are not case sensitive and can appear anywhere
on the command line following the command.
-l (lowercase L) specifies the number of lines per page for the output file. The format of the -l option is -lnum,
where num is a decimal constant. For example, -l30 sets the number of lines per page in the output file to 30.
The space between the option and the decimal constant is optional. The default is 60 lines per page.
-q suppresses the banner and all progress information (run quiet).
input filename is a linked object file. If you omit the input filename, the utility prompts for a filename.
output filename is the name of the cross-reference listing file. If you omit the output filename, the default filename is the input
filename with an .xrf extension.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 281
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Cross-Reference Lister Description www.ti.com
282 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Object File Utilities
Chapter 11
Object File Utilities
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 283
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Object File Utilities www.ti.com
ofd2000 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.
--call_graph 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 ofd2000 --dwarf_display=help.
--dwarf Appends DWARF debug information to program output.
--help Displays help
--output=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", ofd2000 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 ofd2000
--obj_display=help.
--verbose Prints verbose text output.
--xml 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.
284 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Object File Utilities
Note
Object File Display Format: The object file display utility produces data in a text format by default.
This data is not intended to be used as input to programs for further processing of the information.
XML format should be used for mechanical processing.
For COFF, this is a COFF object file (.obj) or an executable file (.out).
output filename is the name of the optional output file to which the disassembly will be written. If an output filename is not specified,
the disassembly is written to standard output.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 285
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Object File Utilities www.ti.com
286 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
Chapter 12
Hex Conversion Utility Description
The TMS320C28x 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 16-bit addresses (see Section 12.15.1)
• Binary file in 8-bit format (see Section 12.3.2)
• Extended Tektronix (Tektronix) (see Section 12.15.4)
• Intel MCS-86 (Intel) (see Section 12.15.2)
• Motorola Exorciser (Motorola-S), supporting 16-bit addresses (see Section 12.15.3)
• Texas Instruments SDSMAC (TI-Tagged), supporting 16-bit addresses (see Section 12.15.5)
• Texas Instruments TI-TXT format, supporting 16-bit addresses (see Section 12.15.6)
• C arrays
12.1 The Hex Conversion Utility's Role in the Software Development Flow.............................................................288
12.2 Invoking the Hex Conversion Utility..................................................................................................................... 289
12.3 Understanding Memory Widths.............................................................................................................................293
12.4 The ROMS Directive............................................................................................................................................... 297
12.5 The SECTIONS Directive........................................................................................................................................300
12.6 The Load Image Format (--load_image Option)...................................................................................................302
12.7 Excluding a Specified Section.............................................................................................................................. 303
12.8 Assigning Output Filenames.................................................................................................................................303
12.9 Image Mode and the --fill Option...........................................................................................................................304
12.10 Array Output Format............................................................................................................................................ 305
12.11 Building a Table for an On-Chip Boot Loader.................................................................................................... 305
12.12 Using Secure Flash Boot on TMS320F2838x Devices...................................................................................... 312
12.13 Controlling the ROM Device Address.................................................................................................................313
12.14 Control Hex Conversion Utility Diagnostics...................................................................................................... 314
12.15 Description of the Object Formats......................................................................................................................315
12.16 Hex Conversion Utility Error Messages............................................................................................................. 321
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 287
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
12.1 The Hex Conversion Utility's Role in the Software Development Flow
Figure 12-1 highlights the role of the hex conversion utility in the software development process.
C
source
files
Macro C2xx
source C/C++
compiler assembler
files source
Assembler Transition
Archiver
source assistant
Macro Assembler
library Assembler
source
Object Library-build
Archiver files utility
Debugging
tools
Library of Run-time-
object support
files Linker library
Post-link
optimizer
Executable
object file
Hex-conversion
utility
Figure 12-1. The Hex Conversion Utility in the TMS320C28x Software Development Flow
288 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
• Specify the options and filenames in a command file. You can create a file that stores command line
options and filenames for invoking the hex conversion utility. The following example invokes the utility using a
command file called hexutil.cmd:
hex2000 hexutil.cmd
In addition to regular command line information, you can use the hex conversion utility ROMS and SECTIONS
directives in a command file.
12.2.1 Invoking the Hex Conversion Utility From the Command Line
To invoke the hex conversion utility, enter:
hex2000 [options] filename
filename names an object file or a command file (for more information, see Section 12.2.2).
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 289
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
290 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 291
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
To invoke the utility and use the options you defined in a command file, enter:
hex2000 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:
hex2000 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 */
• 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, .econst:
}
292 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
Output file(s)
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 293
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
Note
Binary Format is 8 Bits Wide: You cannot change the memory width of the Binary format. The Binary
hex format supports an 8-bit memory width only. See Section 12.15.6 for more about using the ROMS
directive with an 8-bit format.
Note
TI-TXT Format is 8 Bits Wide: You cannot change the memory width of the TI-TXT format. The
TI-TXT hex format supports an 8-bit memory width only. See Section 12.15.6 for more about using the
ROMS directive with the TI-TXT hex format.
Figure 12-3 demonstrates how the memory width is related to object file data.
Source file
.word 0 AABBh
.word 01122h
AA BB
11 22
AABB AA
Data after
phase I of 1122 BB
hex2000
11
22
294 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
The default ROM width that the hex conversion utility uses depends on the output format:
• All hex formats except TI-Tagged are configured as lists of 8-bit bytes; the default ROM width for these
formats is 8 bits.
• TI-Tagged is a 16-bit format; the default ROM width for TI-Tagged is 16 bits.
Note
The TI-Tagged Format is 16 Bits Wide
You cannot change the ROM width of the TI-Tagged format. The TI-Tagged format supports a 16-bit
ROM width only.
Note
TI-TXT Format is 8 Bits Wide
You cannot change the ROM width of the TI-TXT format. The TI-TXT hex format supports only an
8-bit ROM width. See Section 12.15.6 for more about using the ROMS directive with the TI-TXT hex
format.
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 12.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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 295
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
Figure 12-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=16
AABB1122
15 0
Source file
.word 0 AABB h
.word 01122 h
AA BB
11 22
--memwidth=16 --memwidth=8
AABB AA
Data after
phase I of 1122 BB
hex2000 11
22
Output files
--romwidth=16
--outfile=file.wrd A A B B 1 1 2 2
--outfle=file.b1 AA 11
--romwidth=8
--outfile=file.byt A A B B1 1 2 2
296 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
Note
When the --order Option Applies
• This option applies only when you use a memory width with a value less than 16. Otherwise,
--order is ignored.
• This option does not affect the way memory words are split into output files. Think of the files as
a set: the set contains a least significant file and a most significant file, but there is no ordering
over the set. When you list filenames for a set of files, you always list the least significant first,
regardless of the --order option.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 297
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
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 12.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 12.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 12.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 12.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 12.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.
12.4.1 When to Use the ROMS Directive
If you do not use a ROMS directive, the utility defines a single default range that includes the entire address
space. This is equivalent to a ROMS directive with a single range without origin or length.
Use the ROMS directive when you want to:
• Program large amounts of data into fixed-size ROMs. When you specify memory ranges corresponding to
the length of your ROMs, the utility automatically breaks the output into blocks that fit into the ROMs.
• Restrict output to certain segments. You can also use the ROMS directive to restrict the conversion to
a certain segment or segments of the target address space. The utility does not convert the data that falls
outside of the ranges defined by the ROMS directive. Sections can span range boundaries; the utility splits
them at the boundary into multiple ranges. If a section falls completely outside any of the ranges you define,
the utility does not convert that section and issues no messages or warnings. Thus, you can exclude sections
without listing them by name with the SECTIONS directive. However, if a section falls partially in a range and
partially in unconfigured memory, the utility issues a warning and converts only the part within the range.
• Use image mode. When you use the --image option, you must use a ROMS directive. Each range is filled
completely so that each output file in a range contains data for the whole range. Holes before, between,
or after sections are filled with the fill value from the ROMS directive, with the value specified with the --fill
option, or with the default value of 0.
298 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
Figure 12-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. Map File Output From Showing Memory Ranges is a
segment of the map file resulting from the example in A ROMS Directive Example.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 299
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
Map File Output From A ROMS Directive Example 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:
This section ... Has this range ...
.text 0x00004000 through 0x0000487F
.data 0x00005B80 through 0x00005FFF
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:
This section ... Has this range ...
.data 0x00006000 through 0x0000633F
.table 0x00006700 through
0x00007C7F
The rest of the range is filled with 0xFF0 (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
12.5 The SECTIONS Directive
You can convert specific sections of the object file by name with the hex conversion utility SECTIONS directive.
You can also specify those sections that you want to locate in ROM at a different address than the load address
specified in the linker command file. If you:
• Use a SECTIONS directive, the utility converts only the sections that you list in the directive and ignores all
other sections in the object file.
• Do not use a SECTIONS directive, the utility converts all initialized sections that fall within the configured
memory.
Uninitialized sections are never converted, whether or not you specify them in a SECTIONS directive.
300 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
Note
Sections Generated by the C/C++ Compiler: The TMS320C28x C/C++ compiler automatically
generates these sections:
• Initialized sections: .text, .econst or .const (depending on the ABI), and .cinit
• Uninitialized sections: .ebss or .bss, .stack, and .esysmem or .sysmem
Use the SECTIONS directive in a command file. (See Section 12.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 }
In the example below, the object file contains six initialized sections: .text, .data, .econst, .vectors, .coeff,
and .tables. If you want only .text and .data to be converted, use this a SECTIONS directive:
SECTIONS { .text: .data: }
To configure both of these sections for boot loading, add the boot keyword:
SECTIONS { .text = boot .data = boot }
For more information about --boot and other command line options associated with boot tables, see Section 12.2
and Section 12.11.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 301
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
Note
Concerning Load Image Format: These options are invalid when creating a load image:
• --memwidth
• --romwidth
• --order
• --zero
• --byte
If a boot table is being created, either using the SECTIONS directive or the --boot option, the ROMS
directive must be used.
302 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
The utility creates the output files by writing the least significant bits to xyz.b0 and the most significant bits to
xyz.b1.
2. It looks for the --outfile options. You can specify names for the output files with the --outfile option. If no
filenames are listed in the ROMS directive and you use --outfile options, the utility takes the filename from
the list of --outfile options. The following options have the same effect as the ROMS directive above:
--outfile=xyz.b0 --outfile=xyz.b1
If your *.out file contains sections allocated to multiple pages, separate output files are generated for each
page. See Section 8.5.4.2 for information about specifying memory pages.
If both the ROMS directive and --outfile options are used, the ROMS directive overrides the --outfile options.
3. It assigns a default filename. If you specify no filenames or fewer names than output files, the utility
assigns a default filename. A default filename consists of the base name from the input file plus a 2- to
3-character extension. The extension has three parts:
a. A format character, based on the output format (see Section 12.15):
a for ASCII-Hex
i for Intel
m for Motorola-S
t for TI-Tagged
x for Tektronix
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 303
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
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 16-bit target processor and you are creating Intel format output. With no
output filenames specified, the utility produces two 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 four
output files:
ROMS
{
range1: o = 0x1000 l = 0x1000
range2: o = 0x2000 l = 0x1000
}
Note
Defining the Ranges of Target Memory
If you use image mode, you must also use a ROMS directive. In image mode, each output file
corresponds directly to a range of target memory. You must define the ranges. If you do not supply
the ranges of target memory, the utility tries to build a memory image of the entire target processor
address space. This is potentially a huge amount of output data. To prevent this situation, the utility
requires you to explicitly restrict the address space with the ROMS directive.
304 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 305
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
306 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
initial value for the SPIBRR register can be specified with the --spibrr option. Only the --spi8 format uses these
control register values in the boot table.
If the register values are not specified for the --spi8 format, the hex conversion utility uses the default values
0x02 for LOSPCP and 0x7F for SPIBRR. When the boot table format options are specified and the ROMS
directive is not specified, the ASCII format hex utility output does not produce the address record.
12.11.5 Setting the Entry Point for the Boot Table
After completing the boot load process, execution starts at the default entry point specified by the linker and
contained in the object file. By using the --entrypoint option with the hex conversion utility, you can set the entry
point to a different address.
For example, if you want your program to start running at address 0x0123 after loading, specify --
entrypoint=0x0123 on the command line or in a command file. You can determine the --entrypoint address
by looking at the map file that the linker generates.
Note
Valid Entry Points
The value can be a constant, or it can be a symbol that is externally defined (for example, with
a .global) in the assembly source.
The F2810/12 can boot through the SCI-A 8-bit, SPI-A 8-bit, GP I/O 8-bit, or GP I/I 16-bit interface. The format of
the boot table is shown in Table 12-4.
Table 12-4. Boot Table Format
Description Word Content
Boot table header 1 Key value (0x10AA or 0x08AA)
2-9 Register initialization value or reserved for future use
10-11 Entry point
Block header 12 Block size in number of words (n1)
13-14 Destination address of the block
Block data 15 Raw data for the block (n1 words)
Block header 16 + nl Block size in number of words
. Destination address of the block
Block data . Raw data for the block
Additional block headers and data, as ... Content as appropriate
required
Block header with size 0 0x0000; indicates the end of the boot table.
The C28x can boot through either the serial 8-bit or parallel interface with either 8- or 16-bit data. The format
is the same for any combination: the boot table consists of a field containing the destination address, a field
containing the length, and a block containing the data. You can boot only one section. If you are booting from an
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 307
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
8-bit channel, 16-bit words are stored in the table with MSBs first; the hex conversion utility automatically builds
the table in the correct format. Use the following options to specify the boot table source:
• To boot from a SCI-A port, specify --sci8 when invoking the utility. Do not specify --memwidth or --romwidth.
• To boot from a SPI-A port, specify --spi8 when invoking the utility. Do not specify --memwidth or --romwidth.
Use --lospcp to set the initial value for the LOSPCP register and --spibrr to set the initial value for the SPIBRR
register. If the register values are not specified for the --spi8 format, the hex conversion utility uses the default
value 0x02 for LOSPCP and 0x7F for SPIBRR.
• To load from a general-purpose parallel I/O port, invoke the utility with --gpio8 or --gpio16. Do not specify
--memwidth or --romwidth.
The command file in Example 12-1 allows you to boot the .text and .cinit sections of test.out from a 16-bit-wide
EPROM at location 0x3FFC00. The map file test.map is also generated.
Example 12-1. Sample Command File for Booting From 8-Bit SPI Boot
/*---------------------------------------------------------------------------*/
/* Hex converter command file. */
/*---------------------------------------------------------------------------*/
test.out /* Input file */
--ascii /* Select ASCII format */
--map=test.map /* Specify the map file */
--outfile=test_spi8.hex /* Hex utility out file */
--boot /* Consider all the input sections as boot sections */
--spi8 /* Specify the SPI 8-bit boot format */
--lospcp=0x3F /* Set the initial value for the LOSPCP as 0x3F */
/* The -spibrr option is not specified to show that */
/* the hex utility uses the default value (0x7F) */
--entrypoint=0x3F0000 /* Set the entry point */
The command file in Example 12-1 generates the out file in Figure 12-6. The control register values are coded in
the boot table header and that header has the address that is specified with the --entrypoint option.
308 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
Key value
LOSPCP initial value
SPIBRR register initial value
Reserved for future use Entry point
02 00 82 10 89 00 3F 00 00 00 00 00
Figure 12-6. Sample Hex Converter Out File for Booting From 8-Bit SPI Boot
The command file in Example 12-2 allows you to boot the .text and .cinit sections of test.out from the 16-bit
parallel GP I/O port. The map file test.map is also generated.
Example 12-2. Sample Command File for C28x 16-Bit Parallel Boot GP I/O
/*---------------------------------------------------------------------*/
/* Hex converter command file. */
/*---------------------------------------------------------------------*/
test.out /* Input file */
--ascii /* Select ASCII format */
--map=test.map /* Specify the map file */
--outfile=test_gpio16.hex /* Hex utility out file */
--gpio16 /* Specify the 16-bit GP I/O boot format */
SECTIONS
{
.text: paddr=BOOT
.cinit: paddr=BOOT
}
The command file in Example 12-2 generates the out file in Figure 12-7.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 309
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
A8 00 00 06
00 02 10 82 00 89 00 3F 00 00 00 00
Figure 12-7. Sample Hex Converter Out File for C28x 16-Bit Parallel Boot GP I/O
310 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
The command file in Example 12-3 allows you to boot the .text and .cinit sections of test.out from a 16-bit wide
EPROM from the SCI-A 8-bit port. The map file test.map is also generated.
Example 12-3. Sample Command File for Booting From 8-Bit SCI Boot
/*---------------------------------------------------------------------*/
/* Hex converter command file. */
/*---------------------------------------------------------------------*/
test.out /* Input file */
-ascii /* Select ASCII format */
--map=test.map /* Specify the map file */
--outfile=test_sci8.hex /* Hex utility out file */
--sci8 /* Specify the SCI 8-bit boot format */
SECTIONS
{
.text: paddr=BOOT
.cinit: paddr=BOOT
}
The command file in Example 12-3 generates the out file in Figure 12-8.
02 00 82 10 89 00 3F 00 00 00 00 00
Figure 12-8. Sample Hex Converter Out File for Booting From 8-Bit SCI Boot
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 311
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
• Use either the --image option or the --load_image option when using the --cmac option. If you use the --image
option, set both --memwidth and --romwidth to 16.
• If you use the --boot option (and other boot table options described in Section 12.11.3) with the --cmac option,
the CMAC algorithm assumes that a fill value of 1 is used for gaps between boot table regions. Because of
this assumption, you should also set --fill=0xFFFF when using the --boot and --cmac options together.
• Specify a HEX directive with one entry that represents all the allocated flash memory. Use a 128-bit aligned
length and specify the optional fill value. (The default fill is set to 0’s.)
• Define the global CMAC tags in C code.
The CMAC feature uses four secure flash boot memory regions that are hardcoded for start/end/tag addresses,
and one flexible CMAC region. The flexible region can encompass the entire allocated region as input in the
HEX directive or user-specified start/end addresses defined in C code.
C code definitions like the following are required to reserve space for the CMAC tag symbols.
struct CMAC_TAG
{ char tag[8];
uint32_t start;
uint32_t end;
};
#pragma RETAIN(cmac_sb_1)
#pragma LOCATION(cmac_sb_1, 0x080002)
const char cmac_sb_1[8] = { 0 };
#pragma RETAIN(cmac_sb_2)
#pragma LOCATION(cmac_sb_2, 0x088002)
const char cmac_sb_2[8] = { 0 };
#pragma RETAIN(cmac_sb_3)
#pragma LOCATION(cmac_sb_3, 0x0a8002)
const char cmac_sb_3[8] = { 0 };
#pragma RETAIN(cmac_sb_4)
#pragma LOCATION(cmac_sb_4, 0x0be002)
const char cmac_sb_4[8] = { 0 };
#pragma RETAIN(cmac_all)
#pragma LOCATION(cmac_all, 0x087002)
const struct CMAC_TAG cmac_all = { 0 }, 0x0, 0x0};
312 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
The four secure flash boot region CMAC tags are stored in the cmac_sb_1 through cmac_sb_4 symbols. The
cmac_all symbol stores the CMAC tag for the flexible user-specified region. For cmac_all :
• If the start and end CMAC_TAG struct members are zero, then the CMAC algorithm runs over entire
memory region specified in the HEX directive. The hex conversion utility populates the start and end memory
locations with the addresses input from the HEX directive entry.
• If the start and end members are non-zero, then the CMAC algorithm is instead applied between the
specified addresses.
RETAIN pragmas are required in the C code if these symbols are not accessed in the application code.
LOCATION pragmas are required to place symbols at the required memory locations. The LOCATION entries
for cmac_sb_1 through cmac_sb_4 are at fixed addresses. The LOCATION address for cmac_all can be
user-specified. However, it must not be located within any secure flash boot regions, because the ROM CMAC
implementation on the devices does not support this.
The CMAC algorithm is applied prior to the hex conversion. No changes are made to the original input ELF
executable.
The hex conversion utility applies the CMAC algorithm only to CMAC regions that have global symbols defined.
So if an ELF executable defines only cmac_sb_1 and cmac_all , then only those two CMAC tags will be
generated and populated in the generated hex output file.
12.13 Controlling the ROM Device Address
The hex conversion utility output address field corresponds to the ROM device address. The EPROM
programmer burns the data into the location specified by the hex conversion utility output file address field.
The hex conversion utility offers some mechanisms to control the starting address in ROM of each section.
However, many EPROM programmers offer direct control of the location in ROM in which the data is burned.
The address field of the hex-conversion utility output file is controlled by the following items, which are listed from
low to high priority:
1. The linker command file. By default, the address field of the hex conversion utility output file is the load
address (as given in the linker command file) .
2. The paddr parameter of the SECTIONS directive. When the paddr parameter is specified for a section,
the hex conversion utility bypasses the section load address and places 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.
4. The --byte option. Some EPROM programmers may require the output file address field to contain a byte
count rather than a word count. If you use the −byte option, the output file address increments once for each
byte. For example, if the starting address is 0h, the first line contains eight words, and you use no −byte
option, the second line would start at address 8 (8h). If the starting address is 0h, the first line contains
eight words, and you use the −byte option, the second line would start at address 16 (010h). The data in
both examples are the same; −byte affects only the calculation of the output file address field, not the actual
target processor address of the converted data.
The --byte option causes the address records in an output file to refer to byte locations within the file,
whether the target processor is byte-addressable or not.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 313
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
314 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
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.
12.15.1 ASCII-Hex Object Format (--ascii Option)
The ASCII-Hex object format supports 16-bit addresses. The format consists of a byte stream with bytes
separated by spaces. Figure 12-9 illustrates the ASCII-Hex format.
Nonprintable
Nonprintable Address end code
start code
^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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 315
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
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 12-10 illustrates the Intel hexadecimal object format.
Start
character Extended linear
address record
Address
Most significant 16 bits
Data
records
:00000001FF
Checksum
Byte Record End-of-file
count type record
316 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
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 12-11 illustrates the Motorola-S object format.
Record Address Checksum
type
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 317
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
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 12-12 illustrates the Tektronix object format.
Checksum: 21h = 1+5+6+8+1+0+0+0+0+0+0+
0+
2+0+2+0+2+0+2+0+2+0+2+
Block length 0
1ah = 26 Object code: 6 bytes
Header %15621810000000202020202020
character
Load address: 10000000h
Block type: 6 Length of
(data) load address
318 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
Figure 12-13 illustrates the tag characters and fields in TI-Tagged object format.
Start-of-file Load
record Program address Tag characters
identifier
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 ( : ).
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 319
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
For example, suppose the ROMS directive for a format that uses 16-bit ROM widths, such as ASCII-Hex with the
--romwidth=16 option used, is as follows:
/* Memory counted as 16-bit words */
ROMS
{
FLASH: origin=0x3f000000, length=0x1000
}
You would double the address and length in the ROMS directive when using an 8-bit ROM width:
/* Memory counted as 8-bit bytes */
ROMS
{
FLASH: origin=0x7e000000, length=0x2000
}
320 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Hex Conversion Utility Description
Section
start
@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
sections overlapping
Description Two or more section load addresses overlap, or a boot table address overlaps another section.
Action This problem may be caused by an incorrect translation from load address to hexadecimal output-file address that is
performed by the hex-conversion utility when memory width is less than data width. See Section 12.3 and Section
12.13.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 321
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Hex Conversion Utility Description www.ti.com
322 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Sharing C/C++ Header Files With Assembly Source
Chapter 13
Sharing C/C++ Header Files With Assembly Source
You can use the .cdecls assembler directive to share C headers containing declarations and prototypes between
C and assembly code. Any legal C/C++ can be used in a .cdecls block and the C/C++ declarations will cause
suitable assembly to be generated automatically, allowing you to reference the C/C++ constructs in assembly
code.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 323
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Sharing C/C++ Header Files With Assembly Source www.ti.com
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.
13.2 Notes on C/C++ Conversions
The following sections describe C and C++ conversion elements that you need to be aware of when sharing
header files with assembly source.
13.2.1 Comments
Comments are consumed entirely at the C level, and do not appear in the resulting converted assembly file.
324 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Sharing C/C++ Header Files With Assembly Source
Note
Be Careful With the __ASM_HEADER__ Macro
You must be very careful not to use this macro to introduce any changes in the code that could
result in inconsistencies between the code processed while compiling the C/C++ source and while
converting to assembly.
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)
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 325
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Sharing C/C++ Header Files With Assembly Source www.ti.com
Macro values are not interpreted as they are converted. For example, the following results in the assembler
substitution symbol OFFSET being set to the literal string value 5+12 and not the value 17. This happens
because the semantics of the C/C++ language require that macros are evaluated in context and not when they
are parsed.
#define OFFSET 5+12
Because macros in C/C++ are evaluated in their usage context, C/C++ printf escape sequences such as \n are
not converted to a single character in the converted assembly macro. See Section 13.2.11 for suggestions on
how to use C/C++ macro strings.
Macros are converted using the .define directive (see Section 13.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 13.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.
13.2.9 The #undef Directive
Symbols undefined using the #undef directive before the end of the .cdecls are not converted to assembly.
13.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.
13.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.
326 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Sharing C/C++ Header Files With Assembly Source
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 13.4.7 for
the .cstring directive syntax.)
13.2.12 C/C++ Built-In Functions
The C/C++ built-in functions, such as sizeof( ), are not translated to their assembly counterparts, if any, if they
are used in macros. Also, their C expression values are not inserted into the resulting assembly macro because
macros are evaluated in context and there is no active context when converting the macros to assembly.
Suitable functions such as $sizeof( ) are available in assembly expressions. However, as the basic types such
as int/char/float have no type representation in assembly, there is no way to ask for $sizeof(int), for example, in
assembly.
13.2.13 Structures and Unions
C/C++ structures and unions are converted to assembly .struct and .union elements. Padding and ending
alignments are added as necessary to make the resulting assembly structure have the same size and member
offsets as the C/C++ source. The primary purpose is to allow access to members of C/C++ structures, as well as
to facilitate debugging of the assembly code. For nested structures, the assembly .tag feature is used to refer to
other structures/unions.
The alignment is also passed from the C/C++ source so that the assembly symbol is marked with the same
alignment as the C/C++ symbol. (See Section 13.2.3 for information about pragmas, which may attempt to
modify structures.) Because the alignment of structures is stored in the assembly symbol, built-in assembly
functions like $sizeof( ) and $alignof( ) can be used on the resulting structure name symbol.
When using unnamed structures (or unions) in typedefs, such as:
typedef struct { int a_member; } mystrname;
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
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 327
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Sharing C/C++ Header Files With Assembly Source www.ti.com
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);
...
}
328 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Sharing C/C++ Header Files With Assembly Source
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.
13.3.3 Templates
No support exists for templates.
13.3.4 Virtual Functions
No support exists for virtual functions, as they have no assembly representation.
13.4 Special Assembler Support
13.4.1 Enumerations (.enum/.emember/.endenum)
The following directives support a pseudo-scoping for enumerations:
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.
To use a member's value, the format is ENUM_NAME.MEMBER, similar to using a structure member.
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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 329
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Sharing C/C++ Header Files With Assembly Source www.ti.com
330 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Sharing C/C++ Header Files With Assembly Source
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 331
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Sharing C/C++ Header Files With Assembly Source www.ti.com
332 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Symbolic Debugging Directives
Appendix A
Symbolic Debugging Directives
The assembler supports several directives that the TMS320C28x C/C++ compiler uses for symbolic debugging.
These directives differ for the two debugging formats, DWARF and COFF.
These directives are not meant for use by assembly-language programmers. They require arguments that can
be difficult to calculate manually, and their usage must conform to a predetermined agreement between the
compiler, the assembler, and the debugger. This appendix documents these directives for informational purposes
only.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 333
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Symbolic Debugging Directives www.ti.com
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:
cl2000 --symdebug:none --keep_asm input_file
334 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com XML Link Information File Description
Appendix B
XML Link Information File Description
The TMS320C28x 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.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 335
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
XML Link Information File Description www.ti.com
336 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com XML Link Information File Description
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 337
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
XML Link Information File Description www.ti.com
338 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com XML Link Information File Description
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 339
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
XML Link Information File Description www.ti.com
340 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com XML Link Information File Description
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 341
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
XML Link Information File Description www.ti.com
342 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com CRC Reference Implementation
Appendix C
CRC Reference Implementation
This appendix contains source code in C for a reference implementation of a CRC calculation routine that is
compatible with the linker-generated CRC tables. This code is found in the file labeled ref_crc.c.
This appendix also contains source code for a simple example application using linker-generated CRC tables
and copy tables. The application contains several tasks which share a common run area. Linker-generated copy
tables move the tasks from their load addresses to the run address. The application also uses the reference
CRC calculation routine to compute CRC values which are compared against the linker-generated values.
This code is for reference only, and no warranty is made as to suitability for any purpose.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 343
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
CRC Reference Implementation www.ti.com
/*****************************************************************************/
/* Reference implementation of a CRC calculation function */
/* */
/* gen_crc is the interface function which should be called from the */
/* application. There is also a stand-alone test mode that can be used */
/* if _RUN_MAIN is defined. */
/*****************************************************************************/
/*---------------------------------------------------------------------------*/
/* This file does NOT implement a general-purpose CRC function. */
/* Specifically, it does not handle parameterization by initial value, bit */
/* reflection, or final XOR value. This implementation is intended only to */
/* implement the CRC functions used by the linker for C28x CRC tables. The */
/* algorithms used by the linker are selected to match the CRC algorithms in */
/* the PRIME and IEEE 802.15.4-2006 standards, which use the polynomials */
/* supported by the C28x VCU hardware. To understand CRCs in general, */
/* especially what other parameters exist, see: */
/* */
/* "A Painless Guide To CRC Error Detection Algorithms" likely at: */
/* http://www.ross.net/crc/download/crc_v3.txt */
/* Author : Ross Williams ([email protected].). */
/* Date : 3 June 1993. */
/* Status : Public domain (C code). */
/*---------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
/*---------------------------------------------------------------------------*/
344 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com CRC Reference Implementation
/* These are the CRC algorithms supported by the linker, which match the */
/* polynomials supported in C28x VCU hardware, which match the PRIME and */
/* IEEE 802.15.4-2006 standards. These must match the values in crc_tbl.h. */
/*---------------------------------------------------------------------------*/
#define CRC32_PRIME 0
#define CRC16_802_15_4 1
#define CRC16_ALT 2
#define CRC8_PRIME 3
typedef struct crc_config_t
{
int id;
int degree;
unsigned long poly;
} crc_config_t;
const crc_config_t crc_config[] = { { CRC32_PRIME, 32, 0x04c11db7 },
{ CRC16_802_15_4, 16, 0x1021 },
{ CRC16_ALT, 16, 0x8005 },
{ CRC8_PRIME, 8, 0x07 } };
unsigned long crc_table[256] = { 0 };
const crc_config_t *find_config(int id) {
size_t i;
for (i = 0; i < sizeof(crc_config) / sizeof(*crc_config); i++)
if (crc_config[i].id == id)
return &crc_config[i];
fprintf(stderr, "invalid config id %d\n", id);
exit(EXIT_FAILURE);
return NULL;
}
/*---------------------------------------------------------------------------*/
/* Table-driven version */
/*---------------------------------------------------------------------------*/
unsigned long generate_mask(int degree)
{
unsigned long half = (1ul << (degree / 2)) - 1;
return half << (degree / 2) | half;
}
void generate_crc_table(const crc_config_t *config)
{
int i, j;
unsigned long bit, crc;
unsigned long high_bit = (1ul << (config->degree - 1));
unsigned long mask = generate_mask(config->degree);
for (i = 0; i < 256; i++)
{
crc = (unsigned long)i << config->degree - 8;
for (j = 0; j < 8; j++)
{
bit = crc & high_bit;
crc <<= 1;
if (bit) crc^= config->poly;
}
crc_table[i] = crc & mask;
}
}
/*****************************************************************************/
/* gen_crc - Return the CRC value for the data using the given CRC algorithm */
/* int id : identifies the CRC algorithm */
/* char *data : the data */
/* size_t len : the size of the data */
/*****************************************************************************/
unsigned long gen_crc(int id, const unsigned char *data, size_t len)
{
/*-----------------------------------------------------------------------*/
/* Note: this is not a general-purpose CRC function. It does not handle */
/* parameterization by initial value, bit reflection, or final XOR */
/* value. This CRC function is specialized to the CRC algorithms in the */
/* linker used for C28x CRC tables. */
/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
/* This CRC function is not intended to be optimal; it is written such */
/* that it works and generates the same result on all 8-bit and 16-bit */
/* targets, including C28x, other TI DSPs, and typical desktops. */
/*-----------------------------------------------------------------------*/
const crc_config_t *config = find_config(id);
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 345
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
CRC Reference Implementation www.ti.com
346 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com CRC Reference Implementation
#include <stdio.h>
#include <cpy_tbl.h>
#include <crc_tbl.h>
extern COPY_TABLE task1_ctbl;
extern COPY_TABLE task2_ctbl;
extern COPY_TABLE task3_ctbl;
extern CRC_TABLE task1_crctbl;
extern CRC_TABLE union_crctbl;
/****************************************************************************/
/* copy_in - provided by the RTS library to copy code from its load */
/* address to its run address. */
/* my_check_CRC - verify that the CRC values stored in the given table */
/* match the computed value at run time, using load address. */
/* taskX - perform a simple task. These routines share the same run */
/* address. */
/****************************************************************************/
extern void copy_in(COPY_TABLE *tp);
extern unsigned int my_check_CRC(CRC_TABLE *tp);
extern void task1(void);
extern void task2(void);
extern void task3(void);
int x = 0;
main()
{
unsigned int ret_val = 0;
unsigned int CRC_ok = 1;
printf("Start task copy test with CRC checking.\n");
printf("Check CRC of task1 section.\n");
ret_val = my_check_CRC(&task1_crctbl);
if (ret_val == 1)
printf("\nPASSED: CRCs for task1_crc_tbl match.\n");
else
{
CRC_ok = 0;
printf("\nFAILED: CRCs for task1_crc_tbl do NOT match.\n");
}
/*************************************************************************/
/* Copy task1 into the run area and execute it. */
/*************************************************************************/
copy_in(&task1_ctbl);
task1();
printf("Check CRC of UNION.\n");
if ((ret_val = my_check_CRC(&union_crctbl)) == 1)
printf("\nPASSED: CRCs for union_crc_tbl match.\n");
else
{
CRC_ok = 0;
printf("\nFAILED: CRCs for union_crc_tbl do NOT match.\n");
}
copy_in(&task2_ctbl);
task2();
copy_in(&task3_ctbl);
task3();
printf("Copy table and CRC tasks %s!!\n",
((CRC_ok == 1 && x == 6)) ? "PASSED" : "FAILED");
}
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 347
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
CRC Reference Implementation www.ti.com
#include <stdio.h>
#include "crc_tbl.h"
/****************************************************************************/
/* gen_crc() - computes the CRC value of data using the CRC algorithm ID */
/* specified. Found in ref_crc.c */
/****************************************************************************/
unsigned long gen_crc(int id, const unsigned char *data, size_t len);
/****************************************************************************/
/* my_check_CRC() - verify the CRC values for all records stored in the */
/* given CRC table. Print diagnostic information also. */
/****************************************************************************/
unsigned int my_check_CRC(CRC_TABLE *tp)
{
int i;
unsigned int ret_val = 1;
uint32_t my_crc;
printf("\n\tTABLE INFO: rec size=%d, num_rec=%d.",
tp->rec_size, tp->num_recs);
for (i = 0; i < tp->num_recs; i++)
{
CRC_RECORD crc_rec = tp->recs[i];
/**************************************************/
/* COMPUTE CRC OF DATA STARTING AT crc_rec.addr */
/* FOR crc_rec.size UNITS. USE */
/* crc_rec.crc_alg_ID to select algorithm. */
/* COMPARE COMPUTED VALUE TO crc_rec.crc_value. */
/**************************************************/
my_crc = gen_crc(crc_rec.crc_alg_ID, (unsigned char *)crc_rec.addr,
crc_rec.size);
printf("\n\tCRC record: page=%x, alg=%x, addr = %lx, size=%lx, "
"\n\t\tcrc=%lx, my_crc=%lx.",
crc_rec.page_id, crc_rec.crc_alg_ID,
crc_rec.addr, crc_rec.size, crc_rec.crc_value, my_crc);
if (my_crc == crc_rec.crc_value)
printf("\n\tCRCs match for record %d.\n", i);
else
{
ret_val = 0;
printf("\n\tCRCs DO NOT match for record %d.\n", i);
}
}
return ret_val;
}
#include <stdio.h>
extern int x;
#pragma CODE_SECTION(task1, ".task1_scn")
void task1(void) { printf("hit task1, x is %d\n", x); x += 1; }
#include <stdio.h>
extern int x;
#pragma CODE_SECTION(task2, ".task2_scn")
void task2(void) { printf("hit task2, x is %d\n", x); x += 2; }
348 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com CRC Reference Implementation
#include <stdio.h>
extern int x;
#pragma CODE_SECTION(task3, ".task3_scn")
void task3(void) { printf("hit task3, x is %d\n", x); x += 3; }
/****************************************************************************/
/* Linker Generated Copy Tables - Example #1 */
/* */
/* 3 separate tasks are loaded into 3 separate areas of target memory. */
/* They all must be run in a common area of memory (overlay). Before */
/* each task is run, it is copied into its run space using a linker */
/* generated copy table for each task. */
/* */
/* Two linker generated CRC tables are created. One is for .task1_scn */
/* and the other is for the UNION. The UNION table will contain CRC */
/* records for .task1_scn, .task2_scn and .task3_scn. */
/****************************************************************************/
-c
-x
ex1.obj
task1.obj
task2.obj
task3.obj
check_crc.obj
ref_crc.obj
-o ex1.out
-m ex1.map
-stack 0x1000
-heap 0x800
MEMORY
{
PAGE 0 : RESET(R): origin = 0x000000, length = 0x00002
VECTORS(R) : origin = 0x000002, length = 0x003FE
PROG(R) : origin = 0x3f0000, length = 0x10000
PAGE 1 : RAM1 (RW) : origin = 0x000402 , length = 0x003FE
PAGE 1 : RAM2 (RW) : origin = 0x001000 , length = 0x04000
PAGE 1 : RAM3 (RW) : origin = 0x3e0000 , length = 0x08000
}
SECTIONS
{
UNION
{
.task2_scn: load = RAM3, PAGE = 1, table(_task2_ctbl)
.task3_scn: load = RAM3, PAGE = 1, table(_task3_ctbl)
.task1_scn: load = RAM3, PAGE = 1, table(_task1_ctbl),
crc_table(_task1_crctbl)
} run = PROG, PAGE = 0, crc_table(_union_crctbl, algorithm=CRC16_ALT)
vectors : load = VECTORS, PAGE = 0
.text : load = PROG, PAGE = 0
.data : load = 440h, PAGE = 1
.cinit : > PROG, PAGE = 0
.ebss : > RAM3, PAGE = 1
.econst : > RAM3, PAGE = 1
.reset : > RESET, PAGE = 0
.stack : > RAM2, PAGE = 1
.sysmem : > RAM2, PAGE = 1
.esysmem : > RAM3, PAGE = 1
.ovly > RAM2, PAGE = 1
}
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 349
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
CRC Reference Implementation www.ti.com
350 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Glossary
Appendix D
Glossary
D.1 Terminology
ABI Application binary interface.
absolute lister A debugging tool that allows you to create assembler listings that contain absolute
addresses.
address constant A symbol with a value that is an address plus an addend that is an absolute constant
expression 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.
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 A symbol that is assigned a constant value with the .set directive.
constant
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
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 351
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Glossary www.ti.com
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. For
TMS320C28x, the size of a byte is 16-bits, which is also the size of a word.
C/C++ compiler A software program that translates C source statements into assembly language source
statements.
COFF Common object file format; a system of object files configured according to a standard
developed by AT&T. These files are relocatable in memory space.
command file A file that contains options, filenames, directives, or commands for the linker or hex
conversion utility.
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 A method of processing one block of source code or an alternate block of source code,
processing according to the evaluation of a specified expression.
constant An expression that does not in any way refer to a register or memory reference.
expression
cross-reference A utility that produces an output file that lists the symbols that were defined, what file they
lister were defined in, what reference type they are, what line they were defined on, which lines
referenced them, and their assembler and linker final values. The cross-reference lister
uses linked object files as input.
cross-reference An output file created by the assembler that lists the symbols that were defined, what line
listing 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).
352 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Glossary
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.
environment A system symbol that you define and assign to a string. Environmental variables are often
variable included in Windows batch files or UNIX shell scripts such as .cshrc or .profile.
epilog The portion of code in a function that restores the stack and returns.
executable module A linked object file that can be executed in a target system.
external symbol A symbol that is used in the current program module but defined or declared in a different
program module.
field For the TMS320C28x, a software-configurable data type whose length can be
programmed to be any value in the range of 1-16 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 A utility that converts object files into one of several standard ASCII hexadecimal formats,
utility suitable for loading into an EPROM programmer.
high-level The ability of a compiler to retain symbolic and high-level language information (such as
language type and function definitions) so that a debugging tool can use this information.
debugging
hole An area between the input sections that compose an output section that contains no
code.
incremental linking Linking files in several passes. Incremental linking is useful for large applications,
because you can partition the application, link the parts separately, and then link all of
the parts together.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 353
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Glossary www.ti.com
initialization at An autoinitialization method used by the linker when linking C/C++ code. The linker uses
load time 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.
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
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.
memory map A map of target system memory space that is partitioned into functional blocks.
memory reference An operand that refers to a location in memory using a target-specific syntax.
operand
mnemonic An instruction name that the assembler translates into machine code.
354 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Glossary
model statement Instructions or assembler directives in a macro definition that are assembled each time a
macro is invoked.
object file An assembled or linked file that contains machine-language object code.
object module A linked, executable object file that can be downloaded and executed on a target system.
optimizer A software tool that improves the execution speed and reduces the size of C programs.
options Command-line parameters that allow you to request additional or specific functions when
you invoke a software tool.
output module A linked, executable object file that is downloaded and executed on a target system.
overlay page A section of physical memory that is mapped into the same address range as another
section of memory. A hardware switch determines which range is active.
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.
relocatable An expression that refers to at least one external symbol, register, or memory location.
constant The value of the expression is not known until link time.
expression
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-time-support A library file, rts.src, that contains the source for the run time-support functions.
library
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 355
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Glossary www.ti.com
section A relocatable block of code or data that ultimately will be contiguous with other sections in
the memory map.
section program An element that keeps track of the current location within a section; each section has its
counter (SPC) 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.
symbolic The ability of a software tool to retain symbolic information that can be used by a
debugging debugging tool such as an emulator or simulator.
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 that is not defined as part of the memory map and cannot be loaded with code or
memory data.
uninitialized A object file section that reserves space in the memory map but that has no actual
section 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.
356 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Glossary
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 A term or group of terms that contains only symbols or assembly-time constants that have
expression been defined before they appear in the expression.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 357
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Revision History www.ti.com
Revision History
Changes from December 16, 2020 to June 15, 2021 (from Revision V (December 2020) to
Revision W (June 2021)) Page
• Corrected the name of the C28_CHECKSUM_16 algorithm.......................................................................... 257
• Corrected the name of the C28_CHECKSUM_16 algorithm.......................................................................... 266
Changes from September 1, 2020 to December 15, 2020 (from Revision U (September 2020) to
Revision V (December 2020)) Page
• Added the --lfu_reference_elf command-line option.........................................................................................48
• Added the .preserve directive for use with Live Firmware Update (LFU)......................................................... 78
• Added the SYM_PRESERVE and SYM_UPDATE type for the .elfsym directive........................................... 109
• Added the .preserve directive for use with Live Firmware Update (LFU)....................................................... 134
• Removed documentation of the --rom linker option, which is not supported.................................................. 180
• Added support for Cyclic Redundancy Check (CRC) checks over memory ranges.......................................257
• Added the C28_CHECKSUM algorithm for CRC checks to match the CCS checksum utility........................257
• Added support for Cyclic Redundancy Code (CRC) checks over memory ranges........................................ 262
• The new C28_CHECKSUM algorithm operated on 16-bit units, unlike the CRC algorithms......................... 266
• Documented Hex Conversion Utility options related to the boot table for use with parallel XINTF streams.. 289
• Documented Hex Conversion Utility options related to image loading........................................................... 289
• Documented additional Hex Conversion Utility options related to image loading...........................................302
Changes from February 28, 2020 to August 31, 2020 (from Revision T (February 2020) to
Revision U (August 2020)) Page
• Updated the numbering format for tables, figures, and cross-references throughout the document................ 11
• Removed references to the Processors wiki throughout the document............................................................11
The following table lists changes made to this document prior to changes to the document numbering format.
The left column identifies the first version of this document in which that particular change appeared.
Version
Chapter Location Additions / Modifications / Deletions
Added
Program
SPRU513T Section 3.3.2.3 Corrected information about RAM and ROM model use of CINIT for initialization.
Loading
Clarified that either --rom_model or --ram_model is required if only the linker is being
SPRU513T Linker Section 8.4.26 run, but --rom_model is the default if the compiler runs on C/C++ files on the same
command line.
Clarified that zero initialization takes place only if the --rom_model linker option is
SPRU513T Linker Section 8.4.36
used, not if the --ram_model option is used.
Section 8.5.4.2,
Added LAST operator to define a symbol with the run-time address of the last
SPRU513T Linker Section 8.5.11.7,
allocated byte in the related memory range.
and Section 8.5.11.8
Hex
Boot tables can now be used with the hex conversion utility's Secure Flash Boot
SPRU513T Conversion Section 12.12
(--cmac) capability.
Utility
358 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Revision History
Version
Chapter Location Additions / Modifications / Deletions
Added
Hex
Provided example showing the effects of 8-bit memory width vs. 16-bit memory
SPRU513T Conversion Section 12.15.6
width on the ROMS directive syntax.
Utility
The default file extensions for object files created by the compiler have been
changed in order to prevent conflicts when C and C++ files have the same names.
SPRU513S -- throughout -- Object files generated from C source files have the .c.obj extension. Object files
generated from C++ source files have the .cpp.obj extension. Object files generated
from assembly source files still have the .obj extension.
Hex
Added support for the secure flash boot capability provided by TMS320F2838x
SPRU513S Conversion Section 12.12
devices.
Utility
SPRU513R.1 Linker Section 8.5.9 Added documentation for the NOINIT special section type. (EABI only)
Added further documentation of EABI support. This includes identifying features that
SPRU513R -- throughout -- are supported only for COFF or EABI. Identified examples as COFF-specific where
necessary.
SPRU513R Object Modules Section 2.1 Added information about the ELF object file format.
Section 2.3.1,
SPRU513R Object Modules Added information about section names used by EABI.
Section 2.4.1
SPRU513R Object Modules Section 2.6 Revised information about types of symbols for clarity.
Program
SPRU513R Section 3.3.2 Added information about the RAM model and ROM model for EABI.
Loading
Assembler
SPRU513R Section 4.4 Added information about controlling the ABI setting.
Description
Assembler
SPRU513R Section 4.8.6 Corrected list of symbolic constants.
Description
Assembler
SPRU513R Section 4.8.7 Added the documentation for the FPU RB register.
Description
Added topics for directives
Assembler
SPRU513R Section 5.12 related to EABI: .bss, .common, .elfsym, .group, .gmember,
Directives
endgroup, .retain, .retainrefs, .weak, .xfloat, and .xldouble.
Assembler
SPRU513R .bits topic Modified the description of the .bits directive.
Directives
Assembler
SPRU513R .usect topic Modified the description of the .usect directive.
Directives
Assembler .symdepend
SPRU513R Split .symdepend and .weak directive topics.
Directives topic, .weak topic
SPRU513R Linker Section 8.4 Added the --emit_references:file linker option.
Added linker options related to EABI: --cinit_compression, --copy_compression, --
SPRU513R Linker Section 8.4
retain, --unused_section_elimination, --warn_sections, and --zero_init.
SPRU513R Linker Section 8.5.11.4 Added symbols automatically defined by the linker for EABI.
SPRU513R Linker Section 8.6.2 Added information about weak symbols used by EABI.
SPRU513R Linker Section 8.8.5 Added information about compression available with EABI.
SPRU513Q Added support for EABI. The COFF ABI is the default.
Added support for 64-bit floating point operations (--float_support=fpu64).
Section 4.8.6, Added support for fast integer division (--idiv_support=idiv0).
Assembler,
SPRU513Q Section 4.11, and Added support for additional TMU instructions (--tmu_support=tmu1).
Linker
Section 8.4.11 Added support for Cyclic Redundancy Check (CRC) with the VCU (--
vcu_support=vcrc).
Section 8.4, Section
Added the --ecc=on linker option, which enables ECC generation. Note that ECC
SPRU513Q Linker 8.4.12, and Section
generation is now off by default.
8.5.10
SPRU513Q Linker Section 8.5.7.3 Added linker syntax to combine initialized section with uninitialized sections.
SPRU513W – AUGUST 2001 – REVISED JUNE 2021 TMS320C28x Assembly Language Tools 359
Submit Document Feedback v21.6.0.LTS
Copyright © 2021 Texas Instruments Incorporated
Revision History www.ti.com
Version
Chapter Location Additions / Modifications / Deletions
Added
Hex
Section 12.2.1 and
SPRU513P Conversion Added the --array option, which causes the array output format to be generated.
Section 12.10
Utility
Object
Modules, Section 2.4.1
SPRU513M Added information about DP load optimization.
Assembler and .usect topic
Directives
Section 4.3, Section
Assembler
SPRU513M 4.11, and Section Documented support for CLA version 2 and CLA v2 background tasks.
Description
4.11.3
Assembler
SPRU513M .usect topic Explain the effect of the alignment flag for the .usect directive.
Directives
Linker Provided a link to an E2E blog post that provides examples that perform cyclic
SPRU513M Section 8.9
Description redundancy checking using linker-generated CRC tables.
Linker
SPRU513L Section 8.5.10 Documented revised behavior of ECC directives.
Description
Several linker options have been deprecated, removed, or renamed. The linker
Linker
SPRU513K Section 8.4 continues to accept some of the deprecated options, but they are not recommended
Description
for use.
Linker Information about accessing files and libraries from a linker command file has been
SPRU513J Section 8.5.3
Description added.
Linker
SPRU513J Section 8.9.1.1 The list of available CRC algorithms has been expanded.
Description
Object File A –cg option has been added to the Object File Display utility to display function
SPRU513J Section 11.1
Utilities stack usage and callee information in XML format.
Program Section 3.3.3.1 and
SPRU513I Added the BINIT (boot-time initialization) copy table.
Loading, Linker Section 8.8.4.2
SPRU513I Linker Section 8.4.20 Added modules as a filter for the --mapfile_contents linker option.
SPRU513I Linker Section 8.5.5.2.1 Added an example for placing functions in RAM.
SPRU513I Linker Section 8.8.4.3 Documented the table() operator.
The near and far keywords are deprecated, and the small memory model is no
longer supported; the only memory model uses 32-bit pointers. The C27x object
mode is also no longer supported. The .bss, .const, and .sysmem sections are no
SPRU513H -- --
longer used; the .ebss, .econst, and .esysmem sections are used instead. As a
result, the --farheap linker option, far call trampolines, and several other related
features are no longer documented.
SPRU513H Object Modules Section 2.4.4 Added information about the current section and how directives interact with it.
Section 2.6 and
SPRU513H Object Modules Added information about various types of symbols and about symbol tables.
Section 2.6.4
Assembler Section 4.3 and
SPRU513G Added support for Type 2 VCU via --vcu_support=vcu2.
Description Section 4.11
Assembler Section 4.3 and
SPRU513G Added support for Type 1 CLA via --cla_support=cla1.
Description Section 4.11
Assembler The naming of function frames in scratchpad memory for the CLA compiler has
SPRU513H Section 4.11.3
Description changed.
Section 8.4.2,
SPRU513H Linker Section 8.5.11.7, Added information about referencing linker symbols.
and Section 8.6.1
SPRU513H Linker Section 8.4.11 Added a list of the linker's predefined macros.
SPRU513G Linker Section 8.5.5.1 Removed invalid syntax for load and fill properties.
360 TMS320C28x Assembly Language Tools SPRU513W – AUGUST 2001 – REVISED JUNE 2021
v21.6.0.LTS Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
IMPORTANT NOTICE AND DISCLAIMER
TI PROVIDES TECHNICAL AND RELIABILITY DATA (INCLUDING DATASHEETS), DESIGN RESOURCES (INCLUDING REFERENCE
DESIGNS), APPLICATION OR OTHER DESIGN ADVICE, WEB TOOLS, SAFETY INFORMATION, AND OTHER RESOURCES “AS IS”
AND WITH ALL FAULTS, AND DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION ANY
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF THIRD
PARTY INTELLECTUAL PROPERTY RIGHTS.
These resources are intended for skilled developers designing with TI products. You are solely responsible for (1) selecting the appropriate
TI products for your application, (2) designing, validating and testing your application, and (3) ensuring your application meets applicable
standards, and any other safety, security, or other requirements. These resources are subject to change without notice. TI grants you
permission to use these resources only for development of an application that uses the TI products described in the resource. Other
reproduction and display of these resources is prohibited. No license is granted to any other TI intellectual property right or to any third party
intellectual property right. TI disclaims responsibility for, and you will fully indemnify TI and its representatives against, any claims, damages,
costs, losses, and liabilities arising out of your use of these resources.
TI’s products are provided subject to TI’s Terms of Sale (https:www.ti.com/legal/termsofsale.html) or other applicable terms available either
on ti.com or provided in conjunction with such TI products. TI’s provision of these resources does not expand or otherwise alter TI’s
applicable warranties or warranty disclaimers for TI products.IMPORTANT NOTICE
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2021, Texas Instruments Incorporated