Docsity

Motorola DSP Assembler Reference Manual - Prof. Jayant Datta, Assignments of Electrical and Electronics Engineering

Partial preview of the text

Download Motorola DSP Assembler Reference Manual - Prof. Jayant Datta and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

MOTOROLA DIGITAL SIGNAL PROCESSING

DEVELOPMENT SOFTWARE

MOTOROLA DSP

ASSEMBLER REFERENCE MANUAL

Specification and information herein are subject to change without notice. Motorola re- serves the right to make changes without further notice to any products described in this document to improve reliability, function, or design. Motorola does not assume any liability arising out of the application or use of any product or circuit described herein, neither does it convey any license under its patent rights or the rights of others. Motorola is a registered trademark of Motorola, Inc. Motorola, Inc. is an Equal Employment/Affirmative Action Em- ployer.

This manual documents the assembler as of version 5.3.2 of the software.

© Copyright Motorola, Inc. 1994. All rights reserved.

ASM56000, SIM56000, ASM96000, SIM96000, ASM56100, and SIM56100 are trade- marks of Motorola.

MS-DOS and Windows are trademarks of Microsoft Corporation.

Sun-4 and SunOS are trademarks of Sun Microsystems, Inc.

Macintosh and MPW are trademarks of Apple Computer.

iv DSP ASSEMBLER REFERENCE MANUAL MOTOROLA

Preface

The element names are printed in lower case and contained in angle brackets. Some common elements used to describe directives are:

A statement comment

Supporting Publications

DSP56000 Family Manual. Motorola, Inc. 1992.

DSP96002 User’s Manual. Motorola, Inc. 1989.

DSP56100 Family Manual. Motorola, Inc. 1993.

Motorola DSP Simulator Reference Manual. Motorola, Inc. 1994.

Motorola DSP Linker/Librarian Reference Manual. Motorola, Inc. 1994.

MOTOROLA DSP ASSEMBLER REFERENCE MANUAL v

TABLE OF CONTENTS

Paragraph Page Number Title Number

MOTOROLA DSP ASSEMBLER REFERENCE MANUAL vii

TABLE OF CONTENTS

Paragraph Page

viii DSP ASSEMBLER REFERENCE MANUAL MOTOROLA

TABLE OF CONTENTS (Continued)

Paragraph Page Number Title Number

6.3.6 Macros and Conditional Assembly............................. 74

6.3.7 Structured Programming.................................... 74

Chapter 7 STRUCTURED CONTROL STATEMENTS

7.1 INTRODUCTION............................................ 171

7.2 STRUCTURED CONTROL DIRECTIVES......................... 171

7.3 SYNTAX................................................... 172

7.3.1 .BREAK Statement........................................ 172

7.3.2 .CONTINUE Statement.................................... 173

7.3.3 .FOR Statement.......................................... 174

7.3.4 .IF Statement............................................ 175

7.3.5 .LOOP Statement......................................... 176

7.3.6 .REPEAT Statement....................................... 177

7.3.7 .WHILE Statement........................................ 177

7.4 SIMPLE AND COMPOUND EXPRESSIONS....................... 178

7.4.1 Simple Expressions....................................... 178

7.4.1.1 Condition Code Expressions.............................. 178

7.4.1.2 Operand Comparison Expressions......................... 179

7.4.2 Compound Expressions.................................... 180

7.5 STATEMENT FORMATTING................................... 180

7.5.1 Expression Formatting..................................... 180

7.5.2 .FOR/.LOOP Formatting.................................... 181

7.5.3 Assembly Listing Format................................... 181

7.6 EFFECTS ON THE PROGRAMMER’S ENVIRONMENT............. 181

Appendix A ASCII CHARACTER CODES

Appendix B DIRECTIVE SUMMARY

B.1 ASSEMBLY CONTROL....................................... 185

B.2 SYMBOL DEFINITION....................................... 186

B.3 DATA DEFINITION/STORAGE ALLOCATION..................... 186

x DSP ASSEMBLER REFERENCE MANUAL MOTOROLA

TABLE OF CONTENTS (Continued)

