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, Blackfin, EZ-KIT Lite, SHARC, TigerSHARC,
and VisualDSP++ 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 of This Manual ................................................................ xiii
Intended Audience ........................................................................ xiii
Manual Contents ........................................................................... xiv
What’s New in This Manual ............................................................ xv
Technical or Customer Support ....................................................... xv
Supported Processors ...................................................................... xvi
Product Information ..................................................................... xvii
MyAnalog.com ........................................................................ xvii
Processor Product Information ................................................ xviii
Related Documents .................................................................. xix
Online Technical Documentation ............................................. xix
Accessing Documentation From VisualDSP++ ....................... xx
Accessing Documentation From Windows ............................. xx
Accessing Documentation From the Web .............................. xxi
Printed Manuals ....................................................................... xxi
VisualDSP++ Documentation Set ........................................ xxii
Type 1: Compute | DregX«···DM | DregY«···PM ......................... 8-17
Type 3: Dreg/Ireg/Mreg «···» DM/PM ......................................... 8-18
Type 4: Compute | Dreg «···» DM ............................................... 8-19
Type 6: Dreg «··· Data16 ............................................................. 8-20
Type 7: Reg1/2 «··· Data16 ......................................................... 8-21
Type 8: Compute | Dreg1 «··· Dreg2 ........................................... 8-22
Type 9: Compute ........................................................................ 8-23
Type 9a: Compute ...................................................................... 8-26
Type 10: Direct Jump ................................................................. 8-28
Type 10a: Direct Jump/Call ........................................................ 8-29
Type 11: Do ··· Until .................................................................. 8-30
xADSP-219x DSP Instruction Set Reference
CONTENTS
Type 12: Shift | Dreg «···» DM .................................................... 8-31
Type 14: Shift | Dreg1 «··· Dreg2 ................................................. 8-32
Type 15: Shift Data8 ................................................................... 8-33
Type 16: Shift Reg0 .................................................................... 8-34
Type 17: Any Reg «···Any Reg ..................................................... 8-35
Type 18: Mode Change ............................................................... 8-36
Type 19: Indirect Jump/Call ........................................................ 8-37
Type 20: Return .......................................................................... 8-38
Type 21: Modify DagI ................................................................. 8-39
Type 21a: Modify DagI ............................................................... 8-40
Type 22: DM «··· Data16 ............................................................ 8-41
Type 22a: PM «··· Data24 ............................................................ 8-42
Type 23: Divide primitive, DIVQ ................................................ 8-43
Type 24: Divide primitive, DIVS ................................................. 8-44
Type 25: Saturate ........................................................................ 8-45
Type 26:Push/Pop/Cache ............................................................ 8-46
Type 29: Dreg «···» DM .............................................................. 8-47
Type 30: NOP ............................................................................ 8-48
Type 31: Idle ............................................................................... 8-49
Type 32: Any Reg «···» PM/DM .................................................. 8-50
Type 32a: DM«···DAG Reg | DAG Reg«···Ireg ............................. 8-51
Type 33: Reg3 «··· Data12 ........................................................... 8-52
Type 34: Dreg «···» IOreg ............................................................ 8-53
Type 35: Dreg «···»Sreg ............................................................... 8-54
ADSP-219x DSP Instruction Set Referencexi
CONTENTS
Type 36: Long Jump/Call ........................................................... 8-55
Type 37: Interrupt ...................................................................... 8-56
INDEX
xiiADSP-219x DSP Instruction Set Reference
PREFACE
Thank you for purchasing and developing systems using ADSP-219x
DSPs from Analog Devices.
Purpose of This Manual
The ADSP-219x DSP Instruction Set Reference provides assembly syntax
information for ADSP-219x DSPs. The syntax descriptions cover instructions that execute within the DSP’s processor core (processing elements,
program sequencer, and data address generators). For architecture and
design information on the DSP, see the ADSP-219x/2192 DSP Hardware Reference.
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 manuals and data sheets) that
describe your target architecture.
ADSP-219x DSP Instruction Set Referencexiii
Manual Contents
Manual Contents
This reference presents instruction information organized by the type of
the instruction. Instruction types relate to the machine language opcode
for the instruction. On this DSP, the opcodes categorize the instructions
by the portions of the DSP architecture that execute the instructions. The
following chapters cover the different types of instructions.
•“Instruction Set Summary” on page 1-1—This chapter provides a
syntax summary of all instructions and describes the conventions
that are used on the instruction reference pages.
•“ALU Instructions” on page 2-1—These instruction specify opera-
tions that occur in the DSP’s ALU.
•“MAC Instructions” on page 3-1—These instructions specify operations that occur in the DSP’s Shifter.
•“Shifter Instructions” on page 4-1—These instructions specify
operations that occur in the DSP’s Shifter.
•“Multifunction Instructions” on page 5-1—These instructions
specify parallel, single-cycle operations.
•“Data Move Instructions” on page 6-1—These instructions specify
memory and register access operations.
•“Program Flow Instructions” on page 7-1—These instructions
specify program sequencer operations.
•“Instruction Opcodes” on page 8-1—This chapter lists the instruction encoding fields for all instructions.
Each of the DSP’s instructions is specified in this text. The reference page
for an instruction shows the syntax of the instruction, describes its function, gives one or two assembly-language examples, and identifies fields of
xivADSP-219x DSP Instruction Set Reference
Preface
its opcode. The instructions are referred to by type, ranging from 1 to 37.
These types correspond to the opcodes that ADSP-219x DSPs recognize,
but are for reference only and have no bearing on programming.
Some instructions have more than one syntactical form; for example, the
instruction “Type 9: Compute” on page 8-23 has many distinct forms.
Many instructions can be conditional. These instructions are prefaced by
IF COND; for example:
If COND compute;
In a conditional instruction, the execution of the entire instruction is
based on the specified condition.
What’s New in This Manual
Revision 2.0 of the ADSP-219x DSP Instruction Set Reference corrects all
known document errata issues.
L
This instruction set reference is a companion document to the
ADSP-219x/2192 DSP Hardware Reference (Rev 1.1, April 2004).
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
Supported Processors
The following is the list of Analog Devices, Inc. processors supported in
VisualDSP++®.
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 families: ADSP-TS101 and ADSP-TS20x.
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 families: ADSP-2106x, ADSP-2116x, ADSP-2126x, and
ADSP-2136x.
xviADSP-219x DSP Instruction Set Reference
Blackfin® (ADSP-BFxxx) Processors
The name Blackfin refers to a family of 16-bit, embedded processors.
VisualDSP++ currently supports the following Blackfin families:
ADSP-BF53x and ADSP-BF56x.
ADSP-21xx Processors
The ADSP-21xx processors are high-performance 16-bit DSPs for communications, instrumentation, industrial/control, voice/speech, medical
and military applications. The family includes the ADSP-218x,
ADSP-219x, and mixed-signal products (ADSP-21990, ADSP-21991,
and ADSP-21992).
Product Information
You can obtain product information from the Analog Devices Web site,
from the product CD-ROM, or from the printed publications (manuals).
Preface
Analog Devices is online at www.analog.com. Our Web site provides information 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. MyAnalog.com provides access to books, application notes, data
sheets, code examples, and more.
ADSP-219x DSP Instruction Set Referencexvii
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.
Online documentation comprises the VisualDSP++ Help system, software
tools manuals, hardware tools manuals, processor manuals, the 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. For easy
printing, supplementary .PDF files of most manuals are also provided.
ADSP-219x DSP Instruction Set Referencexix
Product Information
Each documentation file type is described as follows.
File Description
.CHMHelp system files and manuals in Help format
.HTM or
.HTML
.PDFVisualDSP++ and processor manuals in Portable Documentation Format (PDF).
Dinkum Abridged C++ library and FlexLM network license manager software documentation. Viewing and printing the
Internet Explorer 4.0 (or higher).
Viewing and printing the .PDF files requires a PDF reader, such as Adobe Acrobat
Reader (4.0 or higher).
.HTML files requires a browser, such as
If documentation is not installed on your system as part of the software
installation, you can add it from the VisualDSP++ CD-ROM at any time
by running the Tools installation. 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 (toolbar buttons, menu commands, and windows).
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 documentation from Windows.
xxADSP-219x DSP Instruction Set Reference
Preface
Help system files (.
CHM) are located in the Help folder, and .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 system, to access all the other .CHM files.
•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.
•Access the .PDF files by clicking the Start button and choosing
Programs, Analog Devices, VisualDSP++, Documentation for
Printing, and the name of the book.
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.
Printed Manuals
For general questions regarding literature ordering, call the Literature
Center at 1-800-ANALOGD (1-800-262-5643) and follow the prompts.
ADSP-219x DSP Instruction Set Referencexxi
Product Information
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.
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.
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.
xxiiADSP-219x DSP Instruction Set Reference
Conventions
Text conventions used in this manual are identified and described as
follows.
ExampleDescription
Preface
Close command
(File menu)
{this | that}Alternative items in syntax descriptions appear within curly brackets and
[this | that]Optional items in syntax descriptions appear within brackets and separated
[this,…]Optional item lists in syntax descriptions appear within brackets delimited
.SECTIONCommands, directives, keywords, and feature names are in text with let-
filenameNon-keyword placeholders appear in text with italic style format.
L
a
Titles in 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).
separated by vertical bars; read the example as this or that. One or the
other is required.
by vertical bars; read the example as an optional
by commas and terminated with an ellipse; read the example as an optional
comma-separated list of this.
ter gothic font.
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.
this or that.
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 War ni ng appears instead of this
symbol.
ADSP-219x DSP Instruction Set Referencexxiii
Preface
L
Additional conventions, which apply only to specific chapters, may
appear throughout this document.
ADSP-219x DSP Instruction Set Referencexxiv
1INSTRUCTION SET SUMMARY
This chapter provides a summary of the instructions in the ADSP-219x
DSP’s instruction set. Chapters 2 through 8 describe these instructions in
more detail as follows:
•“ALU Instructions” on page 2-1
•“MAC Instructions” on page 3-1
•“Shifter Instructions” on page 4-1
•“Multifunction Instructions” on page 5-1
•“Data Move Instructions” on page 6-1
•“Program Flow Instructions” on page 7-1
•“Instruction Opcodes” on page 8-1
Also, this chapter identifies mnemonics for using DSP registers, bits, and
operating conditions. This information appears in the following
summaries:
•“Core Registers Summary” on page 1-2
•“Arithmetic Status (ASTAT) Register” on page 1-3
•“Condition Code (CCODE) Register” on page 1-5
•“Interrupt Control (ICNTL) Register” on page 1-6
•“Interrupt Mask (IMASK) Register and Interrupt Latch (IRPTL)
Register” on page 1-7
ADSP-219x DSP Instruction Set Reference1-1
Core Registers Summary
•“Mode Status (MSTAT) Register” on page 1-8
•“System Status (SSTAT) Register” on page 1-10
•“Condition Codes Summary” on page 1-11
For information on instruction reference notation, see “Conventions” on
page xxiii.
Core Registers Summary
The DSP has three categories of registers: core registers, system control
registers, and I/O registers. Table 1-1 lists and describes the DSP’s core
registers. For information about system control and I/O registers, see the
ADSP-219x/2192 DSP Hardware Reference.
Table 1-1. Core Registers
TypeRegistersFunction
ALU dataAX0, AX1, AY0, AY1,
AR, AF
Multiplier dataMX0, MX1, MY0, MY1,
MR0, MR1, MR2
Shifter dataSI, SE, SB, SR0, SR1, SR2
DAG addressI0, I1, I2, I3
I4, I5, I6, I7
M0, M1, M2, M3
M4, M5, M6, M7
L0, L1, L2, L3
L4, L5, L6, L7
16-bit data registers (X and Y) provide input
for ALU, multiplier, and shifter operations.
AR and AF are ALU result and feedback registers. MR and SR are multiplier result and feedback registers. SR also is the shifter results
register.
In this text, Dreg denotes unrestricted use of
data registers as a data register file, while “
XOP” and “YOP” denote restricted use.
The data registers (except AF, SE, and SB) serve
as a register file for unconditional, single-function instructions.
DAG1 index registers
DAG2 index registers
DAG1 modify registers
DAG2 modify registers
DAG1 length registers
DAG2 length registers
1-2ADSP-219x DSP Instruction Set Reference
Table 1-1. Core Registers (Cont’d)
TypeRegistersFunction
Instruction Set Summary
System controlB0, B1, B2, B3, B4, B5,
B6, B7, SYSCTL, CACTL
Program flowCCODE
LPSTACKA
LPSTACKP
STACKA
STACKP
InterruptICNTL
IMASK
IRPTL
StatusASTAT
MSTAT
SSTAT (read-only)
PageDMPG1
DMPG2
IJPG
IOPG
Bus exchangePXHolds eight LSBs of 24-bit memory data for
ShifterSE
SB
DAG1 base address registers (B0-3), DAG2
base address registers (B4-7), System control,
and Cache control
Software condition register
Loop PC stack A register, 16 address LSBs
Loop PC stack P register, 8 address MSBs
PC stack A register, 16 address LSBs
PC stack P register, 8 address MSBs
Interrupt control register
Interrupt mask register
Interrupt latch register
Arithmetic status flags
Mode control and status flags
System status
The DSP updates the status bits in ASTAT, indicating the status of the
most recent ALU, multiplier, or shifter operation.
ADSP-219x DSP Instruction Set Reference1-3
Arithmetic Status (ASTAT) Register
Table 1-2. ASTAT Register Bit Definitions
BitNameDescription
0AZALU result zero. Logical NOR of all bits written to the ALU result register
(AR) or ALU feedback register (AF).
0 =ALU output ≠ 0
1 =ALU output = 0
1ANALU result negative. Sign of the value written to the ALU result register
(AR) or ALU feedback register (AF).
0 =ALU output positive (+)
1 =ALU output negative (−)
2AVALU result overflow.
0 =No overflow
1 =Overflow
3ACALU result carry.
0 =No carry
1 =Carry
4AS ALU x input sign. Sign bit of the ALU x-input operand; set by the ABS
instruction only.
0 =Positive (+)
1 =Negative (−)
5AQALU quotient. Sign of the resulting quotient; set by the DIVS or DIVQ
instructions.
0 =Positive (+)
1 =Negative (−)
6MVMultiplier overflow. Records overflow/underflow condition for MR result
register.
0 =No overflow or underflow
1 =Overflow or underflow
7SSShifter input sign. Sign of the shifter input operand.
0 =Positive (+)
1 =Negative (−)
8SVShifter overflow. Records overflow/underflow condition for SR result reg-
ister.
0 =No overflow or underflow
1 =Overflow or underflow
1-4ADSP-219x DSP Instruction Set Reference
Instruction Set Summary
Condition Code (CCODE) Register
Using the CCODE register (shown in Table 1-3), conditional instructions
may base execution on a comparison of the CCODE value (user-selected) and
the SWCOND condition (DSP status). The CCODE register holds a value
between 0x0 and 0xF, which the instruction tests against when the conditional instruction uses SWCOND or NOT SWCOND. Note that the CCODE register
has a one-cycle effect latency.
Table 1-3. CCODE Register Bit Definitions
CCODESoftware Condition
ValueSWCOND (1010)NOT SWCOND (1011)
0x00PF0 pin highPF0 pin low
0x01PF1 pin highPF1 pin low
0x02PF2 pin highPF2 pin low
0x03PF3 pin highPF3 pin low
0x04PF4 pin highPF4 pin low
0x05PF5 pin highPF5 pin low
0x06PF6 pin highPF6 pin low
0x07PF7 pin highPF7 pin low
0x08ASNOT AS
0x09SVNOT SV
0x0APF8 pin highPF8 pin low
0x0BPF9 pin highPF9 pin low
0x0CPF10 pin highPF10 pin low
0x0DPF11 pin highPF11 pin low
0x0EPF12 pin highPF12 pin low
0x0FPF13 pin highPF13 pin low
ADSP-219x DSP Instruction Set Reference1-5
Interrupt Control (ICNTL) Register
Interrupt Control (ICNTL) Register
Refer to Table 1-4 for ICNTL register bit definitions.
Table 1-4. ICNTL Register Bit Definitions
BitNameDescription
0reservedwrite 0
1reservedwrite 0
2reservedwrite 0
3reservedwrite 0
4INEInterrupt nesting enable.
0 =Disabled
1 =Enabled
5GIEGlobal interrupt enable.
0 =Disabled
1 =Enabled
6reservedwrite 0
7BIASRNDMAC biased rounding mode.
0 =Disabled
1 =Enabled
8-9reservedwrite 0
10PCSTKEPC stack interrupt enable.
0 =Disabled
1 =Enabled
11EMUCNTEEmulator cycle counter interrupt enable.
0 =Disabled
1 =Enabled
12-15reservedwrite 0
1-6ADSP-219x DSP Instruction Set Reference
Instruction Set Summary
Interrupt Mask (IMASK) Register and
Interrupt Latch (IRPTL) Register
Refer to Table 1-5 for IMASK register and IRPTL register bit definitions.
Table 1-5. IMASK and IRPTL Register Bit Definitions
3STACKStack interrupt mask. Generated from any of the following stack status
states: (if PCSTKE enabled) PC stack is pushed or popped and hits
high-water mark, any stack overflows, or the status or PC stacks underflow.
4User-defined
5User-defined
6User-defined
7User-defined
8User-defined
9User-defined
10User-defined
11User-defined
12User-defined
13User-defined
14User-defined
15User-definedLowest priority
ADSP-219x DSP Instruction Set Reference1-7
Mode Status (MSTAT) Register
Mode Status (MSTAT) Register
Refer to Table 1-6 for MSTAT register bit definitions.
Table 1-6. MSTAT Register Bit Definitions
BitNameDescription
0SEC_REG
or
SR
1BIT_REV
or
BR
2AV_LATCH
or
OL
Secondary data registers enable.
Determines which set of data registers is currently active.
0 =Deactivate secondary set of data registers (default).
Primary register set (set that is active at reset) enabled and used for
normal operation; secondary register set disabled.
1 =Activate secondary set of data registers.
Secondary register set enabled and used for alternate DSP context
(for example, interrupt servicing); primary register set disabled, current contents preserved.
For details, see “Switching Contexts” on page 7-16.
Bit-reversed addressing enable.
Enables and disables bit-reversed addressing on DAG1 index registers only.
0 =Disable
1 =Enable
For details, see “Bit-Reversed Addressing” on page 6-16.
ALU overflow latch mode enable. Determines how the ALU overflow flag,
0 =Disable
Once an ALU overflow occurs and sets the
ister, the
subsequent ALU operation that does not generate an overflow.
1 =Enable
Once an ALU overflow occurs and sets the
ister, the
For details on clearing the
SETBIT, CLRBIT, TGLBIT” on page 2-19 and “Register-to-Register Move” on page 6-22.
AV, gets cleared.
AV bit in the ASTAT reg-
AV bit remains set until explicitly cleared or is cleared by a
AV bit in the ASTAT reg-
AV bit remains set until the application explicitly clears it.
AV bit, see “Bit Manipulation: TSTBIT,
1-8ADSP-219x DSP Instruction Set Reference
Instruction Set Summary
Table 1-6. MSTAT Register Bit Definitions (Cont’d)
BitNameDescription
3AR_SAT
or
AS
4M_MODE
or
MM
5TIMER
or
TI
ALU saturation mode enable.
For signed values, determines whether ALU AR results that overflowed or underflowed are saturated or not. Enables or disables saturation for all subsequent ALU operations.
0 =Disable
AR results remain unsaturated and return as is.
1 =Enable
AR results saturated according to the state of the AV and AC status
flags in ASTAT.
AVACAR register
00ALU output
01ALU output
100x7FFF
110x8000
Only the results written to the AR register are saturated. If results
are written to the AF register, wraparound occurs, but the AV and
AC flags reflect the saturated result.
MAC result mode.
Determines the numeric format of multiplier operands. For all
MAC operations, the multiplier adjusts the format of the result
according to the selected mode.
0 =Fractional mode, 1.15 format.
1 =Integer mode, 16.0 format.
For details, see “Data Format Options” on page 3-3.
Timer enable.
Starts and stops the timer counter.
0 =Stops the timer count.
1 =Starts the timer count.
For details on timer operation, see the ADSP-219x/2192 DSP Hardware Reference.
6SEC_DAG
or
SD
Secondary DAG registers enable.
Determines which set of DAG address registers is currently active.
0 =Primary registers.
1 =Secondary registers.
For details, see “Secondary DAG Registers” on page 6-7 and
“Switching Contexts” on page 7-16.
ADSP-219x DSP Instruction Set Reference1-9
System Status (SSTAT) Register
System Status (SSTAT) Register
Refer to Table 1-7 for SSTAT register bit definitions.
Table 1-7. SSTAT Register Bit Definitions
BitNameDescription
0PCSTKEMPTY
or
PCE
1PCSTKFULL
or
PCF
2PCSTKLVL
or
PCL
3Reserved
4LPSTKEMPTY
or
LSE
5LPSTKFULL
or
LSF
6STSSTKEMPTY
or
SSE
7STKOVERFLOW
or
SOV
PC stack empty.
0 =PC stack contains at least one pushed address.
1 =PC stack is empty.
PC stack full.
0 =PC stack contains at least one empty location.
1 =PC stack is full.
PC stack level.
0 =PC stack contains between 3 and 28 pushed addresses.
1 =PC stack is at or above the high-water mark (28 pushed
addresses), or it is at or below the low-water mark (3 pushed
addresses).
Loop stack empty.
0 =Loop stack contains at least one pushed address.
1 =Loop stack is empty.
Loop stack full.
0 =Loop stack contains at least one empty location.
1 =Loop stack is full.
Status stack empty.
0 =Status stack contains at least one pushed status.
1 =Status stack is empty.
Stacks overflowed.
0 =Overflow/underflow has not occurred.
1 =At least one of the stacks (PC, loop, counter, status) has
overflowed, or the PC or status stack has underflowed.
This bit cleared only on reset. Loop stack underflow is not
detected because it occurs only as a result of a POP LOOP
operation.
1-10ADSP-219x DSP Instruction Set Reference
Instruction Set Summary
Condition Codes Summary
Refer to Table 1-8 for CCODE register bit definitions.
Table 1-8. Condition Codes Summary
CodeConditionDescription
0000EQEqual to zero (= 0).
0001NENot equal to zero (≠ 0).
0010GTGreater than zero (> 0).
0011LELess than or equal to zero (≤ 0).
0100LTLess than zero (< 0).
0101GEGreater than or equal to zero (≥ 0).
0110AVALU overflow.
0111NOT AVNot ALU overflow.
1000ACALU carry.
1001NOT ACNot ALU carry.
1010SWCONDSWCOND (based on CCODE register condition). (For
CCODE details, see Table 1-3 on page 1-5.)
1011NOT SWCONDNot SWCOND (based on CCODE register condition). (For
CCODE details, see Table 1-3 on page 1-5.)
1100MVMAC overflow.
1101NOT MVNot MAC overflow.
1110NOT CECounter not expired.
1111TRUEAlways true.
ADSP-219x DSP Instruction Set Reference1-11
Instruction Summary
Instruction Summary
The conventions for ADSP-219x instruction syntax descriptions appear in
Table 1-9. Other parts of the instruction syntax and opcode information
also appear in this section. The following sections provide summaries of
the DSP’s instruction set:
•“ALU Instructions” on page 1-14
•“Multiplier Instructions” on page 1-15
•“Shifter Instructions” on page 1-16
•“Data Move Instructions” on page 1-16
•“Program Flow Instructions” on page 1-18
•“Multifunction Instructions” on page 1-19
For a list of instructions by types, see “Instruction Opcodes” on page 8-1.
Table 1-9. Instruction Set Notation
NotationMeaning
UPPERCASEExplicit syntax—assembler keyword (notation only; the assembler is
case-insensitive and lowercase is the preferred programming convention)
;Semicolon—instruction terminator
,Comma—separates multiple optional items within vertical bars
or separates parallel operations in multifunction instructions
The instruction set provides ALU instructions for performing arithmetic
and logical operations on 16- and 24-bit fixed-point data. This chapter
includes the following sections:
•“ALU Instruction Conventions” on page 2-1
•“ALU Instruction Reference” on page 2-4
ALU Instruction Conventions
This chapter describes each of the arithmetic instructions and the following related topics:
•“Input Registers” on page 2-1
•“Output Registers” on page 2-2
•“Constants” on page 2-2
•“ALU Mode Control” on page 2-3
•“ALU Status Flags” on page 2-4
Input Registers
The unconditional single-function ALU instructions described in this
chapter can use any of the DSP’s 16 data registers (
ands. The conditional single-function ALU instructions are restricted to
ADSP-219x DSP Instruction Set Reference2-1
Dregs) as input oper-
the use of specific data registers for both the x and y input operands.
When restrictions apply,
XOP refers to the x operand, and YOP refers to the
y operand.
Output Registers
ALU instructions use one of two output registers:
AF—ALU Feedback register. Results are directly available for the y
•
input only in the next conditional ALU operation.
•
AR—ALU Result register. Results output to this register are imme-
diately available as the x-input only in the next conditional ALU,
MAC, or shifter operation or as either x or y input into the next
unconditional ALU, MAC, or shifter operation.
Constants
You can use constants in any of the following single-function ALU
instructions:
•Add operations
•Subtract operations
•Bitwise logic operations
•PASS operation
Valid constants are those formed from powers of two that fall within the
range of −
32768 (0x8000) and +32767 (0x7FFF). Table 2-1 lists the valid
constants.
2-2ADSP-219x DSP Instruction Set Reference
ALU Instructions
Table 2-1. Valid Constant Values
Positive (+)Negative (−)
DecimalHexadecimalDecimalHexadecimal
10x000120xFFFE
20x000230xFFFD
40x000450xFFFB
80x000890xFFF7
160x0010170xFFEF
320x0020330xFFDF
640x0040650xFFBF
1280x00801290xFF7F
2560x01002570xFEFF
5120x02005130xFDFF
10240x040010250xFBFF
20480x080020490xF7FF
40960x100040970xEFFF
81920x200081930xDFFF
163840x4000163850xBFFF
327670x7FFF327680x8000
ALU Mode Control
The MSTAT register’s AV_LATCH bit and AR_SAT bit enable and disable two
ALU modes: ALU overflow latch mode and ALU saturation mode. For
more information on these modes, see the bit descriptions in Table 1-6 on
page 1-8.
ADSP-219x DSP Instruction Set Reference2-3
ALU Status Flags
The ASTAT register’s AZ, AN, AV, AC, AS, and AQ bits record the status of ALU
operations, indicating whether the result of the operation was equal to
zero, negative, overflowed, carried, signed, or produced a quotient. For
information on these modes, see the bit descriptions in Table 1-2 on
page 1-4.
ALU Instruction Reference
ALU instructions include:
•“Add/Add with Carry” on page 2-5
•“Subtract X−Y/Subtract X−Y with Borrow” on page 2-9
•“Subtract Y−X/Subtract Y−X with Borrow” on page 2-13
•“Bitwise Logic: AND, OR, XOR” on page 2-16
•“Bit Manipulation: TSTBIT, SETBIT, CLRBIT, TGLBIT” on
page 2-19
•“Clear: PASS” on page 2-22
•“Negate: NOT” on page 2-25
•“Absolute Value: ABS” on page 2-28
•“Increment” on page 2-31
•“Decrement” on page 2-34
•“Divide Primitives: DIVS and DIVQ” on page 2-37
•“Generate ALU Status Only: NONE” on page 2-46
2-4ADSP-219x DSP Instruction Set Reference
ALU Instructions
Add/Add with Carry
AR=DREG1+DREG2;
AFDREG + C
C
[IF COND]AR=XOP+YOP;
AFYOP + C
C
constant
constant + C
Function
Adds the input operands and stores the result in the specified result
register.
If execution is based on a condition, the ALU performs the addition only
if the condition evaluates true, and it performs a
NOP operation if the con-
dition evaluates false.
Input
For the unconditional form of this instruction, use any of these data registers for the
AR ALU Result register. Results are directly available
for x input only in the next conditional ALU,
MAC, or shifter operation or as either x or y input
in the next unconditional ALU, MAC, or shifter
operation.
AF ALU Feedback register. Results are directly avail-
able for the y input only in the next conditional
ALU operation.
Status Flags
Affected Flags–set or cleared by the operationUnaffected Flags
AZ, AN, AV, ACAS, AQ, MV, SS, SV
For information on these status bits in the ASTAT register, see Table 1-2 on page 1-4.
Details
Omitting the condition forces unconditional execution of the instruction.
This instruction uses binary addition to add the x and y operands and the
carry bit, when specified.
The operands are stored in data registers, or, in the case of constants, supplied in the instruction. For the conditional form of this instruction, data
registers are restricted.
2-6ADSP-219x DSP Instruction Set Reference
ALU Instructions
You can substitute a constant for the y operand. For a list of valid constants, see Table 2-1 on page 2-3. To add a negative constant, use either of
the following syntaxes:
AR = AR - 4097;
AR = AR + 0xEFFF;
Carry Option
IF AC AR = AX0 + AY0 + C;
The above instruction executes if a carry occurs in the previous instruction. The AR register receives the result of the addition of the x and y
operands and the carry-in bit from the previous instruction. Otherwise, it
performs a NOP operation.
The form XOP + C is a special case of XOP + YOP + C in which YOP = 0.
You cannot add or subtract constants in multifunction instructions, and
you are restricted to the use of particular data registers in multifunction
and conditional instructions.
Examples
AR = AX0 + AX1;/* add Dregs */
AF = MY0 + MR1 + C;/* add Dregs and carry */
AR = SR0 + C;/* add Dreg and carry */
IF EQ AR = AX0 + AY0;/* add X and Y ops */
IF LT AF = AX1 + AF + C;/* add Xop, Yop, and carry */
IF AV AR = SR0 + C;/* add Xop and carry */
IF AC AR = AR + 1024;/* add Xop and constant */
IF SWCOND AR = MR0 + 1024 + C;/* add Xop, constant, */
/* and carry */
ADSP-219x DSP Instruction Set Reference2-7
Add/Add with Carry
See Also
•“Type 9: Compute” on page 8-23
•“Condition Code (CCODE) Register” on page 1-5
•“Mode Status (MSTAT) Register” on page 1-8
2-8ADSP-219x DSP Instruction Set Reference
ALU Instructions
Subtract X−Y/Subtract X−Y with Borrow
AR=DREG1−DREG2;
AFDREG + C - 1
+ C - 1
[IF COND]AR=XOP−YOP;
AFYOP + C - 1
+ C - 1
constant
constant + C - 1
Function
Subtracts the input operands and stores the result in the specified result
register.
If execution is based on a condition, the ALU performs the subtraction
only if the condition evaluates true, and it performs a
NOP operation if the
condition evaluates false.
Input
For the unconditional form of this instruction, use any of these data registers for the
AR ALU Result register. Results are directly available
for x input only in the next conditional ALU,
MAC, or shifter operation or as either x or y input
in the next unconditional ALU, MAC, or shifter
operation.
AF ALU Feedback register. Results are directly avail-
able for the y input only in the next conditional
ALU operation.
Status Flags
Affected Flags–set or cleared by the operation Unaffected Flags
AZ, AN, AV, ACAS, AQ, MV, SS, SV
For information on these status bits in the ASTAT register, see Table 1-2 on page 1-4.
Details
Omitting the condition forces unconditional execution of the instruction.
This instruction uses binary addition to subtract the y operand from the x
operand and then adds the carry bit minus one, when specified. The quantity C−1 effectively implements a borrow capability for multiprecision
subtractions.
2-10ADSP-219x DSP Instruction Set Reference
ALU Instructions
The operands are stored in data registers, or, in the case of constants, supplied in the instruction. For the conditional form of this instruction, data
registers are restricted.
You can substitute a constant for the y operand. For a list of valid constants, see Table 2-1 on page 2-3. To subtract a negative constant, use
either of the following syntaxes:
AR = AX0 - 4097;
AR = AX0 + 0xEFFF;
Using the borrow option for example:
IF AC AR = AX0 - AY0 + C - 1;
The instruction executes if a carry occurs in the previous instruction. The
AR register receives the result of the subtraction of the x and y operands
and the carry bit from the previous instruction. Otherwise, it performs a
NOP operation.
The form XOP + C - 1 is a special case of XOP - YOP + C - 1 in which
YOP = 0.
You cannot add or subtract constants in multifunction instructions, and
you are restricted to the use of particular data registers in multifunction
and conditional instructions.
Examples
AR = AX0 - AX1;/* sub Dregs */
AF = MY0 - MR1 + C - 1;/* sub Dregs and carry */
AR = SR0 + C - 1;/* sub Dreg and carry */
IF EQ AR = AX0 - AY0;/* sub X and Y ops */
IF LT AF = AX1 - AF + C - 1;/* sub Xop, Yop, and carry */
IF AV AR = SR0 + C - 1;/* sub Xop and carry */
ADSP-219x DSP Instruction Set Reference2-11
Subtract X−Y/Subtract X−Y with Borrow
IF AC AR = AR - 1024;/* sub Xop and constant */
IF SWCOND AR = MR0 - 1024 + C - 1; /* sub Xop, const, and carry */
See Also
•“Type 9: Compute” on page 8-23
•“Condition Code (CCODE) Register” on page 1-5
•“Mode Status (MSTAT) Register” on page 1-8
2-12ADSP-219x DSP Instruction Set Reference
ALU Instructions
Subtract Y−X/Subtract Y−X with Borrow
AR=DREG2-DREG1;
AFDREG1 + C -1
[IF COND]AR=YOP-XOP;
AFXOP + C -1
Function
Subtracts the input operands and stores the result in the specified result
register.
If execution is based on a condition, the ALU performs the subtraction
only if the condition evaluates true, and it performs a
NOP operation if the
condition evaluates false.
Input
For the unconditional form of this instruction, you can use any of these
data registers for the DREG inputs:
AR ALU Result register. Results are directly available
for x input only in the next conditional ALU,
MAC, or shifter operation or as either x or y input
in the next unconditional ALU, MAC, or shifter
operation.
AF ALU Feedback register. Results are directly avail-
able for the y input only in the next conditional
ALU operation.
Status Flags
Affected Flags–set or cleared by the operationUnaffected Flags
AZ, AN, AV, ACAS, AQ, MV, SS, SV
For information on these status bits in the ASTAT register, see Table 1-2 on page 1-4.
Details
Omitting the condition forces unconditional execution of the instruction.
This instruction uses binary addition to subtract the x operand from the y
operand and then adds the carry bit minus one, when specified. The quantity C - 1 effectively implements a borrow capability for multiprecision
subtractions.
The operands are stored in data registers, or, in the case of constants, supplied in the instruction. For the conditional form of this instruction, data
registers are restricted.
You can substitute a constant for the y operand. For a list of valid constants, see Table 2-1 on page 2-3. To subtract a negative constant, you use
this syntax:
AR = -4097 - AR;
AR = 0xEFFF - AR;
2-14ADSP-219x DSP Instruction Set Reference
ALU Instructions
Using the borrow option for example:
IF AC AR = AY0 - AX0 + C - 1;
The instruction executes if a carry occurs in the previous instruction. The
AR register receives the result of the subtraction of the y and x operands
and the carry bit from the previous instruction. Otherwise, it performs a
NOP operation.
The form -XOP + C - 1 is a special case of YOP - XOP + C - 1 in which
YOP = 0.
You cannot add or subtract constants in multifunction instructions, and
you are restricted to the use of particular data registers in multifunction
and conditional instructions.
Examples
AR = AY0 - AY1;/* sub Dregs */
AF = MR0 - SR1 + C -1;/* sub Dregs, add carry */
IF EQ AR = AY0 - AX1;/* sub Xop from Yop */
IF LT AF = AF - AX0 + C -1;/* sub Xop from Yop, add carry */
See Also
•“Type 9: Compute” on page 8-23
•“Condition Code (CCODE) Register” on page 1-5
•“Mode Status (MSTAT) Register” on page 1-8
ADSP-219x DSP Instruction Set Reference2-15
Bitwise Logic: AND, OR, XOR
Bitwise Logic: AND, OR, XOR
AR=DREG1ANDDREG2;
AFOR
XOR
[IF COND]AR=XOPANDYOP;
AFORconstant
XOR
Function
Performs the specified bitwise logical operation (logical
AND, inclusive OR,
or exclusive XOR) and stores the result in the specified result register.
If execution is based on a condition, the ALU performs the operation only
if the condition evaluates true, and it performs a NOP operation if the condition evaluates false.
Only the conditional form of the bitwise operations accept a constant for
the y operand.
Input
For the unconditional form of this instruction, you can use any of these
data registers for the
AR ALU Result register. Results are directly available
for x input only in the next conditional ALU,
MAC, or shifter operation or as either x or y input
in the next unconditional ALU, MAC, or shifter
operation.
AF ALU Feedback register. Results are directly avail-
able for the y input only in the next conditional
ALU operation.
Status Flags
Affected Flags–set or cleared by the operationUnaffected Flags
AZ, AN, AV (cleared), AC (cleared)AS, AQ, MV, SS, SV
For information on these status bits in the ASTAT register, see Table 1-2 on page 1-4.
Details
Omitting the condition forces unconditional execution of the instruction.
The operands are stored in data registers, or, in the case of constants, supplied in the instruction. For the conditional form of this instruction, data
registers are restricted.
You can substitute a constant for the y operand. For a list of valid constants, see Table 2-1 on page 2-3.
ADSP-219x DSP Instruction Set Reference2-17
Bitwise Logic: AND, OR, XOR
Examples
AX0 = 0xAAAA;/* load 1010 1010 1010 1010 */
AX1 = 0x5555;/* load 0101 0101 0101 0101 */
AY0 = 0xAAAA;/* load 1010 1010 1010 1010 */
AY1 = 0x5555;/* load 0101 0101 0101 0101 */
AR = AX0 AND AX1;/* AR = 0000 0000 0000 0000 */
AF = AY0 OR AY1;/* AF = 1111 1111 1111 1111 */
AR = AX0 XOR AY0;/* AR = 0000 0000 0000 0000 */
IF EQ AR = AX0 AND AY0;/* AR = 1010 1010 1010 1010 */
IF LT AF = AX1 OR AY0;/* AF = 1111 1111 1111 1111 */
IF SWCOND AR = AX0 XOR 0x1000; /* AR = 1011 1010 1010 1010 */
See Also
•“Type 9: Compute” on page 8-23
•“Condition Code (CCODE) Register” on page 1-5
•“Mode Status (MSTAT) Register” on page 1-8
2-18ADSP-219x DSP Instruction Set Reference
Bit Manipulation: TSTBIT, SETBIT, CLRBIT, TGLBIT
[IF COND]AR=TSTBITn OF XOP;
AFSETBIT
CLRBIT
TGLBIT
Function
ALU Instructions
Performs the specified bit-manipulation operation on the n bit of the
input operand and stores the result in the specified result register.
•TSTBIT Performs an AND operation with 1 in the selected bit.
•SETBIT Performs an OR operation with 1 in the selected bit.
•CLRBIT Performs an AND operation with 0 in the selected bit.
•TGLBIT Performs an XOR operation with 1 in the selected bit.
If execution is based on a condition, the ALU performs the operation only
if the condition evaluates true, and it performs a NOP operation if the condition evaluates false.
Input
For this instruction, the x operand is restricted. Valid
Xops
AX0, AX1, AR, MR0, MR1, MR2, SR0, SR1
XOP registers are:
x
ADSP-219x DSP Instruction Set Reference2-19
Bit Manipulation: TSTBIT, SETBIT, CLRBIT, TGLBIT
Output
AR ALU Result register. Results are directly available
for x input only in the next conditional ALU,
MAC, or shifter operation or as either x or y input
in the next unconditional ALU, MAC, or shifter
operation.
AF ALU Feedback register. Results are directly avail-
able for the y input only in the next conditional
ALU operation.
Status Flags
Affected Flags–set or cleared by the operationUnaffected Flags
AZ, AN, AV (cleared), AC (cleared)AS, AQ, MV, SS, SV
For information on these status bits in the ASTAT register, see Table 1-2 on page 1-4.
Details
Omitting the condition forces unconditional execution of the instruction.
The operand is stored in an XOP data register and the instruction specifies
the particular bit within it. You cannot perform any of the bit manipulation operations in multifunction instructions.
Examples
AX0 = 0xAAAA;/* load 1010 1010 1010 1010 */
AR = TSTBIT 0x5 OF AX0;/* AR = 0x0020 */
AF = SETBIT 0x4 OF AX0;/* AF = 0xAABA */
AF = CLRBIT 0xB OF AX0;/* AF = 0xA2AA */
AR = TGLBIT 0xF OF AX0;/* AR = 0x2AAA */
2-20ADSP-219x DSP Instruction Set Reference
See Also
ALU Instructions
•“Type 9: Compute” on page 8-23
•“Condition Code (CCODE) Register” on page 1-5
•“Mode Status (MSTAT) Register” on page 1-8
ADSP-219x DSP Instruction Set Reference2-21
Clear: PASS
Clear: PASS
AR=PASSDREG;
AFconstant
AR=[PASS] 0 ;
AF
[IF COND]AR=PASSXOP;
AFYOP
constant
Function
Passes the source operand unmodified through the ALU unit and stores it
in the specified result register. Unlike the move register instruction, this
instruction affects the
ASTAT status flags.
The PASS 0 operation (the PASS keyword is optional) provides another way
to clear the AR register.
If execution is based on a condition, the ALU performs the operation only
if the condition evaluates true, and it performs a NOP operation if the condition evaluates false.
Input
For the unconditional form of this instruction, use any of these data registers for the DREG inputs:
AR ALU Result register. Results are directly available
for x input only in the next conditional ALU,
MAC, or shifter operation or as either x or y input
in the next unconditional ALU, MAC, or shifter
operation.
AF ALU Feedback register. Results are directly avail-
able for the y input only in the next conditional
ALU operation.
Status Flags
Affected Flags–set or cleared by the operationUnaffected Flags
AZ, AN, AV (cleared), AC (cleared)AS, AQ, MV, SS, SV
For information on these status bits in the ASTAT register, see Table 1-2 on page 1-4.
Details
Omitting the condition forces unconditional execution of the instruction.
The operands are stored in the data registers, or, in the case of constants,
supplied in the instruction. For the conditional form of this instruction,
data registers are restricted.
You can substitute a constant for the y operand. For a list of valid constants, see Table 2-1 on page 2-3.
ADSP-219x DSP Instruction Set Reference2-23
Clear: PASS
Combine
PASS 0 with memory read and write operations in multifunction
instructions to clear the AR register; for example:
AR = PASS 0, AX0 = DM(I0, M0), AY0 = PM(I4, M4);
You cannot use DREG data registers or the PASS constant operation (other
than -1, 0, or 1) in multifunction instructions.
Some forms of the PASS instruction result from the special case of the y
input operand is 0, and other forms of the PASS instruction result from the
special case of YOP is a constant.
Examples
AR = PASS SI;/* pass Dreg to AR */
AF = PASS 1024;/* pass constant to AF */
AR = PASS 0;/* pass 0 to AR */
AF = PASS 0;/* pass 0 to AF */
IF EQ AR = PASS AX1;/* pass Xop to AR */
IF LT AF = PASS AY0;/* pass Yop to AR */
IF AV AR = PASS 1024;/* pass constant to AR */
See Also
•“Type 9: Compute” on page 8-23
•“Condition Code (CCODE) Register” on page 1-5
•“Mode Status (MSTAT) Register” on page 1-8
2-24ADSP-219x DSP Instruction Set Reference
ALU Instructions
Negate: NOT
AR=NOTDREG;
AF
[IF COND]AR=NOTXOP;
AFYOP
Function
Performs a logical ones complement operation on the source operand and
stores it in the specified result register.
If execution is based on a condition, the ALU performs the operation only
if the condition evaluates true, and it performs a
NOP operation if the con-
dition evaluates false.
Input
For the unconditional form of this instruction, use any of these data registers for the DREG inputs:
AR ALU Result register. Results are directly available
for x input only in the next conditional ALU,
MAC, or shifter operation or as either x or y input
in the next unconditional ALU, MAC, or shifter
operation.
AF ALU Feedback register. Results are directly avail-
able for the y input only in the next conditional
ALU operation.
Status Flags
Affected Flags–set or cleared by the operationUnaffected Flags
AZ, AN, AV (cleared), AC (cleared)AS, AQ, MV, SS, SV
For information on these status bits in the ASTAT register, see Table 1-2 on page 1-4.
Details
Omitting the condition forces unconditional execution of the instruction.
The operands are stored in the data registers. For the conditional form of
this instruction or in multifunction instructions, data registers are
restricted.
Examples
AR = NOT SI;/* put neg SI in AR*/
AF = NOT AY0;/* put neg AY0 in AF */
IF EQ AR = NOT AX0;/* put neg AX0 in AR */
IF LT AF = NOT AF;/* put neg AF in AR*/
2-26ADSP-219x DSP Instruction Set Reference
See Also
ALU Instructions
•“Type 9: Compute” on page 8-23
•“Condition Code (CCODE) Register” on page 1-5
•“Mode Status (MSTAT) Register” on page 1-8
ADSP-219x DSP Instruction Set Reference2-27
Absolute Value: ABS
Absolute Value: ABS
AR=ABSDREG;
AF
[IF COND]AR=ABSXOP;
AF
Function
Performs a logical ones complement operation on the x input operand and
stores it in the specified result register.
If execution is based on a condition, the ALU performs the operation only
if the condition evaluates true, and it performs a
NOP operation if the con-
dition evaluates false.
Input
For the unconditional form of this instruction, use any of these data registers for the DREG inputs:
For this instruction, the x operand is restricted. Valid
Xops
AX0, AX1, AR, MR0, MR1, MR2, SR0, SR1
XOP registers are:
2-28ADSP-219x DSP Instruction Set Reference
ALU Instructions
Output
AR ALU Result register. Results are directly available
for x input only in the next conditional ALU,
MAC, or shifter operation or as either x or y input
in the next unconditional ALU, MAC, or shifter
operation.
AF ALU Feedback register. Results are directly avail-
able for the y input only in the next conditional
ALU operation.
Status Flags
Affected Flags–set or cleared by the operationUnaffected Flags
AZ, AN (set if xop is 0x8000), AV (set if xop is
0x8000), AC (cleared), AS (set if xop is negative)
For information on these status bits in the ASTAT register, see Table 1-2 on page 1-4.
AQ, MV, SS, SV
Details
Omitting the condition forces unconditional execution of the instruction.
The operands are stored in the data registers. For the conditional form of
this instruction or in multifunction instructions, data registers are
restricted.
Examples
AR = ABS SI;/* put abs SI in AR*/
AF = ABS AY0;/* put abs AY0 in AF */
IF EQ AR = ABS AX0;/* put abs AX0 in AR */
IF LT AF = ABS SR0;/* put abs SR0 in AF */
ADSP-219x DSP Instruction Set Reference2-29
Absolute Value: ABS
See Also
•“Type 9: Compute” on page 8-23
•“Condition Code (CCODE) Register” on page 1-5
•“Mode Status (MSTAT) Register” on page 1-8
2-30ADSP-219x DSP Instruction Set Reference
Increment
AR=DREG + 1 ;
AF
[IF COND]AR=YOP + 1 ;
AF
Function
ALU Instructions
Increments the y input operand by adding
0x0001 to it and stores the value
in the specified result register.
If execution is based on a condition, the ALU performs the operation only
if the condition evaluates true, and it performs a NOP operation if the condition evaluates false.
Input
For the unconditional form of this instruction, use any of these data registers for the DREG inputs:
For this instruction, the y operand is restricted. Valid
Yop s
AY0, AY1, AF, 0
IOP registers are:
ADSP-219x DSP Instruction Set Reference2-31
Increment
Output
AR ALU Result register. Results are directly available
for x input only in the next conditional ALU,
MAC, or shifter operation or as either x or y input
in the next unconditional ALU, MAC, or shifter
operation.
AF ALU Feedback register. Results are directly avail-
able for the y input only in the next conditional
ALU operation.
Status Flags
Affected Flags–set or cleared by the operationUnaffected Flags
AZ, AN, AV, ACAS, AQ, MV, SS, SV
For information on these status bits in the ASTAT register, see Table 1-2 on page 1-4.
Details
Omitting the condition forces unconditional execution of the instruction.
The operands are stored in the data registers. For the conditional form of
this instruction or in multifunction instructions, data registers are
restricted.
Examples
AR = SI + 1;/* inc SI and place in AR*/
AF = AX0 + 1;/* inc AX0 and place in AF */
IF EQ AR = AY0 + 1;/* inc AY0 and place in AR */
IF LT AF = AF + 1;/* inc AF and place in AF*/
2-32ADSP-219x DSP Instruction Set Reference
See Also
ALU Instructions
•“Type 9: Compute” on page 8-23
•“Condition Code (CCODE) Register” on page 1-5
•“Mode Status (MSTAT) Register” on page 1-8
ADSP-219x DSP Instruction Set Reference2-33
Decrement
Decrement
AR=DREG - 1 ;
AF
[IF COND]AR=YOP - 1 ;
AF
Function
Decrements the y operand by subtracting
0x0001 from it and stores the
value in the specified result register.
If execution is based on a condition, the ALU performs the operation only
if the condition evaluates true, and it performs a NOP operation if the condition evaluates false.
Input
For the unconditional form of this instruction, use any of these data registers for the DREG inputs:
For this instruction, the y operand is restricted. Valid
Yop s
AY0, AY1, AF, 0
IOP registers are:
2-34ADSP-219x DSP Instruction Set Reference
ALU Instructions
Output
AR ALU Result register. Results are directly available
for x input only in the next conditional ALU,
MAC, or shifter operation or as either x or y input
in the next unconditional ALU, MAC, or shifter
operation.
AF ALU Feedback register. Results are directly avail-
able for the y input only in the next conditional
ALU operation.
Status Flags
Affected Flags–set or cleared by the operationUnaffected Flags
AZ, AN, AV, ACAS, AQ, MV, SS, SV
For information on these status bits in the ASTAT register, see Table 1-2 on page 1-4.
Details
Omitting the condition forces unconditional execution of the instruction.
The operands are stored in the data registers. For the conditional form of
this instruction or in multifunction instructions, data registers are
restricted.
Examples
AR = SI - 1;/* dec SI and place in AR*/
AF = AX0 - 1;/* dec AX0 and place in AF */
IF EQ AR = AY0 - 1;/* dec AY0 and place in AR */
IF LT AF = AF - 1;/* dec AF and place in AF*/
ADSP-219x DSP Instruction Set Reference2-35
Decrement
See Also
•“Type 9: Compute” on page 8-23
•“Condition Code (CCODE) Register” on page 1-5
•“Mode Status (MSTAT) Register” on page 1-8
2-36ADSP-219x DSP Instruction Set Reference
ALU Instructions
Divide Primitives: DIVS and DIVQ
DIVS YOP, XOP ;
DIVQ XOP ;
Function
The
DIVS primitive calculates the quotient’s sign bit. The DIVQ primitive
calculates the quotient one bit at a time.
Use both divide primitives to implement a YOP÷XOP operation on signed
(twos complement) numbers. Use the DIVQ primitive alone to implement a
YOP ÷ XOP operation on unsigned (ones complement) numbers.
The divide primitives perform a single-precision divide on a 32-bit
numerator by a 16-bit denominator to yield a 16-bit, truncated quotient.
Single-precision divides executes in sixteen cycles. Higher precision
divides require more cycles since you must execute the DIVQ primitive for
each bit in the quotient.
The divide operation requires four data registers—one 16-bit data register
to hold the 16-bit divisor, two 16-bit data registers to hold the 32-bit dividend, and one 16-bit data register to hold the resulting 16-bit quotient.
Input
Use signed (twos complement) or unsigned (ones complement) operands,
but both operands must be the same number format. The resulting quotient has the same number format as its operands.
XOP Divisor. Both divide primitives take an x input
operand. Valid
Xops
AX0, AX1, AR, MR0, MR1, MR2, SR0, SR1
XOP registers are:
ADSP-219x DSP Instruction Set Reference2-37
Divide Primitives: DIVS and DIVQ
YOP Dividend. Only the DIVS primitive, which calcu-
lates the sign bit of the quotient, takes a y input
operand. The y input operand must contain the
upper 16 bits of the dividend. Valid YOP registers
are:
Yop s
AY1, AF
For unsigned division (DIVQ only), AF must be used as the y input operand
to hold the upper 16 bits of the dividend. Before issuing the DIVQ primitive, you must explicitly load the lower 16 bits of the dividend into either
AY0.
For signed division (DIVS and DIVQ), use AY1 or AF as they input operand
to contain the upper 16 bits of the dividend. Before issuing either of the
divide primitives, you must explicitly load the lower 16 bits of the dividend into AY0.
Output
AY0 ALU divide result register. At the end of the divide
operation, the AYO data register contains the
quotient.
AF ALU Feedback register. At the end of the divide
operation,
AF contains the final remainder. This
value is incorrect. If you need to use it, correct it
before doing so.
2-38ADSP-219x DSP Instruction Set Reference
ALU Instructions
Status Flags
Affected Flags–set or cleared by the operationUnaffected Flags
AQAZ, AN, AV, AC, AS, MV, SS, SV
For information on these status bits in the ASTAT register, see Table 1-2 on page 1-4.
Details
These instructions implement
DIVS and DIVQ. A single-precision divide, with a 32-bit numerator and a
YOP ÷ XOP. There are two divide primitives,
16-bit denominator, yielding a 16-bit quotient, executes in 16 cycles.
Higher precision divides are also possible.
The division can be signed or unsigned, but both the numerator and
denominator must be the same, signed or unsigned. Set up the divide by
sorting the upper half of the numerator in any permissible YOP (AY1 or AF),
the lower half of the numerator in AY0, and the denominator in any permissible XOP. The divide operation is then executed with the divide
primitives, DIVS and DIVQ. Repeated execution of DIVQ implements a
non-restoring conditional add-subtract division algorithm. At the conclusion of the divide operation, the quotient will be in AY0.
To implement a signed divide, first execute the DIVS instruction once,
which computes the sign of the quotient. Then execute the DIVQ instruction as many times as there are bits remaining in the quotient (for
example, for a signed, single-precision divide, execute
DIVS once and DIVQ
15 times).
To implement an unsigned divide, place the upper half of the numerator
in
AF and then set the AQ bit to zero by manually clearing it in the Arith-
metic Status register (
ASTAT). This indicates that the sign of the quotient is
positive. Then execute the DIVQ instruction as many times as there are bits
in the quotient (for example, for an unsigned single-precision divide, execute DIVQ 16 times).
ADSP-219x DSP Instruction Set Reference2-39
Divide Primitives: DIVS and DIVQ
The quotient bit generated on each execution of
DIVS and DIVQ is the AQ
bit, which is written to the ASTAT register at the end of each cycle. The
final remainder produced by this algorithm (left over in the AF register) is
not valid and must be corrected if it is needed.
Examples
For example code and code walk-through, see “Division Applications” on
page 2-45.
See Also
•For more information, see “Division Theory” on page 2-40, “Divi-
sion Exceptions” on page 2-43, and “Division Applications” on
page 2-45.
•“Type 23: Divide primitive, DIVQ” on page 8-43
•“Type 24: Divide primitive, DIVS” on page 8-44
•“Condition Code (CCODE) Register” on page 1-5
•“Mode Status (MSTAT) Register” on page 1-8
Division Theory
The ADSP-219x DSP family’s instruction set contains two instructions
for implementing a non-restoring divide algorithm. These instructions
take as their operands’ twos complement or unsigned numbers, and in 16
cycles produce a truncated quotient of 16 bits. For most numbers and
applications, these primitives produce the correct results. However, certain situations produce results that are off by one LSB. This section
describes these situations, and presents alternatives for producing the correct results.
2-40ADSP-219x DSP Instruction Set Reference
ALU Instructions
Computing a 16-bit fixed-point quotient from two numbers is accomplished by 16 executions of the
DIVQ instruction for unsigned numbers.
Signed division uses the DIVS instruction first, followed by fifteen DIVQ
instructions. Regardless of the division you perform, both input operands
must be of the same type (signed or unsigned) and produce a result of the
same type.
These two instructions are used to implement a conditional add/subtract,
non-restoring division algorithm. As its name implies, the algorithm functions by adding or subtracting the divisor to/from the dividend. The
decision as to which operation to perform is based on the previously generated quotient bit. Each add/subtract operation produces a new partial
remainder, which is used in the next step.
The term “non-restoring” refers to the fact that the final remainder is not
correct. With a restoring algorithm, it is possible, at any step, to take the
partial quotient, multiply it by the divisor, and add the partial remainder
to recreate the dividend. With this non-restoring algorithm, it is necessary
to add two times the divisor to the partial remainder if the previously
determined quotient bit is zero. It is easier to compute the remainder
using the multiplier than in the ALU.
Signed Division
Signed division is accomplished by first storing the 16-bit divisor in an
XOP register (AX0, AX1, AR, MR2, MR1, MR0, SR1, or SR0). The 32-bit dividend
must be stored in two separate 16-bit registers. The lower 16-bits must be
stored in
AY0, and the upper 16-bits can be in AY1 or AF.
The DIVS primitive is executed once, with the proper operands (such as
DIVS AY1, AX0) to compute the sign of the quotient. The sign bit of the
quotient is determined by XORing (exclusive ORing) the sign bits of each
operand. The entire 32-bit dividend is shifted left one bit. The lower 15
bits of the dividend with the recently determined sign bit appended are
stored in
the lower word appended is stored in
AY0, and the lower 15 bits of the upper word, with the MSB of
AF.
ADSP-219x DSP Instruction Set Reference2-41
Divide Primitives: DIVS and DIVQ
To complete the division, 15
DIVQ instructions are executed. Operation of
the DIVQ primitive is described below.
Unsigned Division
Computing an unsigned division is done like signed division, except the
first instruction is not a DIVS, but another DIVQ. The upper word of the
dividend must be stored in AF, and the AQ bit of the ASTAT register must be
set to zero before the divide begins.
The DIVQ instruction uses the AQ bit of the ASTAT register to determine
whether the dividend should be added to or subtracted from the partial
remainder stored in AF and AY0. If AQ is zero, a subtraction occurs. A new
value for AQ is determined by XORing the MSB of the divisor with the
MSB of the dividend. The 32-bit dividend is shifted left one bit, and the
inverted value of AQ is moved into the LSB.
Output Formats
As in multiplication, the format of a division result is based on the format
of the input operands. The division logic is designed to work most efficiently with fully fractional numbers—those most commonly used in
fixed-point DSP applications. A signed, fully fractional number uses one
bit before the binary point as the sign, with 15 bits (or 31 bits in double
precision) to the right, for magnitude.
If the dividend is in M.N format (M bits before the binary point, N bits
after), and the divisor is in O.P format, the quotient’s format will be
(M-O+1).(N-P-1). Dividing a 1.31 number by a 1.15 number produces a
quotient whose format is (1-1+1).(31-15-1) or 1.15.
Before dividing two numbers, ensure that the format of the quotient will
be valid. For example, if you attempt to divide a 32.0 number by a 1.15
number, the result attempts to be in (32-1+1).(0-15-1) or 32.-16 format.
This cannot be represented in a 16-bit register.
2-42ADSP-219x DSP Instruction Set Reference
ALU Instructions
In addition to proper output format, ensure that a divide overflow does
not occur. Even when a division of two numbers produces a valid output
format, it is possible that the number will overflow and be unable to fit
within the constraints of the output. For example, to divide a 16.16 number by a 1.15 number, the output format would be (16-1+1).(16-15-1) or
16.0, which is valid. Assume you have 16384 (0x4000) as the dividend
and .25 (0x2000) as the divisor, the quotient is 65536, which does not fit
in 16.0 format. This operation overflows, producing an erroneous result.
Check input operands before division to ensure that an overflow will not
result. If the magnitude of the upper 16 bits of the dividend is larger than
the magnitude of the divisor, an overflow will result.
Integer Division
One special case of division that deserves special mention is integer division. There may be some cases where you wish to divide two integers, and
produce an integer result. It can be seen that an integer-integer division
will produce an invalid output format of (32-16+1).(0-0-1), or 17.-1.
To generate an integer quotient, shift the dividend to the left one bit,
placing it in 31.1 format. The output format for this division will be
(31-16+1).(1-0-1), or 16.0. Ensure that no significant bits are lost during
the left shift, or an invalid result will be generated.
Division Exceptions
Although the divide primitives for the ADSP-219x DSP family work correctly in most instances, there are two cases where an invalid or inaccurate
result can be generated. The first case involves signed division by a negative number. If you attempt to use a negative number as the divisor, the
quotient generated may be one LSB less than the correct result. The other
case concerns unsigned division by a divisor greater than 0x7FFF. If the
divisor in an unsigned division exceeds
0x7FFF, an invalid quotient will be
generated.
ADSP-219x DSP Instruction Set Reference2-43
Divide Primitives: DIVS and DIVQ
Negative Divisor Error
The quotient produced by a divide with a negative divisor will generally
be one LSB less than the correct result. The divide algorithm implemented
on the ADSP-219x DSP family, which does not correctly compensate for
the twos complement format of a negative number, causes this inaccuracy.
There is one case where this discrepancy does not occur. When the result
of the division operation equals
0x8000, it is correctly represented, and is
not one LSB off.
There are several ways to correct for this error. Before changing any code,
however, determine if a one-LSB error in your quotient is a significant
problem. In some cases, the LSB is small enough to be insignificant.
If exact results are necessary, two solutions are possible. One is to avoid
division by negative numbers. If your divisor is negative, take its absolute
value and invert the sign of the quotient after division. This will produce
the correct result.
Another technique is to check the result by multiplying the quotient by
the divisor. Compare this value with the dividend; if they are off by more
than the value of the divisor, increase the quotient by one.
Unsigned Division Error
Unsigned divisions can produce erroneous results if the divisor is greater
0x7FFF. Do not attempt to divide two unsigned numbers when the
than
divisor has a one in the MSB. If you must perform such a division, shift
both operands right one bit. This will maintain the correct orientation of
operands.
Shifting both operands may result in a one LSB error in the quotient. This
can be solved by multiplying the quotient by the original (not shifted)
divisor. Subtract this value from the original dividend to calculate the
error. If the error is greater than the divisor, add one to the quotient; if it
is negative, subtract one from the quotient.
2-44ADSP-219x DSP Instruction Set Reference
ALU Instructions
Division Applications
Each of the problems mentioned in “Division Exceptions” on page 2-43
can be compensated in software. Listing 2-1 shows the program section
divides. This code can be used to divide two signed or unsigned numbers
to produce the correct quotient, or an error condition.
Listing 2-1. Division Routine Using DIVS and DIVQ
/* signed division algorithm with fix for negative division error
inputs:
AYy1 - 16 MSB of numerator
AYy0 - 16 LSB of numerator
AR- denominator
outputs:
AR- corrected quotient
intermediate (scratch) registers:
MR0, AF
signed_div:
MR0 = AR, AR = ABS AR;
/*save copy of denominator, make it positive*/
DIVS AY1, AR;DIVQ AR;
DIVQ AR;DIVQ AR;
DIVQ AR;DIVQ AR;
DIVQ AR;DIVQ AR;
DIVQ AR;DIVQ AR;
DIVQ AR;DIVQ AR;
DIVQ AR;DIVQ AR;
DIVQ AR;DIVQ AR;
AR = AY0, AF = PASS MR0;/*get sign of denominator*/
IF LT AR = -AY0;/*if neg, invert output, place in ar*/
RTS;
*/
ADSP-219x DSP Instruction Set Reference2-45
Generate ALU Status Only: NONE
Generate ALU Status Only: NONE
NONE = <ALU Operation> ;
Function
Performs the indicated unconditional ALU operation but does not load
the results into the AR or AF result registers. Generates ALU status flags
only. Use this instruction to set ALU status without disturbing the contents of the AR and AF result registers.
Input
XOP Limits the registers for the x input operand. Valid
XOP registers are:
Xops
AX0, AX1, AR, MR0, MR1, MR2, SR0, SR1
YOP Limits the registers for the x input operand. Valid
YOP registers are:
Yop s
AY0, AY1, AF, 0
Output
None. Generates ALU status flags only.
2-46ADSP-219x DSP Instruction Set Reference
ALU Instructions
Status Flags
Affected Flags–set or cleared by the operationUnaffected Flags
Depending on ALU operation—AZ, AN, AV, AC, AS, AQMV, SS, SV
For information on these status bits in the ASTAT register, see Table 1-2 on page 1-4.
Details
Use any unconditional ALU operation (except ALU operations that use
constants) to generate ALU status flags.
The following ALU operations may not appear in the
•NONE = <XOP> + <constant>; For other add operations, see
“Add/Add with Carry” on page 2-5.
•NONE = <XOP> - <constant>;
-or-
NONE = -<XOP> + <constant>;
For other subtract operations, see “Subtract X−Y/Subtract X−Y
with Borrow” on page 2-9.
•NONE = PASS <constant>; with any constant other than -1, 0, or 1.
For other clear operations, see “Clear: PASS” on page 2-22.
NONE = <XOP> <AND|OR|XOR> <constant>;
•
For other logical operations, see “Bitwise Logic: AND, OR, XOR”
on page 2-16.
•
NONE with TSTBIT, SETBIT, CLRBIT, or TGLBIT.
NONE with the division primitives (DIVS or DIVQ).
•
Examples
NONE= syntax:
NONE = AX0 - AF;/* generate status from sub */
NONE = AX1 + AF;/* generate status from add */
ADSP-219x DSP Instruction Set Reference2-47
Generate ALU Status Only: NONE
NONE = AF - AX1;/* generate status from sub */
NONE = PASS 0;/* generate status from pass */
NONE = AX1 OR AY0;/* generate status from or */
See Also
•“Type 8: Compute | Dreg1 «··· Dreg2” on page 8-22
•“Condition Code (CCODE) Register” on page 1-5
•“Mode Status (MSTAT) Register” on page 1-8
2-48ADSP-219x DSP Instruction Set Reference
3MAC INSTRUCTIONS
The instruction set provides MAC instructions that perform high-speed
multiplication and multiply with cumulative add/subtract operations.
MAC instructions include:
•“Multiply” on page 3-8
•“Multiply with Cumulative Add” on page 3-11
•“Multiply with Cumulative Subtract” on page 3-14
•“MAC Clear” on page 3-17
•“MAC Round/Transfer” on page 3-19
•“MAC Saturate” on page 3-21
•“Generate MAC Status Only: NONE” on page 3-24
This chapter describes the individual MAC instructions and these related
topics:
•“MAC Input Registers” on page 3-2
•“MAC Output Registers” on page 3-2
•“Data Format Options” on page 3-3
•“Status Flags” on page 3-7
For details on condition codes and data input and output registers, see
“Condition Codes” on page 8-8 and “Core Register Codes” on page 8-11.
ADSP-219x DSP Instruction Set Reference3-1
MAC Input Registers
Multiply Instruction Conventions
MAC Input Registers
All unconditional, single-function multiply and multiply with accumulative add or subtract instructions can use any
and y input operands (for details, see “Core Register Codes” on
page 8-11). A program can use, for example, the ALU registers for the
multiplication or shifter operations, without issuing a separate data move
instruction. This capability simplifies register allocation in algorithm coding. For example, using the DSP’s dual accumulator:
SR = SR + MX0 * MY0 (SS);
In multifunction operations, you can use only certain registers for the
x-input operand (AR, MX0, MX1, MR0, MR1, MR2, SR0, SR1) and the y-input
operand (MY0, MY1, SR1, 0).
DREG data register for the x
All conditional MAC instructions must use the restricted XOP and YOP data
registers for the x and y input operands, or an XOP register for the x-input
and 0 for the y-input.
MAC Output Registers
All MAC instructions can use the multiplier MR output registers or the
shifter
Availability of the shifter SR output registers for multiplier operations provides dual-accumulator functionality.
When MR is the result register, results are directly available from MR0, MR1,
or MR2 as the x-input operand into the very next multiplier operation.
MR = MR + AX0 * AX0 (SS);
3-2ADSP-219x DSP Instruction Set Reference
SR output registers to receive the result of a multiplier operation.
MAC Instructions
When
SR is the result register, the 16-bit value in SR1 (bits 31:16 of the
40-bit result) is directly available as the y-input operand into the very next
multiplier operation. This functionality is most useful when shifting the
results of a multiply/accumulate operation since it decreases the number
of required data moves.
SR = SR + AX0 * AY0 (SS);
SR = SR + SR1 * AY0 (SS);
Data Format Options
Multiplier operations require the instruction to specify the data format of
the input operands (signed or unsigned) or specify that the multiplier
rounds (RND) the product of two signed operands.
All data format options, except the round (RND) option, which affects the
product stored in the result register, specify the format of both input operands in x/y order. The data format options are:
•(RND) Round value in result register.
When overflow occurs, rounds the product to the most significant
twenty-four bits—SR2/SR1 or MR2/MR1 represent the rounded 24-bit
result. Otherwise, rounds bits 31:16 to16 bits—MR1 or SR1 contain
the rounded 16-bit result.
With (
RND) selected, the multiplier considers both input operands
signed (twos complement). If the DSP is in fractional mode
(MSTAT:M_MODE=0), the multiplier rounds the result after adjusting
for fractional data format. For details, see “Numeric Format
Modes” on page 3-6.
The DSP provides two rounding modes (biased and unbiased) to
support a variety of application algorithms. For details, see
“Rounding Modes” on page 3-4.
ADSP-219x DSP Instruction Set Reference3-3
Rounding Modes
•
(SS) Both input operands are signed numbers. Signed numbers
are in twos complement format.
Use this option to multiply two signed single-precision numbers or
to multiply the upper portions of two signed multi-precision
numbers.
•(SU) X-input operand is signed; y-input operand is unsigned.
Use this option to multiply a signed single-precision number by an
unsigned single-precision number.
•(US) X-input operand is unsigned; y-input operand is signed.
Use this option to multiply an unsigned single-precision number
by a signed single-precision number.
•(UU) Both input operands are unsigned numbers. Unsigned numbers are in ones complement format.
Use this option to multiply two unsigned single-precision numbers
or to multiply the lower portions of two signed multi-precision
numbers.
Rounding Modes
Rounding operates on the boundary between bits 15 and 16 of the 40-bit
adder result. The multiplier directs the rounded output to the MR or the
SR result registers.
ADSP-219x DSPs provide two modes for rounding. The rounding algorithm is the same for both modes, but the final results can differ when the
product equals the midway value (MR0 = 0x8000).
3-4ADSP-219x DSP Instruction Set Reference
MAC Instructions
In both methods, the multiplier adds
1 to the value of bit 15 in the adder
chain. But when MR0 = 0x8000, the multiplier forces bit 16 in the result
output to 0. Although applied on every rounding operation, the result of
this algorithm is evident only when MR0 = 0x8000 in the adder chain.
The rounding mode determines the final result. The BIASRND bit in the
•Unbiased rounding. Default mode. Rounds up only when MR1/SR1
set to an odd value; otherwise, rounds down. Yields a zero
large-sample bias.
•Biased rounding. Always rounds up when MR0/SR0 is set to 0x8000.
Table 3-1 shows the results of rounding for both modes.
Table 3-1. MR result values
MR Value before RNDBiased RND ResultUnbiased RND Result
00-0000-800000-0001-000000-0000-0000
00-0001-800000-0002-000000-0002-0000
00-0000-800100-0001-000100-0001-0001
00-0001-800100-0002-000100-0002-0001
00-0000-7FFF00-0000-FFFF00-0000-FFFF
00-0001-7FFF00-0001-FFFF00-0001- FFFF
Unbiased rounding, which is preferred for most algorithms, yields a zero
large-sample bias, assuming uniformly distributed values. Biased rounding
supports efficient implementation of bit-specified algorithms, such as
GSM speech compression routines.
ADSP-219x DSP Instruction Set Reference3-5
Numeric Format Modes
Numeric Format Modes
The multiplier can operate on integers or fractions. The M_MODE bit in the
MSTAT register selects the mode. M_MODE = 0 selects fractional mode, and
M_MODE = 1 selects integer mode.
The mode determines whether the multiplier shifts the product before
adding or subtracting it from the result register.
Integer mode 16.0 integer format.
The LSB of the 32-bit product is aligned with the
LSB of MR0/SR0.
In multiply and accumulate operations, the multiplier sign-extends the 32-bit product (8 bits) and
then adds or subtracts that value from the result
register to form the new 40-bit result.
The multiplier sets the MV/SV overflow bit when the
result falls outside the range of −1 to +1−231.
Fractional mode 1.15 fraction format.
Fractions range from −1 to +1−215. The MSB of the
product is aligned with the MSB of MR1/SR1.
MR1-0/SR1-0 hold a 32-bit fraction (1.31 format) in
the range of −
1 to +1−2
the eight sign-extended bits. In total, the
31
, and MR2/SR2 contains
MR/SR reg-
isters contains a fraction in 9.31 format.
In multiply and accumulate operations, the multiplier adjusts the format of the 32-bit product before
adding or subtracting it from the result register. To
do so, the multiplier sign-extends the product
3-6ADSP-219x DSP Instruction Set Reference
MAC Instructions
(seven bits), shifts it one bit to the left, and then
adds or subtracts that value from the result register
to form the new 40-bit result.
The multiplier sets the
MV/SV overflow bit when the
result falls outside the range of −1 to +1−231.
Status Flags
Two status flags in the ASTAT register record the status of multiplier operations. MV = 1 records an overflow or underflow state when MR is the
specified result register, and SV = 1 records an overflow or underflow state
when SR is the specified result register.
ADSP-219x DSP Instruction Set Reference3-7
Multiply
Multiply
MR=DREG1*DREG2(RND) ;
SRSS
[IF COND]MR=XOP*YOP(RND) ;
SRXOPSS
SU
US
UU
SU
US
UU
Function
Multiplies the input operands and stores the result in the specified result
register. Optionally, inputs may be signed or unsigned, and output may be
rounded. For more information on input and output options, see “Data
Format Options” on page 3-3.
If execution is based on a condition, the multiplier performs the multiplication only if the condition evaluates true, and it performs a
NOP operation
if the condition evaluates false. Omitting the condition forces unconditional execution of the instruction.
3-8ADSP-219x DSP Instruction Set Reference
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.