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 implication or otherwise under the patent rights of Analog Devices, Inc.
Trademark and Service Mark Notice
The Analog Devices logo, VisualDSP++, Blackfin, SHARC, and TigerSHARC are registered trademarks of Analog Devices, Inc.
All other brand and product names are trademarks or service marks of
their respective owners.
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 ...................................................................... xvi
Analog Devices Web Site .......................................................... xvi
VisualDSP++ Online Documentation ...................................... xvii
Technical Library CD ............................................................. xviii
Notation Conventions .................................................................. xviii
xiiVisualDSP++ 5.0 Assembler and Preprocessor Manual
PREFACE
Thank you for purchasing Analog Devices, Inc. development software for
digital signal processing (DSP) applications.
Purpose
The VisualDSP++ 5.0 Assembler and Preprocessor Manual contains infor-
mation about the assembler and preprocessor utilities for the following
Analog Devices, Inc. processor families—Blackfin® (ADSP-BFxxx),
SHARC® (ADSP-21xxx), and TigerSHARC® (ADSP-TSxxx) processors.
The manual describes how to write assembly programs for these processors
and provides reference information about related development software.
It also provides information on new and legacy syntax for assembler and
preprocessor 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++ 5.0 Assembler and Preprocessor Manualxiii
Manual Contents
Manual Contents
The manual consists of:
•Chapter 1, “Assembler”
Provides an overview of the process of writing and building
assembly programs. It also provides information about assembler
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
This revision of the VisualDSP++ 5.0 Assembler and Preprocessor Manual
documents assembler and preprocessor functionality that is new to VisualDSP++® 5.0 and updates (up to update 6), including support for new
ADSP-2146x SHARC processors.
In addition, modifications and corrections based on errata reports against
the previous revision of the manual have been made.
xivVisualDSP++ 5.0 Assembler and Preprocessor Manual
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
•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++ 5.0 Assembler and Preprocessor Manualxv
Supported Processors
Supported Processors
The assembler and preprocessor of VisualDSP++ 5.0 supports the following Analog Devices, Inc. processors.
•Blackfin (ADSP-BFxxx)
•SHARC (ADSP-21xxx)
•TigerSHARC (ADSP-TSxxx)
The majority of the information in this manual applies to all processors.
For a complete list of processors supported by VisualDSP++ 5.0, refer to
the online Help.
Product Information
Product information can be obtained from the Analog Devices Web site,
VisualDSP++ online Help system, and a technical library CD.
Analog Devices Web Site
The Analog Devices Web site, www.analog.com, provides information
about a broad range of products—analog integrated circuits, amplifiers,
converters, and digital signal processors.
To access a complete technical library for each processor family, go to
http://www.analog.com/processors/technical_library. The manuals
selection opens a list of current manuals related to the product as well as a
link to the previous revisions of the manuals. When locating your manual
title, note a possible errata check mark next to the title that leads to the
current correction report against the manual.
xviVisualDSP++ 5.0 Assembler and Preprocessor Manual
Preface
Also note,
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 about products you are interested in. You can choose to receive
weekly e-mail notifications containing updates to the Web pages that meet
your interests, including documentation errata against all manuals. MyAn-
alog.com
provides access to books, application notes, data sheets, code
examples, and more.
Visit MyAnalog.com to sign up. If you are a registered user, just log on.
Your user name is your e-mail address.
VisualDSP++ Online Documentation
Online documentation comprises the VisualDSP++ Help system, software
tools manuals, hardware tools manuals, processor manuals, Dinkum
Abridged C++ library, and FLEXnet License Tools documentation. You
can search easily across the entire VisualDSP++ documentation set for any
topic of interest.
For easy printing, supplementary Portable Documentation Format (.pdf)
files for all manuals are provided on the VisualDSP++ installation CD.
Each documentation file type is described as follows.
File Description
.chmHelp system files and manuals in Microsoft help format
.htm or
.html
.pdfVisualDSP++ and processor manuals in PDF format. Viewing and printing the
Dinkum Abridged C++ library and FLEXnet license tools software
documentation. Viewing and printing the .html files requires a browser, such as
Internet Explorer 6.0 (or higher).
.pdf files requires a PDF reader, such as Adobe Acrobat Reader (4.0 or higher).
VisualDSP++ 5.0 Assembler and Preprocessor Manualxvii
Notation Conventions
Technical Library CD
The technical library CD contains seminar materials, product highlights,
a selection guide, and documentation files of processor manuals, VisualDSP++ software manuals, and hardware tools manuals for the following
processor families: Blackfin, SHARC, TigerSHARC, ADSP-218x, and
ADSP-219x.
To order the technical library CD, go to http://www.analog.com/proces-
sors/technical_library
processor, click the request CD check mark, and fill out the order form.
Data sheets, which can be downloaded from the Analog Devices Web site,
change rapidly, and therefore are not included on the technical library
CD. Technical manuals change periodically. Check the Web site for the
latest manual revisions and associated documentation errata.
, navigate to the manuals page for your
Notation Conventions
Text conventions used in this manual are identified and described as
follows.
L
ExampleDescription
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-
xviiiVisualDSP++ 5.0 Assembler and Preprocessor Manual
Additional conventions, which apply only to specific chapters, may
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
that. One or the other is required.
rated by vertical bars; read the example as an optional
this or
this or that.
Preface
L
a
[
ExampleDescription
[this,…]Optional item lists in syntax descriptions appear within brackets
delimited by commas and terminated with an ellipse; read the example
as an optional comma-separated list of
.SECTIONCommands, directives, keywords, and feature names are in text with
letter gothic font.
filenameNon-keyword placeholders appear in text with italic style format.
Note: For correct operation, ...
A Note provides supplementary information on a related topic. In the
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.
Warn in g: 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.
this.
VisualDSP++ 5.0 Assembler and Preprocessor Manualxix
Notation Conventions
xxVisualDSP++ 5.0 Assembler and Preprocessor Manual
1ASSEMBLER
This chapter provides information on how to use the assembler to develop
and assemble programs for SHARC (ADSP-21xxx), TigerSHARC
(ADSP-TSxxx), and Blackfin (ADSP-BFxxx) processors.
The chapter contains the following sections:
•“Assembler Guide” on page 1-2
Describes how to develop new programs using the processor’s
assembly language
•“Assembler Syntax Reference” on page 1-37
Provides the assembler rules and conventions of syntax used to
define symbols (identifiers), expressions, and to describe different
numeric and comment formats
•“Assembler Command-Line Reference” on page 1-141
Provides reference information on the assembler’s switches and
conventions
L
VisualDSP++ 5.0 Assembler and Preprocessor Manual1-1
The code examples in this manual have been compiled using
VisualDSP++ 5.0 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++ 5.0, you can run the assembler drivers for each processor
family from the VisualDSP++ integrated debugging and development
environment (IDDE) or from an operating system command line The
assembler processes assembly source, data, and header files to produce an
object file. Assembler operations depend on two types of controls:
assembler directives and assembler switches.
VisualDSP++ 5.0 supports the following assembler drivers.
•easm21k.exe (for SHARC processors)
•easmts.exe (for TigerSHARC processors)
•easmblkfn.exe (for Blackfin processors)
This section describes how to develop new programs in the Analog
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 these
topics:
•“Writing Assembly Programs” on page 1-4
•“Using Assembler Support for C Structs” on page 1-21
•“Preprocessing a Program” on page 1-24
•“Using Assembler Feature Macros” on page 1-25
•“Generating Make Dependencies” on page 1-33
•“Reading a Listing File” on page 1-34
1-2VisualDSP++ 5.0 Assembler and Preprocessor Manual
Assembler
•“Enabling Statistical Profiling for Assembly Functions” on
page 1-35
•“Specifying Assembler Options in VisualDSP++” on page 1-170
For information about a processor’s architecture, including the instruction
set used when writing assembly programs, refer to the Hardware Reference
and the Programming Reference for the appropriate processor.
Assembler Overview
The assembler processes data from assembly source (.asm), data (.dat),
and header (.h) files to generate object files in executable and linkable
format (ELF), an industry-standard format for binary object files. The
object file has a .doj extension.
In addition to the object file, the assembler can produce a listing file
(.lst) that shows the correspondence between the binary code and the
source.
Assembler switches are specified from the VisualDSP++ IDDE or from the
command line used to invoke the assembler. These switches allow you to
control 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. For more information, see
“Assembler Command-Line Reference” on page 1-141.
You can also set assembler options via the Assemble page of the Project Options dialog box in VisualDSP++. For more information, see “Specify-
ing Assembler Options in VisualDSP++” on page 1-170.
VisualDSP++ 5.0 Assembler and Preprocessor Manual1-3
Assembler Guide
Writing Assembly Programs
Assembler directives are coded in assembly source files. The directives
allow you to define variables, set up hardware features, and identify program sections for placement within processor memory. The assembler uses
directives for guidance as it translates a source program into object code.
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 shows a graphical overview of the assembly process. The figure
shows the preprocessor processing the assembly source (.asm) and header
(.h) files.
Assemble your source files from the VisualDSP++ environment or using
any mechanism, such as a batch file or makefile, that supports invoking an
appropriate assembler driver with a specified command-line command.
By default, the assembler processes an intermediate 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 about the linker and archiver, refer to the VisualDSP++ 5.0 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 file is a text file 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
1-4VisualDSP++ 5.0 Assembler and Preprocessor Manual
Assembler
Assembler
Preprocessor
Intermediate
preprocessed
file (.IS)
Assembly source file
(.ASP)
Data initialization file
(.DAT)
Header file
(.H)
Listing file
(.LST)
Object file
(.OBJ)
Figure 1-1. Assembler Input and Output Files
.IMPORT directive on page 1-90.) 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 switch (on page 1-159) to produce a
listing file.
The assembly source file may contain preprocessor commands, such as
#include
source program. The preprocessor’s only output, an intermediate source
file (
preprocessor output is a temporary file that is deleted during the assembly
process.
VisualDSP++ 5.0 Assembler and Preprocessor Manual1-5
, that cause the preprocessor to include header files (.h) into the
.is), is the assembler’s primary input. In normal operation, the
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, which is
documented in the processor’s Programming Reference. Each instruction
line must be terminated by a semicolon (;). On TigerSHARC processors,
each instruction line (which can contain up to 4 instructions) is terminated by an additional semicolon (;;). Figure 1-2 on page 1-8 shows an
example assembly source file.
To mark the location of an instruction, place an address label at the beginning 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),
Assembler directives begin with a period (.) and end with a semicolon (;).
The assembler does not differentiate between directives in lowercase or
uppercase.
L
1-6VisualDSP++ 5.0 Assembler and Preprocessor Manual
This manual prints directives in uppercase to distinguish them
from other assembly statements.
For a complete description of the assembler’s directive set, see “Assembler
Directives” on page 1-67.
Preprocessor Commands
Preprocessor commands begin with a pound sign (#) and end with a
carriage return. The pound sign must be the first non-white space
character on the line containing the command. If the command is longer
than one line, use a backslash (\) and a carriage return to continue the
command onto the next line.
Do not put any characters between the backslash and the carriage return.
Unlike assembler directives, preprocessor commands are case sensitive and
must be lowercase. For example,
#include "string.h"
#define MAXIMUM 100
For more information, see “Writing Preprocessor Commands” on
page 2-3. For a list of the preprocessor commands, see “Preprocessor
Command-Line Reference” on page 2-45.
Program Structure
An assembly source file defines code (instructions) and data. It also
organizes the instructions and data to allow the use of the linker description file (
.ldf) to describe how code and data are mapped into the
memory on your target processor. The way you structure your code and
data into memory should follow the memory architecture of the target
processor.
VisualDSP++ 5.0 Assembler and Preprocessor Manual1-7
Assembler Guide
Use the
.SECTION directive to organize the code and data in assembly
source files. The .SECTION directive defines a grouping of instructions and
data that occupies contiguous memory addresses in the processor. The
name given in a .SECTION directive corresponds to an input section name
in the linker description file.
Table 1-1, Table 1-2, and Table 1-3 show suggested input section names
for data and code that can be used in your assembly source for various
processors. Using these predefined names in your sources makes it easier
to take advantage of the default .ldf file included in your DSP system.
However, you may also define your own sections. For information on
.ldf files, refer to the VisualDSP++ 5.0 Linker and Utilities Manual.
Table 1-1. Suggested Input Section Names for a SHARC .ldf File
.SECTION NameDescription
seg_pmcoA section in program memory that holds code
seg_dmdaA section in data memory that holds data
seg_pmdaA section in program memory that holds data
seg_rthA section in program memory that holds system initialization code
and interrupt service routines
seg_swco A section in short word memory that holds instructions encoded for
execution from short word memory.
NOTE: Applies to the ADSP-2146x processors only.
Table 1-2. Suggested Input Section Names for a TigerSHARC .ldf File
.SECTION NameDescription
data1A section that holds data in memory block M1
data2A section that holds data in memory block M2 (specified with the
PM memory qualifier)
programA section that holds code
1-8VisualDSP++ 5.0 Assembler and Preprocessor Manual
Assembler
Table 1-3. Suggested Input Section Names for a Blackfin .ldf File
.SECTION NameDescription
data1A section that holds data
programA section that holds code
constdataA section that holds global data (which is declared as constant) and
literal constants such as strings and array initializers
Use sections in a program to group elements to meet hardware constraints.
For example, the ADSP-BF535 processor has a separate program and data
memory in Level 1 memory only. Level 2 memory and external memory
are not separated into instruction and data memory.
To group the code that resides in off-chip memory, declare a section for
that code and place that section in the selected memory with the linker.
The example assembly program defines three sections. Each section begins
with a
.SECTION directive or end-of-file.
.SECTION directive and ends with the occurrence of the next
Table 1-4 lists the sections in the source program:
Table 1-4. Sections in Source Programs
SectionBlackfinSHARCTigerSHARC
Data Section
Variables and buffers are declared and can be
initialized
Program Section
Data, instructions, and possibly other types of
statements are in this section, including statements that are needed for conditional assembly
data1
constdata
seg_rth
program
seg_dmdadata1
data2
seg_pmcoprogram
Figure 1-2, Figure 1-3 on page 1-14, and Figure 1-4 on page 1-17
describe assembly code file structure for each processor family. They show
how a program divides into sections that match the memory segmentation
VisualDSP++ 5.0 Assembler and Preprocessor Manual1-9
Assembler Guide
of a DSP system. Notice that an assembly source may contain preprocessor commands (such as
#ifdef
SECTIONS{} commands define the .SECTION placements in the system’s
(for conditional assembly), or #define (to define macros). The
#include to include other files in source code),
physical memory as defined by the linker’s MEMORY{} command. Assembler
directives, such as .VAR (or .BYTE for Blackfin processors), appear within
sections to declare and initialize variables.
Code File Structure for SHARC Processors
Figure 1-2 describes assembly code file structure for SHARC processors.
Looking at Figure 1-2, notice that the .PRECISION and .ROUND_ZERO
directives inform the assembler to store floating-point data with 40-bit
precision and to round a floating-point value to a closer-to-zero value if it
does not fit in the 40-bit format.
LDF for SHARC Processors
Listing 1-1 shows a sample user-defined .ldf file for SHARC processors.
Looking at the file’s SECTIONS{} command, notice that the INPUT_SECTION
commands map to the names of memory sections (such as program, data1,
data2, ctor, heaptab, and so on) used in the example assembly sample