Paragraph Page Appendix F

  • Chapter Preface
  • 1.1 INTRODUCTION MOTOROLA DSP ASSEMBLER
  • 1.2 ASSEMBLY LANGUAGE
  • 1.3 INSTALLING THE ASSEMBLER
  • 1.4 RUNNING THE ASSEMBLER
  • 1.5 ASSEMBLER PROCESSING
  • 1.6 DEFINITION OF TERMS
  • 1.7 ASSEMBLER SUPPORT FOR DIGITAL SIGNAL PROCESSING
    • Chapter
  • 2.1 INPUT FILE FORMAT WRITING ASSEMBLY LANGUAGE PROGRAMS
  • 2.2 SYMBOL NAMES
  • 2.3 STRINGS
  • 2.4 SOURCE STATEMENT FORMAT
  • 2.4.1 Label Field
  • 2.4.2 Operation Field.
  • 2.4.3 Operand Field.
  • 2.4.4 Operation 2 Field
  • 2.4.5 Operand 2 Field
  • 2.4.6 Data Transfer Fields.
  • 2.4.7 Comment Field
  • 2.5 ASSEMBLER OUTPUT
    • Chapter
  • 3.1 INTRODUCTION EXPRESSIONS
  • 3.2 ABSOLUTE AND RELATIVE EXPRESSIONS
  • 3.3 EXPRESSION MEMORY SPACE ATTRIBUTE
  • 3.4 INTERNAL EXPRESSION REPRESENTATION
  • 3.5 CONSTANTS
  • 3.5.1 Numeric Constants. Number Title Number
  • 3.5.2 String Constants.
  • 3.6 OPERATORS
  • 3.6.1 Unary operators
  • 3.6.2 Arithmetic operators
  • 3.6.3 Shift operators
  • 3.6.4 Relational operators
  • 3.6.5 Bitwise operators
  • 3.6.6 Logical operators
  • 3.7 OPERATOR PRECEDENCE
  • 3.8 FUNCTIONS
  • 3.8.1 Mathematical Functions
  • 3.8.2 Conversion Functions.
  • 3.8.3 String Functions
  • 3.8.4 Macro Functions.
  • 3.8.5 Assembler Mode Functions
    • Chapter
  • 4.1 INTRODUCTION SOFTWARE PROJECT MANAGEMENT
  • 4.2 SECTIONS
  • 4.3 SECTIONS AND DATA HIDING
  • 4.3.1 Sections and Symbols
  • 4.3.2 Sections and Macros
  • 4.3.3 Nested and Fragmented Sections
  • 4.4 SECTIONS AND RELOCATION
  • 4.5 ADDRESS ASSIGNMENT
  • 4.5.1 The ORG Directive
  • 4.5.2 Overlays
  • 4.5.3 Address Assignment Examples
  • 4.5.4 Circular Buffers.
  • 4.6 EXAMPLE 1: MULTI-PROGRAMMER ENVIRONMENT
  • 4.6.1 Absolute Mode Implementation
  • 4.6.2 Relative Mode Implementation. Number Title Number
  • 4.7 EXAMPLE 2: OVERLAYS
  • 4.7.1 Absolute Mode Implementation
  • 4.7.2 Relative Mode Implementation.
  • 4.8 EXAMPLE 3: BOOTSTRAP OVERLAY
  • 4.8.1 Absolute Mode Implementation
  • 4.8.2 Relative Mode Implementation.
    • Chapter
  • 5.1 MACRO OPERATIONS MACRO OPERATIONS AND CONDITIONAL ASSEMBLY
  • 5.2 MACRO LIBRARIES
  • 5.3 MACRO DEFINITION
  • 5.4 MACRO CALLS
  • 5.5 DUMMY ARGUMENT OPERATORS
  • 5.5.1 Dummy argument concatenation operator - .
  • 5.5.2 Return value operator -?
  • 5.5.3 Return hex value operator - %
  • 5.5.4 Dummy argument string operator - "
  • 5.5.5 Macro local label override operator - ^
  • 5.6 DUP, DUPA, DUPC, DUPF DIRECTIVES
  • 5.7 CONDITIONAL ASSEMBLY
    • Chapter
  • 6.1 INTRODUCTION ASSEMBLER SIGNIFICANT CHARACTERS AND DIRECTIVES
  • 6.2 ASSEMBLER SIGNIFICANT CHARACTERS
  • 6.3 ASSEMBLER DIRECTIVES
  • 6.3.1 Assembly Control
  • 6.3.2 Symbol Definition
  • 6.3.3 Data Definition/Storage Allocation
  • 6.3.4 Listing Control and Options
  • 6.3.5 Object File Control
  • E.3.4.7 Object File Comments Number Title Number
  • E.3.5 String Table
  • E.4 DIFFERENCES IN DSP OBJECT FORMAT AND STANDARD COFF.
  • E.4.1 Multiple Memory Spaces
  • E.4.2 Object File Transportability.
  • E.4.3 Structure Size Fields
  • E.4.4 Relocation Information
  • E.4.5 Block Data Sections
  • E.4.6 Other Extensions
  • E.5 OBJECT FILE DATA EXPRESSION FORMAT.
  • E.5.1 Data Expression Generation
  • E.5.2 Data Expression Interpretation.
  • E.5.2.1 User Expression - { }
  • E.5.2.2 Relocatable Expression - [ ]
  • E.5.2.3 Memory Space Operator - @
  • E.5.2.4 Bit Size Operator - #
  • E.5.2.5 Memory Attribute Operator - :
  • E.5.2.6 Line Number Operator -!
  • E.5.2.7 BFxxx Instruction Mask Function - @FBF()
  • E.5.2.8 Local Relocatable Reference Function - @LRF().
  • E.5.2.9 Alternate Encoding Function - @ENC()
  • F.1 INTRODUCTION DEVICE-DEPENDENT INFORMATION
  • F.1.1 Instruction Set Summary
  • F.1.2 Register Names and Usage
  • F.1.3 Condition Code Mnemonics
  • F.1.4 Instruction Set Summary
  • F.1.5 Register Names and Usage
  • F.1.6 Condition Code Mnemonics
  • F.1.7 Instruction Set Summary
  • F.1.8 Register Names and Usage

