Texas Instruments TMS320C54x User Manual

TMS320C54x
Assembly Language Tools
User’s Guide
Literature Number: SPRU102C
October1998
Printed on Recycled Paper

IMPORTANT NOTICE

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.
Copyright 1998, Texas Instruments Incorporated

About This Manual

The use these assembly language tools:
-
-
-
-
-
-

How to Use This Manual

Read This First

TMS320C54x Assembly Language Tools User’s Guide
Assembler Archiver Linker Absolute lister Cross-reference lister Hex conversion utility
Preface
tells you how to
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

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 0001 2f x .byte 47 3 0002 32 z .byte 50 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
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.
Symbol Definition Symbol Definition
size in
AR0–AR7 Auxiliary Registers
0 through 7 B,b Suffix — binary integer Q,q Suffix — octal integer H,h Suf fix — hexadecimal
integer LSB Least significant bit MSB
-
’C54x is used throughout this manual to collectively refer to the
TMS320C541, TMS320C542, TMS320C543, TMS320C544, TMS320C545, TMS320C546, TMS320C547, TMS320C548, TMS320C549, and TMS320C545L
Most significant bit
PC Program counter
register
SP Stack pointer register
ST Status register
devices.
Read This First
v

Related Documentation From Texas Instruments

Related Documentation From Texas Instruments
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.
TMS320C54x DSP Reference Set, Volume 2: Mnemonic Instruction
(literature number SPRU172) describes the TMS320C54x
Set
digital signal processor mnemonic instructions individually. Also includes a summary of instruction set classes and cycles.
TMS320C54x DSP Reference Set, Volume 3: Algebraic Instruction
Set
(literature number SPRU179) describes the TMS320C54x digital signal processor algebraic instructions individually. Also includes a summary of instruction set classes and cycles.
TMS320C54x DSP Reference Set, Volume 4: Applications Guide
(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
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

If You Need Assistance

If You Need Assistance. . .
-
World-Wide Web Sites
TI Online http://www.ti.com Semiconductor Product Information Center (PIC) http://www.ti.com/sc/docs/pic/home.htm DSP Solutions http://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-0333 Fax: (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-2320 Fax: (281) 274-2324 Email: 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:
Multi-Language Support +33 1 30 70 11 69 Fax: +33 1 30 70 10 32 Email: epic@ti.com Deutsch +49 8161 80 33 11 or +33 1 30 70 11 68 English +33 1 30 70 11 65 Francais +33 1 30 70 11 64
Italiano +33 1 30 70 11 67 EPIC Modem BBS +33 1 30 70 11 99 European Factory Repair +33 4 93 22 25 40 Europe Customer Training Helpline Fax: +49 81 61 80 40 10
t
http://www.ti.com/sc/docs/dsps/support.htm
-
Asia-Pacific
Literature Response Center +852 2 956 7288 Fax: +852 2 956 2200 Hong Kong DSP Hotline +852 2 956 7268 Fax: +852 2 956 1002 Korea DSP Hotline +82 2 551 2804 Fax: +82 2 551 2828 Korea DSP Modem BBS +82 2 551 2914 Singapore DSP Hotline Fax: +65 390 7179 Taiwan DSP Hotline +886 2 377 1450 Fax: +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-8735 Fax: +03-3457-7071 or (INTL) 813-3457-7071 DSP BBS via Nifty-Serve Type “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.
Mail: Texas Instruments Incorporated Email: dsph@ti.com
Technical Documentation Services, MS 702 P.O. Box 1443 Houston, Texas 77251-1443
Note: When calling a Literature Response Center to order documentation, please specify the literature number of the
viii
book.
+03-3457-0972 or (INTL) 813-3457-0972 Fax: +03-3457-1259 or (INTL) 813-3457-1259

Contents

Contents
1 Introduction 1-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Provides an overview of the software development tools.
1.1 Software Development Tools Overview 1-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Tools Descriptions 1-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2 Introduction to Common Object File Format 2-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
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.
2.1 COFF File Types 2-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Sections 2-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 How the Assembler Handles Sections 2-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.1 Uninitialized Sections 2-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.2 Initialized Sections 2-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.3 Named Sections 2-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.4 Subsections 2-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.5 Section Program Counters 2-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.6 An Example That Uses Sections Directives 2-9. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.4 How the Linker Handles Sections 2-12. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.4.1 Default Memory Allocation 2-13. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.4.2 Placing Sections in the Memory Map 2-14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5 Relocation 2-15. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6 Runtime Relocation 2-17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.7 Loading a Program 2-18. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8 Symbols in a COFF File 2-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.1 External Symbols 2-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.2 The Symbol Table 2-20. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3 Assembler Description 3-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Explains how to invoke the assembler and discusses source statement format, valid constants and expressions, and assembler output.
3.1 Assembler Overview 3-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 Assembler Development Flow 3-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3 Invoking the Assembler 3-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ix
Contents
3.4 Naming Alternate Files and Directories for Assembler Input 3-7. . . . . . . . . . . . . . . . . . . . . .
3.4.1 Using the –i Assembler Option 3-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.4.2 Using the A_DIR Environment Variable 3-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.5 Source Statement Format 3-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.5.1 Source Statement Syntax 3-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.5.2 Label Field 3-11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.5.3 Mnemonic Field 3-11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.5.4 Operand Field 3-12. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.5.5 Instruction Field 3-13. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.5.6 Comment Field 3-13. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.6 Constants 3-14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.6.1 Binary Integers 3-14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.6.2 Octal Integers 3-14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.6.3 Decimal Integers 3-15. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.6.4 Hexadecimal Integers 3-15. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.6.5 Character Constants 3-15. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.6.6 Assembly-Time Constants 3-16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.6.7 Floating-Point Constants 3-16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.7 Character Strings 3-17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.8 Symbols 3-18. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.8.1 Labels 3-18. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.8.2 Symbolic Constants 3-18. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.8.3 Defining Symbolic Constants (–d Option) 3-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.8.4 Predefined Symbolic Constants 3-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.8.5 Substitution Symbols 3-20. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.8.6 Local Labels 3-21. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.9 Expressions 3-24. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.9.1 Operators 3-25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.9.2 Expression Overflow and Underflow 3-25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.9.3 Well-Defined Expressions 3-26. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.9.4 Conditional Expressions 3-27. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.9.5 Relocatable Symbols and Legal Expressions 3-27. . . . . . . . . . . . . . . . . . . . . . . . . . .
3.10 Built-in Functions 3-29. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.11 Extended Addressing Support 3-30. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.12 Source Listings 3-31. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.13 Cross-Reference Listings 3-35. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4 Assembler Directives 4-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Describes the directives according to function, and presents the directives in alphabetical order.
4.1 Directives Summary 4-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Compatibility With the TMS320C1x/C2x/C2xx/C5x Assembler Directives 4-7. . . . . . . . . . .
4.3 Directives That Define Sections 4-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4 Directives That Initialize Constants 4-1 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5 Directives That Align the Section Program Counter 4-15. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
x
Contents
4.6 Directives That Format the Output Listing 4-17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.7 Directives That Reference Other Files 4-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.8 Conditional Assembly Directives 4-20. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.9 Assembly-Time Symbol Directives 4-21. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.10 Miscellaneous Directives 4-23. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.11 Directives Reference 4-25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5 Macro Language 5-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Describes macro directives, substitution symbols used as macro parameters, and how to create macros.
5.1 Using Macros 5-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2 Defining Macros 5-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3 Macro Parameters/Substitution Symbols 5-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3.1 Substitution Symbols 5-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3.2 Directives That Define Substitution Symbols 5-8. . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3.3 Built-In Substitution Symbol Functions 5-9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3.4 Recursive Substitution Symbols 5-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3.5 Forced Substitution 5-1 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3.6 Accessing Individual Characters of Subscripted Substitution Symbols 5-12. . . . .
5.3.7 Substitution Symbols as Local Variables in Macros 5-13. . . . . . . . . . . . . . . . . . . . . .
5.4 Macro Libraries 5-14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.5 Using Conditional Assembly in Macros 5-15. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.6 Using Labels in Macros 5-17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7 Producing Messages in Macros 5-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.8 Formatting the Output Listing 5-21. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.9 Using Recursive and Nested Macros 5-22. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.10 Macro Directives Summary 5-25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6 Archiver Description 6-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contains instructions for invoking the archiver, creating new archive libraries, and modifying existing libraries.
6.1 Archiver Overview 6-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2 Archiver Development Flow 6-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3 Invoking the Archiver 6-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.4 Archiver Examples 6-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7 Linker Description 7-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Explains how to invoke the linker, provides details about linker operation, discusses linker directives, and presents a detailed linking example.
7.1 Linker Overview 7-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.2 Linker Development Flow 7-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.3 Invoking the Linker 7-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents
xi
Contents
7.4 Linker Options 7-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.1 Relocation Capabilities (–a and –r Options) 7-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.2 Disable Merge of Symbolic Debugging Information (–b Option) 7-10. . . . . . . . . . .
7.4.3 C Language Options (–c and –cr Options) 7-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.4 Define an Entry Point (–e global_symbol Option) 7-11. . . . . . . . . . . . . . . . . . . . . . .
7.4.5 Set Default Fill Value (–f cc Option) 7-11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.6 Make a Symbol Global (–g global_symbol Option) 7-12. . . . . . . . . . . . . . . . . . . . . .
7.4.7 Make All Global Symbols Static (–h Option) 7-12. . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.8 Define Heap Size (–heap constant Option) 7-12. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.9 Alter the Library Search Algorithm (–l Option, –i Option, and
C_DIR Environment V ariable) 7-13. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.10 Disable Conditional Linking (–j Option) 7-16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.11 Ignore Alignment Flags (–k Option) 7-16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.12 Create a Map File (–m filename Option) 7-16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.13 Name an Output Module (–o filename Option) 7-17. . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.14 Specify a Quiet Run (–q Option) 7-17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.15 Strip Symbolic Information (–s Option) 7-17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.16 Define Stack Size (–stack constant Option) 7-18. . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.17 Introduce an Unresolved Symbol (–u symbol Option) 7-18. . . . . . . . . . . . . . . . . . . .
7.4.18 Specify a COFF Format (–v Option) 7-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.19 Display a Message for Output Section Information (–w Option) 7-19. . . . . . . . . . .
7.4.20 Exhaustively Read Libraries (–x Option) 7-20. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.5 Linker Command Files 7-21. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.5.1 Reserved Names in Linker Command Files 7-24. . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.5.2 Constants in Command Files 7-24. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.6 Object Libraries 7-25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.7 The MEMORY Directive 7-27. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.7.1 Default Memory Model 7-27. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.7.2 MEMORY Directive Syntax 7-27. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.8 The SECTIONS Directive 7-32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.8.1 Default Configuration 7-32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.8.2 SECTIONS Directive Syntax 7-32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.8.3 Allocation 7-35. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.9 Specifying a Section’s Runtime Address 7-41. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.9.1 Specifying Load and Run Addresses 7-41. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.9.2 Uninitialized Sections 7-42. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.9.3 Referring to the Load Address by Using the .label Directive 7-42. . . . . . . . . . . . . .
7.10 Using UNION and GROUP Statements 7-45. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.10.1 Overlaying Sections With the UNION Statement 7-45. . . . . . . . . . . . . . . . . . . . . . . .
7.10.2 Grouping Output Sections Together 7-47. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.11 Overlay Pages 7-48. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.11.1 Using the MEMORY Directive to Define Overlay Pages 7-48. . . . . . . . . . . . . . . . . .
7.11.2 Using Overlay Pages With the SECTIONS Directive 7-50. . . . . . . . . . . . . . . . . . . .
7.11.3 Page Definition Syntax 7-51. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xii
Contents
7.12 Default Allocation Algorithm 7-53. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.12.1 Allocation Algorithm 7-53. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.12.2 General Rules for Output Sections 7-54. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.13 Special Section Types (DSECT, COPY, and NOLOAD) 7-56. . . . . . . . . . . . . . . . . . . . . . . . .
7.14 Assigning Symbols at Link Time 7-57. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.14.1 Syntax of Assignment Statements 7-57. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.14.2 Assigning the SPC to a Symbol 7-58. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.14.3 Assignment Expressions 7-58. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.14.4 Symbols Defined by the Linker 7-60. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.14.5 Symbols Defined Only For C Support (–c or –cr Option) 7-60. . . . . . . . . . . . . . . . .
7.15 Creating and Filling Holes 7-61. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.15.1 Initialized and Uninitialized Sections 7-61. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.15.2 Creating Holes 7-61. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.15.3 Filling Holes 7-63. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.15.4 Explicit Initialization of Uninitialized Sections 7-64. . . . . . . . . . . . . . . . . . . . . . . . . . .
7.16 Partial (Incremental) Linking 7-65. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.17 Linking C Code 7-67. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.17.1 Runtime Initialization 7-67. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.17.2 Object Libraries and Runtime Support 7-67. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.17.3 Setting the Size of the Stack and Heap Sections 7-68. . . . . . . . . . . . . . . . . . . . . . . .
7.17.4 Autoinitialization (ROM and RAM Models) 7-68. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.17.5 The –c and –cr Linker Options 7-70. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.18 Linker Example 7-71. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8 Absolute Lister Description 8-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Explains how to invoke the absolute lister to obtain a listing of the absolute addresses of an object file.
8.1 Producing an Absolute Listing 8-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2 Invoking the Absolute Lister 8-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.3 Absolute Lister Example 8-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9 Cross-Reference Lister Description 9-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Explains how to invoke the cross-reference lister to obtain a listing of symbols, their definitions, and their references in the linked source files.
9.1 Producing a Cross-Reference Listing 9-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.2 Invoking the Cross-Reference Lister 9-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.3 Cross-Reference Listing Example 9-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10 Hex Conversion Utility Description 10-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
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.
10.1 Hex Conversion Utility Development Flow 10-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.2 Invoking the Hex Conversion Utility 10-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents
xiii
Contents
10.3 Command File 10-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.3.1 Examples of Command Files 10-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.4 Understanding Memory Widths 10-9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.4.1 Target Width 10-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.4.2 Data Width 10-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.4.3 Memory Width 10-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.4.4 ROM Width 10-11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.4.5 A Memory Configuration Example 10-14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.4.6 Specifying Word Order for Output Words 10-14. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.5 The ROMS Directive 10-16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.5.1 When to Use the ROMS Directive 10-18. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.5.2 An Example of the ROMS Directive 10-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.5.3 Creating a Map File of the ROMS Directive 10-21. . . . . . . . . . . . . . . . . . . . . . . . . . .
10.6 The SECTIONS Directive 10-22. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7 Output Filenames 10-24. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7.1 Assigning Output Filenames 10-24. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.8 Image Mode and the –fill Option 10-26. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.8.1 The –image Option 10-26. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.8.2 Specifying a Fill Value 10-27. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.8.3 Steps to Follow in Image Mode 10-27. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.9 Building a Table for an On-Chip Boot Loader 10-28. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.9.1 Description of the Boot Table 10-28. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.9.2 The Boot Table Format 10-28. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.9.3 How to Build the Boot Table 10-29. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.9.4 Booting From a Device Peripheral 10-31. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.9.5 Setting the Entry Point for the Boot Table 10-32. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.9.6 Using the ’C54x Boot Loader 10-32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.10 Controlling the ROM Device Address 10-34. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.10.1 Controlling the Starting Address 10-34. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.10.2 Controlling the Address Increment Index 10-36. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.10.3 The –byte Option 10-36. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.10.4 Dealing With Address Holes 10-37. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.11 Description of the Object Formats 10-38. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.11.1 ASCII-Hex Object Format (–a Option) 10-39. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.11.2 Intel MCS-86 Object Format (–i Option) 10-40. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.11.3 Motorola Exorciser Object Format (–m1, –m2, –m3 Options) 10-41. . . . . . . . . . . .
10.11.4 Texas Instruments SDSMAC Object Format (–t Option) 10-42. . . . . . . . . . . . . . . . .
10.11.5 Extended Tektronix Object Format (–x Option) 10-43. . . . . . . . . . . . . . . . . . . . . . . .
10.12 Hex Conversion Utility Error Messages 10-44. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xiv
Contents
11 Mnemonic-to-Algebraic Translator Description 11-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
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.
11.1 Translator Overview 11-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.1.1 What the Translator Does 11-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.1.2 What the Translator Does Not Do 11-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.2 Translator Development Flow 11-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.3 Invoking the Translator 11-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.4 Translation Modes 11-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.4.1 Literal Mode (–t Option) 11-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.4.2 About Symbol Names in Literal Mode 11-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.4.3 Expansion Mode (–e Option) 11-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.5 How the Translator Works With Macros 11-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.5.1 Directives in Macros 11-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.5.2 Macro Local Variables 11-9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.5.3 Defining Labels When Invoking A Macro 11-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A Common Object File Format A-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contains supplemental technical data about the internal format and structure of COFF object files.
A.1 COFF File Structure A-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.1.1 Overall Object File Structure A-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.1.2 Typical Object File Structure A-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.1.3 Impact of Switching Operating Systems A-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.2 File Header Structure A-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.3 Optional File Header Format A-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.4 Section Header Structure A-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.5 Structuring Relocation Information A-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.6 Line-Number Table Structure A-12. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.7 Symbol Table Structure and Content A-14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.7.1 Special Symbols A-16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.7.2 Symbol Name Format A-18. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.7.3 String Table Structure A-18. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.7.4 Storage Classes A-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.7.5 Symbol Values A-20. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.7.6 Section Number A-21. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.7.7 Type Entry A-21. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.7.8 Auxiliary Entries A-23. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B Symbolic Debugging Directives B-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Discusses symbolic debugging directives that the C compiler uses.
Contents
xv
Contents
C Hex Conversion Utility Examples C-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Illustrates command file development for a variety of memory systems and situations.
C.1 Base Code for the Examples C-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C.2 Example 1: Building A Hex Command File for Two 8-Bit EPROMs C-3. . . . . . . . . . . . . . . .
C.3 Example 2: Avoiding Holes With Multiple Sections C-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C.4 Example 3: Generating a Boot Table C-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C.5 Example 4: Generating a Boot Table for LP Core Devices C-17. . . . . . . . . . . . . . . . . . . . . . .
D Error Messages D-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Lists the error messages that the assembler and linker issue, and gives a description of the condition(s) that caused each error.
E Glossary E-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Defines terms and acronyms used in this book.
xvi

Figures

Figures
1–1 TMS320C54x Software Development Flow 1-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2–1 Partitioning Memory Into Logical Blocks 2-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2–2 Object Code Generated by the File in Example 2–1 2-11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2–3 Combining Input Sections to Form an Executable Object Module 2-13. . . . . . . . . . . . . . . . . . .
3–1 Assembler Development Flow 3-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4–1 The .space and .bes Directives 4-11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4–2 The .field Directive 4-12. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4–3 Initialization Directives 4-14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4–4 The .align Directive 4-16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4–5 Allocating .bss Blocks Within a Page 4-31. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4–6 The .field Directive 4-49. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4–7 The .usect Directive 4-95. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6–1 Archiver Development Flow 6-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–1 Linker Development Flow 7-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–2 Memory Map Defined in Example 7–3 7-31. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–3 Section Allocation Defined by Example 7–4 7-34. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–4 Runtime Execution of Example 7–6 7-44. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–5 Memory Allocation Shown in Example 7–7 and Example 7–8 7-46. . . . . . . . . . . . . . . . . . . . . .
7–6 Overlay Pages Defined by Example 7–10 and Example 7–11 7-49. . . . . . . . . . . . . . . . . . . . . .
7–7 RAM Model of Autoinitialization 7-69. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–8 ROM Model of Autoinitialization 7-69. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8–1 Absolute Lister Development Flow 8-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8–2 module1.lst 8-9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8–3 module2.lst 8-9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9–1 Cross-Reference Lister Development Flow 9-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–1 Hex Conversion Utility Development Flow 10-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–2 Hex Conversion Utility Process Flow 10-9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–3 Data and Memory Widths 10-11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–4 Data, Memory, and ROM Widths 10-13. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–5 ’C54x Memory Configuration Example 10-14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–6 Varying the Word Order 10-15. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–7 The infile.out File From Example 10–1 Partitioned Into Four Output Files 10-20. . . . . . . . . . .
10–8 Sample Command File for Booting From a ’C54x EPROM 10-33. . . . . . . . . . . . . . . . . . . . . . . .
10–9 Hex Command File for Avoiding a Hole at the Beginning of a Section 10-37. . . . . . . . . . . . . .
10–10 ASCII-Hex Object Format 10-39. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–11 Intel Hex Object Format 10-40. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents
xvii
Figures
10–12 Motorola-S Format 10-41. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–13 TI-Tagged Object Format 10-42. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–14 Extended Tektronix Object Format 10-43. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11–1 Translator Development Flow 11-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11–2 Literal Mode Process 11-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11–3 Expansion Mode Process 11-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11–4 Defining Labels 11-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11–5 Rewritten Source Code 11-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–1 COFF File Structure A-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–2 COFF Object File A-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–3 Section Header Pointers for the .text Section A-9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–4 Line-Number Blocks A-12. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–5 Line-Number Entries A-13. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–6 Symbol Table Contents A-14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–7 Symbols for Blocks A-17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–8 Symbols for Functions A-17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–9 String Table A-18. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–1 A Two 8-Bit EPROM System C-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–2 Data From Output File C-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–3 EPROM System for a ’C54x C-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–4 EPROM System for a ’C54xLP C-17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xviii
Tables

Tables

3–1 Operators Used in Expressions (Precedence) 3-25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3–2 Expressions With Absolute and Relocatable Symbols 3-27. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3–3 Assembler Built-In Math Functions 3-29. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3–4 Symbol Attributes 3-35. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4–1 Assembler Directives Summary 4-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4–2 Memory-Mapped Registers 4-70. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–1 Functions and Return Values 5-9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–2 Creating Macros 5-25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–3 Manipulating Substitution Symbols 5-25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–4 Conditional Assembly 5-25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–5 Producing Assembly-Time Messages 5-26. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–6 Formatting the Listing 5-26. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–1 Operators Used in Expressions (Precedence) 7-59. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9–1 Symbol Attributes 9-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–1 Options 10-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–2 Boot-Loader Options 10-29. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–3 Options for Specifying Hex Conversion Formats 10-38. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–1 File Header Contents A-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–2 File Header Flags (Bytes 18 and 19) A-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–3 Optional File Header Contents A-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–4 Section Header Contents for COFF1 Files A-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–5 Section Header Contents for COFF2 Files A-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–6 Section Header Flags A-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–7 Relocation Entry Contents A-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–8 Relocation Types (Bytes 8 and 9) A-11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–9 Line-Number Entry Format A-12. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–10 Symbol Table Entry Contents A-15. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–11 Special Symbols in the Symbol Table A-16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–12 Symbol Storage Classes A-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–13 Special Symbols and Their Storage Classes A-20. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–14 Symbol Values and Storage Classes A-20. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–15 Section Numbers A-21. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–16 Basic Types A-22. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–17 Derived Types A-22. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–18 Auxiliary Symbol Table Entries Format A-23. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–19 Filename Format for Auxiliary Table Entries A-24. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents
xix
Tables
A–20 Section Format for Auxiliary Table Entries A-24. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–21 Tag Name Format for Auxiliary Table Entries A-24. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–22 End-of-Structure Format for Auxiliary Table Entries A-25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–23 Function Format for Auxiliary Table Entries A-25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–24 Array Format for Auxiliary Table Entries A-26. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A–25 End-of-Blocks/Functions Format for Auxiliary Table Entries A-26. . . . . . . . . . . . . . . . . . . . . . . .
A–26 Beginning-of-Blocks/Functions Format for Auxiliary Table Entries A-27. . . . . . . . . . . . . . . . . . .
A–27 Structure, Union, and Enumeration Names Format for Auxiliary Table Entries A-27. . . . . . . .
xx

Examples

Examples
2–1 Using Sections Directives 2-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2–2 Code That Generates Relocation Entries 2-15. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3–1 $n Local Labels 3-21. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3–2 name? Local Labels 3-23. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3–3 Well-Defined Expressions 3-26. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3–4 Assembler Listing 3-33. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3–5 Sample Cross-Reference Listing 3-35. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4–1 Sections Directives 4-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–1 Macro Definition, Call, and Expansion 5-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–2 Calling a Macro With Varying Numbers of Arguments 5-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–3 The .asg Directive 5-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–4 The .eval Directive 5-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–5 Using Built-In Substitution Symbol Functions 5-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–6 Recursive Substitution 5-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–7 Using the Forced Substitution Operator 5-11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–8 Using Subscripted Substitution Symbols to Redefine an Instruction 5-12. . . . . . . . . . . . . . . . .
5–9 Using Subscripted Substitution Symbols to Find Substrings 5-13. . . . . . . . . . . . . . . . . . . . . . . .
5–10 The .loop/.break/.endloop Directives 5-16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–11 Nested Conditional Assembly Directives 5-16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–12 Built-In Substitution Symbol Functions Used in a Conditional Assembly
5–13 Unique Labels in a Macro 5-17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–14 Producing Messages in a Macro 5-20. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–15 Using Nested Macros 5-22. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–16 Using Recursive Macros 5-23. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–1 Linker Command File 7-22. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–2 Command File With Linker Directives 7-23. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–3 The MEMORY Directive 7-28. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–4 The SECTIONS Directive 7-34. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–5 The Most Common Method of Specifying Section Contents 7-38. . . . . . . . . . . . . . . . . . . . . . . .
7–6 Copying a Section From ROM to RAM 7-43. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–7 The UNION Statement 7-45. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–8 Separate Load Addresses for UNION Sections 7-45. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–9 Allocate Sections Together 7-47. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–10 Memory Directive With Overlay Pages 7-48. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–11 SECTIONS Directive Definition for Overlays in Figure 7–6 7-50. . . . . . . . . . . . . . . . . . . . . . . . .
Code Block 5-16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents
xxi
Examples
7–12 Default Allocation for TMS320C54x Devices 7-53. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–13 Linker Command File, demo.cmd 7-72. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7–14 Output Map File, demo.map 7-73. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–1 A ROMS Directive Example 10-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10–2 Map File Output From Example 10–1 Showing Memory Ranges 10-21. . . . . . . . . . . . . . . . . .
11–1 Treatment of Symbol Names in Literal Mode 11-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11–2 Expansion Mode 11-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11–3 Directives in Macros 11-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11–4 Macro Local Variables 11-9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–1 Assembly Code for Hex Conversion Utility Examples C-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–2 A Linker Command File for Two 8-Bit EPROMs C-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–3 A Hex Command File for Two 8-Bit EPROMs C-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–4 Map File Resulting From Hex Command File in Example C–3 on page C-5 C-7. . . . . . . . . . .
C–5 Method One for Avoiding Holes C-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–6 Method Two for Avoiding Holes C-9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–7 C Code for Example 3 C-10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–8 Linker Command File to Form a Single Boot Section C-12. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–9 Section Allocation Portion of Map File Resulting From the Command File C-13. . . . . . . . . . .
C–10 Hex Command File for Converting a COFF File C-15. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–11 Map File Resulting From the Command File in Example C–10 C-16. . . . . . . . . . . . . . . . . . . . .
C–12 Hex Conversion Utility Output File Resulting From the Command File
in Example C–10 C-16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–13 C Code for a ’C54xLP C-17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–14 Linker Command File for a ’C54xLP C-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–15 Section Allocation Portion of Map File Resulting From the Command File
in Example C–14 C-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–16 Hex Command File for Converting a COFF File C-22. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C–17 Map File Resulting From the Command File in Example C–16 C-23. . . . . . . . . . . . . . . . . . . . .
C–18 Hex Conversion Utility Output File Resulting From the Command File in C–16 C-23. . . . . . .
xxii
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 develop­ment 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,
Format
, discusses this object format in detail.
Introduction to Common Object File
Topic Page
1.1 Software Development Tools Overview 1-2. . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Tools Descriptions 1-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Introduction
1-1

Software Development Tools Overview

1.1 Software Development Tools Overview
Figure 1–1 illustrates the ’C54x software development flow. The shaded portion of the figure highlights the most common path of software develop­ment; 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
1.2 Tools 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, assem­bler directives, and macro directives. Y ou can use assembler directives to control various aspects of the assembly process, such as the source list­ing format, data alignment, and section content.
-
The linker combines relocatable COFF object files (created by the assem­bler) 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 ob­ject 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
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 opera­tions.
-
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
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.
Common Object File Format
sections
. Both the assembler and the
, which explains the
Topic Page
2.1 COFF File Types 2-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Sections 2-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 How the Assembler Handles Sections 2-4. . . . . . . . . . . . . . . . . . . . . . . . . .
2.4 How the Linker Handles Sections 2-12. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5 Relocation 2-15. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6 Runtime Relocation 2-17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.7 Loading a Program 2-18. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8 Symbols in a COFF File 2-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Introduction to Common Object File Format
2-1

COFF File Types

COFF File Types /Sections
2.1 COFF File Types
The following types of COFF files exist:
-
-
-
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.2 Sections

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 con­tain three default sections:
.text section usually contains executable code .data section usually contains initialized data .bss section usually 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 sections contain data or code. The .text and .data sections
are initialized; named sections created with the .sect assembler directive are also initialized.
uninitialized sections reserve space in the memory map for uninitialized
data. The .bss section is uninitialized; named sections created with the .usect assembler direc­tive are also uninitialized.
2-2
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

How the Assembler Handles Sections

2.3 How 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.1 Uninitialized 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.
Loading...
+ 439 hidden pages