Making a Fast Transition from
ADSP-21xx to ADSP-219x
common across ADI ELF assemblers. The IDE
provides a common environment and options.
The VisualDSP debugger is based on the robust
Contributed by Barbara Zino
and complete DWARF-2 format.
Version 1.2
See also: App Note "A Quick Primer on ELF
and DWARF-2".
Introduction
Whether you are upgrading existing 21xx code
or writing new code, you will want to be aware
of what is new and different with the ADSP219x instruction set and tools.
This application note was written for anyone
who is coming on-board with ADSP-219x and
would like detailed information on the
assembler tools. It is intended to assist in:
1) Upgrading existing 21xx assembly code to
ADSP-219x
2) Writing new assembly code for the ADSP219x
For a complete description of the ADSP-219x,
please see the ADSP-219x DSP Instruction Set
Reference (Part 82-00390-02).
ELF and DWARF-2
The ADSP-219x assembler and linker are part
of the new family of ADI ELF assemblers and
linkers that operate within the VisualDSP IDE
environment.
The tools produce industry standard formats:
• ELF Object File Format
• DWARF-2 Debugging Format
Getting Started
To assist in the upgrade of existing 21xx
applications, the assembler can optionally
process legacy syntax.
If you are using the command line version of the
new assembler or the IDE, the default is the new
ELF assembler directives:
easm219x myNew.asm
Specify the -legacy option to have the 5.x/6.x
syntax accepted by the new assembler: In
addition, you will likely want to specify the -c
option. This makes the 21xx -legacy case
sensitive:
easm219x -legacy -c myLegacy.dsp
The -legacy assembler option processes the
21xx directives and syntax that pre-date the new
family of ELF assemblers. The assembler
legacy option allows you to focus on core issues
and ignore syntax differences.
To enable assemble legacy code within the IDE
build environment:
Project Options
Assemble
Additional Options
Add "-legacy -c"
Copyright 2000, Analog Devices, Inc. All rights reserved. Analog Devices assumes no responsibility for customer product design or the use or application of customers’ products or
for any infringements of patents or rights of others which may result from Analog Devices assistance. All trademarks and logos are property of their respective holders. Information
furnished by Analog Devices Applications and Development Tools Engineers is believed to be accurate and reliable, however no responsibility is as sumed by Analog Devices
regarding the technical accuracy of the content provided in all Analog Devices’ Engineer-to-Engineer Notes.
When Upgrading Existing Code
• Assemble with -legacy
• Review instruction diagnostics (if any)
and revise to ADSP-219x
When Writing New Code
• Code with new ELF directives
• Do not use the -legacy option
Please note that you cannot mix "old and new"
syntax in the same assembly source file. You
can combine "old and new" in the same
application by assembling distinct source files
that are then linked together.
Resulting error with 9x assembler:
[Error E24] "MYSQRT.DSP":61
Assembler Error: 218x to 219x incompatibility:
No More POS or NEG.
Must use CCODE register.
Some existing 21xx assembly applications will
require no source code changes. Others may
need changes for the ADSP-219x core
instruction set. Here is a sampling of 21xx
legacy code with invalid ADSP-219x
instructions and the assembler messages that are
reported after passing the code through the
ADSP-219x assembler. These are the places in
the code that you need to change.
The following diagnostics are reported whether
or not the -legacy option is in effect. The -legacy
option in the 9x assembler is for 21xx syntax
compatibility only, not instruction compatibility.
For 8x processing, use the -legacy option with
the 8x assembler.
easm218x -legacy -c myApp.dsp
No NEG or POS CONDITION
218x code:
pwr_ok: IF NEG JUMP frac;
Solution:
Since SE is no longer a DREG (group 0
register), its use in a multi function move is
illegal. Select one of the ADSP-219x DREG.
[Warning W35] “CcodeLatency.asm":26
Assembler Warning: Detected a CCODE latency
problem. The CCODE write is immediately followed
by a CCODE conditional check. There is a 1-cycle
latency between writing to the CCODE register and
testing the condition. There is no stall in the
sequencer. If you don't add an instruction after the
CCODE write, your conditional check will be based
on the old CCODE!
Solution:
// CCODE latency accounted for
ccode=0x03;
i0=1;
if not swcond ar = abs ax0;
WRITING NEW CODE
When you write new code, use the ELF
directives that are common across the ADI ELF
assemblers. There are three ELF directives that
are the building blocks of any ELF assembly
program. Think of them as "The Three
Musketeers":
.SECTION DIRECTIVE
Sections are named contiguous locations of
program or data memory.
One or more section qualifiers indicate the
section properties. Section qualifiers begin with
"/". For example "/dm" or "/pm".
The section type is optional and the default is
SHT_PROGBITS. It is unlikely you will ever
need to override the section type for sections in
ELF binary object file for your application so
you can just ignore this paragraph altogether ☺.
.SECTION Examples
.section/pm program;
.section/dm data1;
1) .SECTION
2) .VAR
3) .GLOBAL
NOTATION
The notation used to describe the syntax in this
document:
*0 or more
+1 or more
?Optional item (0 or 1 may appear)
There are some advantages to using .section
directives:
• Permits multiple code sections
• Gives you more control over data placement
• Readable displays via the ElfDump utility
Multiple /pm (/code) .sections are allowed in
219x. In 21xx there was only a single .module
(code section).
In 219x, you determine placement of data
buffers in the assembler source by locating them
within the desired section. This differs from
21xx where the linker placed the data buffers at
locations of its own choosing.
EE-130Page 3
Technical Notes on using Analog Devices’ DSP components and development tools
You specify section placement in memory in the
LDF (Linker-Description-File) for your
application. For more info on LDF files, see the
Linker Guide "LDF Programming Examples",
"Linker Description File Reference" and the
Overlay Example for the 2192-12.
ELFDUMP
The ElfDump utility shows the contents of
object and executable files in a readable format.
It has many options. Total section size and
variable placement within each section are
easily viewed via ElfDump section displays.
.VAR INITIALIZATION
The -legacy directives separated the .VAR/DM
and .VAR/PM declarations from the .INIT or
.INIT24 initializations. The new style is an "all
in one" declare and initialize.
The default is to treat the .VAR initializers as 16
bit constants. 24 bit constants are supported via
the /INIT24 qualifier on the .VAR directive.
The default for the .VAR directive initialization
is to treat the initializers as 16 bit constants.
DM Data Variable 16 Bit Initialization
For example, if you want to see a code
disassembly (mnemonic display) of section
"program" in the object file file9x:
elfdump -ni program file9x.doj
Please run ElfDump -help for the complete list
of options.
.VAR DIRECTIVE
The .VAR directive defines and initializes data
objects.
The assembler provides error diagnostics for an
incorrect # of initializers if you use the form of
the syntax with an explicit declarator followed
by its initializers. In the example above, the
bufferTooFew .VAR directive is explicitly
declared with 5 elements. Only 3 elements are
initialized and the assembler reports the
discrepancy.
[Warning W41] "test.asm":4 'bufferTooFew':
Too few initializers specified.
Expected 5 but found 3. The remaining 2
elements were initialized to zero.
.GLOBAL DIRECTIVE
Symbols declared as global are program scope
and are thus visible outside the local file. By
default, symbols are file scope (local). The
.global directive must be used to export a
symbol.
The ELF directives were designed with the
syntax and semantics of C in mind. Memory
reference notation has been extended to the
more familiar C-style. You may find this
notation self-documenting and less prone to
error or you may prefer to keep coding in the
style you are already accustomed to.
Note: The -legacy option is not needed to
process old memory reference syntax where the
ordering of the operands determined the action
taken. The new assembler always accepts both
the old and new memory reference syntax styles.
" SEE APPENDIX A:
MEMORY REFERENCE SYNTAX
The following examples are identified by
description and the instruction type number as
defined in the 219x Instruction Set Guide.
// Type 4 :
// Multifunction ALU or MACC with memory
// read or write using DAG post-modify
//
AF=AF+1,AX0=DM(I0,M1);! legacy
AF=AF+1,AX0=DM(I0+=M1); // new syntax
// Type 21 : DAG Modify
//
MODIFY(I4,M5);! legacy
MODIFY(I4+=M5);// new syntax
If another file needs to access the symbol,
specify .global in the file that declares it and
.extern in the file(s) that references it.
.global symbol (, symbol )* ;
.GLOBAL Example
.global Function1, Function2;
Function1:
ax1 = dm(1, i4);
Function2:
EE-130Page 5
Technical Notes on using Analog Devices’ DSP components and development tools
// Type 21a : DAG Immediate Modify
//
MODIFY(I4,3);! legacy
MODIFY(I4+=3);// new syntax
// Type 29: DAG Memory Read/Write
// with Immediate Modify (Post-modify with
// update or offset without update)
//
DM(2,I1)=MR1;! offset
DM(I1+2)=MR1;// offset, new syntax
//Type 32:
// Pre-modify offset/
// Post-modify Update
// DAG memory read/write
//
DM(M5,I4)=m3;! pre-modify offset
DM(I4+M5)=m3;// new syntax
PRE-PROCESSOR
Here are the pre-processor basics:
EASM219x -legacy
Pre-Processing Flow of Control
• The pre-processor for the 219x assembler
and linker is the C style pre-processor
pp.exe. This is the same pre-processor used
by the other ELF assemblers and linkers,
including 21k, 2116x, and TigerSharc.
• The pre-processor for 21xx is asmpp.exe. To
preserve legacy code pre-processing, specify
the -legacy option and the 219x assembler
will call asmpp.exe as an additional preprocessing step after the pp.exe preprocessor.
• Specify the -sp (skip preprocessor) option
and neither pre-processor will be called.
Pre-Processor Flow Of Control
The 219x pre-processor produces "*.is" output
files. The naming convention for ADSP-219x
assembly source suffixes is .ASM.
EXAMPLE.DSP
#
PP.EXE
#
EXAMPLE.IS
#
ASMPP.EXE
#
EXAMPLE.APP
By default, the pre-processor files are written to
the temporary directory as specified by the
environment variable TMP on the PC (or
TMPDIR on Unix). The temporary files are
deleted upon completion of the assembly.
To obtain permanent copies of the pre-processor
temporary files, run the assembler with the preprocessor only option:
easm219x -pp -o example.tmp example.asm
EASM219x Default Pre-Processing
Flow of Control
EXAMPLE.ASM
#
PP.EXE
#
EXAMPLE.IS
When the -legacy option is specified, an
additional pre-processing pass is added after the
*.is is produced. It calls the legacy preprocessor asmpp.exe which processes the
.macro, .const, .include, and .local directives.
The legacy suffix convention for assembly
source was .DSP.
This runs the pre-processor on example.asm and
writes the temporary file example.is to the
current directory. It is not deleted.
easm219x -pp -legacy example.dsp
This runs the pre-processor on example.dsp and
leaves the temporary files example.is and
example.app in the current directory.
.CONST UPGRADE EXAMPLE
The .const directive is replaced by the C-style
#define macro and H# with 0x hex constant
syntax
21xx asmpp.exe
.CONST base=H#0D49,sqrt2=H#5A82;
EE-130Page 6
Technical Notes on using Analog Devices’ DSP components and development tools
The question mark "?" can be used to replace
the .local directive to avoid creating duplicate
labels when a macro is expanded multiple times.
219x pp.exe
If you are using the -legacy option, the legacy
pre-processor directives will be processed in
addition to the C pre-processor directives.
Without -legacy, rely solely on the C preprocessor directives.
" SEE APPENDIX B:
PRE_PROCESOR REFERENCE
EXPRESSIONS
There are places in the source where the
assembler processes symbols and literal
constants that may form expressions. We lump
these all under the category of "expressions".
SET POINTER
The "^" set point operator legacy syntax is
recognized when assembled with the -legacy
option. The "^" set point operator is no longer
required. Simply omit it when writing new code
for ADSP-219x.
The .VAR directive accepts a list of one or more
initializers from an external data file that by
convention is a file ending in ".dat" and referred
to as "dat" files. The legacy behavior for
There was some legacy behavior that seemed
just plain ol' wrong and the 9x -legacy doesn't
duplicate it. For instance "123" in the old tools
was treated as decimal "1230".
Recommendation:
The -legacy option has trouble with some of the
legacy dat files. It is recommended you change
the dat file constants to be hex prefixed with 0x
or H# whether you are using -legacy or not.
" SEE APPENDIX C:
DATA INITIALIZATION FILES
CASE SENSITIVITY
The 219x assembler is case sensitive, meaning
symbols must have the exact same case letter for
letter to be recognized as the same symbol.
The default for 21xx was case insensitive. It
uppercased all symbol references.
NEW (219x)
Case sensitive
ELF assemblers follow the C rules (case sensitive)
CALL AllMixedUp;
CALL allmixedup;
Will be treated as referencing different functions.
A POSSIBLE SURPRISE
If you are mixing legacy and non-legacy
assemblies you may be surprised by a linker
report for an unresolved reference. The reason
is the default on case sensitivity differs between
the old and new assemblers. You may
unintentionally reference and define a function
in a different case.
Look at the example below. ALLMIXEDUP is
referenced in all upper-case, but the definition is
the case sensitive AllMixedUp. The linker will
report an error for ALLMIXEDUP as
unresolved if these objects are linked together.
Solution: Use -legacy -c when mixing old and
new.
EE-130Page 8
Technical Notes on using Analog Devices’ DSP components and development tools
The -c option makes it case insensitive and
avoids any potential mismatch of definitions in
non-legacy modules.
-c Assembled with -legacy
.extern AllMixedUp;
Directives -- OLD and NEW
Welcome to the world of legacy directives and
the new ELF directives. This section shows the
legacy directives and how you would rewrite
them using the ELF directives instead. Side by
side examples are presented.
CALL AllMixedUp;
// with -c, case sensitive
// AllMixedUp
// without -c, case insensitive
// so upper-cased
// “ALLMIXEDUP”
Assembled without -legacy:
.global AllMixedUp;
AllMixedUp:
… code …
// case sensitive “as-is”
// “AllMixedUp”
.MODULE DIRECTIVE
In 21xx, every assembly program began with a
.module directive. In the ELF assemblers,
.section directives that define code sections
replace modules.
When the -legacy option is specified, the
assembler translates the .module directive to the
appropriate .section directive. "program" is the
name of the code section in the default *.ldf
(linker-description-file) used by the compilers.
In the absence of a specific /SEG qualifier on
the .module directive, the 219x assembler uses
"program" as the default name.
Use the .section directive when writing new
code. The .ENDMOD directive is not needed.
The beginning of the next section or the end-offile indicates the section ending point.
EXPRESSIONS SYNTAX
Expression syntax is for writing constants and
performing length, pointer, address and page
OLD (21xx)
.MODULE _dummy_;
.ENDMOD;
operations. Legacy expression syntax is
accepted only when the -legacy option is
.MODULE/SEG=myCode _dummy_;
.ENDMOD;
specified.
When writing new code, do not specify the
NEW (219x)
-legacy option and change to the new expression
syntax, where applicable.
" SEE APPENDIX D:
EXPRESSIONS REFERENCE
EE-130Page 9
Technical Notes on using Analog Devices’ DSP components and development tools
ELF .SECTION directives provide the
assembler with explicit directions on where to
place the code and data. You can switch back
and forth between sections and the assembler
adds on to the appropriate section wherever it
had left off.
Note: The ELF directives include a .PREVIOUS
directive for treating the sections as a stack. We
recommend you explicitly specify the section by
name to reduce the chance of an error when
adding new code.
.section/data data1;
.var …
.var …
.section/code program;
label1:
code …
code …
.section/data data1;
.var …
.section/code program;
code …
code …
label2:
code …
.VAR DIRECTIVE WITH SEG
.VAR DIRECTIVE WITHOUT SEG
In 219x, the segment is determined by which
section the .VAR directive is located within.
Every .VAR directive must reside within a
section.
/SEG=segName qualifier. In 219x, the segment
is determined by which .section the .VAR
directive is located within. The /seg qualifier
does not appear on the .VAR directive. It is the
section name.
-legacy .VAR WITHOUT /SEG
When the assembler is run in the -legacy mode,
it must determine what section each .VAR
OLD (21xx)
belongs to. If the .var has an explicit
/seg=segName qualifier it creates a section by
that name (or adds it to an already existing one
of that name).
If there is no /seg=segName qualifier, the 9x
assembler defaults to "data1" for DM and
"program" for PM. (These match the section
names the compiler uses).
-legacy .VAR WITH /ABS
To support the -legacy /ABS=address qualifier
on the .var directive, the new assembler
automatically generates the linker commands in
an LDF file that can be included in your
application's LDF.
Declaring and initializing PM data in 21xx was
accomplished via the .VAR directive for the
declaration and the .INIT24 directive for the
initialization.
// .var eq_outq in "cmn.asm", line 12,
//section 'data1', section index 4
//
RESOLVE( eq_outq, 0x10022 )
Include in Application LDF
•LDF INCLUDE command
INCLUDE(resolve_cmn.ldf)
.VAR AND .INIT DIRECTIVES
Declaring and initializing 16 bit data in 21xx
was accomplished via the .VAR directive for the
declaration and the .INIT directive for the
initialization.
With the ELF directives, the .VAR directive
declares and initializes "all in one" directive.
The default is 16-bit initialization.
With the ELF directives, the .VAR directive
declares and initializes. The /INIT24 qualifier is
needed to indicate it is a full 24 bit initialization.
Remember, the .VAR directive default is 16 bits
whether it is DM or PM data.
219x tools to automatically convert out of range
jump or call instructions to long.
The jump/call optimization is optional. You can
continue to code with short and long syntax as
you did in 21xx, if you prefer. (The 21xx
method means you must manually optimize the
code).
EE-130Page 12
Technical Notes on using Analog Devices’ DSP components and development tools
The -legacy option has no bearing on the
jump/call syntax or expansion option.
SHORT VERSUS LONG SYNTAX
The assembler will encode the instructions
based on syntax. It encodes short versus long
jumps and calls based on the keyword that is
specified. The "L" means long.
• LJUMP vs JUMP
• LCALL vs CALL
Out of range short jumps/calls receive errors
is done automatically by the tools. There is no
re-coding needed at the source level.
" SEE APPENDIX F:
JUMP/CALL EXPANSION REFERENCE
UNIVERSAL ELF DIRECTIVES
The set of universal ELF directives are common
among the family of ADI ELF assemblers, but
please keep in mind that some of them have no
meaning for a particular processor. For
example, the floating point directives are not
applicable to 219x which is a fixed point
processor.
[Error E33] ”JumpOutOfRange10.asm":2539
Jump offset out of range: -4096 to 4095
(Type 10). Jump at PC offset 464 to
destination '_L_250512' at PC offset 5764.
Recode with LJUMP or use the -jcs2l
(JumpCallShort2Long) option for automatic
conversion to long jump.
Long jumps/calls range that fit in a short range
receive warnings.
[Warning W32] "LJumpShort.asm":32
Jump doesn't require long range: 24 bit address
(Type 36 2 Word Instruction). LJUMP at PC
offset 58 to destination 'endLabel' at PC offset
154. This can be recoded with a single word
Type 10 JUMP.
-JCS2L OPTION (Jump-Call-Short-2-Long)
A new optimization was introduced in the
ADSP-219x assembler and linker.
easm219x -jcs2l
easm219x -JumpCallShort2Long
The -jcs2l option instructs the tools to change
out of range short jumps and calls to long. This
The Reference chart is complete. Some of these
directives are used by the compiler. You will see
them if you look at the "*.s" intermediate file
produced by the compiler.
" SEE APPENDIX G:
ELF DIRECTIVES REFERENCE
SOFTWARE UPDATE NEWS
The following are new features since the initial
7.0 release that are relevant to upgrading from
5.x/6.x:
• Comment Conversion
• .VAR Blocks and Initialization
CommentConverter
The { } legacy comment syntax is supported for
–legacy assemblies.
It is no longer supported for assemblies without
the –legacy option.
EE-130Page 13
Technical Notes on using Analog Devices’ DSP components and development tools
APPENDIX A: MEMORY REFERENCE SYNTAX
(Referenced from Page 5)
TYPEOLDNEW
POST MODIFY WITH
UPDATE
PRE MODIFY OFFSET
IMMEDIATE OFFSET
IMMEDIATE MODIFY
DM(<Ireg>,<Mreg>)DM(<Ireg> += <Mreg>)
DM(<Mreg>,<Ireg>)DM(<Ireg> + <Mreg>)
DM(<Expr >, <Ireg>)
<Expr> is an 8 bit 2's compliment number
DM(<Ireg>,<Expr>)
<Expr> is an 8 bit 2's compliment number
DM(<Ireg> + <Expr>)
<Expr> is an 8 bit 2's compliment number
DM(<Ireg> += <Expr>)
<Expr> is an 8 bit 2's compliment number
Copyright 2000, Analog Devices, Inc. All rights reserved. Analog Devices assumes no responsibility for customer product design or the use or application of customers’ products or
for any infringements of patents or rights of others which may result from Analog Devices assistance. All trademarks and logos are property of their respective holders. Information
furnished by Analog Devices Applications and Development Tools Engineers is believed to be accurate and reliable, however no responsibility is as sumed by Analog Devices
regarding the technical accuracy of the content provided in all Analog Devices’ Engineer-to-Engineer Notes.
APPENDIX B: PRE-PROCESSOR REFERENCE
(Referenced from Page 7)
LEGACY
PURPOSEUPGRADINGNEW BEHAVIOR
DIRECTIVE
*.app filePre-processor output
file is *.app.
.const xConstant definition.
Pre-processor is
asmpp.exe.
.includePre-processor is
asmpp.exe.
.local symbol;Applies to program
labels in macros to
prevent duplicate
names upon macro
expansion.
.macro ..
.endmacro;
Macro definition.
Pre-processor is
asmpp.exe.
*.is219x pre-processor output file
is *.is.
#define xC pre-processing style
#includeC pre-processing style
Put question mark at
the end of each label
reference within the
macro definition