MOTOROLA DSP ASSEMBLER REFERENCE MANUAL xi

TABLE OF CONTENTS

Paragraph Page Number Title Number

F.1.9 Condition Code Mnemonics................................. 305

Appendix G HOST-DEPENDENT INFORMATION

G.1 INTRODUCTION............................................ 307

G.2 DOS/386 ENVIRONMENT.................................... 307

G.2.1 Hardware Requirements................................... 307

G.2.2 Installation.............................................. 308

G.2.3 Source File Text.......................................... 308

G.2.4 Invoking the Assembler.................................... 308

G.3 SunOS ENVIRONMENT...................................... 309

G.3.1 Hardware Requirements................................... 309

G.3.2 Installation.............................................. 309

G.3.3 Source File Text.......................................... 310

G.3.4 Invoking the Assembler.................................... 310

G.4 MACINTOSH ENVIRONMENT................................. 310

G.4.1 Hardware Requirements................................... 311

G.4.2 Installation.............................................. 311

G.4.3 Source File Text.......................................... 311

G.4.4 Invoking the Assembler.................................... 312

MOTOROLA DSP ASSEMBLER REFERENCE MANUAL 1

Chapter 1

MOTOROLA DSP ASSEMBLER

1.1 INTRODUCTION

The Motorola DSP Assemblers are programs that process assembly language source statements written for Motorola’s family of digital signal processors. The assembler trans- lates these source statements into object programs compatible with other Motorola DSP software and hardware products.

1.2 ASSEMBLY LANGUAGE

The assembly language provides mnemonic operation codes for all machine instructions in the digital signal processor instruction set. In addition, the assembly language contains mnemonic directives which specify auxiliary actions to be performed by the assembler. These directives are not always translated into machine language. The assembly lan- guage enables the programmer to define and use macro instructions which replace a sin- gle statement with a predefined sequence of statements found in the macro definition. Conditional assembly also is supported.

1.3 INSTALLING THE ASSEMBLER

The assembler is distributed on various media and in different formats depending on the host environment. See Appendix G, HOST-DEPENDENT INFORMATION, for details on installing and operating the assembler on your particular machine.

1.4 RUNNING THE ASSEMBLER

