T exas Instruments (TI) reserves the right to make changes to its products or to discontinue any
semiconductor product or service without notice, and advises its customers to obtain the latest
version of relevant information to verify , before placing orders, that the information being relied
on is current.
TI warrants performance of its semiconductor products and related software to the specifications
applicable at the time of sale in accordance with TI’s standard warranty . T esting and other quality
control techniques are utilized to the extent TI deems necessary to support this warranty.
Specific testing of all parameters of each device is not necessarily performed, except those
mandated by government requirements.
Certain applications using semiconductor products may involve potential risks of death,
personal injury , or severe property or environmental damage (“Critical Applications”).
TI SEMICONDUCTOR PRODUCTS ARE NOT DESIGNED, INTENDED, AUTHORIZED, OR
WARRANTED TO BE SUITABLE FOR USE IN LIFE-SUPPORT APPLICATIONS, DEVICES
OR SYSTEMS OR OTHER CRITICAL APPLICATIONS.
Inclusion of TI products in such applications is understood to be fully at the risk of the customer.
Use of TI products in such applications requires the written approval of an appropriate TI officer .
Questions concerning potential risk applications should be directed to TI through a local SC
sales office.
In order to minimize risks associated with the customer’s applications, adequate design and
operating safeguards should be provided by the customer to minimize inherent or procedural
hazards.
TI assumes no liability for applications assistance, customer product design, software
performance, or infringement of patents or services described herein. Nor does TI warrant or
represent that any license, either express or implied, is granted under any patent right, copyright,
mask work right, or other intellectual property right of TI covering or relating to any combination,
machine, or process in which such semiconductor products or services might be or are used.
The goal of this book is to help you learn how to use the Texas Instruments
assembly language tools specifically designed for the TMS320C54x DSPs.
This book is divided into four parts:
-
Introductory information gives you an overview of the assembly
language development tools and also discusses common object file
format (COFF), which helps you to use the TMS320C54x tools more
efficiently.
before using the assembler and linker.
-
Assembler description contains detailed information about using the
assembler. This section explains how to invoke the assembler and
discusses source statement format, valid constants and expressions,
assembler output, and assembler directives. It also describes macro
elements.
-
Additional assembly language tools describes in detail each of the
tools provided with the assembler to help you create assembly language
source files. For example, Chapter 7 explains how to invoke the linker, how
the linker operates, and how to use linker directives. Chapter 10 explains
how to use the hex conversion utility.
Read Chapter 2, Introduction to Common Object File Format,
iii
Page 4
Notational Conventions
How to Use This Manual / Notational Conventions
-
Reference material provides supplementary information. This section
contains technical data about the internal format and structure of COFF
object files. It discusses symbolic debugging directives that the C compiler
uses. Finally, it includes hex conversion utility examples, assembler and
linker error messages, and a glossary.
Notational Conventions
This document uses the following conventions:
-
Program listings, program examples, and interactive displays appear in a
special typeface. Examples use a bold version of the special
typeface for emphasis; 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 program listing:
2 00012fx .byte47
3 000232z.byte50
4 0003.text
-
In syntax descriptions, the instruction, command, or directive is in a bold
typeface font 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. Here is
an example of command line syntax:
abs500
filename
abs500 is a command. The command invokes the absolute lister and has
one parameter, indicated by
filename
. When you invoke the absolute
lister, you supply the name of the file that the absolute lister uses as input.
-
Square brackets ( [ and ] ) identify an optional parameter. If you use an
optional parameter, you specify the information within the brackets; you
don’t enter the brackets themselves. This is an example of a command
that has an optional parameter:
hex500 [
–options] filename
The hex500 command has two parameters. The first parameter ,
is optional. Since
second parameter,
options
is plural, you may select several options. The
filename
, is required.
–options
,
iv
Page 5
Notational Conventions
-
In assembler syntax statements, column 1 is reserved for the first
character of a label or symbol. If the label or symbol is optional, it is usually
not shown. If it is a required parameter, then it will be shown starting
against the left margin of the shaded box, as in the example below. No
instruction, command, directive, or parameter, other than a symbol or
label, should begin in column 1.
Note that .byte does not
begin in column 1.
symbol
The
The
words
blocking flag
.usect ”
section name”, size in words [, blocking flag]
[, alignment flag
symbol
is required for the .usect directive and must begin in column 1.
section name
must be enclosed in quotes and the section
must be separated from the
and
alignment flag
]
section name
by a comma. The
are optional and, if used, must be
separated by commas.
-
Some directives can have a varying number of parameters. For example,
the .byte directive can have up to 100 parameters. The syntax for this
directive is:
.byte
value
[,
... , value
1
]
n
This syntax shows that .byte must have at least one value parameter, but
you have the option of supplying additional value parameters, separated
by commas.
-
Following are other symbols and abbreviations used throughout this
document.
The following books describe the TMS320C54x devices and related support
tools. To obtain a copy of any of these TI documents, call the Texas
Instruments Literature Response Center at (800) 477–8924. When ordering,
please identify the book by its title and literature number.
TMS320C54x DSP Reference Set
ordered as a set with literature number SPRU210. T o order an individual
book, use the document-specific literature number:
is composed of four volumes that can be
TMS320C54x DSP Reference Set, Volume 1: CPU and Peripherals
(literature number SPRU131) describes the TMS320C54x 16-bit,
fixed-point, general-purpose digital signal processors. Covered
are its architecture, internal register structure, data and program
addressing, the instruction pipeline, DMA, and on-chip
peripherals. Also includes development support information, parts
lists, and design considerations for using the XDS510 emulator.
(literature number SPRU179) describes the TMS320C54x
digital signal processor algebraic instructions individually. Also
includes a summary of instruction set classes and cycles.
(literature number SPRU173) describes software and hardware
applications for the TMS320C54x digital signal processor. Also
includes development support information, parts lists, and design
considerations for using the XDS510 emulator.
TMS320 DSP Development Support Reference Guide
SPRU011) describes the TMS320 family of digital signal processors and
the tools that support these devices. Included are code-generation tools
(compilers, assemblers, linkers, etc.) and system integration and debug
tools (simulators, emulators, evaluation modules, etc.). Also covered are
available documentation, seminars, the university program, and factory
repair and exchange.
TMS320C54x Optimizing C Compiler User’s Guide
SPRU103) describes the ’C54x C compiler. This C compiler accepts
ANSI standard C source code and produces TMS320 assembly
language source code for the ’C54x generation of devices.
vi
(literature number
(literature number
Page 7
Related Documentation From Texas Instruments / Trademarks
Trademarks
TMS320C54x C Source Debugger User’s Guide
(literature number
SPRU099) tells you how to invoke the ’C54x emulator, evaluation
module, and simulator versions of the C source debugger interface. This
book discusses various aspects of the debugger interface, including
window management, command entry, code execution, data
management, and breakpoints. It also includes a tutorial that introduces
basic debugger functionality.
TMS320 Third-Party Support Reference Guide
(literature number
SPRU052) alphabetically lists over 100 third parties that provide various
products that serve the family of TMS320 digital signal processors. A
myriad of products and applications are offered—software and hardware
development tools, speech recognition, image processing, noise
cancellation, modems, etc.
Digital Signal Processing Applications with the TMS320 Family, Volumes
1, 2, and 3
(literature numbers SPRA012, SPRA016, SPRA017)
Volumes 1 and 2 cover applications using the ’C10 and ’C20 families of
fixed-point processors. Volume 3 documents applications using both
fixed-point processors, as well as the ’C30 floating-point processor.
HP-UX is a trademark of Hewlett-Packard Company.
PC is a trademark of International Business Machines Corporation.
Solaris is a trademark of Sun Microsystems, Inc.
UNIX is a registered trademark of Unix System Laboratories, Inc.
XDS510 is a trademark of Texas Instruments Incorporated.
Read This First
vii
Page 8
If You Need Assistance
If You Need Assistance. . .
-
World-Wide Web Sites
TI Onlinehttp://www.ti.com
Semiconductor Product Information Center (PIC)http://www.ti.com/sc/docs/pic/home.htm
DSP Solutionshttp://www.ti.com/dsps
320 Hotline On-line
-
North America, South America, Central America
Product Information Center (PIC)(972) 644-5580
TI Literature Response Center U.S.A.(800) 477-8924
Software Registration/Upgrades(214) 638-0333Fax: (214) 638-7742
U.S.A. Factory Repair/Hardware Upgrades(281) 274-2285
U.S. Technical Training Organization(972) 644-5580
DSP Hotline(281) 274-2320Fax: (281) 274-2324Email: dsph@ti.com
DSP Modem BBS(281) 274-2323
DSP Internet BBS via anonymous ftp to ftp://ftp.ti.com/pub/tms320bbs
-
Europe, Middle East, Africa
European Product Information Center (EPIC) Hotlines:
Literature Response Center+852 2 956 7288Fax: +852 2 956 2200
Hong Kong DSP Hotline+852 2 956 7268Fax: +852 2 956 1002
Korea DSP Hotline+82 2 551 2804Fax: +82 2 551 2828
Korea DSP Modem BBS+82 2 551 2914
Singapore DSP HotlineFax: +65 390 7179
Taiwan DSP Hotline+886 2 377 1450Fax: +886 2 377 2718
Taiwan DSP Modem BBS+886 2 376 2592
Taiwan DSP Internet BBS via anonymous ftp to ftp://dsp.ee.tit.edu.tw/pub/TI/
-
Japan
Product Information Center+0120-81-0026 (in Japan)Fax: +0120-81-0036 (in Japan)
DSP Hotline+03-3769-8735 or (INTL) 813-3769-8735Fax: +03-3457-7071 or (INTL) 813-3457-7071
DSP BBS via Nifty-ServeType “Go TIASP”
-
Documentation
When making suggestions or reporting errors in documentation, please include the following information that is on the title
page: the full title of the book, the publication date, and the literature number.
Discusses the basic COFF concept of sections and how they can help you use the assembler
and linker more efficiently . Common object file format, or COFF, is the object file format used
by the tools.
Explains how to invoke the hex utility to convert a COFF object file into one of several standard
hexadecimal formats suitable for loading into an EPROM programmer.
Explains how to invoke the mnemonic-to-algebraic translator utility to convert a source file
containing mnemonic instructions to a source file containing algebraic instructions.
C–17Map File Resulting From the Command File in Example C–16C-23. . . . . . . . . . . . . . . . . . . . .
C–18Hex Conversion Utility Output File Resulting From the Command File in C–16C-23. . . . . . .
xxii
Page 23
Chapter 1
Introduction
The TMS320C54x DSPs are supported by the following assembly language
tools:
-
Assembler
-
Archiver
-
Linker
-
Absolute lister
-
Cross-reference utility
-
Hex conversion utility
-
Mnemonic-to-algebraic translator 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 compiler and debugging tools; however, the compiler and
debugger are not shipped with the assembly language tools. For detailed
information on the compiler and debugger and for complete descriptions of the
TMS320C54x devices, refer to the books listed in
From Texas Instruments
on page vi.
Related Documentation
The assembly language tools create and use object files in common object file
format (COFF) to facilitate modular programming. Object files contain
separate blocks (called sections) of code and data that you can load into ’C54x
memory spaces. You can program the ’C54x more efficiently if you have a
basic understanding of COFF . Chapter 2,
Figure 1–1 illustrates the ’C54x software development flow. The shaded
portion of the figure highlights the most common path of software development; the other portions are optional.
Figure 1–1. TMS320C54x Software Development Flow
C
source
files
Macro
source
files
Archiver
C compiler
Assembler
source
Assembly
translation
assistant
Macro
library
Archiver
Library of
object
files
Hex conversion
utility
EPROM
programmer
Absolute lister
Assembler
COFF
object
files
Linker
Executable
COFF
file
Cross-reference
lister
Assembler
source
Library-build
utility
Runtime-
support
library
Debugging
tools
’C54x
1-2
Page 25
1.2Tools Descriptions
The following list describes the tools that are shown in Figure 1–1:
-
The C compiler translates C source code into ’C54x assembly language
source code. The compiler package includes the library-build utility , with
which you can build your own runtime libraries. The C compiler is not
shipped with the assembly language tools package.
-
The assembler translates assembly language source files into machine
language COFF object files. Source files can contain instructions, assembler directives, and macro directives. Y ou can use assembler directives to
control various aspects of the assembly process, such as the source listing format, data alignment, and section content.
-
The linker combines relocatable COFF object files (created by the assembler) into a single executable COFF object module. As it creates the
executable module, it adjusts references to symbols and resolves external
references. It also accepts archiver library members and output modules
created by a previous linker run. Linker directives allow you to combine object file sections, bind sections or symbols to addresses or within memory
ranges, and define or redefine global symbols.
Tools Descriptions
-
The archiver collects a group of files into a single archive file. For exam-
ple, you can collect several macros into a macro library. The assembler
searches the library and uses the members that are called as macros by
the source file. You can also use the archiver to collect a group of object
files into an object library. The linker includes in the library the members
that resolve external references during the link.
-
The mnemonic-to-algebraic assembly translator utility converts an
assembly language source file containing mnemonic instructions to an
assembly language source file containing algebraic instructions.
-
The library-build utility builds your own customized, C, runtime-support
library . Standard runtime-support library functions are provided as source
code in rts.src and as object code in rts.lib.
-
The TMS320C54x DSP accepts COFF files as input, but most EPROM
programmers do not. The hex conversion utility converts a COFF object
file into TI-tagged, Intel, Motorola, or Tektronix object format. The
converted file can be downloaded to an EPROM programmer.
Introduction
1-3
Page 26
Tools Descriptions
-
The absolute lister accepts linked object files as input and creates .abs
files as output. You assemble .abs files to produce a listing that contains
absolute rather than relative addresses. Without the absolute lister,
producing such a listing would be tedious and require many manual operations.
-
The cross-reference lister uses object files to produce a cross-reference
listing showing symbols, their definitions, and their references in the linked
source files.
The purpose of this development process is to produce a module that can be
executed in a ’C54x target system. Y ou can use one of several debugging tools
to refine and correct your code. Available products include:
-
An instruction-accurate software simulator
-
An extended development system (XDS510) emulator
-
An evaluation module (EVM)
For information about these debugging tools, see the
Debugger User’s Guide
.
TMS320C54x C Source
1-4
Page 27
Chapter 2
Introduction to Common Object File Format
The assembler and linker create object files that can be executed by a
TMS320C54x device. The format for these object files is called common object
file format (COFF).
COFF makes modular programming easier, because it encourages you to
think in terms of blocks of code and data when you write an assembly language
program. These blocks are known as
linker provide directives that allow you to create and manipulate sections.
This chapter provides an overview of COFF sections. For additional
information, see Appendix A,
COFF structure.
Each COFF file type has a different header format. The data portions of the
COFF files are identical. For details about the COFF file structure, see
Appendix A,
The TMS320C54x assembler and C compiler create COFF2 files. The linker
can read and write all types of COFF files. By default, the linker creates COFF2
files. Use the –v linker option to specify a different format. The linker supports
COFF0 and COFF1 files for older versions of the assembler and C compiler
only.
COFF0
COFF1
COFF2
Common Object File Format
.
2.2Sections
The smallest unit of an object file is called a
section
. A section is a block of code
or data that will ultimately occupy contiguous space in the memory map. Each
section of an object file is separate and distinct. COFF object files always contain three default sections:
.text sectionusually contains executable code
.data sectionusually contains initialized data
.bss sectionusually reserves space for uninitialized variables
In addition, the assembler and linker allow you to create, name, and link
named
sections that are used like the .data, .text, and .bss sections.
There are two basic types of sections:
initialized sectionscontain data or code. The .text and .data sections
are initialized; named sections created with the
.sect assembler directive are also initialized.
uninitialized sectionsreserve space in the memory map for uninitialized
data. The .bss section is uninitialized; named
sections created with the .usect assembler directive are also uninitialized.
2-2
Page 29
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 memory map;
this function is called
allocation
. Because most systems contain several types
of memory, using sections can help you use target memory more efficiently.
All sections are independently relocatable; you can place any section into any
allocated block of target memory . For example, you can define a section that
contains an initialization routine and then allocate the routine into a portion of
the memory map that contains ROM.
Figure 2–1 shows the relationship between sections in an object file and a
hypothetical target memory.
Figure 2–1. Partitioning Memory Into Logical Blocks
Sections
Object File
.bss
.data
.text
Target Memory
RAM
EEPROM
ROM
Introduction to Common Object File Format
2-3
Page 30
How the Assembler Handles Sections
2.3How the Assembler Handles Sections
The assembler identifies the portions of an assembly language program that
belong in a section. The assembler has five directives that support this
function:
-
.bss
-
.usect
-
.text
-
.data
-
.sect
The .bss and .usect directives create
and .sect directives create
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 subsection 2.3.4,
information.
Note: Default Section Directive
If you don’t use any of the sections directives, the assembler assembles
everything into the .text section.
2.3.1Uninitialized Sections
Uninitialized sections reserve space in processor memory; they are usually
allocated into RAM. These sections have no actual contents in the object file;
they simply reserve memory. A program can use this space at runtime for
creating and storing variables.
Uninitialized data areas are built by using the .bss and .usect assembler
directives.
uninitialized sections
initialized sections
.
Subsections
; the .text, .data,
, page 2-8, for more
2-4
-
The .bss directive reserves space in the .bss section.
-
The .usect directive reserves space in a specific, uninitialized named
section.
Each time you invoke the .bss directive, the assembler reserves more space
in the appropriate section. Each time you invoke the .usect directive, the
assembler reserves more space in the specified named section.
Page 31
The syntax for these directives is:
.bss
symbol, size in words [, [blocking flag]
symbol
.usect ”
section name ”, size in words
How the Assembler Handles Sections
[,
alignment flag
[, [
blocking flag]
]]
[,
alignment flag
]]
symbol
size in words
blocking flag
alignment flag
section name
points to the first word reserved by this invocation of the .bss
or .usect directive. The
symbol
corresponds to the name of
the variable that you’re reserving space for. It can be referenced by any other section and can also be declared as a
global symbol (with the .global assembler directive).
is an absolute expression.
-
The .bss directive reserves
size
words in the .bss sec-
tion.
-
The .usect directive reserves
size
words in
section
name.
is an optional parameter. If you specify a value greater than
0 for this parameter, the assembler associates size words
contiguously; the allocated space will not cross a page
boundary , unless size is greater than a page, in which case
the object will start on a page boundary.
is an optional parameter. If you specify a value greater than
0 for this parameter, the section is aligned to a long
word
boundary.
tells the assembler which named section to reserve space
in. For more information about named sections, see
subsection 2.3.3,
Named Sections
, on page 2-7.
The .text, .data, and .sect directives tell the assembler to stop assembling into
the current section and begin assembling into the indicated section. The .bss
and .usect directives, however,
do not
end the current section and begin a new
one; they simply escape temporarily from the current section. The .bss and
.usect directives can appear anywhere in an initialized section without
affecting its contents.
Uninitialized subsections are created with the .usect directive. The assembler
treats uninitialized subsections in the same manner as uninitialized sections.
See subsection 2.3.4,
Subsections
, on page 2-8 for more information on
creating subsections.
Introduction to Common Object File Format
2-5
Page 32
How the Assembler Handles Sections
2.3.2Initialized Sections
Initialized sections contain executable code or initialized data. The contents
of these sections are stored in the object file and placed in processor memory
when the program is loaded. Each initialized section is independently relocatable and may reference symbols that are defined in other sections. The linker
automatically resolves these section-relative references.
Three directives tell the assembler to place code or data into a section. The
syntaxes for these directives are:
.text [
value
.data [
value
.sect ”
When the assembler encounters one of these directives, it stops assembling
into the current section (acting as an implied end-current-section command).
It then assembles subsequent code into the designated section until it encounters another .text, .data, or .sect directive. The
starting value of the section program counter. The starting value of the section
program counter can be specified only once; it must be done the first time the
directive for that section is encountered. By default, the SPC starts at 0.
section name
]
]
” [,
value
]
value
, if present, specifies the
2-6
Sections are built through an iterative process. For example, when the assembler first
encounters a .data directive, the .data section is empty. The statements following this first .data directive are assembled into the .data section
(until the assembler encounters a .text or .sect directive). If the assembler
encounters subsequent .data directives, it adds the statements following
these .data directives to the statements already in the .data section. This
creates a single .data section that can be allocated contiguously into memory .
Initialized subsections are created with the .sect directive. The assembler
treats initialized subsections in the same manner as initialized sections. See
subsection 2.3.4,
Subsections
, on page 2-8 for more information on creating
subsections.
Page 33
2.3.3Named Sections
How the Assembler Handles Sections
Named sections are sections that
you
create. Y ou can use them like the default
.text, .data, and .bss sections, but they are assembled separately.
For example, repeated use of the .text directive builds up a single .text section
in the object file. When linked, this .text section is allocated into memory as a
single unit. Suppose there is a portion of executable code (perhaps an initialization routine) that you don’t want allocated with .text. If you assemble this
segment of code into a named section, it is assembled separately from .text,
and you can allocate it into memory separately . Y ou can also assemble initialized data that is separate from the .data section, and you can reserve space
for uninitialized variables that is separate from the .bss section.
Two directives let you create named sections:
-
The .usect directive creates sections that are used like the .bss section.
These sections reserve space in RAM for variables.
-
The .sect directive creates sections, like the default .text and .data
sections, that can contain code or data. The .sect directive creates named
sections with relocatable addresses.
The syntax for these directives is shown below:
symbol
.usect ”
.sect ”
section name”, size in words
section name
”
[, [
blocking flag
] [,
alignment flag
]]
The
section name
parameter is the name of the section. Y ou can create up to
32 767 separate named sections. A section name can be up to 200 characters.
For COFF1 files, only the first 8 characters are significant. For the .sect and
.usect directives, a section name can refer to a subsection (see subsection
2.3.4,
Subsections
, for details).
Each time you invoke one of these directives with a new name, you create a
new named section. Each time you invoke one of these directives with a name
that was already used, the assembler assembles code or data (or reserves
space) into the section with that name.
different directives
. That is, you cannot create a section with the .usect direc-
You cannot use the same names with
tive and then try to use the same section with .sect.
Introduction to Common Object File Format
2-7
Page 34
How the Assembler Handles Sections
2.3.4Subsections
Subsections are smaller sections within larger sections. Like sections,
subsections can be manipulated by the linker. Subsections give you tighter
control of the memory map. Y ou can create subsections by using the .sect or
.usect directive. The syntax for a subsection name is:
section name:subsection name
A subsection is identified by the base section name followed by a colon, then
the name of the subsection. A subsection can be allocated separately or
grouped with other sections using the same base name. For example, to
create a subsection called _func within the .text section, enter the following:
.sect ”.text:_func”
You can allocate _func separately or within all the .text sections.
You can create two types of subsections:
-
Initialized subsections are created using the .sect directive. See
subsection 2.3.2,
Initialized Sections
, on page 2-6.
-
Uninitialized subsections are created using the .usect directive. See
subsection 2.3.1,
Subsections are allocated in the same manner as sections. See Section 7.8,
The SECTIONS Directive
2.3.5Section Program Counters
The assembler maintains a separate program counter for each section. These
program counters are known as
An SPC represents the current address within a section of code or data.
Initially , the assembler sets each SPC to 0. As the assembler fills a section with
code or data, it increments the appropriate SPC. If you resume assembling into
a section, the assembler remembers the appropriate SPC’s previous value
and continues incrementing the SPC at that point.
The assembler treats each section as if it began at address 0; the linker
relocates each section according to its final location in the memory map. For
more information, see Section 2.5,
Uninitialized Sections
, on page 2-4.
, on page 7-32 for more information.
section program counters
Relocation
, on page 2-15.
, or SPCs.
2-8
Page 35
2.3.6An Example That Uses Sections Directives
Example 2–1 shows how you can build COFF sections incrementally, using
the sections directives to swap back and forth between the different sections.
Y ou can use sections directives to begin assembling into a section for the first
time, or to continue assembling into a section that already contains code. In
the latter case, the assembler simply appends the new code to the code that
is already in the section.
The format in Example 2–1 is a listing file. Example 2–1 shows how the SPCs
are modified during assembly. A line in a listing file has four fields:
Field 1contains the source code line counter.
Field 2contains the section program counter.
Field 3contains the object code.
Field 4contains the original source statement.
How the Assembler Handles Sections
Introduction to Common Object File Format
2-9
Page 36
How the Assembler Handles Sections
Example 2–1. Using Sections Directives
2************************************************
3** Assemble an initialized table into .data. **
4************************************************
5000000.data
6000000 0011coeff.word011h,022h,033h
000001 0022
000002 0033
7************************************************
8** Reserve space in .bss for a variable. **
9************************************************
10 000000.bssbuffer,10
11************************************************
12** Still in .data. **
13************************************************
14 000003 0123ptr.word0123h
15************************************************
16** Assemble code into the .text section. **
17************************************************
18 000000.text
19 000000 100fadd:LD0Fh,A
20 000001 f010aloop:SUB#1,A
000002 0001
21 000003 f842BCaloop,AGEQ
000004 0001’
22************************************************
23** Another initialized table into .data. **
24************************************************
25 000004.data
26 000004 00aaivals.word0AAh, 0BBh, 0CCh
000005 00bb
000006 00cc
27************************************************
28** Define another section for more variables. **
29************************************************
30 000000var2.usect”newvars”, 1
31 000001inbuf.usect”newvars”, 7
32************************************************
33** Assemble more code into .text. **
34************************************************
35 000005.text
36 000005 110ampy:LD0Ah,B
37 000006 f166mloop:MPY#0Ah,B
000007 000a
38 000008 f868BCmloop,BNOV
000009 0006’
39************************************************
40** Define a named section for int. vectors. **
41************************************************
42 000000.sect”vectors”
43 000000 0011.word011h, 033h
44 000001 0033
2-10
Field 2Field 1Field 3Field 4
Page 37
How the Assembler Handles Sections
As Figure 2–2 shows, the file in Example 2–1 creates five sections:
.textcontains ten 16-bit words of object code.
.datacontains seven words of object code.
vectorsis a named section created with the .sect directive; it contains
two words of initialized data.
.bssreserves 10 words in memory.
newvarsis a named section created with the .usect directive; it reserves
eight words in memory.
The second column shows the object code that is assembled into these
sections; the first column shows the line numbers of the source statements that
generated the object code.
Figure 2–2. Object Code Generated by the File in Example 2–1
A character string is a string of characters enclosed in
double
quotes. Double
quotes that are part of character strings are represented by two consecutive
double quotes. The maximum length of a string varies and is defined for each
directive that requires a character string. Characters are represented
internally as 8-bit ASCII characters.
These are examples of valid character strings:
”sample program”defines the 14-character string
”PLAN ””C”””defines the 8-character string
sample program.
PLAN ”C”.
Character strings are used for the following:
-
Filenames, as in .copy ”filename”
-
Section names, as in .sect ”section name”
-
Data initialization directives, as in .byte ”charstring”
-
Operands of .string directives
Assembler Description
3-17
Page 64
Symbols
3.8Symbols
3.8.1Labels
Symbols are used as labels, constants, and substitution symbols. A symbol
name is a string of up to 200 alphanumeric characters (A –Z, a–z, 0–9, $,
and _). The first character in a symbol cannot be a number, and symbols cannot contain embedded blanks. The symbols you define are case sensitive; for
example, the assembler recognizes ABC, Abc, and abc as three unique
symbols. You can override case sensitivity with the – c assembler option. A
symbol is valid only during the assembly in which it is defined, unless you use
the .global directive to declare it as an external symbol.
Symbols used as labels become symbolic addresses associated with locations in the program. Labels used locally within a file must be unique.
Mnemonic opcodes and assembler directive names (without the ”.” prefix) are
valid label names.
Labels can also be used as the operands of .global, .ref, .def, or .bss directives;
for example:
.globallabel1
label2NOP
3.8.2Symbolic Constants
Symbols can be set to constant values. By using constants, you can equate
meaningful names with constant values. The .set and .struct/.tag/.endstruct
directives enable you to set constants to symbolic names. Symbolic constants
cannot
be used:
K.set1024;constant definitions
maxbuf .set2*K
value .set0.
delta .set1.
item.struct;item structure definition
i_len .endstruct
array .tagitem;array declaration
The assembler also has several predefined symbolic constants; these are
discussed in the next section.
ADDlabel1,B
Blabel2
be redefined. The following example shows how these directives can
.intvalue;constant offsets value = 0
.intdelta;constant offsets delta = 1
.bssarray, i_len*K
3-18
Page 65
3.8.3Defining Symbolic Constants (–d Option)
The –d option equates a constant value with a symbol. The symbol can then
be used in place of a value in assembly source. The format of the –d option
is as follows:
Symbols
asm500 –d
The
name
name=[value
is the name of the symbol you want to define. The
you want to assign to the symbol. If the
Within assembler source, you may test the symbol with the following direc-
tives:
Type of TestDirective Usage
Existence.if $isdefed(”
Nonexistence.if $isdefed(”
Equal to value.if
Not equal to value.if
Note that the argument to the $isdefed built-in function must be enclosed in
quotes. The quotes cause the argument to be interpreted literally rather than
as a substitution symbol.
3.8.4Predefined Symbolic Constants
The assembler has several predefined symbols, including the following:
]
value
is the value
value
is omitted, the symbol is set to 1.
name
”)
name
”) = 0
name
=
value
name
!=
value
-
$, the dollar sign character, represents the current value of the section
program counter (SPC).
-
Register symbols, including AR0 – AR7
-
Symbols that are defined by using the .mmregs directive (see Table 4–2
on page 4-70 for a list of registers)
Assembler Description
3-19
Page 66
Symbols
3.8.5Substitution Symbols
Symbols can be assigned a string value (variable). This enables you to alias
character strings by equating them to symbolic names. Symbols that
represent character strings are called substitution symbols. When the
assembler encounters a substitution symbol, its string value is substituted for
the symbol name. Unlike symbolic constants, substitution symbols can be
redefined.
A string can be assigned to a substitution symbol anywhere within a program;
for example:
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.macroADDRA,ADDRB ;add2 macro definition
LD ADDRA, A
ADD ADDRB, A
STL A, ADDRB
.endm
; add2 invocation
add2 LOC1, LOC2;add ”LOC1” argument to a
;second argument ”LOC2”.
; instructions for expanded macro:
;LD LOC1, A
;ADD LOC2, A
;STL A, LOC2
For more information about macros, see Chapter 5,
Macro Language
.
3-20
Page 67
3.8.6Local Labels
Symbols
Local labels are special labels whose scope and effect are temporary . A local
label can be defined in two ways:
-
$n, where n is a decimal digit in the range of 0–9. For example, $4 and $1
are valid local labels.
-
NAME?, where NAME is any legal symbol name as described above. The
assembler replaces the question mark with a period followed by a unique
number. When the source code is expanded, you will not see the unique
number in the listing file. Your label appears with the question mark as it
did in the macro definition. You cannot declare this label as global.
Normal labels must be unique (they can be declared only once), and they can
be used as constants in the operand field. Local labels, however, can be
undefined and defined again or automatically generated. Local labels cannot
be defined by directives.
A local label can be undefined, or reset, in one of four ways:
-
By using the .newblock directive
-
By changing sections (using a .sect, .text, or .data directive)
-
By entering an include file (specifying the .include or .copy directive)
-
By leaving an include file (specifying the .include or .copy directive)
Example 3–1 demonstrates the $n form. This example assumes that symbols
ADDRA, ADDRB, ADDRC have been defined previously.
Example 3–1. $n Local Labels
(a) Code that uses a local label legally
Label1:LD ADDRA, A; Load Address A to Accumulator A.
$1LD ADDRA, A; $1: load ADDRA to Accumulator A.
$2ADD ADDRC, A; $2: add ADDRC.
$1NOP
SUB ADDRB, A; Subtract Address B.
BC $1, ALT; If less than zero, branch to $1;
LD ADDRB, A; otherwise, load ADDRB to A
B $2; and branch to $2.
.newblock ; Undefine $1 so it can be used
; again.
BC $1, ALT; If less than zero, branch to $1.
STL A, ADDRC; Store ACC low in ADDRC.
Assembler Description
3-21
Page 68
Symbols
(b) Code that uses a local label illegally
Label1:LD ADDRA, A; Load Address A to Accumulator A.
$1LD ADDRA, A; $1: Load ADDRA To Accumulator A.
$2ADD ADDRC, A; $2: Add ADDRC.
$1NOP ; WRONG: $1 is multiply defined.
SUB ADDRB, A; Subtract Address B.
BC $1, ALT; If less than zero, branch to $1;
LD ADDRB, A; otherwise, load ADDRB To A
B $2; and Branch to $2.
BC $1, ALT; If less than 0, branch to $1.
STL A, ADDRC; Store Acc low in ADDRC.
Local labels are especially useful in macros. If a macro contains a normal label
and is called more than once, the assembler issues a multiple-definition error.
If you use a local label and .newblock within a macro, however, the local label
is used and reset each time the macro is expanded.
Up to ten local labels can be in effect at one time. After you undefine a local
label, you can define it and use it again. Local labels do not appear in the object
code symbol table.
The maximum label length is shortened to allow for the unique suffix. If the
macro is expanded fewer than 10 times, the maximum label length is 126 characters. If the macro is expanded from 10 to 99 times, the maximum label length
is 125.
3-22
name
Example 3–2 demonstrates the
? form.
Page 69
Example 3–2. name? Local Labels
;*********************************************************
; First definition of local label ’mylab’
;*********************************************************
nop
mylab?nop
b mylab?
;*********************************************************
; Include file has second definition of ’mylab’
;*********************************************************
b mylab?
;*********************************************************
; Fourth definition of ’mylab’ in macro, macros use
; different namespace to avoid conflicts
;*********************************************************
mymac.macro
mylab?nop
mymac
;*********************************************************
; Reference to third definition of ’mylab’, note that
; definition is not reset by macro invocation nor
; conflicts with same name defined in macro
;*********************************************************
b mylab?;
*********************************************************
; Changing section, allowing fifth definition of ’mylab’
;*********************************************************
.sect ”Secto_One”
nop
mylab?.word 0
nop
nop
b mylab?
;*********************************************************
;.newblock directive, allowing sixth definition of ’mylab’
An expression is a constant, a symbol, or a series of constants and symbols
separated by arithmetic operators. The range of valid expression values is
–32 768 to 32 767. Three main factors influence the order of expression evaluation:
ParenthesesExpressions that are enclosed in parentheses are
Precedence groupsThe ’C54x assembler uses the same order of pre-
cedence as the C language does as summarized
in Table 3–1. This differs from the order of precedence of other TMS320 assemblers. 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 as happens in the C
language.
8 / 4*2 = 4 , but 8 / (4*2) = 1
3-24
Page 71
3.9.1Operators
Table 3–1 lists the operators that can be used in expressions.
Note: Differences in Precedence From Other TMS320 Assemblers
Some other TMS320 processors use a different order of precedence than
the TMS320C54x, and occasionally different results may be produced from
the same source code for this reason. The ’C54x uses the same order of precedence as the C language.
Table 3–1. Operators Used in Expressions (Precedence)
SymbolsOperatorsEvaluation
+ – ~Unary plus, minus, 1s complementRight to left
* / %Multiplication, division, moduloLeft to right
+ –Addition, subtractionLeft to right
<< >>Left shift, right shiftLeft to right
Expressions
< <= > >=Less than, LT or equal, greater than,
GT or equal
!=, =[=]Not equal to, equal toLeft to right
&Bitwise ANDLeft to right
^Bitwise exclusive ORLeft to right
|Bitwise ORLeft to right
Note:Unary +, –, and * have higher precedence than the binary forms.
3.9.2Expression Overflow and Underflow
The assembler checks for overflow and underflow conditions when arithmetic
operations are performed at assembly time. It issues a V alue Truncated warn-
ing whenever an overflow or underflow occurs. The assembler
for overflow or underflow in multiplication.
Left to right
does not
check
Assembler Description
3-25
Page 72
Expressions
3.9.3Well-Defined Expressions
Some assembler directives require well-defined expressions as operands.
Well-defined expressions contain only symbols or assembly-time constants
that are defined before they are encountered in the expression. The evaluation
of a well-defined expression must be absolute.
Example 3–3. Well-Defined Expressions
(a) Valid well-defined expressions
label1.word 0
label2.word 3
X.set50h
goodsym1 .set100h + X: Because value of X is defined before
goodsym2 .set$; All references to previously defined local
goodsym3 .setlabel1: labels, including the current SPC ($), are
goodsym4 .setlabel2 – label1; Although label1 and label2 are not
(b) Invalid well-defined expressions
.data
.word 1
.word 2
; referenced, this is a valid well-defined
; expression
; considered to be well-defined.
; absolute symbols, because they are local
; labels defined in the same section, their
; difference can be computed by the assembler.
; The difference is absolute, so the
; expression is well-defined.
.global Y
badsym1 .setY; Because Y is external and is not defined in
badsym2 .set50h + Y; the current file, its value is unknown to
badsym3 .set50h + Z; Although Z is defined in the current file,
Z.set60h; its definition appears after the expression
3-26
; the assembler. Therefore, it cannot be used
; where a well-defined expression is needed.
; in which it is used. All symbols and
; constants that appear in well-defined
; expressions must be defined before they are
; referenced.
Page 73
3.9.4Conditional 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= =Equal to
! =Not equal to
<Less than<=Less than or equal to
>Greater than> =Greater than or equal to
Conditional expressions evaluate to 1 if true and 0 if false; they 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.
3.9.5Relocatable Symbols and Legal Expressions
T able 3–2 summarizes valid operations on absolute, relocatable, and external
symbols. An expression cannot contain multiplication or division by a relocatable or external symbol. An expression cannot contain unresolved symbols
that are relocatable to other sections.
Expressions
Symbols or registers that have been defined as global with the .global directive
can also be used in expressions; in T able 3–2, these symbols and registers are
referred to as
external
.
Relocatable registers can be used in expressions; the addresses of these
registers are relocatable with respect to the register section they were defined
in, unless they have been declared as external.
Table 3–2. Expressions With Absolute and Relocatable Symbols
If A is... andIf B is... , thenA + B is... andA – B is...
A and B must be in the same section; otherwise, this is illegal.
†
Assembler Description
3-27
Page 74
Expressions
Following are examples of expressions that use relocatable and absolute symbols. These examples use four symbols that are defined in the same section:
.global extern_1 ; Defined in an external module
intern_1: .word ’”D’ ; Relocatable, defined in current module
LAB1: .set 2 ; LAB1 = 2
intern_2 ; Relocatable, defined in current module
Example 1
-
The statements in this example use an absolute symbol, LAB1 (which is
defined above to have a value of 2). The first statement loads the value 51
into the accumulator:
LD #LAB1 + ((4+3) * 7), A ; ACC A = 51
LD #LAB1 + 4 + (3*7), A ; ACC A = 27
-
Example 2
All legal expressions can be reduced to one of two forms:
relocatable symbol ± absolute symbol
or
absolute value
Unary operators can be applied only to absolute values; they cannot be
applied to relocatable symbols. Expressions that cannot be reduced to
contain only one relocatable symbol are illegal. The first statement in the
following example is valid; the statements that follow it are invalid.
LD extern_1 – 10, B ; Legal
LD 10–extern_1, B ; Can’t negate reloc. symbol
LD –(intern_1), B ; Can’t negate reloc. symbol
LD extern_1/10, B ; / isn’t additive operator
LD intern_1 + extern_1, B ; Multiple relocatables
-
Example 3
The first statement below is legal; although intern_1 and intern_2 are
relocatable, their difference is absolute because they’re in the same
section. Subtracting one relocatable symbol from another reduces the
expression to
relocatable symbol + absolute value
. The second statement
is illegal because the sum of two relocatable symbols is not an absolute
value.
LD intern_1 – intern_2 + extern_1, B ; Legal
LD intern_1 + intern_2 + extern_1, B ; Illegal
-
Example 4
An external symbol’s placement is important to expression evaluation.
Although the statement below is similar to the first statement in the
previous example, it is illegal because of left-to-right operator precedence;
the assembler attempts to add intern_1 to extern_1.
LD intern_1 + extern_1 – intern_2, B ; Illegal
3-28
Page 75
3.10 Built-in Functions
The assembler supports built-in functions for conversions and transcendental
math computations. Table 3–3 describes the built-in functions. Note that
must be a constant value. See Table 5–1 for a description of the assembler’s
non-mathematical built-in functions.
Table 3–3. Assembler Built-In Math Functions
FunctionDescription
$acos(
expr
)returns the arc cosine of
$asin(
expr
)returns the arc sine of
$atan(
expr
)returns the arc tangent of
expr
$atan2(
$ceil(
)returns the arc tangent of
(–pi to pi)
expr
)returns the smallest integer that is not less than the
expression
expr
as a floating-point value
expr
as a floating-point value
expr
as a floating-point value
expr
as a floating-point value
Built-in Functions
expr
$cosh(
$cos(
expr
$cvf(
expr
$cvi(
expr
expr
$exp(
$fabs(
$floor(
$fmod(
$int(
expr
$ldexp(
$log10(
$log(
expr
$max(
$min(
expr1, expr2
expr
)returns the hyperbolic cosine of
value
)returns the cosine of
)converts
)converts
)returns the result of raising e to the
expr
)returns absolute value of
expr
)returns the largest integer that is not greater than the
expression
expr1, expr2
)returns 1 if
expr1, expr2
)returns the remainder after dividing
)returns the result of
expr2
expr
)returns the base 10 logarithm of
)returns the natural logarithm of
expr1, expr2
)returns the maximum of 2 expressions
)returns the minimum of 2 expressions
expr
expr
expr
power
expr
to floating-point value
to integer value
has an integer result
expr1
expr
as a floating-point
as a floating-point value
expr
power
expr
as a floating-point value
expr1
multiplied by 2 raised to the
expr
expr
and
expr2
Assembler Description
3-29
Page 76
Extended Addressing Support
Built-in Functions / Extended Addressing Support
Table 3–3. Assembler Built-In Math Functions (Continued)
FunctionDescription
$pow(
expr1, expr2
)raises
expr1
to the power
expr
2
$round(
$sgn(
$sin(
$sinh(
$sqrt(
$tan(
$tanh(
$trunc(
expr
)returns the result of
expr
)returns the sign of
expr
)returns the sine of
expr
)returns the hyperbolic sine of
expr
)returns the square root of
expr
)returns the tangent of
expr
)returns the hyperbolic tangent of
expr
)returns the result of
3.11 Extended Addressing Support
The assembler accepts a pseudo-op, LDX, for loading the value of a label,
function, etc. that resides (or may reside) in extended program memory . LDX
is used to load the upper 8 bits of a 24-bit address.
For example, if a function, F1, is in extended program memory (which is 24 bits
instead of 16), the value or address of F1 may be loaded as follows:
value
value
expr
rounded to the nearest integer
expr
expr
as a floating-point value
expr
as a floating-point
expr
as a floating-point value
expr
as a floating-point value
expr
as a floating-point
expr
rounded toward zero
3-30
LDX#F1,16,A;loads the upper 8 bits of the 24-bit
;address of F1
OR#F1,A,A;adds in the lower 16 bits of the
;address of F1
BACCA;all 24 bits of F1 have been loaded
;into accumulator A
Note that it is necessary to use both LDX and OR to load the entire 24-bit
address.
Page 77
3.12 Source Listings
A source listing shows source statements and the object code they produce.
To obtain a listing file, invoke the assembler with the –l (lowercase L) option.
Two banner lines, a blank line, and a title line are at the top of each source listing page. Any title supplied by a .title directive is printed on the title line; a page
number is printed to the right of the title. If you don’t 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 may produce a line in the listing file that shows a
source statement number, an SPC value, the object code assembled, and the
source statement. A source statement may produce more than one word of
object code. The assembler lists the SPC value and object code on a separate
line for each additional word. Each additional line is listed immediately
following the source statement line.
Field 1: Source Statement Number
Source Listings
Line Number
The source statement number is a decimal. 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
The assembler may precede a line with a letter; the letter indicates
that the line is assembled from an included file.
Nesting Level Number
The assembler may precede a line with a number; the number indicates the nesting level of macro expansions or loop blocks.
Field 2: Section Program Counter
This field contains the section program counter (SPC) value, which
is hexadecimal. All sections (.text, .data, .bss, and named sections)
maintain separate SPCs. Some directives do not affect the SPC and
leave this field blank.
Assembler Description
3-31
Page 78
Source Listings
Field 3: Object Code
This field contains the hexadecimal representation of the object
code. All machine instructions and directives use this field to list
object code. This field also indicates the relocation type by appending one of the following characters to the end of the field:
This field contains the characters of the source statement as they
were scanned by the assembler. The assembler accepts a maximum
line length of 200 characters. Spacing in this field is determined by
the spacing in the source statement.
Example 3–4 shows an assembler listing with each of the four fields identified.
A cross-reference listing shows symbols and their definitions. To obtain a
cross-reference listing, invoke the assembler with the –x option or use the
.option directive. The assembler will append the cross-reference to the end of
the source listing.
Labelcolumn contains each symbol that was defined or referenced
Valuecolumn contains a hexadecimal number, which is the value
Definition(DEFN) column contains the statement number that defines
Reference(REF) column lists the line numbers of statements that refer-
Table 3–4. Symbol Attributes
Character or NameMeaning
REF
UNDF
’Symbol defined in a .text section
”Symbol defined in a .data section
+Symbol defined in a .sect section
–Symbol defined in a .bss or .usect section
during the assembly.
assigned to the symbol or a name that describes the symbol’s
attributes. A value may also be followed by a character that
describes the symbol’s attributes. Table 3–4 lists these characters and names.
the symbol. This column is blank for undefined symbols.
ence the symbol. A blank in this column indicates that the symbol was never used.
External reference (.global symbol)
Undefined
Assembler Description
3-35
Page 82
Cross-Reference Listings
Note that when the assembler generates a cross–reference listing for an
assembly file that contains .include directives, it keeps a record of the include
file and line number in which a symbol is defined/referenced. It does this by
assigning a letter reference (A, B, C, etc.) for each include file. The letters are
assigned in the order in which the .include directives are encountered in the
assembly source file.
The A in the cross–reference listing refers to incl0.asm (the first file included).
B refers to incl1.asm; C refers to incl2.asm.
Assembler Description
3-37
Page 84
Chapter 4
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 (Sections 4.1 through 4.10)
describes the directives according to function, and the second part
(Section 4.11) is an alphabetical reference.
This section summarizes the assembler directives.
Besides the assembler directives documented here, the TMS320C54x
software tools support the following directives:
-
The assembler uses several directives for macros. The macro directives
are listed in this chapter, but they are described in detail in Chapter 5,
Macro Language
-
The absolute lister also uses directives. Absolute listing directives are not
entered by the user but are inserted into the source program by the
absolute lister. Chapter 8,
directives; they are not discussed in this chapter.
-
The C compiler uses directives for symbolic debugging. Unlike other
directives, symbolic debugging directives are not used in most assembly
language programs. Appendix B,
discusses these directives; they are not discussed in this chapter.
.
Absolute Lister Description
Symbolic Debugging Directives
, discusses these
,
Note: Labels and Comments in Syntax
Any source statement that contains a directive may also contain a label and
a comment. Labels begin in the first column (they are the only elements, except comments, that can appear in the first column), and comments must be
preceded by a semicolon or an asterisk if the comment is the only statement
on the line. To improve readability, labels and comments are not shown as
part of the directive syntax.
Table 4–1. Assembler Directives Summary
(a) Directives that define sections
Mnemonic and SyntaxDescriptionPage
.bss
symbol, size in words [, blocking
[,
alignment
.clink [”
.dataAssemble into the .data (initialized data) section4-39
.sect ”
.textAssemble into the .text (executable code) section4-88
symbol
section name
section name
.usect”
]
”]Enables conditional linking for the current or specified
(c) Directives that align the section program counter (SPC)
Mnemonic and SyntaxDescriptionPage
.align [
size in words
.evenAlign the SPC to a word boundary.4-27
(d) Directives that format the output listing
Mnemonic and SyntaxDescriptionPage
.drlistEnable listing of all directive lines (default)4-41
.drnolistSuppress listing of certain directive lines4-41
.fclistAllow false conditional code block listing (default)4-46
.fcnolistSuppress false conditional code block listing4-46
]Align the SPC on a word boundary specified by the
parameter; the parameter must be a power of 2, or
default to page boundary . Aligns to word (1), even (2),
etc.
4-27
.length
.listRestart the source listing4-61
.mlistAllow macro listings and loop blocks (default)4-69
.mnolistSuppress macro listings and loop blocks4-69
.nolistStop the source listing4-61
.option {B | L | M | R | T | W | X}Select output listing options4-74
.pageEject a page in the source listing4-76
.sslistAllow expanded substitution symbol listing4-81
.ssnolistSuppress expanded substitution symbol listing
(h) Directives that define symbols at assembly time
Mnemonic and SyntaxDescriptionPage
.asg [”]
substitution symbol
.endstructEnd structure definition4-84
.endunionEnd union definition4-90
.equEquate a value with a symbol4-79
character string
[”],
Assign a character string to a substitution symbol4-28
well-defined expression
.eval
substitution symbol
.label
symbol
.setEquate a value with a symbol4-79
.structBegin structure definition4-84
.tagAssign structure attributes to a label4-84
.union
,
Perform arithmetic on numeric substitution
symbols
Define a load-time relocatable label in a section4-59
Begin union definition4-90
4-28
(i) Miscellaneous directives
Mnemonic and SyntaxDescriptionPage
.algebraicSignifies that the file contains algebraic assembly
source
.c_modeSignifies that calls and branches are within the normal
16-bit address range.
.emsg
string
.endEnd program4-44
.far_modeSignifies that calls and branches are far calls4-45
.mmregsEnter memory-mapped registers into the symbol table4-70
.mmsg
.newblockUndefine local labels4-73
.sblock [”]
[, ... , ”
.version [
.wmsg
string
section name
value
string
[”]
section name
]Specify the device for which processor instructions
”]
Send user-defined error messages to the output
device
Send user-defined messages to the output device4-42
Designates sections for blocking4-77
are being built
Send user-defined warning messages to the output
device
4-26
4-35
4-42
4-97
4-42
4-6
Page 90
Compatibility With the TMS320C1x/C2x/C2xx/C5x Assembler Directives
4.2Compatibility With the TMS320C1x/C2x/C2xx/C5x Assembler Directives
This section explains how the TMS320C54x assembler directives differ from
the TMS320C1x/C2x/C2xx/C5x assembler directives.
-
The ’C54x .long and .float directives place the
value at the lower address, while the ’C1x/C2x/C2xx/C5x assembler direc-
least
tives place the
significant word at the lower address. Also, the ’C54x
.long and .float directives automatically align the SPC on an even word
boundary, while the ’C1x/C2x/C2xx/C5x assembler directives do not.
-
Without arguments, the ’C54x and the ’C1x/C2x/C2xx/C5x assemblers
both align the SPC at the next 128-word boundary. However, the ’C54x
.align directive also accepts a constant argument, which must be a power
of 2, and this argument causes alignment of the SPC on that word boundary. The .align directive for the ’C1x/C2x/C2xx/C5x assembler does not
accept this constant argument.
-
The .field directive for the ’C54x packs fields into words starting at the
significant bit of the word. The ’C1x/C2x/C2xx/C5x assembler .field directive places fields into words starting at the
most
significant word of the
least
significant bit of the word.
most
-
The .field directive for the ’C54x handles values of 1 to 32 bits, contrasted
with the ’C1x/C2x/C2xx/C5x assembler which handles values of 1 to 16
bits. With the ’C54x assembler, objects that are 16 bits or larger start on
a word boundary and are placed with the most significant bits at the lower
address.
-
The ’C54x .bss and .usect directives have an additional flag called the
alignment flag which specifies alignment on an even word boundary . The
’C1x/C2x/C2xx/C5x .bss and .usect directives do not use this flag.
-
The .string directive for the ’C54x initializes one character per word, unlike
the ’C1x/C2x/C2xx/C5x assembler .string, which packs two characters
per word. The new .pstring directive packs two characters per word, as the
former .string did.
-
The following directives are new with the ’C54x assembler and are not
supported by the ’C1x/C2x/C2xx/C5x assembler:
DirectiveUsage
.xfloatSame as .float without automatic alignment
.xlongSame as .long without automatic alignment
.pstring
Same as .string, but packs two chars/word
Assembler Directives
4-7
Page 91
Directives That Define Sections
4.3Directives That Define Sections
These directives associate portions of an assembly language program with
the appropriate sections:
-
.bss reserves space in the .bss section for uninitialized variables.
-
.clink sets the STYP_CLINK flag in the type field for the named section.
The .clink directive can be applied to initialized or uninitialized sections.
The STYP_CLINK flag enables conditional linking by telling the linker to
leave the section out of the final COFF output of the linker if there are no
references found to any symbol in the section.
-
.data identifies portions of code in the .data section. The .data section
usually contains initialized data.
-
.sect defines initialized named sections and associates subsequent code
or data with that section. A section defined with .sect can contain code or
data.
-
.text identifies portions of code in the .text section. The .text section
usually contains executable code.
-
.usect 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,
Introduction to Common Object File Format
, discusses COFF
sections in detail.
4-8
Page 92
Directives That Define Sections
Example 4–1 shows how you can use sections directives to associate code
and data with the proper sections. This is an output listing; column 1 shows line
numbers, and column 2 shows the SPC values. (Each section has its own program counter, or SPC.) When code is first placed in a section, its SPC equals
0. When you resume assembling into a section after other code is assembled,
the section’s SPC resumes counting as if there had been no intervening code.
The directives in Example 4–1 perform the following tasks:
.textinitializes words with the values 1, 2, 3, 4, 5, 6, 7, and 8.
.datainitializes words with the values 9, 10, 11, 12, 13, 14, 15,
and 16.
var_defsinitializes words with the values 17 and 18.
.bssreserves 19 words.
xyreserves 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.
Assembler Directives
4-9
Page 93
Directives That Define Sections
Example 4–1. Sections Directives
1**************************************************.
2* Start assembling into the .text section *
3**************************************************
4000000.text
5000000 0001.word 1,2
6000002 0003.word 3,4
7
8**************************************************
9* Start assembling into the .data section *
10**************************************************
11000000.data
12000000 0009.word 9, 10
13000002 000B.word 11, 12
000003 000C
14
15**************************************************
16* Start assembling into a named, *
17* initialized section, var_defs *
18**************************************************
19000000.sect ”var_defs”
20000000 0011.word 17, 18
000001 0012
21
22**************************************************
23* Resume assembling into the .data section *
24**************************************************
25000004.data
26000004 000D.word 13, 14
000005 000E
27000000.bsssym, 19 ; Reserve space in .bss
28000006 000F.word 15, 16 ; Still in .data
000007 0010
29
30**************************************************
31* Resume assembling into the .text section *
32**************************************************
33000004.text
34000004 0005.word 5, 6
000005 0006
35000000usym.usect ”xy”, 20 ; Reserve space in xy
36000006 0007.word 7, 8 ; Still in .text
000007 0008
000001 0002
000003 0004
000001 000A
4-10
Page 94
4.4Directives That Initialize Constants
This section describles several directives that assemble values for the current
section.
-
The .bes and .space directives reserve a specified number of bits in the
current section. The assembler fills these reserved bits with 0s.
Y ou can reserve words by multiplying the desired number of words by 16.
J
When you use a label with .space, it points to the
contains reserved bits.
J
When you use a label with .bes, it points to the
reserved bits.
Figure 4–1 shows the .space and .bes directives. Assume the following
code has been assembled for this example:
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.
Directives That Initialize Constants
first
word that
last
word that contains
Figure 4–1. The .space and .bes Directives
17 bits
reserved
20 bits
reserved
Res_1 = 02h
Res_2 = 06h
Assembler Directives
4-1 1
Page 95
Directives That Initialize Constants
-
The .byte, .ubyte, .char, and .uchar directives place one or more 8-bit
values into consecutive words of the current section. These directives are
similar to .word and .uword, except that the width of each value is
restricted to 8 bits.
-
The .field directive places a single value into a specified number of bits
in the current word. With .field, you can pack multiple fields into a single
word; the assembler does not increment the SPC until a word is filled.
Figure 4–2 shows how fields are packed into a word. For this example,
assume the following code has been assembled; notice that the SPC
doesn’t change for the first three fields (the fields are packed into the same
word):
.float and .xfloat calculate the single-precision (32-bit) IEEE floatingpoint representation of a single floating-point value and store it in two consecutive words in the current section. The most significant word is stored
first. The .float directive automatically aligns to the long word boundary,
and .xfloat does not.
-
.int, .uint, .half, .uhalf, .short, .ushort, .word, and .uword place one or
more 16-bit values into consecutive words in the current section.
-
.double and .ldouble calculate the single-precision (32-bit) IEEE floating-
point representation of one or more floating-point values and store them
in two consecutive words in the current section. The .double directive
automatically aligns to the long word boundary.
-
.long, .ulong, and .xlong place 32-bit values into two consecutive words
in the current section. The most significant word is stored first. The .long
directive automatically aligns to a long word boundary, and the .xlong
directive does not.
-
.string and .pstring place 8-bit characters from one or more character
strings into the current section. The .string directive is similar to .byte, placing an 8-bit character in each consecutive word of the current section. The
.pstring also has a width of 8 bits but packs two characters into a word. For
.pstring, the last word in a string is padded with null characters (0) if
necessary.
Note: These Directives in a .struct/.endstruct Sequence
The directives listed above
do not
initialize memory when they are part of a
.struct/.endstruct sequence; rather, they define a member’s size. For more
information about the .struct/.endstruct directives, see Section 4.9,
Assembly-Time Symbol Directives
, on page 4-21.
Figure 4–3 compares the .byte, .int, .long, .xlong, .float, .xfloat, .word, and
.string directives. For this example, assume that the following code has been
assembled:
4.5Directives That Align the Section Program Counter
The .align directive aligns the SPC at a 1-word to 128-word boundary. This
ensures that the code following the directive begins on an x-word or page
boundary. If the SPC is already aligned at the selected boundary, it is not
incremented. Operands for the .align directive must equal a power of 2
0
between 2
example:
Operand of 1 aligns SPC to word boundary
The .align directive with no operands defaults to a page boundary.
The .even directive aligns the SPC so that it points to the next word boundary.
It is equivalent to specifying the .align directive with an operand of 1. Using
.even with an operand of 2 aligns the SPC to the next long word boundary . Any
unused bits in the current word are filled with 0s.
Figure 4–4 demonstrates the .align directive. Assume that the following code
has been assembled:
and 216 (although directives beyond 27 are not meaningful). For
2aligns SPC to long word/even boundary
128 aligns SPC to page boundary
The .drlist directive causes printing of the directive lines to the listing; the
.drnolist directive turns it off. You can use the .drnolist directive to
suppress the printing of the following directives:
You can use the .drlist directive to turn the listing on again.
-
The source code contains a listing of 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.
Directives That Format the Output Listing
-
The .list and .nolist directives turn the output listing on and off. You can
use the .nolist directive to stop the assembler from printing selected
source statements in the listing file. Use the .list directive to turn the listing
on again.
-
The source code contains a listing of macro expansions and loop blocks.
The .mlist and .mnolist directives turn this listing on and off. Y ou can use
the .mlist directive to print all macro expansions and loop blocks to the
listing, and the .mnolist directive to suppress this listing.
-
The .option directive controls certain features in the listing file. This
directive has the following operands:
Blimits the listing of .byte directives to one line.
Llimits the listing of .long directives to one line.
Mturns off macro expansions in the listing.
Rresets the B, M, T, and W options.
Tlimits the listing of .string directives to one line.
Wlimits the listing of .word directives to one line.
Xproduces a symbol cross-reference listing. (You can also obtain
a cross-reference listing by invoking the assembler with the
–x option.)
-
The .page directive causes a page eject in the output listing.
Assembler Directives
4-17
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.