ANALOG DEVICES W4.5 Assembler Manual

W4.5
Assembler and Preprocessor Manual
Analog Devices, Inc. One Technology Way Norwood, Mass. 02062-9106
Revision 2.0, April 2006
Part Number:
82-000420-04
a
Copyright Information
©2006 Analog Devices, Inc., ALL RIGHTS RESERVED. This document may not be reproduced in any form without prior, express written consent from Analog Devices, Inc.
Printed in the USA.
Disclaimer
Analog Devices, Inc. reserves the right to change this product without prior notice. Information furnished by Analog Devices is believed to be accurate and reliable. However, no responsibility is assumed by Analog Devices for its use; nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted by impli­cation or otherwise under the patent rights of Analog Devices, Inc.
Trademark and Service Mark Notice
The Analog Devices logo, the CROSSCORE logo, VisualDSP++, SHARC, TigerSHARC, Blackfin, and EZ-KIT Lite are registered trade­marks of Analog Devices, Inc.
All other brand and product names are trademarks or service marks of their respective owners.

CONTENTS

CONTENTS

PREFACE

Purpose ......................................................................................... xiii
Intended Audience ........................................................................ xiii
Manual Contents ........................................................................... xiv
What’s New in this Manual ............................................................ xiv
Technical or Customer Support ....................................................... xv
Supported Processors ...................................................................... xvi
Product Information ..................................................................... xvii
MyAnalog.com ........................................................................ xvii
Processor Product Information ................................................ xviii
Related Documents .................................................................. xix
Online Technical Documentation .............................................. xx
Accessing Documentation From VisualDSP++ ....................... xx
Accessing Documentation From Windows ............................ xxi
Accessing Documentation From the Web .............................. xxi
Printed Manuals ...................................................................... xxii
VisualDSP++ Documentation Set ........................................ xxii
Hardware Tools Manuals ..................................................... xxii
VisualDSP++ 4.5 Assembler and Preprocessor Manual iii
CONTENTS
Processor Manuals .............................................................. xxii
Data Sheets ........................................................................ xxii
Notation Conventions ................................................................. xxiii
ASSEMBLER
Assembler Guide .......................................................................... 1-2
Assembler Overview ................................................................ 1-3
Writing Assembly Programs ..................................................... 1-3
Program Content ................................................................ 1-6
Program Structure .............................................................. 1-7
Code File Structure and LDF for SHARC Processors ..... 1-10
Code File Structure and LDF for TigerSHARC Processors 1-13
Code File Structure and LDF for Blackfin Processors ..... 1-16
Program Interfacing Requirements .................................... 1-20
Using Assembler Support for C Structs .................................. 1-21
Preprocessing a Program ........................................................ 1-24
Using Assembler Feature Macros ........................................... 1-26
Make Dependencies .............................................................. 1-30
Reading a Listing File ............................................................ 1-31
Statistical Profiling for Assembly Functions ............................ 1-31
Assembler Syntax Reference ........................................................ 1-33
Assembler Keywords and Symbols ......................................... 1-34
Assembler Expressions ........................................................... 1-47
Assembler Operators ............................................................. 1-48
Numeric Formats .................................................................. 1-52
iv VisualDSP++ 4.5 Assembler and Preprocessor Manual
CONTENTS
Fractional Type Support .................................................... 1-53
1.31 Fracts .................................................................... 1-53
1.0r Special Case ........................................................... 1-54
Fractional Arithmetic .................................................... 1-54
Mixed Type Arithmetic ................................................. 1-55
Comment Conventions ......................................................... 1-55
Conditional Assembly Directives ............................................ 1-55
C Struct Support in Assembly Built-In Functions ................... 1-59
OFFSETOF() Built-In Function ....................................... 1-59
SIZEOF() Built-In Function ............................................. 1-59
Struct References ................................................................... 1-60
Assembler Directives .............................................................. 1-63
.ALIGN, Specify an Address Alignment ............................. 1-68
.ALIGN_CODE, Specify an Address Alignment ................ 1-70
.ASCII .............................................................................. 1-72
.BYTE, Declare a Byte Data Variable or Buffer .................. 1-73
ASCII String Initialization Support ............................... 1-75
.EXTERN, Refer to a Globally Available Symbol ............... 1-77
.EXTERN STRUCT, Refer to a Struct Defined Elsewhere . 1-78
.FILE, Override the Name of a Source File ........................ 1-80
.FILE_ATTR, Create an attribute in the object file ............ 1-81
.GLOBAL, Make a Symbol Globally Available ................... 1-82
.IMPORT, Provide Structure Layout Information .............. 1-84
.INC/BINARY, Include Contents of a File ......................... 1-86
VisualDSP++ 4.5 Assembler and Preprocessor Manual v
CONTENTS
.LEFTMARGIN, Set the Margin Width of a Listing File ... 1-87
.LIST/.NOLIST, Listing Source Lines and Opcodes .......... 1-88
.LIST_DATA/.NOLIST_DATA, Listing Data Opcodes ..... 1-89
.LIST_DATFILE/.NOLIST_DATFILE, Listing Data Initialization
Files .............................................................................. 1-90
.LIST_DEFTAB, Set the Default Tab Width for Listings ... 1-91
.LIST_LOCTAB, Set the Local Tab Width for Listings ...... 1-92
.LIST_WRAPDATA/.NOLIST_WRAPDATA .................. 1-93
.MESSAGE, Alter the severity of an assembler message ...... 1-94
.NEWPAGE, Insert a Page Break in a Listing File .............. 1-98
.PAGELENGTH, Set the Page Length of a Listing File ...... 1-99
.PAGEWIDTH, Set the Page Width of a Listing File ....... 1-100
.PORT, Legacy Directive ................................................. 1-101
.PRECISION, Select Floating-Point Precision ................. 1-102
.PREVIOUS, Revert to the Previously Defined Section ... 1-103 .PRIORITY, Allow Prioritized Symbol Mapping in the Linker ...
1-104
Linker Operation ........................................................ 1-105
.REFERENCE, .............................................................. 1-107
.ROUND_, Select Floating-Point Rounding .................... 1-108
.SECTION, Declare a Memory Section .......................... 1-111
Common .SECTION Attributes ................................. 1-111
DOUBLE* Qualifiers ................................................. 1-112
TigerSHARC-Specific Qualifiers ................................. 1-113
SHARC-Specific Qualifiers ......................................... 1-114
vi VisualDSP++ 4.5 Assembler and Preprocessor Manual
CONTENTS
Initialization Section Qualifiers ................................... 1-115
.SEGMENT & .ENDSEG, Legacy Directives .................. 1-117
.SEPARATE_MEM_SEGMENTS ................................... 1-117
.SET, Set a Symbolic Alias ............................................... 1-118
.STRUCT, Create a Struct Variable ................................. 1-118
.TYPE, Change Default Symbol Type .............................. 1-122
.VAR, Declare a Data Variable or Buffer .......................... 1-123
.VAR and ASCII String Initialization Support .............. 1-126
.WEAK, Support a Weak Symbol Definition and Reference 1-128
Assembler Command-Line Reference ......................................... 1-129
Running the Assembler ........................................................ 1-130
Assembler Command-Line Switch Descriptions .................... 1-132
-align-branch-lines .......................................................... 1-135
-char-size-8 ..................................................................... 1-136
-char-size-32 ................................................................... 1-136
-char-size-any .................................................................. 1-136
-default-branch-np .......................................................... 1-136
-default-branch-p ............................................................ 1-137
-Dmacro[=definition] ...................................................... 1-137
-double-size-32 ............................................................... 1-137
-double-size-64 ............................................................... 1-138
-double-size-any .............................................................. 1-138
-file-attr attr[=val] ........................................................... 1-138
-flags-compiler ................................................................ 1-139
VisualDSP++ 4.5 Assembler and Preprocessor Manual vii
CONTENTS
-flags-pp -opt1 [,-opt2...] ............................................... 1-140
-g ................................................................................... 1-141
-h[elp] ............................................................................ 1-142
-i|I directory ................................................................... 1-142
-l filename ...................................................................... 1-143
-li filename ..................................................................... 1-144
-M ................................................................................. 1-144
-MM .............................................................................. 1-144
-Mo filename .................................................................. 1-145
User-Specified Defines Options ................................... 1-139
Include Options ......................................................... 1-140
WARNING ea1121: Missing End Labels ..................... 1-141
-Mt filename .................................................................. 1-145
-micaswarn ..................................................................... 1-145
-no-source-dependency ................................................... 1-145
-o filename ..................................................................... 1-146
-pp ................................................................................. 1-146
-proc processor ............................................................... 1-146
-save-temps .................................................................... 1-147
-si-revision version .......................................................... 1-147
-sp ................................................................................. 1-148
-stallcheck ...................................................................... 1-148
-v[erbose] ....................................................................... 1-149
-version .......................................................................... 1-149
viii VisualDSP++ 4.5 Assembler and Preprocessor Manual
CONTENTS
-w ................................................................................... 1-149
-Werror number[,number] .............................................. 1-149
-Winfo number[,number] ............................................... 1-149
-Wno-info ...................................................................... 1-149
-Wnumber[,number] ....................................................... 1-150
-Wsuppress number[,number] ......................................... 1-150
-Wwarn number[,number] .............................................. 1-150
-Wwarn-error .................................................................. 1-150
Specifying Assembler Options in VisualDSP++ ..................... 1-151
PREPROCESSOR
Preprocessor Guide ....................................................................... 2-2
Writing Preprocessor Commands ............................................. 2-3
Header Files and #include Command ....................................... 2-4
Writing Macros ....................................................................... 2-6
Using Predefined Preprocessor Macros ..................................... 2-9
Specifying Preprocessor Options ............................................ 2-13
Preprocessor Command Reference ............................................... 2-14
Preprocessor Commands and Operators ................................. 2-14
#define ............................................................................. 2-16
Variable Length Argument Definitions .......................... 2-17
#elif .................................................................................. 2-19
#else ................................................................................. 2-20
#endif ............................................................................... 2-21
#error ............................................................................... 2-22
VisualDSP++ 4.5 Assembler and Preprocessor Manual ix
CONTENTS
#if .................................................................................... 2-23
#ifdef ............................................................................... 2-24
#ifndef ............................................................................. 2-25
#include ........................................................................... 2-26
#line ................................................................................ 2-28
#pragma ........................................................................... 2-29
#undef ............................................................................. 2-30
#warning .......................................................................... 2-31
# (Argument) ................................................................... 2-32
## (Concatenate) .............................................................. 2-33
? (Generate a Unique Label) .............................................. 2-34
Preprocessor Command-Line Reference ....................................... 2-36
Running the Preprocessor ...................................................... 2-36
Preprocessor Command-Line Switches ................................... 2-37
-cstring ............................................................................. 2-39
-cs! ................................................................................... 2-40
-cs/* ................................................................................. 2-40
-cs// ................................................................................. 2-40
-cs{ ................................................................................... 2-40
-csall ................................................................................ 2-41
-Dmacro[=def] ................................................................. 2-41
-h[elp] .............................................................................. 2-41
-i ...................................................................................... 2-41
-i|I directory ..................................................................... 2-42
x VisualDSP++ 4.5 Assembler and Preprocessor Manual
CONTENTS
Using the -I- Switch ...................................................... 2-43
-M .................................................................................... 2-43
-MM ................................................................................ 2-44
-Mo filename .................................................................... 2-44
-Mt filename ..................................................................... 2-44
-o filename ....................................................................... 2-44
-stringize ........................................................................... 2-44
-tokenize-dot .................................................................... 2-45
-Uname ............................................................................ 2-45
-v[erbose] ......................................................................... 2-45
-version ............................................................................ 2-46
-w ..................................................................................... 2-46
-Wnumber ........................................................................ 2-46
-warn ................................................................................ 2-46
INDEX
VisualDSP++ 4.5 Assembler and Preprocessor Manual xi
-xii VisualDSP++ 4.5 Assembler and Preprocessor Manual

PREFACE

Thank you for purchasing Analog Devices, Inc. development software for digital signal processing (DSP) applications.

Purpose

The VisualDSP++ 4.5 Assembler and Preprocessor Manual contains infor- mation about the assembler preprocessor utilties for the following Analog Devices, Inc. processor families—SHARC® (ADSP-21xxx) processors, TigerSHARC processors.
®
(ADSP-TSxxx) processors, and Blackfin® (ADSP-BFxxx)
The manual describes how to write assembly programs for these processors and reference information about related development software. It also provides information on new and legacy syntax for assembler and prepro­cessor directives and comments, as well as command-line switches.

Intended Audience

The primary audience for this manual is a programmer who is familiar with Analog Devices processors. This manual assumes that the audience has a working knowledge of the appropriate processor architecture and instruction set. Programmers who are unfamiliar with Analog Devices processors can use this manual, but should supplement it with other texts (such as the appropriate hardware reference and programming reference manuals) that describe your target architecture.
VisualDSP++ 4.5 Assembler and Preprocessor Manual xiii

Manual Contents

Manual Contents
The manual consists of:
Chapter 1, “Assembler” Provides an overview of the process of writing and building assem­bly programs. It also provides information about the assembler’s switches, expressions, keywords, and directives.
Chapter 2, “Preprocessor” Provides procedures for using preprocessor commands within assembly source files as well as the preprocessor’s command-line interface options and command sets.

What’s New in this Manual

The VisualDSP++ 4.5 Assembler and Preprocessor Manual is a new manual that documents assembler support for all currently available Analog Devices’ SHARC, TigerSHARC
“Supported Processors”.
Refer to VisualDSP++ 4.5 Product Release Bulletin for information on all new and updated VisualDSP++® 4.5 features and other release information.
xiv VisualDSP++ 4.5 Assembler and Preprocessor Manual
and Blackfin processors listed in

Technical or Customer Support

You can reach Analog Devices, Inc. Customer Support in the following ways:
Visit the Embedded Processing and DSP products Web site at
http://www.analog.com/processors/technicalSupport
E-mail tools questions to
processor.tools.support@analog.com
E-mail processor questions to
processor.support@analog.com (World wide support) processor.europe@analog.com (Europe support) processor.china@analog.com (China support)
Phone questions to 1-800-ANALOGD
Preface
Contact your Analog Devices, Inc. local sales office or authorized distributor
Send questions by mail to:
Analog Devices, Inc. One Technology Way P.O. Box 9106 Norwood, MA 02062-9106 USA
VisualDSP++ 4.5 Assembler and Preprocessor Manual xv

Supported Processors

Supported Processors
The following is the list of Analog Devices, Inc. processors supported in VisualDSP++ 4.5.
TigerSHARC (ADSP-TSxxx) Processors
The name “TigerSHARC” refers to a family of floating-point and fixed-point [8-bit, 16-bit, and 32-bit] processors. VisualDSP++ currently supports the following TigerSHARC processors:
ADSP-TS101 ADSP-TS201 ADSP-TS202 ADSP-TS203
SHARC (ADSP-21xxx) Processors
The name “SHARC” refers to a family of high-performance, 32-bit, floating-point processors that can be used in speech, sound, graphics, and imaging applications. VisualDSP++ currently supports the following SHARC processors:
ADSP-21020 ADSP-21060 ADSP-21061 ADSP-21062 ADSP-21065L ADSP-21160 ADSP-21161 ADSP-21261 ADSP-21262 ADSP-21266 ADSP-21267 ADSP-21363 ADSP-21364 ADSP-21365 ADSP-21366 ADSP-21367 ADSP-21368 ADSP-21369 ADSP-21371 ADSP-21375
xvi VisualDSP++ 4.5 Assembler and Preprocessor Manual
Preface
Blackfin (ADSP-BFxxx) Processors
The name “Blackfin” refers to a family of 16-bit, embedded processors. VisualDSP++ currently supports the following Blackfin processors:
ADSP-BF531 ADSP-BF532 AD6901 ADSP-BF533 ADSP-BF534 AD6902 ADSP-BF535 ADSP-BF536 ADSP-BF541 ADSP-BF537 ADSP-BF538 ADSP-BF542 ADSP-BF539 ADSP-BF561 ADSP-BF544 AD6903 AD6531 ADSP-BF549 AD6901 AD6902

Product Information

You can obtain product information from the Analog Devices Web site, from the product CD-ROM, or from the printed publications (manuals).
Analog Devices is online at mation about a broad range of products—analog integrated circuits, amplifiers, converters, and digital signal processors.

MyAnalog.com

MyAnalog.com is a free feature of the Analog Devices Web site that allows
customization of a Web page to display only the latest information on products you are interested in. You can also choose to receive weekly e-mail notifications containing updates to the Web pages that meet your interests. sheets, code examples, and more.
VisualDSP++ 4.5 Assembler and Preprocessor Manual xvii
MyAnalog.com provides access to books, application notes, data
www.analog.com. Our Web site provides infor-
Product Information
Registration
Visit
www.myanalog.com to sign up. Click Register to use MyAnalog.com.
Registration takes about five minutes and serves as a means to select the information you want to receive.
If you are already a registered user, just log on. Your user name is your e-mail address.

Processor Product Information

For information on embedded processors and DSPs, visit our Web site at
www.analog.com/processors, which provides access to technical publica-
tions, data sheets, application notes, product overviews, and product announcements.
You may also obtain additional information about Analog Devices and its products in any of the following ways.
E-mail questions or requests for information to
processor.support@analog.com (World wide support) processor.europe@analog.com (Europe support) processor.china@analog.com (China support)
Fax questions or requests for information to
1-781-461-3010 (North America) +49-89-76903-157 (Europe)
Access the FTP Web site at
ftp ftp.analog.com (or ftp 137.71.25.69) ftp://ftp.analog.com
xviii VisualDSP++ 4.5 Assembler and Preprocessor Manual

Related Documents

For information on product related development software, see these publications:
VisualDSP++ 4.5 Getting Started Guide
VisualDSP++ 4.5 User’s Guide
VisualDSP++ 4.5 C/C++ Compiler and Library Manual for SHARC
Processors
VisualDSP++ 4.5 C/C++ Compiler and Library Manual for TigerSHARC Processors
VisualDSP++ 4.5 C/C++ Compiler and Library Manual for Blackfin Processors
VisualDSP++ 4.5 Assembler and Preprocessor Manual
Preface
VisualDSP++ 4.5 Linker and Utilities Manual
VisualDSP++ 4.5 Loader Manual
VisualDSP++ 4.5 Product Release Bulletin
VisualDSP++ Kernel (VDK) User’s Guide
Device Drivers and System Services Manual for Blackfin Processors
Quick Installation Reference Card
For hardware information, refer to your processors’s hardware reference, programming reference, or data sheet. All documentation is available online. Most documentation is available in printed form.
Visit the Technical Library Web site to access all processor and tools man­uals and data sheets:
http://www.analog.com/processors/resources/technicalLibrary
VisualDSP++ 4.5 Assembler and Preprocessor Manual xix
Product Information

Online Technical Documentation

Online documentation includes the VisualDSP++ Help system, software tools manuals, hardware tools manuals, processor manuals, Dinkum Abridged C++ library, and Flexible License Manager (FlexLM) network license manager software documentation. You can easily search across the entire VisualDSP++ documentation set for any topic of interest using the Search function of VisualDSP++ Help system. For easy printing, supple­mentary
Each documentation file type is described as follows.
File Description
.CHM Help system files and manuals in Help format
.PDF files of most manuals are also provided.
.HTM or .HTML
.PDF VisualDSP++ and processor manuals in Portable Documentation Format (PDF).
Dinkum Abridged C++ library and FlexLM network license manager software doc­umentation. Viewing and printing the Internet Explorer 5.01 (or higher).
Viewing and printing the Reader (4.5 or higher).
.PDF files requires a PDF reader, such as Adobe Acrobat
.HTML files requires a browser, such as
Access the online documentation from the VisualDSP++ environment, Windows
®
Explorer, or the Analog Devices Web site.
Accessing Documentation From VisualDSP++
From the VisualDSP++ environment:
Access VisualDSP++ online Help from the Help menu’s Contents, Search, and Index commands.
Open online Help from context-sensitive user interface items (tool­bar buttons, menu commands, and windows).
xx VisualDSP++ 4.5 Assembler and Preprocessor Manual
Preface
Accessing Documentation From Windows
In addition to any shortcuts you may have constructed, there are many ways to open VisualDSP++ online Help or the supplementary documenta­tion from Windows.
Help system files (.
CHM) are located in the Help folder of VisualDSP++
environment. The .PDF files are located in the Docs folder of your VisualDSP++ installation CD-ROM. The Docs folder also contains the Dinkum Abridged C++ library and the FlexLM network license manager software documentation.
Using Windows Explorer
Double-click the vdsp-help.chm file, which is the master Help sys­tem, to access all the other .CHM files.
Open your VisualDSP++ installation CD-ROM and double-click any file that is part of the VisualDSP++ documentation set.
Using the Windows Start Button
Access VisualDSP++ online Help by clicking the Start button and choosing Programs, Analog Devices, VisualDSP++, and VisualDSP++ Documentation.
Accessing Documentation From the Web
Download manuals in PDF format at the following Web site:
http://www.analog.com/processors/resources/technicalLibrary/manuals
Select a processor family and book title. Download archive (.ZIP) files, one for each manual. Use any archive management software, such as WinZip, to decompress downloaded files.
VisualDSP++ 4.5 Assembler and Preprocessor Manual xxi
Product Information

Printed Manuals

For general questions regarding literature ordering, call the Literature Center at 1-800-ANALOGD (1-800-262-5643) and follow the prompts.
VisualDSP++ Documentation Set
To purchase VisualDSP++ manuals, call 1-603-883-2430. The manuals may be purchased only as a kit.
If you do not have an account with Analog Devices, you are referred to Analog Devices distributors. For information on our distributors, log onto
http://www.analog.com/salesdir/continent.asp.
Hardware Tools Manuals
To purchase EZ-KIT Lite® and In-Circuit Emulator (ICE) manuals, call 1-603-883-2430. The manuals may be ordered by title or by product number located on the back cover of each manual.
Processor Manuals
Hardware reference and instruction set reference manuals may be ordered through the Literature Center at 1-800-ANALOGD (1-800-262-5643), or downloaded from the Analog Devices Web site. Manuals may be ordered by title or by product number located on the back cover of each manual.
Data Sheets
All data sheets (preliminary and production) may be downloaded from the Analog Devices Web site. Only production (final) data sheets (Rev. 0, A, B, C, and so on) can be obtained from the Literature Center at 1-800-ANALOGD (1-800-262-5643); they also can be downloaded from the Web site.
xxii VisualDSP++ 4.5 Assembler and Preprocessor Manual
Preface
To have a data sheet faxed to you, call the Analog Devices Faxback System at 1-800-446-6212. Follow the prompts and a list of data sheet code numbers will be faxed to you. If the data sheet you want is not listed, check for it on the Web site.

Notation Conventions

Text conventions used in this manual are identified and described as follows.
L
Example Description
Close command (File menu)
{this | that} Alternative required items in syntax descriptions appear within curly
[this | that] Optional items in syntax descriptions appear within brackets and sepa-
[this,…] Optional item lists in syntax descriptions appear within brackets
.SECTION Commands, directives, keywords, and feature names are in text with
filename Non-keyword placeholders appear in text with italic style format.
appear throughout this document.
Titles in in bold style reference sections indicate the location of an item within the VisualDSP++ environment’s menu system (for example, the Close command appears on the File menu).
brackets and separated by vertical bars; read the example as this or
that. One or the other is required.
rated by vertical bars; read the example as an optional this or that.
delimited by commas and terminated with an ellipse; read the example as an optional comma-separated list of
letter gothic font.
this.
Additional conventions, which apply only to specific chapters, may
VisualDSP++ 4.5 Assembler and Preprocessor Manual xxiii
Notation Conventions
Example Description
Note: For correct operation, ...
A Note provides supplementary information on a related topic. In the
L
a
[
online version of this book, the word Note appears instead of this symbol.
Caution: Incorrect device operation may result if ... Caution: Device damage may result if ...
A Caution identifies conditions or inappropriate usage of the product that could lead to undesirable results or product damage. In the online version of this book, the word Caution appears instead of this symbol.
Warning: Injury to device users may result if ... A Warning identifies conditions or inappropriate usage of the product that could lead to conditions that are potentially hazardous for devices users. In the online version of this book, the word Wa rning appears instead of this symbol.
xxiv VisualDSP++ 4.5 Assembler and Preprocessor Manual

1 ASSEMBLER

This chapter provides information on how to use the assembler for devel­oping and assembling programs with SHARC (ADSP-21xxx) processors, TigerSHARC (ADSP-TSxxx) processors, and Blackfin (ADSP-BFxxx) processors.
The chapter contains:
“Assembler Guide” on page 1-2 Describes the process of developing new programs in the proces­sor’s assembly language
“Assembler Syntax Reference” on page 1-33 Provides the assembler rules and conventions of syntax which are used to define symbols (identifiers), expressions, and to describe different numeric and comment formats
“Assembler Command-Line Reference” on page 1-129 Provides reference information on the assembler’s switches and conventions
L
VisualDSP++ 4.5 Assembler and Preprocessor Manual 1-1
The code examples in this manual have been compiled using VisualDSP++ 4.5. The examples compiled with other versions of VisualDSP++ may result in build errors or different output although the highlighted algorithms stand and should continue to stand in future releases of VisualDSP++.

Assembler Guide

Assembler Guide
In VisualDSP++ 4.5, the assembler drivers for each processor family run from the VisualDSP++ Integrated Debugging and Development Environ­ment (IDDE) or from an operating system command line. The assembler processes assembly source, data, header files, and produces an object file. Assembler operations depend on two types of controls: assembler direc­tives and assembler switches.
VisualDSP++ 4.5 supports the following assembler drivers:
For SHARC processors – easm21k.exe assembler driver
For TigerSHARC processors – easmts.exe assembler driver
For Blackfin processors – easmblkfn.exe assembler driver
This section describes the process of developing new programs in the Ana­log Devices’ processor assembly language. It provides information on how to assemble your programs from the operating system’s command line.
Software developers using the assembler should be familiar with:
“Writing Assembly Programs” on page 1-3
“Using Assembler Support for C Structs” on page 1-21
“Preprocessing a Program” on page 1-24
“Using Assembler Feature Macros” on page 1-26
“Make Dependencies” on page 1-30
“Reading a Listing File” on page 1-31
“Statistical Profiling for Assembly Functions” on page 1-31
“Specifying Assembler Options in VisualDSP++” on page 1-151
1-2 VisualDSP++ 4.5 Assembler and Preprocessor Manual
Assembler
For information about the processor architecture, including the instruc­tion set used when writing the assembly programs, see the hardware reference manual and instruction set manual for an appropriate processor.

Assembler Overview

The assembler processes data from assembly source (.ASM), data (.DAT), and include header ( Linkable Format (ELF), an industry-standard format for binary object files. The object file name has a
In addition to the object file, the assembler can produce a listing file, which shows the correspondence between the binary code and the source.
Assembler switches are specified from the VisualDSP++ IDDE or in the command used to invoke the assembler. These switches allow you to con­trol the assembly process of source, data, and header files. Use these switches to enable and configure assembly features, such as search paths, output file names, and macro preprocessing. See “Assembler Com-
mand-Line Reference” on page 1-129.
.H) files to generate object files in Executable and
.DOJ extension.
You can also set assembler options via the Assemble tab of the VisualDSP++ Project Options dialog box (see “Specifying Assembler
Options in VisualDSP++” on page 1-151).

Writing Assembly Programs

Assembler directives are coded in assembly source files. The directives allow you to define variables, set up some hardware features, and identify program’s sections for placement within processor memory. The assembler uses directives for guidance as it translates a source program into object code.
VisualDSP++ 4.5 Assembler and Preprocessor Manual 1-3
Assembler Guide
Write assembly language programs using the VisualDSP++ editor or any editor that produces text files. Do not use a word processor that embeds special control codes in the text. Use an
.ASM extension to source file
names to identify them as assembly source files.
Figure 1-1 on page 1-4 shows a graphical overview of the assembly pro-
cess. The figure shows the preprocessor processing the assembly source (.ASM) and header (.H) files.
Data initialization file
(.DAT)
Object file
Assembly source file
Preprocessor
preprocessed file (.IS)
(.DOJ)
(.ASM)
Intermediate
Assembler
Header file
(.H)
Listing file
(.LST)
Figure 1-1. Assembler Input and Output Files
1-4 VisualDSP++ 4.5 Assembler and Preprocessor Manual
Assembler
Assemble your source files from the VisualDSP++ environment or using any mechanism, such as a batch file or makefile, that will support invok­ing an appropriate assembler driver with a specified command-line command. By default, the assembler processes an input file to produce a binary object file (.
DOJ) and an optional listing file (.LST).
Object files produced by the processor assembler may be used as input to the linker and archiver. You can archive the output of an assembly process into a library file (.DLB), which can then be linked with other objects into an executable. Use the linker to combine separately assembled object files and objects from library files to produce an executable file. For more information on the linker and archiver, see the VisualDSP++ 4.5 Linker and Utilities Manual .
A binary object file (.DOJ) and an optional listing (.LST) file are final results of the successful assembly.
The assembler listing files are text files read for information on the results of the assembly process. The listing file also provides information about the imported c data structures. The listing file tells which imports were used within the program, followed by a more detailed section. (See the .import directive on page 1-84.) The file shows the name, total size and layout with offset for the members. The information appears at the end of the listing. You must specify the -l listname switch (on page 1-143) to get a listing file.
The assembly source file may contain preprocessor commands, such as
#include
, that cause the preprocessor to include header files (.H) into the source program. The preprocessor’s only output, an intermediate source file (.IS), is the assembler’s primary input. In normal operation, the pre­processor output is a temporary file that will be deleted during the assembly process.
VisualDSP++ 4.5 Assembler and Preprocessor Manual 1-5
Assembler Guide
Program Content
Assembly source file statements include assembly instructions, assembler directives, and preprocessor commands.
Assembly Instructions
Instructions adhere to the processor’s instruction set syntax documented in the processor’s instruction set manual. Each instruction line must be terminated by a semicolon (;). On TigerSHARC processors, each instruc­tion line (which can contain up to 4 instructions) is terminated by an additional semicolon (;;).Figure 1-2 on page 1-10 shows an example assembly source file.
To mark the location of an instruction, place an address label at the begin­ning of an instruction line or on the preceding line. End the label with a colon (:) before beginning the instruction. Your program can then refer to this memory location using the label instead of an address. The assembler places no restriction on the number of characters in a label.
Labels are case sensitive. The assembler treats “outer” and “Outer” as unique labels. For example (in Blackfin processors),
outer: [I1] = R0; Outer: R1 = 0X1234; JUMP outer; //jumps back 2 instructions
Assembler Directives
Directives begin with a period (.) and end with a semicolon (;). The assembler does not differentiate between directives in lowercase or uppercase.
L
For example (in Blackfin processors),
1-6 VisualDSP++ 4.5 Assembler and Preprocessor Manual
This manual prints directives in uppercase to distinguish them from other assembly statements.
.SECTION data1; .BYTE2 sqrt_coeff[2] = 0x5D1D, 0xA9ED;
Loading...
+ 210 hidden pages