The general format of the command line to invoke the assembler is:

DSPASM [options]

where:

DSPASM

The name of the Motorola DSP assembler program appropriate for the tar- get processor (see Appendix F, DEVICE-DEPENDENT INFORMATION).

Chapter 1 - MOTOROLA DSP ASSEMBLER

2 DSP ASSEMBLER REFERENCE MANUAL MOTOROLA

For example, for the Motorola DSP56000 processor the name of the assem- bler executable is ASM.

[options]

Any of the following command line options. These can be in any order, but must precede the list of source filenames. Some options can be given more than once; the individual descriptions indicate which options may be speci- fied multiple times. Option letters can be in either upper or lower case.

Command options that are used regularly may be placed in the environment variable DSPASMOPT. If the variable is found in the environment the as- sembler adds the associated text to the existing command line prior to pro- cessing any options. See your host documentation for instructions on how to define environment variables.

Option arguments may immediately follow the option letter or may be sepa- rated from the option letter by blanks or tabs. However, an ambiguity arises if an option takes an optional argument. Consider the following command line:

ASM56000 -B MAIN IO

In this example it is not clear whether the file MAIN is a source file or is meant to be an argument to the -B option. If the ambiguity is not resolved the assembler will assume that MAIN is a source file and attempt to open it for reading. This may not be what the programmer intended.

There are several ways to avoid this ambiguity. If MAIN is supposed to be an argument to the -B option it can be placed immediately after the option letter:

ASM56000 -B MAIN IO

If there are other options on the command line besides those that take op- tional arguments the other options can be placed between the ambiguous option and the list of source file names:

ASM56000 -B MAIN -V IO

An alternative is to use two successive hyphens to indicate the end of the option list:

ASM56000 -B -- MAIN IO

In this latter case the assembler interprets MAIN as a source file name and uses the default naming conventions for the -B option.

Chapter 1 - MOTOROLA DSP ASSEMBLER

4 DSP ASSEMBLER REFERENCE MANUAL MOTOROLA

bol> sequence can be repeated as often as desired. See the DE- FINE directive (Chapter 6) for more information.

Example: ASM96000 -D POINTS 16 prog.asm

All occurrences of the symbol POINTS in the program PROG.ASM will be replaced by the string ‘16’.

-EA -EW

These options allow the standard error output file to be reassigned on hosts that do not support error output redirection from the command line. must be present as an argument, but can be any legal operating system file- name, including an optional pathname.

The -EA option causes the standard error stream to be written to ; if exists, the output stream is appended to the end of the file. The -EW option also writes the standard error stream to ; if exists it is rewound (truncated to zero), and the output stream is written from the be- ginning of the file.

Example: ASM96000 -EW errors prog.asm

Redirect the standard error output to the file ERRORS. If the file al- ready exists, it will be overwritten.

-F

Indicates that the assembler should read command line input from . can be any legal operating system filename, including an optional pathname. is a text file containing further options, arguments, and filenames to be passed to the assembler. The arguments in the file need be separated only by some form of white space (blank, tab, newline). A semi- colon ( ; ) on a line following white space makes the rest of the line a com- ment.

The -F option was introduced to circumvent the problem of limited line lengths in some host system command interpreters. It may be used as often as desired, including within the argument file itself. Command options may also be supplied using the DSPASMOPT environment variable. See the dis- cussion of DSPASMOPT under [options] at the beginning of this section.

Example: ASM96000 -F opts.cmd

Invoke the assembler and take command line options and source filenames from the command file OPTS.CMD.

Chapter 1 - MOTOROLA DSP ASSEMBLER

MOTOROLA DSP ASSEMBLER REFERENCE MANUAL 5

-G

Send source file line number information to the object file. This option is val- id only in conjunction with the -B command line option. The generated line number information can be used by debuggers to provide source-level de- bugging.

Example: ASM56000 -B -G myprog.asm

Assemble the file MYPROG.ASM and send source file line number information to the resulting object file MYPROG.CLN.

-I

When the assembler encounters INCLUDE files, the current directory (or the directory specified in the INCLUDE directive) is first searched for the file. If it is not found and the -I option is specified, the assembler prefixes the file- name (and optional pathname) specified in the INCLUDE directive with and searches the newly formed directory pathname for the file.

