Texas Instruments and its subsidiaries (TI) reserve the right to make changes to their products or to discontinue
any product or service without notice, and advise customers to obtain the latest version of relevant information
to verify, before placing orders, that information being relied on is current and complete. All products are sold
subject to the terms and conditions of sale supplied at the time of order acknowledgement, including those
pertaining to warranty, patent infringement, and limitation of liability.
TI warrants performance of its semiconductor products to the specifications applicable at the time of sale in
accordance with TI’s standard warranty. Testing 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, AUTHORIZED, OR
WARRANTED TO BE SUITABLE FOR USE IN LIFE-SUPPORT DEVICES OR SYSTEMS OR OTHER
CRITICAL APPLICATIONS. INCLUSION OF TI PRODUCTS IN SUCH APPLICATIONS IS UNDERSTOOD TO
BE FULLY AT THE CUSTOMER’S RISK.
In order to minimize risks associated with the customer’s applications, adequate design and operating
safeguards must be provided by the customer to minimize inherent or procedural hazards.
TI assumes no liability for applications assistance or customer product design. TI does not 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. TI’s publication of information regarding any third
party’s products or services does not constitute TI’s approval, warranty or endorsement thereof.
Copyright 1999, Texas Instruments Incorporated
About This Manual
Preface
Read This First
The TMS320C2x/C2xx/C5x Optimizing C Compiler User’s Guide tells you how
to use these compiler tools:
- Compiler
- Source interlist utility
- Optimizer
- Parser
- Library-build utility
The TMS320C2x/C2xx/C5x C compiler accepts American National Standards
Institute (ANSI) standard C source code and produces assembly language
source code for the TMS320C2x/C2xx/C5x devices. This user’s guide discusses the characteristics of the C compiler. It assumes that you already know
how to write C programs. The C Programming Language (second edition), by
Brian W. Kernighan and Dennis M. Ritchie (hereafter referred to as K & R),
describes C based on the ANSI C standard. You can use the Kernighan and
Ritchie book as a supplement to this manual.
Before you use the information about the C compiler in this User’s Guide, you
should read the TMS320C1x/C2x/ C2xx/C5x Code Generation Tools GettingStarted to install the C compiler tools.
iiiRead This First
How to Use This Manual
How to Use This Manual / Notational Conventions
How to Use This Manual
The goal of this book is to help you learn how to use the Texas Instruments C
compiler tools specifically designed for the TMS320C2x/C2xx/C5x devices.
This book is divided into three distinct parts:
- Introductory information, consisting of Chapter 1, provides an overview
of the TMS320C2x/C2xx/C5x development tools.
- Compiler description, consisting of Chapters 2, 5, 6, 7, and 8, describes
how to operate the C compiler and the shell program, and discusses
specific characteristics of the C compiler as they relate to the ANSI C specification. It contains technical information on the TMS320C2x/ C2xx/C5x
architecture and includes information needed for interfacing assembly
language to C programs. It describes libraries and header files in addition
to the macros, functions, and types they declare. Finally, it describes the
library-build utility.
- Reference material, consisting of Appendix B, provides a glossary.
Notational Conventions
This document uses the following conventions.
- Program listings, program examples, and interactive displays are shown
- In syntax descriptions, the instruction, command, or directive is in a bold
in a special typeface similar to a typewriter’s. 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 of C code:
# ifdef NDEBUG
# define assert
face font and parameters are in italics. Portions of a syntax that are in bold
face must 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 a directive syntax:
#include“filename”
The #include preprocessor directive has one required parameter, file-name. The filename must be enclosed in double quotes or angle brackets.
iv
Notational Conventions / Related Documentation From Texas Instruments
-
Square brackets ( [ and ] ) identify an optional parameter. If you use an optional parameter, you specify the information within the brackets; you do
not enter the brackets themselves. Here is an example of a command that
has an optional parameter:
clist asmfile [outfile] [−options]
J The clist command has three parameters.
J The first parameter, asmfile, is required.
J The second and third parameters, outfile and −options, are optional.
J If you omit the outfile, the file has the same name as the assembly file
with the extension .cl.
J Options are preceded by a hyphen.
Related Documentation From Texas Instruments
Related Documentation From Texas Instruments
The following books describe the TMS320C2x/C2xx/C5x 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, identify
the book by its title and literature number (located on the bottom-right corner
of the back cover).
TMS320C2x User’s Guide (literature number SPRU014) discusses the hard-
ware aspects of the ’C2x fixed-point digital signal processors. It describes pin assignments, architecture, instruction set, and software and
hardware applications. It also includes electrical specifications and package mechanical data for all ’C2x devices. The book features a section
with a ’C1x-to-’C2x DSP system migration.
TMS320C2xx User’s Guide (literature number SPRU127) discusses the
hardware aspects of the ’C2xx fixed-point digital signal processors. It describes pin assignments, architecture, instruction set, and software and
hardware applications. It also includes electrical specifications and package mechanical data for all ’C2xx devices. The book features a section
comparing instructions from ’C2x to ’C2xx.
TMS320C5x User’s Guide (literature number SPRU056) describes the
TMS320C5x 16-bit, fixed-point, general-purpose digital signal processors. Covered are its architecture, internal register structure, instruction
set, pipeline, specifications, DMA, and I/O ports. Software applications
are covered in a dedicated chapter.
vRead This First
Related Documentation From Texas Instruments
TMS320C1x/C2x/C2xx/C5x Assembly Language Tools User’s Guide (lit-
erature number SPRU018) describes the assembly language tools (assembler, linker, and other tools used to develop assembly language
code), assembler directives, macros, common object file format, and
symbolic debugging directives for the ’C1x, ’C2x, ’C2xx, and ’C5x generations of devices.
TMS320C2x Software Development System Technical Reference (liter-
ature number SPRU072) provides specific application and design information for using the TMS320C2x Software Development System
(SWDS) board.
TMS320C5x Software Development System Technical Reference (liter-
ature number SPRU066) provides specific application and design information for using the TMS320C5x Software Development System
(SWDS) board.
TMS320C2x C Source Debugger User’s Guide (literature number
SPRU070) tells how to use the ’C2x C source debugger with the ’C2x
emulator, software development system (SWDS), and simulator.
TMS320C5x C Source Debugger User’s Guide (literature number
SPRU055) tells you how to invoke the ’C5x emulator, EVM, 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, and includes a tutorial that introduces basic debugger
functionality.
vi
Related Documentation
The C Programming Language (second edition), by Brian W. Kernighan
You may find these documents helpful as well:
American National Standard for Information Systems—Programming
Programming in C, Kochan, Steve G., Hayden Book Company
Trademarks
MS-DOS is a registered trademark of Microsoft Corp.
PC-DOS is a trademark of International Business Machines Corp.
SPARC is a trademark of SPARC International, Inc.
Related Documentation From Texas Instruments
Related Documentation / Trademarks
and Dennis M. Ritchie, published by Prentice-Hall, Englewood Cliffs,
New Jersey, 1988.
Language C X3.159-1989, American National Standards Institute
(ANSI standard for C)
Sun-OS and Sun Workstation are trademarks of Sun Microsystems, Inc.
XDS is a trademark of Texas Instruments Incorporated.
Describes how to operate the C compiler and the shell program. Contains instructions for invoking the shell program, which compiles, assembles, and links a C source file. Discusses the interlist utility and compiler errors.
Describes how to optimize your C code, including such features as software pipelining and loop
unrolling. Also describes the types of optimizations that are performed when you use the optimizer.
Contains technical information on how the compiler uses the TMS320C2x/C2xx/C5x architecture. Discusses memory and register conventions, stack organization, function-call conventions, system initialization, and TMS320C2x/C2xx/C5x C compiler optimizations. Provides information needed for interfacing assembly language to C programs.
Describes the header files included with the C compiler, as well as the macros, functions, and
types they declare. Summarizes the runtime-support functions according to category (header),
and provides an alphabetical reference of the runtime-support functions.
Describes the utility that custom-makes runtime-support libraries for the options used to compile code. This utility can also be used to install header files in a directory and to create custom
libraries from source archives.
The TMS320C2x, TMS320C2xx, and TMS320C5x devices are members of
the TMS320 family of high-performance CMOS microprocessors optimized
for digital signal processing applications.
The TMS320C2x/C2xx/C5x DSPs are supported by a set of software development tools, which includes an optimizing C compiler, an assembler, a linker,
an archiver, a software simulator, a full-speed emulator, and a software development board.
This chapter provides an overview of these tools and introduces the features
of the optimizing C compiler. The assembler and linker are discussed in detail
in the TMS320C1x/C2x/C2xx/C5x Assembly Language Tools User’s Guide.
Note: Version Information
To use the TMS320C2x/C2xx/C5x C compiler, you must also have version
5.0 (or later) of the TMS320C1x/C2x/C2xx/C5x assembler and linker.
Figure 1−1 illustrates the TMS320C2x/C2xx/C5x software development flow.
The shaded portion of the figure highlights the most common path of software
development for C language programs. The unshaded portions represent peripheral functions that enhance the development process.
Figure 1−1. TMS320C2x/C2xx/C5x Software Development Flow
C
source
files
Macro
source
files
C compiler
Archiver
Macro
library
Archiver
Library of
object files
Hex conversion
utility
EPROM
programmer
Absolute lister
Assembler
source
Assembler
COFF
object
files
Linker
Executable
COFF
file
Cross-reference
lister
Library-build
utility
Run-time-
support
library
Debugging
tools
TMS320C2x
TMS320C2xx
TMS320C5x
1-2
Software Development Tools Overview
The following list describes the tools that are shown in Figure 1−1.
- The C compiler accepts C source code and produces TMS320C2x,
TMS320C2xx, or TMS320C5x assembly language source code. A shellprogram, an optimizer, and an interlist utility are included in the
compiler package.
J The shell program enables you to automatically compile, assemble,
and link source modules.
J The optimizer modifies code to improve the efficiency of C programs.
J The interlist utility interlists C source statements with assembly lan-
guage output.
Chapter 2 describes how to invoke and operate the compiler, the shell, the optimizer, and the interlist utility.
- The assembler translates assembly language source files into machine
language object files. The machine language is based on common object
file format (COFF). The TMS320C1x/C2x/C2xx/C5x Assembly LanguageTools User’s Guide explains how to use the assembler.
- The TMS320C1x/C2x/C5x Assembly Language Tools User’s Guide ex-
plains how to use the archiver. The linker combines object files into a
single executable object module. As it creates the executable module, it
performs relocation and resolves external references. The linker accepts
relocatable COFF object files and object libraries as input.
- The archiver allows you to collect a group of files into a single archive file,
called a library. Using the archiver, you can modify a library by deleting,
replacing, extracting, or adding members. One of the most useful applications of the archiver is building a library of object modules. Three object
libraries are shipped with the C compiler:
J rts25.lib contains ANSI standard run-time-support functions and
compiler-utility functions for the TMS320C2x.
J rts50.lib contains ANSI standard run-time-support functions and
compiler-utility functions for the TMS320C5x.
J rts2xx.lib contains ANSI standard run-time-support functions and
compiler-utility functions for the TMS320C2xx.
- The library-build utility allows you to build a customized run-time-sup-
port library. Standard run-time-support library functions are provided as
source code. These are located in rts.src. See Chapter 8, Library-BuildUtility, for more information.
1-3Introduction
Software Development Tools Overview
- The hex conversion utility converts a COFF object file into TI-Tagged,
ASCII-hex, Intel, Motorola-S, or Tektronix object format. The converted
file can be downloaded to an EPROM programmer.
- The absolute lister is a debugging tool. It accepts linked object files as
input and creates .abs files as output. Once assembled, these .abs files
produce lists that contain absolute rather than relative addresses. See the
TMS320C1x/C2x/C2xx/C5x Assembly Language Tools User’s Guide for
more information about how to use the absolute lister.
- 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. See the TMS320C1x/C2x/C2xx/C5x Assembly LanguageTools User’s Guide for more information about how to use the cross-reference lister.
- The main product of this development process is a module that you can
execute on a TMS320C2x/C2xx/C5x device. You can use one of several
debugging tools to refine and correct your code. Available products
include:
J An instruction-accurate software simulator
J An extended development system (XDS-510) emulator
J An evaluation module (EVM)
1-4
1.2C Compiler Overview
The TMS320C2x/C2xx/C5x C compiler is a full-featured optimizing compiler
that translates standard ANSI C programs into TMS320C2x/C2xx/C5x
assembly language source. The following list describes key characteristics of
the compiler:
- ANSI-standard C
The TMS320C2x/C2xx/C5x compiler fully conforms to the ANSI C standard as defined by the ANSI specification and described in the second edition of Kernighan and Ritchie’s The C Programming Language (K&R). The
ANSI C standard includes extensions to C that provide maximum
portability and increased capability.
- ANSI-standard run-time support
The compiler tools include a complete run time library for each device. All
library functions conform to the ANSI C library standard. The libraries include functions for string manipulation, dynamic memory allocation, data
conversion, timekeeping, trigonometry, and exponential and hyperbolic
functions. Functions for I/O and signal handling are not included because
these are target-system specific. For more information, see Chapter 7,
Run-Time-Support Functions.
C Compiler Overview
- Assembly source output
The compiler generates assembly language source files that you can inspect easily, enabling you to see the code generated from the C source
files.
- COFF object files
The common object file format (COFF) allows you to define your system’s
memory map at link time. This maximizes performance by enabling you to
link C code and data objects into specific memory areas. COFF also supports source-level debugging.
- Compiler shell program
The compiler tools include a shell program used to compile, and link programs in a single step. For more information, see section 2.1, About theShell Program, on page 2-2.
- Flexible assembly language interface
The compiler has clear calling conventions, allowing you to easily write assembly and C functions that call each other. For more information, see
Chapter 6, Run-Time Environment.
1-5Introduction
C Compiler Overview
- Integrated preprocessor
The C preprocessor is integrated with the parser, allowing for faster compilation. Standalone preprocessing or preprocessed listing is also available. For more information, see section 2.5, Controlling the Preprocessor,
on page 2-23.
- Optimization
The compiler uses an optimization pass that employs several advanced
techniques for generating efficient, compact code from C source. General
optimizations can be applied to any C code, and TMS320C2x/C2xx/C5xspecific optimizations take advantage of the TMS320C2x/C2xx/C5x
architecture. For more information about the C compiler’s optimization
techniques, see Chapter 3, Optimizing Your Code.
- Code to initialized data into ROM
For standalone embedded applications, the compiler enables you to link
all code and initialization data into ROM, allowing C code to run from reset.
- Source interlist utility
The compiler tools include a utility that interlists your original C source
statements into the assembly language output of the compiler. Using this
utility, you can easily inspect the assembly code generated for each C
statement. For more information, see section 2.7, Using the Interlist Utility,
on page 2-34.
- Library-build utility
The compiler tools include a utility that lets you easily custom-build object
libraries from source for any combination of run time models or target
CPUs. For more information, see Chapter 8, Library-Build Utility.
1-6
Chapter 2
C Compiler Description
Translating your source program into code that the TMS320C2x/C2xx/C5x
can execute is a multistep process. You must compile, assemble, and link your
source files to create an executable object file. The TMS320C2x/C2xx/C5x
package contains a special shell program that enables you to execute all of
these steps with one command. This chapter provides a complete description
of how to use the dspcl shell to compile, assemble, and link your programs.
This chapter also describes the preprocessor, inline function expansion features, and interlist utility:
The compiler shell program (dspcl) lets you compile, assemble, and optionally
link in one step. The shell runs one or more source modules through the
following:
- The compiler, which includes the parser, optimizer, and code generator,
accepts C source code and produces ’C2x, ’C2xx, ’C5x, assembly language source code.
- The assembler generates a COFF object file.
- The linker links your files to create an executable object file. Use of the
linker is optional at this point. You can compile and assemble various files
with the shell and link them later. See Chapter 4, Linking C Code, for
information about linking the files in a separate step.
The shell compiles and assembles files by default. If you use the −z option,
dspcl will compile, assemble, and link your files. Figure 2−1 illustrates the
paths the shell follows as it both uses and omits the linker.
2-2
Figure 2−1. The Shell Program Overview
C
source
files
C Compiler
Parser
Optimizer
(optional)
Code
generator
Assembler
source
About the Shell Program
With the −z Option
Assembler
COFF
object
files
Linker
Executable
COFF file
For a complete description of the assembler and the linker, see the
TMS320C2x/C2xx/C5x Assembly Language Tools User’s Guide. For information about invoking the compiler tools individually, see section 2.9, Invoking theTools Individually, on page 2-39.
dspclis the command that runs the compiler and the assembler.
optionsaffect the way the shell processes input files.
filenamesare one or more C source files, assembly source files, or
−zis the option that runs the linker. See Chapter 4, Linking C
linker optionscontrol the linking process.
object filesname the object files that the compiler creates.
The −z option and its associated information (linker options and object files)
must follow all filenames and compiler options on the command line. You can
specify all other options (except linker options) and filenames in any order on
the command line. For example, if you wanted to compile two files named
symtab.c and file.c, assemble a third file named seek.asm, and suppress
progress messages (−q), you enter:
object files.
Code, for more information about invoking the linker.
dspcl −q symtab file seek.asm
As dspcl encounters each source file, it prints the C filenames in square
brackets ( [ ] ) and assembly language filenames in angle brackets ( < > ). This
example uses the −q option to suppress the additional progress information
that dspcl produces. Entering the command above produces these messages:
[symtab]
[file]
<seek.asm>
2-4
Invoking the Compiler Shell
The normal progress information consists of a banner for each compiler pass
and the names of functions as they are defined. The example below shows
the output from compiling a single module without the − q option:
Options control the operation of both the shell and the programs it runs. This
section provides a description of option conventions and an option summary
table. It also provides detailed descriptions of the most frequently used options, including options used for type-checking and assembling.
The following apply to the compiler options:
- Options are either single letters or two-letter pairs.
- Options are not case sensitive.
- Options are preceded by a hyphen.
- Single-letter options without parameters can be combined. For example,
−sgq is equivalent to −s −g −q.
- Two-letter pair options that have the same first letter can be combined. For
example, −pe, −pf, and −pk can be combined as −pefk.
- Options that have parameters, such as −uname and −idirectory, cannot
be combined. They must be specified separately.
- Options with parameters can have a space between the option and the
parameter or be right next to each other.
- Files and options can occur in any order except the −z option. The −z op-
tion must follow all other compiler options and precede any linker options.
You can define default options for the shell by using the C_OPTION environment variable. For a detailed description of the C_OPTION environment
variable, see section 2.4.1, Setting Default Shell Options (C_OPTION), on
page 2-21.
Table 2−1 summarizes all shell and linker options. Use the page references
in the table to refer to more complete descriptions of the options.
For an online summary of all the shell and linker options, enter dspcl with no
parameters on the command line.
2-6
Table 2−1. Shell Options Summary
(a) Options that control the compiler shell
OptionEffectPage(s)
Changing the Compiler’s Behavior With Options
−@filenameInterprets contents of a file as one extension to the
command line
−cDisables linking (negate −z)2-14,
−d name[=def]Predefines name2-14
−gEnables symbolic debugging2-14
−i directoryDefines #include search path2-14
−kKeeps the assembly language (.asm) file2-14
−nCompiles only2-14
−qSuppresses progress messages (quiet)2-14
−qqSuppresses all messages (super quiet)2-14
−r <register>Reserves global register2-14
−sInterlists optimizer comments (if available) and
assembly source statements; otherwise, interlists
C and assembly source statements
−ssInterlists optimizer comments with C source and
assembly statements
−unameUndefines name2-15
2-14
4-5
2-15;
2-34
2-15
−v xxDetermines processor: xx = 25, 2xx or 502-15
−z
(b) Options that specify file and directory names
Option
−fafilenameIdentifies assembly language file (default for .asm
−fcfilenameIdentifies C source file (default for .c or no extension) 2-16
−fofilenameIdentifies object file (default for .o*)2-16
Enables linking2-15
EffectPage
2-16
or .s*)
2-7C Compiler Description
Changing the Compiler’s Behavior With Options
Table 2−1. Shell Options Summary (Continued)
(c) Options that change the default file extensions
Option
−eaextensionSets default extension for assembly files2-17
−eoextensionSets default extension for object files2-17
(d) Options that specify directories
Option
−frdirectorySpecifies object file directory2-17
−fsdirectorySpecifies assembly file directory2-17
−ftdirectoryOverride TMP environment variable2-17
(e) Options that overlook ANSI C type-checking
Option
−tfRelaxes prototype checking2-18
−tpRelaxes pointer combination2-18
(f) Options that change the C run-time model
Option
EffectPage
EffectPage
EffectPage
EffectPage
−maAssumes variables are aliased2-19
− mbDisables RPTK instruction2-19
−mlNo LDPK optimization2-19
−mnEnables optimizations disabled by −g2-19
− mpGenerates prolog/epilog inline2-19
− mrLists register-use information2-19
− msOptimizes for code space2-19
− mxAvoids ’C5x silicon bugs2-19
2-8
Loading...
+ 220 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.