The pathname must be a legal operating system pathname. The -I option may be repeated as many times as desired. The directories will be searched in the order specified on the command line.

Example: ASM56000 -I \project\ testprog

This example uses IBM PC pathname conventions, and would cause the assembler to prefix any INCLUDE files not found in the current directory with the \project\ pathname.

-L

This option specifies that a listing file is to be created for assembler output. can be any legal operating system filename, including an optional pathname. A hyphen also may be used as an argument to indicate that the listing file should be sent to the standard output, although the listing file is routed to standard output by default.

If a pathname is not specified, the file will be created in the current directory. If no filename is specified, the assembler will use the basename (filename without extension) of the first filename encountered in the source input file list and append .LST to the basename. If the -L option is not specified, then the assembler will route listing output to the standard output (usually the console or terminal screen) by default. The -L option should be specified

Chapter 1 - MOTOROLA DSP ASSEMBLER

MOTOROLA DSP ASSEMBLER REFERENCE MANUAL 7

below. Note that if this option is not used the assembler runs with all latest revision level enhancements on by default.

Processor Identifier

DSP56001 Rev. C 56001c DSP56002 56002 DSP56004 56004 DSP56166 56166 DSP96001 Rev. B 96001b DSP96002 96002

Example: ASM56000 -P 56001c myprog.asm

Assemble MYPROG.ASM with the DSP56000 Revision C enhance- ments.

-Q

On some hosts the assembler displays a banner on the console when in- voked. This option inhibits the banner display. It has no effect on hosts where the signon banner is not displayed by default.

Example: ASM56000 -Q myprog.asm

Assemble the file MYPROG.ASM but do not display the signon ban- ner on the console.

-R

Run the assembler without the specified processor revision level enhance- ments. This is for backward compatibility so that the assembler will flag new constructions as illegal. can be any of the revision specifiers given be- low, but must be appropriate for the target processor.

This option is superseded by the -P option.

Processor Revision

DSP56001 Rev. C C DSP56002 2 DSP56004 4 DSP56166 6 DSP96000 Rev. B B DSP96001 1

Example: ASM56000 -RC myprog.asm

Assemble MYPROG.ASM without the DSP56000 Revision C en- hancements.

Chapter 1 - MOTOROLA DSP ASSEMBLER

8 DSP ASSEMBLER REFERENCE MANUAL MOTOROLA

-V

This option causes the assembler to report assembly progress (beginning of passes, opening and closing of input files) to the standard error output stream. This is useful to insure that assembly is proceeding normally.

Example: ASM56000 -V myprog.asm

Assemble the file MYPROG.ASM and send progress lines to the standard error output.

-Z

This option causes the assembler to strip symbol information from the ab- solute load file. Normally symbol information is retained in the object file for symbolic reference purposes. Note that this option is valid only when the assembler is in absolute mode via the -A command line option and when an object file is created ( -B option).

Example: ASM56000 -A -B -Z myprog.asm

Assemble the file MYPROG.ASM in absolute mode and strip symbol information from the load file created as output.

A list of operating system compatible filenames (including optional path- names). If no extension is supplied for a given file, the assembler first will attempt to open the file using the filename as supplied. If that is not suc- cessful the assembler appends .ASM to the filename and attempts to open the file again. If no pathname is specified for a given file, the assembler will look for that file in the current directory. The list of files will be processed sequentially in the order given and all files will be used to generate the ob- ject file and listing.

The assembler will redirect the output listing to the standard output if the output listing is not suppressed with the IL option, or if it is not redirected via the -L command line option described above. The standard output generally goes to the console or terminal screen by default, but can be diverted to a file or to a printer by using the I/O redirection facilities of the host operating system, if available. Error messages will always appear on the stan- dard output, regardless of any option settings. Note that some options ( -B , -L ) allow a hyphen as an optional argument which indicates that the corresponding output should be sent to the standard output stream. Unpredictable results may occur if, for example, the object file is explicitly routed to standard output while the listing file is allowed to default to the same output stream.

For more details on assembler operation in a particular machine environment see Appen- dix G, HOST-DEPENDENT INFORMATION.