8x Is PDF
8x Is PDF
8x Is PDF
Part Number
82-002000-01
Analog Devices, Inc.
a
Digital Signal Processor Division
One Technology Way
Norwood, Mass. 02062-9106
Copyright Information
©1996–2001 Analog Devices, Inc., ALL RIGHTS RESERVED. This
document may not be reproduced in any form without prior, express writ-
ten consent from Analog Devices, Inc.
Printed in the USA.
Disclaimer
Analog Devices, Inc. reserves the right to change this product without
prior notice. Information furnished by Analog Devices is believed to be
accurate and reliable. However, no responsibility is assumed by Analog
Devices for its use; nor for any infringement of patents or other rights of
third parties which may result from its use. No license is granted by impli-
cation or otherwise under the patent rights of Analog Devices, Inc.
CONTENTS
INTRODUCTION
Purpose ......................................................................................... 1-1
Audience ...................................................................................... 1-1
Contents Overview ....................................................................... 1-2
Development Tools ....................................................................... 1-3
For More Information About Analog Products ............................... 1-6
For Technical or Customer Support ............................................. 1-7
What’s New in This Manual .......................................................... 1-7
Related Documents ....................................................................... 1-8
Conventions ................................................................................. 1-9
PROGRAMMING MODEL
Overview ...................................................................................... 2-1
Data Address Generators .......................................................... 2-4
Program Sequencer .................................................................. 2-5
Computational Units ............................................................... 2-7
Bus Exchange .......................................................................... 2-8
SOFTWARE EXAMPLES
Overview ...................................................................................... 3-1
System Development Process ....................................................... 3-3
Single-Precision Fir Transversal Filter ............................................ 3-6
Cascaded Biquad IIR Filter ........................................................... 3-8
Sine Approximation .................................................................... 3-10
Single-Precision Matrix Multiply ................................................. 3-12
Radix-2 Decimation-in-Time FFT .............................................. 3-14
Main Module ........................................................................ 3-14
DIT FFT Subroutine ............................................................ 3-16
Bit-Reverse Subroutine .......................................................... 3-21
Block Floating-Point Scaling Subroutine ................................ 3-22
INSTRUCTION SET
Quick List Of Instructions ............................................................ 4-1
ALU Instructions ..................................................................... 4-1
MAC Instructions ................................................................... 4-2
Shifter Instructions .................................................................. 4-2
Move Instructions ................................................................... 4-3
Program Flow Instructions ....................................................... 4-3
MISC Instructions .................................................................. 4-4
Multifunction Instructions ...................................................... 4-4
Overview ...................................................................................... 4-5
Multifunction Instructions ............................................................ 4-7
ALU/MAC with Data and Program Memory Read ................... 4-7
Data and Program Memory Read ............................................. 4-8
Computation with Memory Read ............................................ 4-9
Computation With Memory Write .......................................... 4-9
Computation with Data Register Move .................................. 4-10
ALU, MAC & Shifter Instructions ............................................... 4-14
ALU Group ........................................................................... 4-14
MAC Group .......................................................................... 4-17
Shifter Group ........................................................................ 4-19
MOVE: Read and Write Instructions ........................................... 4-21
Program Flow Control ................................................................ 4-23
Miscellaneous Instructions .......................................................... 4-26
Extra Cycle Conditions ............................................................... 4-28
INSTRUCTION CODING
Overview ..................................................................................... A-1
Opcode Definitions ..................................................................... A-2
Opcode Mnemonics ................................................................... A-10
INDEX
Purpose
The ADSP-218x DSP Instruction Set Reference provides assembly syntax
information for the ADSP-218x Digital Signal Processor (DSP). The syn-
tax descriptions for instructions that execute within the DSP’s processor
core include processing elements, program sequencer, and data address
generators. For architecture and design information on the DSP, see the
ADSP-218x DSP Hardware Reference.
Audience
DSP system designers and programmers who are familiar with signal pro-
cessing concepts are the primary audience for this manual. This manual
assumes that the audience has a working knowledge of microcomputer
technology and DSP-related mathematics.
DSP system designers and programmers who are unfamiliar with signal
processing can use this manual, but should supplement this manual with
other texts, describing DSP techniques.
All readers, particularly programmers, should refer to the DSP’s develop-
ment tools documentation for software development information. For
additional suggested reading, see the section “For More Information
About Analog Products” on page 1-6.
Contents Overview
The Instruction Set Reference is a four chapter book that describes the
instructions syntax for the ADSP-218x DSP.
Chapter one provides introductory information including contacts at Ana-
log Devices, an overview of the development tools, related documentation
and conventions.
Chapter two describes the computational units of the ADSP-218x DSP
and provides a programming example with discussion.
Chapter three describes the process to create executable programs for the
ADSP-218x DSP. It provides several software examples that can be used
to create programs.
Chapter four presents information organized by the type of instruction.
Instruction types relate to the machine language opcode for the instruc-
tion. On this DSP, the opcodes categorize the instructions by the portions
of the DSP architecture that execute the instructions.
Each 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 its opcode. The instructions are also referred to by type,
ranging from 1 to 31. These types correspond to the opcodes that
ADSP-218x DSPs recognize, but are for reference only and have no bear-
ing on programming.
Some instructions have more than one syntactical form; for example,
instruction “Multiply” on page 4-75 has many distinct forms.
Many instructions can be conditional. These instructions are prefaced by
IF cond;for example:
IF EQ MR = MX0 * MY0 (SS);
Development Tools
The ADSP-218x is supported by VisualDSP++®, an easy-to-use program-
ming environment, comprised of an Integrated Development
Environment (IDE) and Debugger. VisualDSP lets you manage projects
from start to finish from within a single, integrated interface. Because the
project development and debug environments are integrated, you can
move easily between editing, building, and debugging activities.
take full advantage of the DSP architecture, including shared memory and
memory overlays. Software Development tools include C Compiler, C
Runtime Library, DSP and Math Libraries, Assembler, Linker, Loader,
Simulator, and Splitter.
C Compiler & Assembler. The C Compiler generates efficient code that is
optimized for both code density and execution time. The C Compiler
allows you to include Assembly language statements inline. Because of
this, you can program in C and still use Assembly for time-critical loops.
You can also use pretested Math, DSP, and C Runtime Library routines to
help shorten your time to market. The ADSP-218x Family Assembly lan-
guage is based on an algebraic syntax that is easy to learn, program, and
debug. The add instruction, for example, is written in the same manner as
the actual equation using registers for variables (for example, AR = AX0 +
AY0;).
Linker & Loader. The Linker provides flexible system definition through
Linker Description Files (.LDF). In a single LDF, you can define different
types of executables for a single or multiprocessor system. The Linker
resolves symbols over multiple executables, maximizes memory use, and
easily shares common code among multiple processors. The Loader sup-
ports creation of a 16-bit host port and 8-bit PROM boot images. Along
with the Linker, the Loader allows a variety of system configurations with
smaller code and faster boot time.
Simulator. The Simulator is a cycle-accurate, instruction-level simulator
that allows you to simulate your application in real time.
Emulator. The EZ-ICE serial emulator system provides state-of-the-art
emulation for the ADSP-218x family of DSPs using a controlled environ-
ment for observing, debugging, and testing activities in a target system.
The key features of the ADSP-218x EZ-ICE include a shielded enclosure
with the reset switch, a high speed RS-232 serial port interface, and sup-
port for 2.5, 3.3 and 5.0V DSPs. The EZ-ICE connects directly to the
target processor via the emulation interface port. It’s ease of use, full
speed emulation, and shield board will ensure that your design process
runs smoothly.
3rd-Party Extensible. The VisualDSP environment enables third-party
companies to add value using Analog Devices’ published set of Applica-
tion Programming Interfaces (API). Third party products including
runtime operating systems, emulators, high-level language compilers, mul-
tiprocessor hardware can interface seamlessly with VisualDSP thereby
simplifying the tools integration task. VisualDSP follows the COM API
format. Two API tools, Target Wizard and API Tester, are also available
for use with the API set. These tools help speed the time-to-market for
vendor products. Target Wizard builds the programming shell based on
API features the vendor requires. The API tester exercises the individual
features independently of VisualDSP. Third parties can use a subset of
these APIs that meets their application needs. The interfaces are fully sup-
ported and backward compatible.
Further details and ordering information are available in the VisualDSP
Development Tools data sheet. This data sheet can be requested from any
Analog Devices sales office or distributor.
Related Documents
For more information about Analog Devices DSPs and development
products, see the following documents:
• ADSP-218x DSP Hardware Reference
• Getting Started Guide for VisualDSP & ADSP-218x Family DSPs
• VisualDSP User's Guide for ADSP-218x Family DSPs
• C Compiler & Library Manual for ADSP-218x Family DSPs
• Assembler Manual for ADSP-218x Family DSPs
• Linker & Utilities Manual for ADSP-218x Family DSPs
All the manuals are included in the software distribution CD-ROM. To
access these manuals, use the Help Topics command in the VisualDSP
environment’s Help menu and select the Online Manuals book. From this
Help topic, you can open any of the manuals, which are in Adobe Acrobat
PDF format.
Conventions
Throughout this manual you will find tables summarizing the syntax of
the instruction groups. Table 1-1 identifies the notation conventions that
apply to all chapters. Note that additional conventions, which apply only
to specific chapters, may appear throughout this manual.
Notation Meaning
// single line comment // or /* */ indicate comments or remarks that explain program code,
/* multi line comment */ but that the assembler ignores. For more details, see the Assembler
Manual for ADSP-218x Family DSPs.
<reg> Refers to any accessible register; see the table “Processor Reg-
isters: reg and dreg” on page 4-22.
Notation Meaning
<dreg> Refers to any data register; see the table “Processor Registers:
reg and dreg” on page 4-22.
Overview
From a programming standpoint, the ADSP-218x processors consist of
three computational units (ALU, MAC and Shifter), two data address
generators, and a program sequencer, plus on-chip peripherals and mem-
ory that vary with each processor. Almost all operations using these
architectural components require one or more registers to store data, to
keep track of values such as pointers, or to specify operating modes.
Internal registers hold data, addresses, control information or status infor-
mation. For example, AX0 stores an ALU operand (data); I4 stores a
DAG2 pointer (address); ASTAT contains status flags from arithmetic oper-
ations; fields in the wait state register control the number of wait states for
different zones of external memory.
There are two types of accesses for registers. The first type of access is
made to dedicated registers such as MX0 and IMASK. These registers can be
read and written explicitly in assembly language. For example:
MX0=1234;
IMASK=0xF;
clears the Wait State Control Register, which is mapped to data memory
location 0x3FFE:
AX0=0;
DM(0x3FFE)=AX0;
The ADSP-218x registers are shown in Figure 2-1. The registers are
grouped by function: data address generators (DAGs), program sequencer,
computational units (ALU, MAC, and shifter), bus exchange (PX), mem-
ory interface, timer, SPORTs, host interface, and DMA interface.
Processor Core
DATA ADDRESS GENERATORS
DAG1 DAG2
(DM addressing only) (DM and PM addressing)
Bit-reverse capability Indirect branch capability TIMER MEMORY INTERFACE
SR1 SR0
Program Sequencer
Registers associated with the program sequencer control subroutines,
loops, and interrupts. They also indicate status and select modes of
operation.
Interrupts
The ICNTL register controls interrupt nesting and external interrupt sensi-
tivity. The IFC register which is 16 bits wide lets you force and clear
interrupts in software. The IMASK register which is 10 bits wide masks (dis-
ables) individual interrupts. ADSP-218x processors support 12
interrupts, two of which (reset, powerdown) are non-maskable.
The ADSP-2181 supports a global interrupt enable instruction (ENA INTS)
and interrupt disable instruction (DIS INTS). Executing the disable inter-
rupt instruction causes all interrupts to be masked without changing the
contents of the IMASK register. Disabling interrupts does not affect serial
port autobuffering, which will operate normally whether or not interrupts
are enabled. The disable interrupt instruction masks all user interrupts
including the powerdown interrupt. The interrupt enable instruction
allows all unmasked interrupts to be serviced again.
Loop Counts
The CNTR register stores the count value for the currently executing loop.
The count stack allows the nesting of count-based loops to four levels. A
write to CNTR pushes the current value onto the count stack before writing
the new value. The following example pushes the current value of CNTR on
the count stack and then loads CNTR with 10.
CNTR=10;
OWRCNTR is a special syntax with which you can overwrite the count value
for the current loop without pushing CNTR on the count stack.
" OWRCNTR cannot be read (i.e. used as a source register), and must not
be written in the last instruction of a DO UNTIL loop.
Stacks
The program sequencer contains four stacks that allow loop, subroutine
and interrupt nesting.
The PC stack is 14 bits wide and 16 locations deep. It stores return
addresses for subroutines and interrupt service routines, and top-of-loop
addresses for loops. PC stack handling is automatic for subroutine calls
and interrupt handling. In addition, the PC stack can be manually pushed
or popped using the PC Stack Control instructions TOPPCSTACK=reg and
reg=TOPPCSTACK.
The loop stack is 18 bits wide, 14 bits for the end-of-loop address and 4
bits for the termination condition code. The loop stack is four locations
deep. It is automatically pushed during the execution of a DO UNTIL
instruction. It is popped automatically during a loop exit if the loop was
nested. The loop stack may be manually popped with the POP LOOP
instruction.
The status stack, which is automatically pushed when the processor ser-
vices an interrupt, accommodates the interrupt mask (IMASK), mode status
(MSTAT) and arithmetic status (ASTAT) registers. The depth and width of
the status stack varies with each processor, since each of the processors has
a different numbers of interrupts. The status stack is automatically popped
when the return from interrupt (RTI) instruction is executed. The status
stack can be pushed and popped manually with the PUSH STS and POP STS
instructions.
The count stack is 14 bits wide and holds counter (CNTR) values for nested
counter-based loops. This stack is pushed automatically with the current
CNTR value when there is a write to CNTR. The counter stack may be manu-
ally popped with the POP CNTR instruction.
Computational Units
The registers in the computational units store data. The ALU and MAC
require two inputs for most operations. The AX0, AX1, MX0, and MX1 regis-
ters store X inputs, and the AY0, AY1, MY0, and MY1 registers store Y inputs.
The AR and AF registers store ALU results; AF can be fed back to the ALU Y
input, whereas AR can provide the X input of any computational unit.
Likewise, the MR0, MR1, MR2, and MF register store MAC results and can be
fed back for other computations. The 16-bit MR0 and MR1 registers together
with the 8-bit MR2 register can store a 40-bit multiply/accumulate result.
The shifter can receive input from the ALU or MAC, from its own result
registers, or from a dedicated shifter input (SI) register. It can store a
32-bit result in the SR0 and SR1 registers. The SB register stores the block
Bus Exchange
The PX register is an 8-bit register that allows data transfers between the
16-bit DMD bus and the 24-bit PMD bus. In a transfer between program
memory and a 16-bit register, PX provides or receives the lower eight bits
implicitly.
Timer
The TPERIOD, TCOUNT, and TSCALE hold the timer period, count, and scale
factor values, respectively. These registers are memory-mapped at loca-
tions 0x3FFD, 0x3FFC, and 0x3FFB respectively.
Serial Ports
SPORT0 and SPORT1 each have receive ( RX), transmit (TX) and control
registers. The control registers are memory-mapped registers at locations
0x3FEF through 0x3FFA in data memory. SPORT0 also has registers for
controlling its multichannel functions. Each SPORT control register con-
tains bits that control frame synchronization, companding, word length
and, in SPORT0, multichannel options. The SCLKDIV register for each
SPORT determines the frequency of the internally generated serial clock,
and the RFSDIV register determines the frequency of the internally gener-
ated receive frame sync signal for each SPORT. The autobuffer registers
control autobuffering in each SPORT.
Programming a SPORT consists of writing to its control register and,
depending on the modes selected, writing to its SCLKDIV and/or RFSDIV
registers as well. The following example code programs SPORT0 for 8-bit
µ-law companding with normal framing and an internally generated serial
clock. RFSDIV is set to 255 for 256 SCLK cycles between RFS assertions.
SCLKDIV is set to 2, resulting in an SCLK frequency that is 1/6 of the CLKIN
frequency.
SI=0xB27;
SI=2;
SI=255;
ADSP-2188N
ADSP-2189 N
ADSP-2185M ADSP-2185N
ADSP-2186M ADSP-2186N
ADSP-2188M ADSP-2187N
ADSP-2189M ADSP-2188N
ADSP-2189N
Other memory-mapped registers control the IDMA port and byte mem-
ory DMA (BDMA) port for booting and runtime operations. These
registers can be used in many ways that includes selecting the byte mem-
ory page, operating in data packing mode, or forcing the boot from
software.
Program Example
Listing 2-1 presents an example of an FIR filter program written for the
ADSP-2181 followed by a discussion of each part of the program. The
program can also be executed on any other ADSP-218x processor, with
minor modifications. This FIR filter program demonstrates much of the
conceptual power of the ADSP-218x family architecture and instruction
set.
A #include <def2181.h>
#define taps 15
#define taps_less_one 14
B .section/dm dm_data;
.var/circ data_buffer[taps]; /* dm data buffer */
.section/pm pm_data;
.var/circ/init24 coefficient[taps] = "coeff.dat";
C .section/pm Interrupts;
start:
jump main; rti; rti; rti; /* 0x0000: ~Reset vector */
rti; rti; rti; rti; /* 0x0004: ~IRQ2 */
rti; rti; rti; rti; ‘ /* 0x0008: ~IRQL1 */
rti; rti; rti; rti; /* 0x000c: ~IRQL0 */
rti; rti; rti; rti; /* 0x0010: SPORT0 Transmit */
jump fir_start; rti; rti; rti; /* 0x0014: SPORT0 Receive */
rti; rti; rti; rti; /* 0x0018: ~IRQE */
rti; rti; rti; rti; /* 0x001c: BDMA */
rti; rti; rti; rti; /* 0x0020: SPORT1 Transmit or ~IRQ1 */
rti; rti; rti; rti; /* 0x0024: SPORT1 Receive or ~IRQ0 */
ax0 = 0;
cntr = length(data_buffer);
/* initialize loop counter */
do clear until ce;
clear: dm(i0,m0) = ax0; /* clear data buffer */
/* setup divide value for 8KHz RFS*/
E ax0 = 0x00c0;
dm(Sport0_Rfsdiv) = ax0;
/* 1.5385 MHz internal serial clock */
ax0 = 0x000c;
dm(Sport0_Sclkdiv) = ax0;
ax0 = 0x69b7;
dm(Sport0_Ctrl_Reg) = ax0;
mainloop:
fir_start:
si = rx0; /* read from sport0 */
dm(i0,m0) = si; /* transfer data to buffer */
mr = 0, my0 = pm(i4,m4), mx0 = dm(i0,m0);
/* setup multiplier for loop */
output value. The subroutine checks for overflow and saturates the output
value to the appropriate full scale. It then writes the result to the transmit
section of SPORT0 and returns.
The subroutine begins by reading a new sample from SPORT0’s receive
data register, RX0, into the SI register. The choice of SI is of no particular
significance. Then, the data is written into the data buffer. Because of the
automatic circular buffer addressing, the new data overwrites the oldest
sample. The N-most recent samples are always in the buffer.
The third instruction of the routine, MR=0, MY0=PM(I4,M4),
MX0=DM(I0,M0), clears the multiplier result register (MR) and fetches the
first two operands. This instruction accesses both program and data mem-
ory but still executes in a single cycle because of the processor’s
architecture. The counter register (CNTR) directs the loop to be performed
taps-1 times.
The convolution label identifies the loop itself, consisting of only two
instructions, one instruction setting up the loop (DO UNTIL) and one
instruction nested in the loop. The MAC instruction multiplies and accu-
mulates the previous set of operands while fetching the next ones from
each memory. This instruction also accesses both memories.
The final result is written back to the SPORT0 transmit data register TX0
to be sent to the communicating device.
pmovlay = 5;
main:
. . .
pmovlay = 4; /* switch to PM overlay #4 */
call Ovl4Function; /* call overlay function */
pmovlay = 5; /* return from overlay #4 & goto overlay #5 */
call Ovl5Function; /* call overlay function */
. . .
Whenever the interrupt service routine is located within the fixed program
memory region, no special context saving of the overlay registers is
required. However, if you would like to place the ISR within an overlay
page, some additional instructions are needed to facilitate the saving or
restoring of the PMOVLAY and DMOVLAY registers. The interrupt vector table
features only four instruction locations per interrupt. Listing 2-2 is an
example of a four instruction implementation that restores the PMOVLAY
register after an interrupt.
Interrupt Vector:
ax0 = PMOVLAY; /* save PMOVLAY value into ax0 */
Toppcstack = ax0; /* push PMOVLAY value onto PC stack */
Jump My_ISR; /* jump to interrupt subroutine */
Rti; /* placeholder in vector table (4 locations total) */
My_ISR:
... /* ISR code goes here */
jump I_Handler;/* use instead of rti to restore PMOVLAY reg */
If the interrupt service routine also accesses alternate data memory overlay
pages, the DMOVLAY register must be saved and restored like the PMOVLAY
register. Listing 2-4 is an example of a DMOVLAY register restoration.
Interrupt Vector:
jump I_Handler; /* jump to interrupt
handler */
rti; /* unreachable instructions */
rti; /* used as placeholders to */
rti; /* occupy all 4 locations of the vector */
My_ISR:
. . . /* isr code goes here */
rts; /* return to I_Handler instead of rti */
" Note: The fixed memory region for program memory occupies
addresses 0x0000 through 0x1fff; the program memory overlay
region occupies addresses 0x2000 through 0x3fff.
To avoid the improper execution of a loop:
• Place hardware loops either in the fixed program memory or in over-
lay pages. Do not place loops whose loop bodies cross the boundary
between program memory and an overlay page.
• Always place interrupt service routines in fixed program memory or
in non-overlay program memory.
• Avoid end-of-loop addresses in ISRs .
Overview
This chapter provides a brief summary of the development process that
you use to create executable programs for the ADSP-218x family proces-
sors. The overview is followed by software examples that you can use as a
guide when writing your own applications.
The software examples presented in this chapter are used for a variety of
DSP operations. The FIR filter and cascaded biquad IIR filter are general
filter algorithms that can be tailored to many applications. Matrix multi-
plication is used in image processing and other areas requiring vector
operations. The sine function is required for many scientific calculations.
The FFT (fast Fourier transform) has wide application in signal analysis.
Each of these examples is described in greater detail in Digital Signal Pro-
cessing Applications Using The ADSP-2100 Family, Volume1, available
from our website at www.analog.com. They are presented here to show
some aspects of typical programs.
The FFT example is a complete program, including a subroutine that per-
forms the FFT, a main calling program that initializes registers and calls
the FFT subroutine, and an auxiliary routine.
Each of the other examples is shown as a subroutine in its own module.
The module starts with a .SECTION assignment for data or code, using the
section name defined in the LDF file. The subroutine can be called from
a program in another module that declares the starting label of the subrou-
tine as an external symbol .EXTERN. This is the same label that is declared
with the .GLOBAL directive in the subroutine module. This makes the sub-
routine callable from routines defined in other .ASM files. The last
instruction in each subroutine is the RTS instruction, which returns con-
trol to the calling program.
Each module is prefaced by a comment block that provides the informa-
tion shown in Table 3-1.
Calling Parameters Register values that the calling program must set before
calling the subroutine
Linker
Step 1: Architecture Description Description File
(.LDF)
VisualDSP
Step 3: System Verification Debugger
Hardware Evaluation
EZ-Kit Lite
debugapp
Target Verification
EZ-ICE
Step 4: Software Verification Working
Code?
NO YES
ROM Production
ELFSPL21
The development process begins with the task of describing the system
and generating source code. You describe the system in the Linker
Description File (.LDF) and you generate source code in C and/or assem-
bly language.
Describing the system in the .LDF file includes providing information
about the hardware environment and memory layout. See the Linker &
Utilities Manual for ADSP-218x Family DSPs manual for details.
Generating source code requires creating code modules, which can be
written in either assembly language or C language. These modules include
y(n) ≡ ∑ h k ( n )x ( n – k )
k=0
In this equation, x(n) and y(n) represent the input to and output from the
filter at time n. The output y(n) is formed as a weighted linear combina-
tion of the current and past input values of x, x(n–k). The weights, hk(n),
are the transversal filter coefficients at time n. In the equation, x(n–k) rep-
resents the past value of the input signal “contained” in the (k+1)th tap of
the transversal filter. For example, x(n), the present value of the input sig-
nal, would correspond to the first tap, while x(n–42) would correspond to
the forty-third filter tap.
The subroutine that realizes the sum-of-products operation used in com-
puting the transversal filter is shown in Listing 3-1.
.SECTION/CODE program;
/*
* FIR Transversal Filter Subroutine
* Calling Parameters
* I0 -> Oldest input data value in delay line
* L0 = Filter length (N)
* I4 -> Beginning of filter coefficient table
* L4 = Filter length (N)
* M1,M5 = 1
* CNTR = Filter length - 1 (N-1)
* Return Values
* MR1 = Sum of products (rounded and saturated)
* I0 -> Oldest input data value in delay line
* I4 -> Beginning of filter coefficient table
*
* Altered Registers
* MX0,MY0,MR
*
* Computation Time
* N - 1 + 5 + 2 cycles
*
* All coefficients and data values are assumed to be
* in 1.15 format.
*
*/
.GLOBAL fir;
.SECTION/DATA data1;
.var number_of_biquads;
.SECTION/CODE program;
* Y(n-2), Y(n-1)
* L0 = 0
* I1 -> scaling factors for each biquad section
* L1 = 0 (in the case of a single biquad)
* L1 = number of biquad sections
* for multiple biquads)
* I4 -> scaled biquad coefficients
* L4 = 5 x [number of biquads]
* M0, M4 = 1
* M1 = -3
* M2 = 1 (in the case of multiple biquads)
* M2 = 0 (in the case of a single biquad)
* M3 = (1 - length of delay line buffer)
*
* Return Value:
* SR1 = output sample Y(n)
*
* Altered Registers:
* SE, MX0, MX1, MY0, MR, SR
*
* Computation Time (with N even):
* ADSP-218X: (8 x N/2) + 5 cycles
* ADSP-218X: (8 x N/2) + 5 + 5 cycles
*
* All coefficients and data values are assumed to
* be in 1.15 format
*
*/
.GLOBAL biquad;
Sine Approximation
The following formula approximates the sine of the input variable x (in
radians):
π
where: 0 ≤ x ≤ ---
2
The approximation is a 5th order polynomial fit, accurate for any value of
x from 0° to 90° (the first quadrant). However, because sin(–x) = –sin(x)
and sin(x) = sin(180° – x), you can infer the sine of any angle from the
sine of an angle in the first quadrant.
The routine that implements this sine approximation, accurate to within
two LSBs, is shown in Listing 3-3. This routine accepts input values in
1.15 format. The coefficients, which are initialized in data memory in
4.12 format, have been adjusted to reflect an input value scaled to the
maximum range allowed by this format. On this scale, 180° ( π radians)
equals the maximum positive value, 0x7FFF, while –180° ( π radians)
equals the maximum negative value, 0x8000.
The routine shown in Listing 3-3 first adjusts the input angle to its equiv-
alent in the first quadrant. The sine of the modified angle is calculated by
multiplying increasing powers of the angle by the appropriate coefficients.
The result is adjusted if necessary to compensate for the modifications
made to the original input value.
/*
*
* Sine Approximation
* Y = Sin(x)
*
* Calling Parameters
* AX0 = x in scaled 1.15 format
* M3 = 1
* L3 = 0
*
* Return Values
* AR = y in 1.15 format
*
* Altered Registers
* AY0,AF,AR,MY1,MX1,MF,MR,SR,I3
*
* Computation Time
* 25 cycles
*/
.SECTION/DATA data1;
.VAR sin_coeff[5] = 0x3240, 0x0053, 0xAACC, 0x08B7,
0x1CCE;
.SECTION/CODE program;
.GLOBAL sin;
MR=MR+MX1*MF (SS);
MF=AR*MF (RND); /* MF = x3, x4, x5 */
approx: MX1=DM(I3,M3); /* Get coeff. C,D,E */
MR=MR+MX1*MF (SS);
AR=PASS SR1;
IF LT AR=PASS AY0; /* Saturate if needed */
AF=PASS AX0;
IF LT AR=-AR; /* Negate output if needed */
RTS;
*
* Calling Parameters
* I1 -> Z buffer in data memory L1 = 0
* I2 -> X, stored by rows in data memory L2 = 0
* I6 -> Y, stored by rows in program memory L6 = 0
* M0 = 1 M1 = S
* M4 = 1 M5 = T
* L0,L4,L5 = 0
* SE = Appropriate scale value
* CNTR = R
*
* Return Values
* Z Buffer filled by rows
*
* Altered Registers
* I0,I1,I2,I4,I5,MR,MX0,MY0,SR
*
* Computation Time
* ((S + 8) × T + 4) × R + 2 + 2 cycles
*/
.SECTION/CODE program;
.GLOBAL spmm;
Main Module
The dit_fft_main module is shown in Listing 3-5. N is the number of
points in the FFT (in this example, N=1024) and N_div_2 is used for speci-
fying the lengths of buffers. To change the number of points in the FFT,
you change the value of these constants and the twiddle factors.
The data buffers twid_real and twid_imag in program memory hold the
twiddle factor cosine and sine values. The inplacereal, inplaceimag,
inputreal and inputimag buffers in data memory store real and imaginary
data values. Sequentially ordered input data is stored in inputreal and
inputimag. This data is scrambled and written to inplacereal and inpla-
ceimag. A four-location buffer called padding is placed at the end of
inplaceimag to allow data accesses to exceed the buffer length. This buffer
assists in debugging but is not necessary in a real system. Variables
(one-location buffers) named groups, bflys_per_group, node_space and
blk_exponent are declared last.
The real parts (cosine values) of the twiddle factors are stored in the buffer
twid_real. This buffer is initialized from the file twid_real.dat. Like-
wise, twid_imag.dat values initialize the twid_imag buffer that stores the
sine values of the twiddle factors. In an actual system, the hardware would
be set up to initialize these memory locations.
The variable called groups is initialized to N_div_2. The variables
bflys_per_group and node_space are each initialized to 2 because there
are two butterflies per group in the second stage of the FFT. The
blk_exponent variable is initialized to zero. This exponent value is
updated when the output data is scaled.
After the initializations are complete, two subroutines are called. The first
subroutine places the input sequence in bit-reversed order. The second
performs the FFT and calls the block floating-point scaling routine.
.SECTION/CODE program;
#define N 1024
#define N_div_2 512 /* For 2048 points */
.SECTION/DATA data1;
.VAR inplacereal[N];
.VAR inplaceimag[N] = "inputimag.dat";
.GLOBAL inplacereal, inplaceimag;
.SECTION/DATA data2;
.SECTION/CODE program;
.SECTION/CODE program;
/* Calling Parameters
* inplacereal=real input data in scrambled order
* inplaceimag=all zeroes (real input assumed)
* twid_real=twiddle factor cosine values
* twid_imag=twiddle factor sine values
* groups=N/2
* bflys_per_group=1
* node_space=1
*
* Return Values
* inplacereal=real FFT results, sequential order
* inplaceimag=imag. FFT results, sequential order
*
* Altered Registers
* I0,I1,I2,I3,I4,I5,L0,L1,L2,L3,L4,L5
* M0,M1,M2,M3,M4,M5
* AX0,AX1,AY0,AY1,AR,AF
* MX0,MX1,MY0,MY1,MR,SB,SE,SR,SI
*
* Altered Memory
* inplacereal, inplaceimag, groups, node_space,
* bflys_per_group, blk_exponent
*/
#define log2N 10
#define N 1024
#define nover2 512
#define nover4 256
fft_strt: CNTR=log2N - 2;
/* Initialize stage counter */
M0=0;
M1=1;
L1=0;
L2=0;
L3=0;
L4=LENGTH(twid_real);
L5=LENGTH(twid_imag);
L6=0;
SB=-2;
I0=inplacereal;
I1=inplacereal + 1;
I2=inplaceimag;
I3=inplaceimag + 1;
M2=2;
CNTR=nover2;
AX0=DM(I0,M0);
AY0=DM(I1,M0);
AY1=DM(I3,M0);
stage_loop: DM(bflys_per_group)=SR0;
/* bflys_per_group=bflys_per_group / 2 */
I0=inplacereal;
I1=inplacereal+nover2;
I2=inplaceimag;
I3=inplaceimag+nover2;
CNTR=nover2;
M2=DM(node_space);
M4=1;
I4=twid_real;
I5=twid_imag;
MY0=PM(I4,M4),MX0=DM(I1,M0); /* MY0=C,MX0=x1 */
MY1=PM(I5,M4),MX1=DM(I3,M0); /* MY1=-S,MX1=y1 */
DO bfly_lp UNTIL CE;
MR=MX0*MY1(SS),AX0=DM(I0,M0);
/* MR=x1(-S),AX0=x0 */
MR=MR+MX1*MY0(RND),AX1=DM(I2,M0);
/* MR=(y1(C)+x1(-S)),AX1=y0 */
AY1=MR1,MR=MX0*MY0(SS);
/* AY1=y1(C)+x1(-S),MR=x1(C) */
MR=MR-MX1*MY1(RND); /* MR=x1(C)-y1(-S) */
AY0=MR1,AR=AX1-AY1;
/* AY0=x1(C)-y1(-S), */
/* AR=y0-[y1(C)+x1(-S)] */
SB=EXPADJ AR,DM(I3,M1)=AR;
/* Check for bit growth, */
/* y1=y0-[y1(C)+x1(-S)] */
AR=AX0-AY0,MX1=DM(I3,M0),MY1=PM(I5,M4);
/* AR=x0-[x1(C)-y1(-S)], */
/* MX1=next y1,MY1=next (-S) */
SB=EXPADJ AR,DM(I1,M1)=AR;
/* Check for bit growth, */
/* x1=x0-[x1(C)-y1(-S)] */
AR=AX0+AY0,MX0=DM(I1,M0),MY0=PM(I4,M4);
/* AR=x0+[x1(C)-y1(-S)], */
/* MX0=next x1,MY0=next C */
SB=EXPADJ AR,DM(I0,M1)=AR;
/* Check for bit growth, */
/* x0=x0+[x1(C)-y1(-S)] */
AR=AX1+AY1; /* AR=y0+[y1(C)+x1(-S)] */
bfly_lp: SB=EXPADJ AR,DM(I2,M1)=AR;
/* Check for bit growth */
CALL bfp_adj;
RTS;
Bit-Reverse Subroutine
The bit-reversal routine, called scramble, puts the input data in
bit-reversed order so that the results will be in sequential order. This rou-
tine uses the bit-reverse capability of the ADSP-218x processors.
.SECTION/CODE program;
/* Calling Parameters
* Sequentially ordered input data in inputreal
*
* Return Values
* Scrambled input data in inplacereal
*
* Altered Registers
* I0,I4,M0,M4,AY1
*
* Altered Memory
* inplacereal
*/
#define N 1024
#define mod_value 0x0010; /* Initialize constants */
.GLOBAL scramble;
L4=0;
L0=0;
CNTR = N;
ENA BIT_REV;/* Enable bit-reversed outputs on DAG1 */
DO brev UNTIL CE;
AY1=DM(I4,M4);/* Read sequentially ordered data */
brev: DM(I0,M0)=AY1;
/* Write data in bit-reversed location */
DIS BIT_REV; /* Disable bit-reverse */
RTS; /* Return to calling program */
.SECTION/CODE program;
/* Calling Parameters
*Radix-2 DIT FFT stage results in inplacereal and inplaceimag
*
* Return Parameters
*inplacereal and inplaceimag adjusted for bit growth
*
* Altered Registers
*I0,I1,AX0,AY0,AR,MX0,MY0,MR,CNTR
*
* Altered Memory
* inplacereal, inplaceimag, blk_exponent
*/
.GLOBAL bfp_adj;
DM(blk_exponent)=AR;
RTS;
ALU Instructions
• “Add/Add with Carry” on page 4-32
• “Subtract X-Y/Subtract X-Y with Borrow” on page 4-36
• “Subtract Y-X/Subtract Y-X with Borrow” on page 4-40
• “Bitwise Logic: AND, OR, XOR” on page 4-43
• “Bit Manipulation: TSTBIT, SETBIT, CLRBIT, TGLBIT” on
page 4-46
• “Clear: PASS” on page 4-49
• “Negate” on page 4-54
• “NOT” on page 4-56
• “Absolute Value: ABS” on page 4-58
• “Increment” on page 4-61
MAC Instructions
• “Multiply” on page 4-75
• “Multiply with Cumulative Add” on page 4-79
• “Multiply with Cumulative Subtract” on page 4-83
• “Squaring” on page 4-87
• “MAC Clear” on page 4-91
• “MAC Transfer MR” on page 4-93
• “Conditional MR Saturation” on page 4-96
Shifter Instructions
• “Arithmetic Shift” on page 4-97
• “Logical Shift” on page 4-100
• “Normalize” on page 4-103
• “Derive Exponent” on page 4-106
• “Block Exponent Adjust” on page 4-110
• “Arithmetic Shift Immediate” on page 4-112
• “Logical Shift Immediate” on page 4-114
Move Instructions
• “Register Move” on page 4-116
• “Load Register Immediate” on page 4-118
• “Data Memory Read (Direct Address)” on page 4-121
• “Data Memory Read (Indirect Address)” on page 4-123
• “Program Memory Read (Indirect Address)” on page 4-125
• “Data Memory Write (Direct Address)” on page 4-127
• “Data Memory Write (Indirect Address)” on page 4-129
• “Program Memory Write (Indirect Address)” on page 4-132
• “IO Space Read/Write” on page 4-134
MISC Instructions
• “Stack Control” on page 4-155
• “Program Memory Overlay Register Update” on page 4-165
• “Data Memory Overlay Register Update” on page 4-168
• “Mode Control” on page 4-161
• “Modify Address Register” on page 4-171
• “No Operation” on page 4-173
• “Interrupt Enable and Disable” on page 4-164
Multifunction Instructions
• “Computation with Memory Read” on page 4-174
• “Computation with Register to Register Move” on page 4-180
• “Computation with Memory Write” on page 4-185
• “Data and Program Memory Read” on page 4-190
• “ALU/MAC with Data and Program Memory Read” on page 4-192
Overview
This chapter provides an overview and detailed reference for the instruc-
tion set of the ADSP-218x family of DSP microprocessors. The
instruction set is grouped into the following categories:
• Computational: ALU, MAC, Shifter
• Move
• Program Flow
• Multifunction
• Miscellaneous
The instruction set is tailored to the computation-intensive algorithms
common in DSP applications. For example, sustained single-cycle multi-
plication/accumulation operations are possible. The instruction set
provides full control of the processors’ three computational units: the
ALU, MAC and Shifter. Arithmetic instructions can process single-preci-
sion 16-bit operands directly; provisions for multiprecision operations are
available.
The high-level syntax of ADSP-218x family source code is both readable
and efficient. Unlike many assembly languages, the ADSP-218x family
instruction set uses an algebraic notation for arithmetic operations and for
data moves, resulting in highly readable source code. There is no perfor-
mance penalty for this; each program statement assembles into one 24-bit
instruction which executes in a single cycle. There are no multicycle
instructions in the instruction set. (If memory access times require, or
contention for off-chip memory occurs, overhead cycles will be required,
but all instructions can otherwise execute in a single cycle.)
In addition to JUMP and CALL, the instruction set’s control instructions
support conditional execution of most calculations and a DO UNTIL loop-
ing instruction. Return from interrupt (RTI) and return from subroutine
(RTS) are also provided.
The IDLE instruction is provided for idling the processor until an interrupt
occurs. IDLE puts the processor into a low-power state while waiting for
interrupts.
Two addressing modes are supported for memory fetches. Direct address-
ing uses immediate address values; indirect addressing uses the I registers
of the two data address generators (DAGs).
The 24-bit instruction word allows a high degree of parallelism in per-
forming operations. The instruction set allows for single-cycle execution
of any of the following combinations:
• Any ALU, MAC or Shifter operation (conditional or non-condi-
tional)
• Any register-to-register move
• Any data memory read or write
• A computation with any data register to data register move
• A computation with any memory read or write
• A computation with a read from two memories
The instruction set allows maximum flexibility. It provides moves from
any register to any other register, and from most registers to/from mem-
ory. In addition, almost any ALU, MAC or Shifter operation may be
combined with any register-to-register move or with a register move to or
from internal or external memory.
Because the multifunction instructions best illustrate the power of the
processors’ architecture, in the next section we begin with a discussion of
this group of instructions.
Multifunction Instructions
Multifunction operations take advantage of the inherent parallelism of the
ADSP-218x family architecture by providing combinations of data moves,
memory reads/memory writes, and computation, all in a single cycle.
The first clause of this instruction (up to the first comma) says that MR, the
MAC result register, gets the sum of its previous value plus the product of
the (current) X and Y input registers of the MAC (MX0 and MY0) both
treated as signed (SS).
In the second and third clauses of this multifunction instruction, two new
operands are fetched. One is fetched from the data memory (DM) pointed
to by index register zero (I0, post modified by the value in M0) and the
other is fetched from the program memory location (PM) pointed to by I4
(post-modified by M5 in this instance). Note that indirect memory address-
ing uses a syntax similar to array indexing, with DAG registers providing
the index values. Any I register may be paired with any M register within
the same DAG.
As discussed in the ADSP-218x DSP Hardware Reference Manual, Chapter
2, “Computational Units,” registers are read at the beginning of the cycle
and written at the end of the cycle. The operands present in the MX0 and
MY0 registers at the beginning of the instruction cycle are multiplied and
added to the MAC result register, MR. The new operands fetched at the
end of this same instruction overwrite the old operands after the multipli-
cation has taken place and are available for computation on the following
cycle. You may, of course, load any data registers in conjunction with the
computation, not just MAC registers with a MAC operation as in our
example.
The computational part of this multifunction instruction may be any
unconditional ALU instruction except division or any MAC instruction
except saturation. Certain other restrictions apply: the next X operand
must be loaded into MX0 from data memory and the new Y operand must
be loaded into MY0 from program memory (internal and external memory
are identical at the level of the instruction set). The result of the computa-
tion must go to the result register ( MR or AR) not to the feedback register
(MF or AF).
In this example we have used the ALU input registers as the destination.
As with the previous multifunction instruction, X operands must come
from data memory and Y operands from program memory (internal or
external memory in either case, for the processors with on-chip memory).
Again the value of the source register for the memory write (AR in this
example) is the value at the beginning of the instruction. The computa-
tion loads a new value into the same register; this is the value in AR at the
end of this instruction. Reversing the order of the clauses would imply
that the result of the computation is written to memory when, in fact, the
previous value of the register is what is written. There is no requirement
that the same register be used in this way although this will usually be the
case in order to pipeline operands to the computation.
Here, an ALU addition operation occurs while a new value is loaded into
AX0 from MR2. As before, the value of AX0 at the beginning of the instruc-
tion is the value used in the computation. The move may be from or to all
ALU, MAC and Shifter input and output registers except the feedback
registers (AF and MF) and SB.
In the example, the data register move loads the AX0 register with the new
value at the end of the cycle. All ALU operations except division, all MAC
operations and all Shifter operations except SHIFT IMMEDIATE are legal.
Computation must be unconditional.
A complete list of data registers is given in “Processor Registers: reg and
dreg” on page 4-22. A complete list of the permissible xops and yops for
computational operations is given in the reference page for each instruc-
tion. “Summary of Valid Combinations for Multifunction Instructions”
AX0 = DM ( I0 , M0 ) , AY0 = PM ( I4 , M4 );
AX1 I1 , M1 AY1 I5 , M5
MX0 I2 , M2 MY0 I6 , M6
MX1 I3 , M3 MY1 I7 , M7
<ALU>* , dreg = DM ( I0 , M0 ) ;
<MAC>* I1 , M1
<SHIFT>* I2 , M2
I3 , M3
I4 , M4
I5 , M5
I6 , M6
I7 , M7
PM ( I4 , M4 )
I5 , M5
I6 , M6
I7 , M7
DM ( I0 , M0 ) = dreg, <ALU>* ;
I1 , M1 <MAC>*
I2 , M2 <SHIFT>*
I3 , M3
I4 , M4
I5 , M5
I6 , M6
I7 , M7
PM ( I4 , M4 )
I5 , M5
I6 , M6
I7 , M7
S EE A LSO
• “ALU/MAC with Data and Program Memory Read” on page 4-7
ALU Group
The following is an example of one ALU instruction, Add/Add with
Carry:
IF AC AR=AX0+AY0+C;
The (optional) conditional expression, IF AC, tests the ALU Carry bit
(AC); if there is a carry from the previous instruction, this instruction exe-
cutes, otherwise a NOP occurs and execution continues with the next
instruction. The algebraic expression AR=AX0+AY0+C means that the ALU
result register (AR) gets the value of the ALU X input and Y input registers
plus the value of the carry-in bit.
Table 4-3 gives a summary list of all ALU instructions. In this list, condi-
tion stands for all the possible conditions that can be tested and xop and
yop stand for the registers that can be specified as input for the ALU. The
conditional clause is optional and is enclosed in square brackets to show
this. A complete list of the permissible xops and yops is given in the refer-
ence page for each instruction. A complete list of conditions is given in
Table 4-9.
NONE = <ALU> ;
MAC Group
Here is an example of one of the MAC instructions,
Multiply/Accumulate:
IF NOT MV MR=MR+MX0*MY0(UU);
The conditional expression, IF NOT MV, tests the MAC overflow bit. If the
condition is not true, a NOP is executed. The expression MR=MR+MX0*MY0 is
the multiply/accumulate operation: the multiplier result register (MR) gets
the value of itself plus the product of the X and Y input registers selected.
The modifier in parentheses (UU) treats the operands as unsigned. There
can be only one such modifier selected from the available set. The modi-
fier (SS) means both are signed, while (US) and (SU) mean that either the
first or second operand is signed; (RND) means to round the (implicitly
signed) result.
Table 4-4 gives a summary list of all MAC instructions. In this list, condi-
tion stands for all the possible conditions that can be tested and xop and
yop stand for the registers that can be specified as input for the MAC. A
complete list of the permissible xops and yops is given in the reference
page for each instructions.
[IF cond] MR = 0;
MF
IF MV SAT MR ;
Shifter Group
Here is an example of one of the Shifter instruction, Normalize:
IF NOT CE SR= SR OR NORM SI (HI);
The conditional expression, IF NOT CE, tests the “not counter expired”
condition. If the condition is false, a NOP is executed. The destination of
all shifting operations is the Shifter Result register, SR. The destination of
exponent detection instructions is SE or SB, as shown in Table 4-5. In this
example, SI, the Shifter Input register, is the operand. The amount and
direction of the shift is controlled by the signed value in the SE register in
all shift operations except an immediate shift. Positive values cause left
shifts; negative values cause right shifts.
The optional SR OR modifier logically ORs the result with the current con-
tents of the SR register; this allows you to construct a 32-bit value in SR
from two 16-bit pieces. NORM is the operator and HI is the modifier that
determines whether the shift is relative to the HI or LO (16-bit) half of SR.
If SR OR is omitted, the result is passed directly into SR.
Table 4-5 gives a summary list of all Shifter instructions. In this list, con-
dition stands for all the possible conditions that can be tested.
reg = DM (<address>) ;
dreg = DM ( I0 , M0 );
I1 , M1
I2 , M2
I3 , M3
I4 , M4
I5 , M5
I6 , M6
I7 , M7
DM ( I0 , M0 ) = dreg ;
I1 , M1 <data>
I2 , M2
I3 , M3
I4 , M4
I5 , M5
I6 , M6
I7 , M7
DM (<address>) = reg ;
dreg = PM ( I4 ’ M4 );
I5 ’ M5
I6 ’ M6
I7 ’ M7
PM ( I4 ’ M4 ) = dreg;
I5 ’ M5
I6 ’ M6
I7 ’ M7
Table 4-7 shows how registers are grouped. These registers are read and
written via their register names.
SB
PX
Table 4-8 gives a summary of all program flow control instructions. The
condition codes are described in Table 4-9.
IDLE [(n)];
EQ Equal Zero AZ = 1
AC ALU Carry AC = 1
AV ALU Overflow AV = 1
MV MAC Overflow MV = 1
Miscellaneous Instructions
There are several miscellaneous instructions. NOP is a no operation instruc-
tion. The PUSH/POP instructions allow you to explicitly control the status,
counter, PC and loop stacks; interrupt servicing automatically pushes and
pops these stacks.
The Mode Control instruction enables and disables processor modes of
operation: bit-reversal on DAG1, latching ALU overflow, saturating the
ALU result register, choosing the primary or secondary register set, GO
mode for continued operation during bus grant, multiplier shift mode for
fractional or integer arithmetic, and timer enabling.
A single ENA or DIS can be followed by any number of mode identifiers,
separated by commas; ENA and DIS can also be repeated. All seven modes
can be enabled, disabled, or changed in a single instruction.
The MODIFY instruction modifies the address pointer in the I register
selected with the value in the selected M register, without performing any
actual memory access. As always, the I and M registers must be from the
same DAG; any of I0-I3 may be used only with one from M0-M3 and the
same for I4-I7 and M4-M7. If circular buffering is in use, modulus logic
applies. See the ADSP-218x DSP Hardware Reference Manual, Chapter 4,
“Data Address Generators” for more information.
The FO (Flag Out), FL0, FL1, and FL2 pins can each be set, cleared, or tog-
gled. This instruction provides a control structure for multiprocessor
communication.
MODIFY ( I0 , M0 );
I1 , M1
I2 , M2
I3 , M3
I4 , M4
I5 , M5
I6 , M6
I7 , M7
ENA INTS;
DIS
Wait States
All family processors allow the programming of wait states for external
memory chips. Up to 15 extra wait state cycles for the ADSP-2185M,
ADSP-2186M, ADSP-2188M, ADSP-2189M, ADSP-2188N,
ADSP-2185N, ADSP-2186N, ADSP-2187N and ADSP-2189N and up
to seven extra wait state cycles for all other ADSP-218x models may be
added to the processor’s access time for external memory. Extra cycles
inserted due to wait states are in addition to any cycles caused by multiple
off-chip accesses. Wait state programming is described in the ADSP-218x
DSP Hardware Reference, Chapter 8, “Memory Interface.”
Wait states and multiple off-chip memory accesses are the two cases when
an extra cycle is generated during instruction execution. The following
case, SPORT autobuffering and DMA, causes the insertion of extra cycles
between instructions.
The permissible conds, xops, and yops are given in a list. The conditional
IF clause is enclosed in square brackets, indicating that it is optional.
The destination register for the add operation must be either AR or AF.
These are listed within parallel bars, indicating that one of the two must
be chosen.
Similarly, the yop term may consist of a Y operand, the carry bit, or the
sum of both. One of these three terms must be used.
Notation Meaning
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– * – – – 0 – –
ALU Instructions
E XAMPLE
/* Conditional ADD with carry */
IF EQ AR = AX0 + AY0 + C;
/* Unconditional ADD */
AR = AR + 512;
D ESCRIPTION
Test the optional condition and, if true, perform the specified addition. If
false then perform a no-operation. Omitting the condition performs the
addition unconditionally. The addition operation adds the first source
operand to the second source operand along with the ALU carry bit, AC, (if
designated by the +C notation), using binary addition. The result is stored
in the destination register. The operands are contained in the data regis-
ters or constant specified in the instruction.
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– – – * * * * *
I NSTRUCTION F ORMAT
Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF Yop Xop 0 0 0 0 COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF YY Xop CC BO COND
E XAMPLE
/* Conditional subtraction */
IF GE AR = AX0 − AY0;
MR2 = AR;
D ESCRIPTION
Test the optional condition and, if true, then perform the specified sub-
traction. If the condition is not true then perform a no-operation.
Omitting the condition performs the subtraction unconditionally. The
subtraction operation subtracts the second source operand from the first
source operand, and optionally adds the ALU Carry bit (AC) minus 1
(0x0001), and stores the result in the destination register. The (C–1) quan-
tity effectively implements a borrow capability for multiprecision
subtractions. The operands are contained in the data registers or constant
specified in the instruction.
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– – – * * * * *
I NSTRUCTION F ORMAT
Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF Yop Xop 0 0 0 0 COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF YY Xop CC BO COND
E XAMPLE
IF GT AR = AY0 – AX0 + C + 1;
D ESCRIPTION
Test the optional condition and, if true, then perform the specified sub-
traction. If the condition is not true then perform a no-operation.
Omitting the condition performs the subtraction unconditionally. The
subtraction operation subtracts the second source operand from the first
source operand, and optionally adds the ALU Carry bit (AC) minus 1
(0x0001), and stores the result in the destination register. The (C–1) quan-
tity effectively implements a borrow capability for multiprecision
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– – – - * * * *
I NSTRUCTION F ORMAT
Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF Yop Xop 0 0 0 0 COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF YY Xop CC BO COND
E XAMPLES
AR = AX0 XOR AY0;
IF FLAG_IN AR = MR0 AND 8192;
D ESCRIPTION
Test the optional condition and if true, then perform the specified bitwise
logical operation (logical AND, inclusive OR, or exclusive OR). If the condi-
tion is not true then perform a no-operation. Omitting the condition
performs the logical operation unconditionally. The operands are con-
tained in the data registers or constant specified in the instruction.
I NSTRUCTION F ORMAT
Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF Yop Xop 0 0 0 0 COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF YY Xop CC BO COND
E XAMPLES
AF = TSTBIT 5 OF AR;
AR = TGLBIT 13 OF AX0;
D ESCRIPTION
Test the optional condition and if true, then perform the specified bit
operation. If the condition is not true then perform a no-operation. Omit-
ting the condition performs the operation unconditionally. These
operations cannot be used in multifunction instructions.
These operations are defined as follows:
I NSTRUCTION F ORMAT
(xop AND/OR/XOR constant)
Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF YY Xop CC BO COND
Clear: PASS
S YNTAX
E XAMPLES
/* Conditional pass*/
IF GE AR = PASS AY0;
/* Unconditional pass*/
AR = PASS 0;
AR = PASS 8191;
/* AR = SIGN(AX0) * MIN(AX0,AY0);*/
D ESCRIPTION
Test the optional condition and if true, pass the source operand unmodi-
fied through the ALU block and store in the destination register. If the
condition is not true perform a no-operation. Omitting the condition per-
forms the PASS unconditionally. The source operand is contained in the
data register or constant specified in the instruction.
is one method of clearing AR. PASS 0 can also be combined with
PASS 0
memory reads and writes in a multifunction instruction to clear AR.
The PASS instruction performs the transfer to the AR or AF register and
affects the ASTAT status flags (for xop, yop, –1, 0, 1 only). This instruction
is different from a register move operation which does not affect any status
flags. The PASS constant operation (using any constant other than –1, 0, or
1) causes the ASTAT status flags to be undefined.
The PASS constant operation (using any constant other than –1, 0, or 1)
may not be used in multifunction instructions.
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– – – – 0 0 * *
I NSTRUCTION F ORMAT
Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF Yop Xop 0 0 0 0 COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF YY Xop CC BO COND
S EE A LSO
• IF Condition Codes Table 4-9 on page 4-25
• “Status Condition Codes” on page A-12
• BO, CC, and YY “ALU/MAC Constant Codes” on page A-25
• “ALU/MAC Result Register Codes” on page A-25
• “AMF Function Codes” on page A-10
• “X Operand Codes” on page A-24
• “Y Operand Codes” on page A-24
Negate
S YNTAX
[ IF cond ] AR = – xop ;
AF yop
E XAMPLES
IF LT AR = – AY0;
D ESCRIPTION
Test the optional condition and if true, then NEGATE the source operand
and store in the destination location. If the condition is not true then per-
form a no-operation. Omitting the condition performs the NEGATE
operation unconditionally. The source operand is contained in the data
register specified in the instruction.
S TATUS G ENERATED (See T a b l e 4 - 1 1 o n p a ge 4 - 3 1 fo r re gi s t e r n ot a t i o n )
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– – – – * * * *
I NSTRUCTION F ORMAT
Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF Yop Xop 0 0 0 0 COND
NOT
S YNTAX
E XAMPLE
IF NE AF = NOT AX0;
D ESCRIPTION
Test the optional condition and if true, then perform the logical comple-
ment (ones complement) of the source operand and store in the
destination location. If the condition is not true then perform a no-oper-
ation. Omitting the condition performs the complement operation
unconditionally. The source operand is contained in the data register
specified in the instruction.
S TATUS G ENERATED (See T a b l e 4 - 1 1 o n p a ge 4 - 3 1 fo r re gi s t e r n ot a t i o n )
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– – – – 0 0 * *
AV Always cleared.
AC Always cleared.
I NSTRUCTION F ORMAT
Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF Yop Xop 0 0 0 0 COND
E XAMPLES
/* Conditional instruction */
/* AR = sign(AX0) * min(AX0,AY0); */
D ESCRIPTION
Test the optional condition and, if true, then take the absolute value of
the source operand and store in the destination location. If the condition
is not true then perform a no-operation. Omitting the condition performs
the absolute value operation unconditionally. The source operand is con-
tained in the data register specified in the instruction.
S TATUS G ENERATED (See T a b l e 4 - 1 1 o n p a ge 4 - 3 1 fo r re gi s t e r n ot a t i o n )
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– – – * 0 * * *
I NSTRUCTION F ORMAT
Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF 0 0 Xop 0 0 0 0 COND
S EE A LSO
• IF Condition Codes Table 4-9 on page 4-25
• “Status Condition Codes” on page A-12
• “ALU/MAC Result Register Codes” on page A-25
• “AMF Function Codes” on page A-10
• “X Operand Codes” on page A-24
Increment
S YNTAX
[ IF cond ] AR = yop + 1 ;
AF
E XAMPLE
IF GT AF = AF + 1;
D ESCRIPTION
Test the optional condition and if true, then increment the source oper-
and by 0x0001 and store in the destination location. If the condition is not
true then perform a no-operation. Omitting the condition performs the
increment operation unconditionally. The source operand is contained in
the data register specified in the instruction.
S TATUS G ENERATED (See T a b l e 4 - 1 1 o n p a ge 4 - 3 1 fo r re gi s t e r n ot a t i o n )
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– – – – * * * *
I NSTRUCTION F ORMAT
Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF Yop Xop 0 0 0 0 COND
Decrement
S YNTAX
[ IF cond ] AR = yop – 1 ;
AF
E XAMPLES
IF EQ AR = AY1 – 1;
D ESCRIPTION
Test the optional condition and if true, then decrement the source oper-
and by 0x0001 and store in the destination location. If the condition is not
true then perform a no-operation. Omitting the condition performs the
decrement operation unconditionally. The source operand is contained in
the data register specified in the instruction.
S TATUS G ENERATED (See T a b l e 4 - 1 1 o n p a ge 4 - 3 1 fo r re gi s t e r n ot a t i o n )
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– – – – * * * *
I NSTRUCTION F ORMAT
Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF Yop Xop 0 0 0 0 COND
D ESCRIPTION
These instructions implement yop÷xop. There are two divide primitives,
DIVS and DIVQ. A single precision divide, with a 32-bit numerator and a
16-bit denominator, yielding a 16-bit quotient, executes in 16 cycles.
Higher precision divides are also possible.
The division can be either signed or unsigned, but both the numerator
and denominator must be the same; both signed or unsigned. The pro-
grammer sets 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 algo-
rithm. At the conclusion of the divide operation the quotient will be in
AY0.
To implement an unsigned divide, first place the upper half of the numer-
ator in AF, then set the AQ bit to zero by manually clearing it in the
Arithmetic Status Register, ASTAT. This indicates that the sign of the quo-
tient is positive. Then execute the DIVQ instruction for as many times as
there are bits in the quotient (e.g., for an unsigned single-precision divide,
execute DIVQ 16 times).
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 (and left over in the AF register) is
not valid and must be corrected if it is needed. For more information,
consult the section “Division Exceptions” on page 4-70 of this manual.
S TATUS G ENERATED (See T a b l e 4 - 1 1 o n p a ge 4 - 3 1 fo r re gi s t e r n ot a t i o n )
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– – * – – – – –
AQ Loaded with the bit value equal to the AQ bit computed on each cycle from
execution of the DIVS or DIVQ instruction.
I NSTRUCTION F ORMAT
DIVQ, Instruction Type 23:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 1 1 1 0 0 0 1 0 Xop 0 0 0 0 0 0 0 0
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 1 1 0 0 0 0 Yop Xop 0 0 0 0 0 0 0 0
D IVISION T HEORY
The ADSP-218x family processors’ instruction set contains two instruc-
tions for implementing a non-restoring divide algorithm. These
instructions take as their operands twos-complement or unsigned num-
bers, and in sixteen cycles produce a truncated quotient of sixteen bits. For
most numbers and applications, these primitives produce the correct
results. However, there are certain situations where results produced will
be off by one LSB. This section documents these situations, and presents
alternatives for producing the correct results.
Computing a 16-bit fixed point quotient from two numbers is accom-
plished by 16 executions of the DIVQ instruction for unsigned numbers.
Signed division uses the DIVS instruction first, followed by fifteen DIVQs.
Regardless of which 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 func-
tions by adding or subtracting the divisor to/from the dividend. The
decision as to which operation is performed is based on the previously
generated quotient bit. Each add/subtract operation produces a new par-
tial remainder, which will be used in the next step.
The phrase 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, while the upper 16-bits can be in either AY1 or AF.
The DIVS primitive is executed once, with the proper operands (ex. DIVS
AY1, AX0) to compute the sign of the quotient. The sign bit of the quotient
is determined by XORing (exclusive-or) the sign bits of each operand. The
entire 32-bit dividend is shifted left one bit. The lower fifteen bits of the
dividend with the recently determined sign bit appended are stored in AY0,
while the lower fifteen bits of the upper word, with the MSB of the lower
word appended is stored in AF.
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 if
the dividend should be added to, or subtracted from the partial remainder
stored in AF and AY0. If AQ is zero, a subtract occurs. A new value for AQ is
determined by XORing the MSB of the divisor with the MSB of the divi-
dend. 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 has been 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 fifteen (or thirty-one in dou-
ble precision) bits 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 O.P format, the quotient’s format will be
(M-O+1).(N-P-1). As you can see, dividing a 1.31 number by a 1.15
number will produce a quotient whose format is (1-1+1).(31-15-1)
or 1.15.
! Before dividing two numbers, you must ensure that the format of
the quotient will be valid. For example, if you attempted to divide
a 32.0 number by a 1.15 number the result would attempt to be in
(32-1+1).(0-15-1) or 32.-16 format. This cannot be represented in
a 16-bit register!
In addition to proper output format, you must ensure that a divide over-
flow does not occur. Even if a division of two numbers produces a legal
output format, it is possible that the number will overflow, and be unable
to fit within the constraints of the output. For example, if you wished 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 legal. Now assume you happened to
have 16384 (0x4000) as the dividend and .25 (0x2000) as the divisor, the
quotient would be 65536, which does not fit in 16.0 format. This opera-
tion would overflow, producing an erroneous result.
Input operands can be checked 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 divi-
sion. 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, you must shift the dividend to the left
one bit, placing it in 31.1 format. The output format for this division will
Division Exceptions
Although the divide primitives for the ADSP-218x 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 quo-
tient 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.
Division Applications
Each of the problems mentioned in “Division Exceptions” on page 4-70
can be compensated for in software. Listing 4-1 shows the program sec-
tion divides. This code can be used to divide two signed or unsigned
numbers to produce the correct quotient, or an error condition.
outputs:
ar - corrected quotient
SEE ALSO
NONE = <ALU>;
E XAMPLES
NONE = AX0 – AY0;
D ESCRIPTION
Perform the designated ALU operation, generate the ASTAT status flags,
then discard the result value. This instruction allows the testing of register
values without disturbing the contents of the AR or AF registers.
I NSTRUCTION F ORMAT
Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 1 0 AMF* Yop Xop 1 0 1 0 1 0 1 0
* ALU codes only.
AMF specifies the ALU or MAC operation (only ALU operations allowed).
Xop: X operand Yop: Y operand
S EE AL SO
• “AMF Function Codes” on page A-10
• “X Operand Codes” on page A-24
• “Y Operand Codes” on page A-24
MAC Instructions
Multiply
S YNTAX
E XAMPLES
/* Conditional multiply xop ∗ yop*/
IF EQ MR = MX0 ∗ MF (UU);
MR1 = MR2;
MR1 = MR2;
D ESCRIPTION
Test the optional condition and, if true, then multiply the two source
operands and store in the destination location. If the condition is not true
perform a no-operation. Omitting the condition performs the multiplica-
tion unconditionally. The operands are contained in the data registers
specified in the instruction. When MF is the destination operand, only bits
31-16 of the product are stored in MF.
The data format selection field following the two operands specifies
whether each respective operand is in Signed (S) or Unsigned (U) format.
The xop is specified first and yop is second. If the xop * xop operation is
used, the data format selection field must be (UU), (SS), or (RND) only.
There is no default; one of the data formats must be specified.
If RND (Round) is specified, the MAC multiplies the two source operands,
rounds the result to the most significant 24 bits (or rounds bits 31-16 to
16 bits if there is no overflow from the multiply), and stores the result in
the destination register. The two multiplication operands xop and yop (or
xop and xop) are considered to be in twos complement format. Rounding
can be either biased or unbiased. For a discussion of biased vs. unbiased
rounding, see the section “Rounding Mode” in the ADSP-218x DSP
Hardware Reference Manual, Chapter 2, “Computational Units.”
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– * – – – – – –
MV Set on MAC overflow (if any of the upper 9 bits of MR are not all one or
zero). Cleared otherwise.
I NSTRUCTION F ORMAT
(xop * yop) Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF Yop Xop 0 0 0 0 COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF 0 0 Xop 0 0 0 1 COND
E XAMPLES
/* Conditional multiply with cumulative add, xop ∗ yop*/
MY0 = 1
CNTR = N-1;
D ESCRIPTION
Test the optional condition and, if true, then multiply the two source
operands, add the product to the present contents of the MR register, and
store the result in the destination location. If the condition is not true
then perform a no-operation. Omitting the condition performs the multi-
ply/accumulate unconditionally. The operands are contained in the data
registers specified in the instruction. When MF is the destination operand,
only bits 31-16 of the 40-bit result are stored in MF.
The ADSP-218x processors support the xop* xop squaring operation. Both
xops must be in the same register. This option allows single-cycle X2 and
∑X2 instructions.
The data format selection field to the right of the two operands specifies
whether each respective operand is in signed (S) or unsigned (U) format.
The xop is specified first and yop is second. If the xop * xop operation is
used, the data format selection field must be (UU), (SS), or (RND) only.
There is no default; one of the data formats must be specified.
If RND (Round) is specified, the MAC multiplies the two source operands,
adds the product to the current contents of the MR register, rounds the
result to the most significant 24 bits (or rounds bits 31-16 to the nearest
16 bits if there is no overflow from the multiply/accumulate), and stores
the result in the destination register. The two multiplication operands xop
and yop (or xop and xop) are considered to be in twos complement format.
All rounding is unbiased, except on the ADSP-217x, ADSP-218x, and
ADSP-21msp58/59 processors, which offer a biased rounding mode. For a
discussion of biased vs. unbiased rounding, see the section “Rounding
Mode” in the ADSP-218x DSP Hardware Reference Manual, Chapter 2,
“Computational Units.”
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– * – – – – – –
MV Set on MAC overflow (if any of the upper 9 bits of MR are not all one or zero).
Cleared otherwise.
I NSTRUCTION F ORMAT
(xop * yop) Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF Yop Xop 0 0 0 0 COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF 0 0 Xop 0 0 0 1 COND
E XAMPLES
IF LT MR = MR – MX1 ∗ MY0 (SU); /* xop ∗ yop */
D ESCRIPTION
Test the optional condition and, if true, then multiply the two source
operands, subtract the product from the present contents of the MR regis-
ter, and store the result in the destination location. If the condition is not
true perform a no-operation. Omitting the condition performs the multi-
ply/subtract unconditionally. The operands are contained in the data
registers specified in the instruction. When MF is the destination operand,
only bits 16-31 of the 40-bit result are stored in MF.
The ADSP-218x processors support the xop* xop squaring operation. Both
xops must be in the same register. This option allows single-cycle X2 and
∑X2 instructions.
The data format selection field to the right of the two operands specifies
whether each respective operand is in signed (S) or unsigned (U) format.
The xop is specified first and yop is second. If the xop * xop operation is
used, the data format selection field must be (UU), (SS), or (RND) only.
There is no default; one of the data formats must be specified.
If RND (Round) is specified, the MAC multiplies the two source operands,
subtracts the product from the current contents of the MR register,
rounds the result to the most significant 24 bits (or rounds bits 31-16 to
16 bits if there is no overflow from the multiply/accumulate), and stores
the result in the destination register. The two multiplication operands xop
and yop (or xop and xop) are considered to be in twos complement format.
The ADSP-218x processors support biased rounding mode, as well as,
unbiased rounding. For a discussion of biased vs. unbiased rounding, see
the section “Rounding Mode” in the ADSP-218x DSP Hardware Reference
Manual, Chapter 2, “Computational Units.”
S TATUS G ENERATED (See T a b l e 4 - 1 1 o n p a ge 4 - 3 1 fo r re gi s t e r n ot a t i o n )
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– * – – – – – –
MV Set on MAC overflow (if any of the upper 9 bits of MR are not all one or
zero). Cleared otherwise.
I NSTRUCTION F ORMAT
(xop * yop) Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF Yop Xop 0 0 0 0 COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF 0 0 Xop 0 0 0 1 COND
S EE A LSO
• IF Condition Codes Table 4-9 on page 4-25
• “Status Condition Codes” on page A-12
• “ALU/MAC Result Register Codes” on page A-25
• “AMF Function Codes” on page A-10
• “X Operand Codes” on page A-24
• “Y Operand Codes” on page A-24
Squaring
S YNTAX
MF (UU)
(RND)
MF (UU)
(RND)
MF (UU)
(RND)
Permissible xops
MX0 AR
MX1 SR1
MR2 SR0
MR1
MR0
E XAMPLES
IF NOT MV MR = MR + MX0 * MX0 (SS); /* ⌺X2 instruction */
MR = AR * AR (UU); /* X2 instruction */
D ESCRIPTION
Test the optional condition and, if true, then square the xop, add the
present contents of the MR register (or subtract the squared result from the
MR register), and store the result in the destination location. If the condi-
tion is not true, then perform a no-operation. Omitting the condition
performs the multiply/accumulate unconditionally. The xop is contained
in the data register specified in the instruction. When MF is the destination
operand, only bits 31-16 of the 40-bit result are stored in MF.
R ESTRICTIONS
The ADSP-218x processors support the xop* xop squaring operation.
However, both xops must be in the same register. This option allows sin-
gle-cycle X2 and 冱X2 instructions. The data format selection field must be
(UU), (SS), or (RND) only. There is no default for the data format selection
field; one of the data formats must be specified. The squaring instruction
cannot be used in a multifunction instruction.
S TATUS G ENERATED
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
- * - - - - - -
MV Set on MAC overflow (if any of upper 9 bits of MR are not all one
or zero). Cleared otherwise.
I NSTRUCTION F ORMAT
(xop * xop) Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF 0 0 Xop 0 0 0 1 COND
Z: Destination register
Xop: X operand COND: Condition
S EE ALSO
MAC Clear
S YNTAX
[ IF cond ] MR = 0;
MF
Permissible conds
EQ NE GT GE LT
LE NEG POS AV NOT AV
AC NOT AC MV NOT MV NOT CE
E XAMPLE
IF GT MR = 0;
D ESCRIPTION
Test the optional condition and, if true, then set the specified register to
zero. If the condition is not true perform a no-operation. Omitting the
condition performs the clear unconditionally. The entire 40-bit MR or
16-bit MF register is cleared to zero.
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– 0 – – – – – –
MV Always cleared.
I NSTRUCTION F ORMAT
Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF 1 1 0 0 0 0 0 0 0 COND
MAC Transfer MR
S YNTAX
[ IF cond ] MR = MR [(RND)] ;
MF
Permissible conds
EQ NE GT GE LT
LE NEG POS AV NOT AV
AC NOT AC MV NOT MV NOT CE
E XAMPLES
/* Conditional transfer MR */
IF EQ MF = MR (RND);
/* Load MR register */
MR0 = DM(MR0_VAL);
MR1 = DM(MR1_VAL);
MR2 = DM(MR2_VAL);
IF MV SAT MR;
D ESCRIPTION
Test the optional condition and, if true, then perform the MR transfer
according to the description below. If the condition is not true then per-
form a no-operation. Omitting the condition performs the transfer
unconditionally.
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
– * – – – – – –
MV Set on MAC overflow (if any of upper 9 bits of MR are not one or zero. Cleared
otherwise.
I NSTRUCTION F ORMAT
Conditional ALU/MAC operation, Instruction Type 9:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF 1 1 0 0 0 0 0 0 0 COND
S EE A LSO
• IF Condition Codes Table 4-9 on page 4-25
• “Status Condition Codes” on page A-12
• “ALU/MAC Result Register Codes” on page A-25
• “AMF Function Codes” on page A-10
Conditional MR Saturation
S YNTAX
IF MV SAT MR;
D ESCRIPTION
Test the MV (MAC Overflow) bit in the Arithmetic Status Register
(ASTAT), and if set, then saturate the lower-order 32 bits of the 40-bit MR
register; if the MV is not set then perform a no-operation.
Saturation of MR is executed with this instruction for one cycle only; MAC
saturation is not a continuous mode that is enabled or disabled. The satu-
ration instruction is intended to be used at the completion of a series of
multiply/accumulate operations so that temporary overflows do not cause
the accumulator to saturate.
The saturation result depends on the state of MV and on the sign of MR (the
MSB of MR2). The possible results after execution of the saturation instruc-
tion are shown in the table below.
0 0 No change
0 1 No change
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
Saturate MR operation, Instruction Type 25:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Arithmetic Shift
S YNTAX
E XAMPLES
/ * Conditional arithmetic shift */
IF LT SR = SR OR ASHIFT SI (LO);
SE = -2;
SR = SR OR LSHIFT SI (LO);
D ESCRIPTION
Test the optional condition and, if true, then perform the designated
arithmetic shift. If the condition is not true then perform a no-operation.
Omitting the condition performs the shift unconditionally. The operation
arithmetically shifts the bits of the operand by the amount and direction
specified in the shift code from the SE register. Positive shift codes cause a
left shift (upshift) and negative codes cause a right shift (downshift).
The shift may be referenced to the upper half of the output field (HI
option) or to the lower half ( LO option). The shift output may be logically
ORed with the present contents of the SR register by selecting the SR OR
option.
For ASHIFT with a positive shift code (i.e. positive value in SE), the oper-
and is shifted left; with a negative shift code (i.e. negative value in SE), the
operand is shifted right. The number of positions shifted is the count in
the shift code. The 32-bit output field is sign-extended to the left (the
MSB of the input is replicated to the left), and the output is zero-filled
from the right. Bits shifted out of the high order bit in the 32-bit destina-
tion field (SR31) are dropped. Bits shifted out of the low order bit in the
destination field (SR0) are dropped.
To shift a double precision number, the same shift code is used for both
halves of the number. On the first cycle, the upper half of the number is
shifted using an ASHIFT with the HI option; on the following cycle, the
lower half of the number is shifted using an LSHIFT with the LO and OR
options. This prevents sign bit extension of the lower word’s MSB.
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
Conditional Shift Operation, Instruction Type 16:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 1 0 0 SF Xop 0 0 0 0 COND
Logical Shift
S YNTAX
E XAMPLES
IF GE SR = SR LSHIFT SI (HI);
D ESCRIPTION
Test the optional condition and, if true, then perform the designated logi-
cal shift. If the condition is not true then perform a no-operation.
Omitting the condition performs the shift unconditionally. The operation
logically shifts the bits of the operand by the amount and direction speci-
fied in the shift code from the SE register. Positive shift codes cause a left
shift (upshift) and negative codes cause a right shift (downshift).
The shift may be referenced to the upper half of the output field (HI
option) or to the lower half ( LO option). The shift output may be logically
ORed with the present contents of the SR register by selecting the SR OR
option.
For LSHIFT with a positive shift code, the operand is shifted left; the num-
bers of positions shifted is the count in the shift code. The 32-bit output
field is zero-filled from the right. Bits shifted out of the high order bit in
the 32-bit destination field (SR31) are dropped.
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 1 0 0 SF Xop 0 0 0 0 COND
SF Shifter Function
S EE A LSO
• IF Condition Codes Table 4-9 on page 4-25
• “Status Condition Codes” on page A-12
• “Shifter Function Codes” on page A-21
• “X Operand Codes” on page A-24
E XAMPLES
/* Normalize instruction without condition */
SR = NORM SI (HI);
D ESCRIPTION
Test the optional condition and, if true, then perform the designated nor-
malization. If the condition is not true then perform a no-operation.
Omitting the condition performs the normalize unconditionally. The
operation arithmetically shifts the input operand to eliminate all but one
of the sign bits. NORM shifts the in the opposite direction of ASHIFT. The
amount of the shift comes from the SE register. The SE register may be
loaded with the proper shift code to eliminate the redundant sign bits by
using the Derive Exponent instruction; the shift code loaded will be the
negative of the quantity: (the number of sign bits minus one).
The shift may be referenced to the upper half of the output field (HI
option) or to the lower half ( LO option). The shift output may be logically
ORed with the present contents of the SR register by selecting the SR OR
option. When the LO reference is selected, the 32-bit output field is
zero-filled to the left. Bits shifted out of the high order bit in the 32-bit
destination field (SR31) are dropped.
The 32-bit output field is zero-filled from the right. If the exponent of an
overflowed ALU result was derived with the HIX modifier, the 32-bit out-
put field is filled from left with the ALU Carry ( AC) bit in the Arithmetic
Status Register (ASTAT) during a NORM (HI) operation. In this case (SE=1
from the exponent detection on the overflowed ALU value) a downshift
occurs.
To normalize a double precision number, the same shift code is used for
both halves of the number. On the first cycle, the upper half of the num-
ber is shifted using the HI option; on the following cycle, the lower half of
the number is shifted using the LO and OR options.
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
Conditional Shift operation, Instruction Type 16:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 1 0 0 SF Xop 0 0 0 0 COND
Derive Exponent
S YNTAX
E XAMPLES
/* Conditional derive exponent */
SR = SR OR NORM SI (LO);
SR = SR OR LSHIFT SI (LO);
D ESCRIPTION
Test the optional condition and, if true, perform the designated exponent
operation. If the condition is not true then perform a no-operation. Omit-
ting the condition performs the exponent operation unconditionally.
The EXP operation derives the effective exponent of the input operand to
prepare for the normalization operation (NORM). EXP supplies the source
operand to the exponent detector, which generates a shift code from the
number of leading sign bits in the input operand. The shift code, stored in
SE at the completion of the EXP instruction, is the effective exponent of the
input value. The shift code depends on which exponent detector mode is
used (HI, HIX, LO).
In the HI mode, the input is interpreted as a single precision signed num-
ber, or as the upper half of a double precision signed number. The
exponent detector counts the number of leading sign bits in the source
operand and stores the resulting shift code in SE. The shift code will equal
the negative of the number of redundant sign bits in the input.
In the HIX mode, the input is interpreted as the result of an add or subtract
which may have overflowed. HIX is intended to handle shifting and nor-
malization of results from ALU operations. The HIX mode examines the
ALU Overflow bit (AV) in the Arithmetic Status Register: if AV is set, then
the effective exponent of the input is +1 (indicating that an ALU overflow
occurred before the EXP operation), and +1 is stored in SE. If AV is not set,
then HIX performs exactly the same operations as the HI mode.
In the LO mode, the input is interpreted as the lower half of a double pre-
cision number. In performing the EXP operation on a double precision
number, the higher half of the number must first be processed with EXP in
the HI or HIX mode, and then the lower half can be processed with EXP in
the LO mode. If the upper half contained a non-sign bit, then the correct
shift code was generated in the HI or HIX operation and that is the code
that is stored in SE. If, however, the upper half was all sign bits, then EXP
in the LO mode totals the number of leading sign bits in the double preci-
sion word and stores the resulting shift code in SE.
S TATUS G ENERATED (See T a b l e 4 - 1 1 o n p a ge 4 - 3 1 fo r re gi s t e r n ot a t i o n )
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
* – – – – – – –
SS Set by the MSB of the input for an EXP operation in the HI or HIX mode with
AV = 0. Set by the MSB inverted in the HIX mode with AV = 1. Not affected
by operations in the LO mode.
I NSTRUCTION F ORMAT
Conditional Shift operation, Instruction Type 16:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 1 0 0 SF Xop 0 0 0 0 COND
SF Shifter Function
E XAMPLES
IF GT SB = EXPADJ SI ;
D ESCRIPTION
Test the optional condition and, if true, perform the designated exponent
operation. If the condition is not true then perform a no-operation. Omit-
ting the condition performs the exponent operation unconditionally. The
Block Exponent Adjust operation, when performed on a series of num-
bers, derives the effective exponent of the number largest in magnitude.
This exponent can then be associated with all of the numbers in a block
floating point representation.
The Block Exponent Adjust circuitry applies the input operand to the
exponent detector to derive its effective exponent. The input must be a
signed twos complement number. The exponent detector operates in HI
mode (see the EXP instruction, above).
At the start of a block, the SB register should be initialized to –16 to set SB
to its minimum value. On each execution of the EXPADJ instruction, the
effective exponent of each operand is compared to the current contents of
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 1 0 0 SF Xop 0 0 0 0 COND
SF = 1111
Xop: Shifter operand COND: Condition
S EE A LSO
• IF Condition Codes Table 4-9 on page 4-25
• “Status Condition Codes” on page A-12
• “Shifter Function Codes” on page A-21
• “X Operand Codes” on page A-24
E XAMPLES
SR = SR OR ASHIFT SR0 BY 3 (LO); /* Do not use +3 */
D ESCRIPTION
Arithmetically shift the bits of the operand by the amount and direction
specified by the constant in the exponent field. Positive constants cause a
left shift (upshift) and negative constants cause a right shift (downshift). A
positive constant must be entered without a + sign.
The shift may be referenced to the upper half of the output field (HI
option) or to the lower half ( LO option). The shift output may be logically
ORed with the present contents of the SR register by selecting the SR OR
option.
For ASHIFT with a positive shift constant the operand is shifted left; with a
negative shift constant the operand is shifted right. The 32-bit output
field is sign-extended to the left (the MSB of the input is replicated to the
left), and the output is zero-filled from the right. Bits shifted out of the
high order bit in the 32-bit destination field (SR31) are dropped. Bits
shifted out of the low order bit in the destination field (SR0) are dropped.
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 1 1 0 SF Xop <exp>
SF Shifter Function
E XAMPLES
/* Shift the MR register into SR by -5 arithmetically */
D ESCRIPTION
Logically shifts the bits of the operand by the amount and direction speci-
fied by the constant in the exponent field. Positive constants cause a left
shift (upshift); negative constants cause a right shift (downshift). A posi-
tive constant must be entered without a + sign.
The shift may be referenced to the upper half of the output field (HI
option) or to the lower half ( LO option). The shift output may be logically
ORed with the contents of the SR register by selecting the SR OR option.
For LSHIFT with a positive shift constant, the operand is shifted left. The
32-bit output field is zero-filled to the left and from the right. Bits shifted
out of the high order bit in the 32-bit destination field (SR31) are dropped.
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 1 1 0 SF Xop <exp>
SF Shifter Function
Move Instructions
Register Move
S YNTAX
reg = reg;
Permissible registers
AX0 MX0 SI SB CNTR
AX1 MX1 SE PX OWRCNTR (write only)
AY0 MY0 SR1 ASTAT RX0
AY1 MY1 SR0 MSTAT RX1
AR MR2 I0-I7 SSTAT (read only) TX0
MR1 M0-M7 IMASK TX1
MR0 L0-L7 ICNTL IFC (write only)
E XAMPLES
I7 = AR;
D ESCRIPTION
Move the contents of the source to the destination location. The contents
of the source are always right-justified in the destination location after the
move.
When transferring a smaller register to a larger register (e.g., an 8-bit reg-
ister to a 16-bit register), the value stored in the destination is either
sign-extended to the left if the source is a signed value, or zero-filled to the
left if the source is an unsigned value. The unsigned registers which (when
used as the source) cause the value stored in the destination to be
zero-filled to the left are: I0 through I7, L0 through L7, CNTR, PX, ASTAT,
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 0 1 0 0 0 0 DST SRC DEST SOURCE
RGP RGP REG REG
To choose the source register group (SRC RGP) and the source register
(SOURCE REG), refer to the table “Register Selection Codes” on page A-19.
To choose the destination register group (DST RGP) and the destination
register (DEST REG), refer to the table “Register Selection Codes” on
page A-19.
reg = <data>;
dreg = <data>;
data: <constant>
Permissible registers
dregs (Instruction Type 6) dregs (Instruction Type 7)
(16-bit load) (maximum 14-bit load)
AX0 MX0 SI SB CNTR
AX1 MX1 SE PX OWRCNTR (write only)
AY0 MY0 SR1 ASTAT RX0
AY1 MY1 SR0 MSTAT RX1
AR MR2 IMASK TX0
MR1 ICNTL TX1
MR0 I0-I7 IFC (write only)
M0-M7
L0-L7
E XAMPLES
I0 = data_buffer;
L0 = length(data_buffer);
D ESCRIPTION
Move the data value specified to the destination location. The data may be
a constant, or any symbol referenced by name or with the length operator.
The data value is contained in the instruction word, with 16 bits for data
register loads and up to 14 bits for other register loads. The value is always
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 0 0 DATA DREG
DATA contains the immediate value to be loaded into the Data Register
destination location. The data is right-justified in the field, so the value
loaded into an N-bit destination register is contained in the lower-order N
bits of the DATA field.
To choose the data register (DREG), refer to the table“DREG Selection
Codes” on page A-14.
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 1 RGP DATA REG
DATA contains the immediate value to be loaded into the Non-Data Regis-
ter destination location. The data is right-justified in the field, so the value
loaded into an N-bit destination register is contained in the lower-order N
bits of the DATA field.
To choose the source register group (SRC RGP) and the source register
(SOURCE REG), refer to the table “Register Selection Codes” on page A-19.
reg = DM ( <addr> ) ;
Permissible registers
AX0 MX0 SI SB CNTR
AX1 MX1 SE PX OWRCNTR (write only)
AY0 MY0 SR1 ASTAT RX0
AY1 MY1 SR0 MSTAT RX1
AR MR2 I0-I7 IMASK TX0
MR1 M0-M7 ICNTL TX1
MR0 L0-L7 IFC (write only)
E XAMPLE
SI = DM(ad_port0);
D ESCRIPTION
The Read instruction moves the contents of the data memory location to
the destination register. The addressing mode is direct addressing (desig-
nated by an immediate address value or by a label). The data memory
address is stored directly in the instruction word as a full 14-bit field. The
contents of the source are always right-justified in the destination register
after the read (bit 0 maps to bit 0).
Note that whenever MR1 is loaded with data, it is sign-extended into MR2.
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
Data Memory Read (Direct Address), Instruction Type 3:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 0 0 0 RGP ADDR REG
ADDR contains the direct address to the source location in Data Memory.
To choose the source register group ( RGP) and the source register ( REG),
refer to the table “Register Selection Codes” on page A-19.
dreg = DM ( I0 M0 ) ;
I1 ’ M1
I2 M2
I3 M3
I4 M4
I5 M5
I6 M6
I7 M7
Permissible dregs
AX0 MX0 SI
AX1 MX1 SE
AY0 MY0 SR1
AY1 MY1 SR0
AR MR2
MR1
MR0
E XAMPLE
AY0 = DM (I3, M1);
D ESCRIPTION
The Data Memory Read Indirect instruction moves the contents of the
data memory location to the destination register. The addressing mode is
register indirect with post-modify. For linear (i.e. non-circular) indirect
addressing, the L register corresponding to the I register used must be
set to zero. The contents of the source are always right-justified in the des-
tination register after the read (bit 0 maps to bit 0).
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
ALU/MAC operation with Data Memory Read, Instruction Type 4:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 1 G 0 0 AMF 0 0 0 0 0 DREG I M
dreg = PM ( I4 M4 );
I5 ’ M5
I6 M6
I7 M7
Permissible dregs
AX0 MX0 SI
AX1 MX1 SE
AY0 MY0 SR1
AY1 MY1 SR0
AR MR2
MR1
MR0
E XAMPLE
MX1 = PM (I6, M5);
D ESCRIPTION
The Program Memory Read Indirect instruction moves the contents of
the program memory location to the destination register. The addressing
mode is register indirect with post-modify. For linear (i.e. non-circular)
indirect addressing, the L register corresponding to theI register used
must be set to zero. The 16 most significant bits of the Program Memory
Data bus (PMD23-8) are loaded into the destination register, with bit PMD8
lining up with bit 0 of the destination register (right-justification). If the
destination register is less than 16 bits wide, the most significant bits are
dropped. Bits PMD7-0 are always loaded into the PX register. You may ignore
these bits or read them out on a subsequent cycle.
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
ALU/MAC operation with Data Memory Read, Instruction Type 4:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 0 1 0 0 AMF 0 0 0 0 0 DREG I M
DM ( <addr> ) = reg;
Permissible registers
AX0 MX0 SI SB CNTR
AX1 MX1 SE PX RX0
AY0 MY0 SR1 ASTAT RX1
AY1 MY1 SR0 MSTAT TX0
AR MR2 I0-I7 SSTAT (read only) TX1
MR1 M0-M7 IMASK
MR0 L0-L7 ICNTL
E XAMPLE
DM(cntl_port0) = AR;
D ESCRIPTION
Moves the contents of the source register to the data memory location
specified in the instruction word. The addressing mode is direct address-
ing (designated by an immediate address value or by a label). The data
memory address is stored directly in the instruction word as a full 14-bit
field. Whenever a register that is less than 16 bits in length is written to
memory, the value written is either sign-extended to the left if the source
is a signed value, or zero-filled to the left if the source is an unsigned
value. The unsigned registers which are zero-filled to the left are: I0
through I7, L0 through L7, CNTR, PX, ASTAT, MSTAT, SSTAT, IMASK, and
ICNTL. All other registers are sign-extended to the left.
Note that whenever MR1 is loaded with data, it is sign-extended into MR2.
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
Data Memory Read (Direct Address), Instruction Type 3:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 0 0 1 RGP ADDR REG
DM ( I0 M0 ) = dreg ;
I1 ’ M1 <data>
I2 M2
I3 M3
I4 M4
I5 M5
I6 M6
I7 M7
data: <constant>
Permissible dregs
AX0 MX0 SI
AX1 MX1 SE
AY0 MY0 SR1
AY1 MY1 SR0
AR MR2
MR1
MR0
E XAMPLE
DM (I2, M0)= MR1;
D ESCRIPTION
The Data Memory Write Indirect instruction moves the contents of the
source to the data memory location specified in the instruction word. The
immediate data may be a constant.
The addressing mode is register indirect with post-modify. For linear (i.e.
non-circular) indirect addressing, the L register corresponding to the I
register used must be set to zero. When a register of less than 16 bits is
written to memory, the value written is sign-extended to form a 16-bit
value. The contents of the source are always right-justified in the destina-
tion location after the write (bit 0 maps to bit 0).
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
ALU/MAC operation with Data Memory Write, Instruction Type 4:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 1 G 1 0 AMF 0 0 0 0 0 DREG I M
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 G Data I M
PM ( I4 , M4 ) = dreg;
I5 M5
I6 M6
I7 M7
Permissible dregs
AX0 MX0 SI
AX1 MX1 SE
AR MR2
MR1
MR0
E XAMPLE
PM (I6, M5) = AR;
D ESCRIPTION
The Program Memory Write Indirect instruction moves the contents of
the source to the program memory location specified in the instruction
word. The addressing mode is register indirect with post-modify. For lin-
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 0 1 1 0 AMF 0 0 0 0 0 DREG I M
IO Space Read/Write
S YNTAX
Permissible dregs
AX0 MX0 SI
AX1 MX1 SE
AR MR2
MR1
MR0
E XAMPLES
IO(23) = AX0;
MY1 = IO(2047);
D ESCRIPTION
The I/O space read and write instructions are used to access the
ADSP-218x’s I/O memory space. These instructions move data between
the processor data registers and the I/O memory space.
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 1 D ADDR DREG
ADDR contains the 11-bit direct address of the source or destination loca-
tion in I/O Memory Space.
To choose a data register (DREG), refer to the table “DREG Selection
Codes” on page A-14.
D specifies the direction of the transfer (0=read, 1=write).
JUMP
S YNTAX
(I5)
(I6)
(I7)
<addr>
Permissible conds
EQ NE GT GE LT
E XAMPLE
IF NOT CE JUMP top_loop; /* CNTR is decremented */
D ESCRIPTION
Test the optional condition and, if true, perform the specified jump. If the
condition is not true then perform a no-operation. Omitting the condi-
tion performs the jump unconditionally. The JUMP instruction causes
program execution to continue at the effective address specified by the
instruction. The addressing mode may be direct or register indirect.
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 1 0 ADDR COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 I 0 0 COND
S EE A LSO
• IF Condition Codes Table 4-9 on page 4-25
• “Status Condition Codes” on page A-12
• “Index Register Selection Codes” on page A-17
(I5)
(I6)
(I7)
<addr>
Permissible conds
EQ NE GT GE LT
E XAMPLE
IF AV CALL scale_down;
D ESCRIPTION
Test the optional condition and, if true, then perform the specified call. If
the condition is not true then perform a no-operation. Omitting the con-
dition performs the call unconditionally. The CALL instruction is intended
for calling subroutines. CALL pushes the PC stack with the return address
and causes program execution to continue at the effective address specified
by the instruction. The addressing modes available for the CALL instruc-
tion are direct or register indirect.
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 1 1 ADDR COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 I 0 1 COND
S EE A LSO
• IF Condition Codes Table 4-9 on page 4-25
• “Status Condition Codes” on page A-12
• “Index Register Selection Codes” on page A-17
E XAMPLE
IF FLAG_IN JUMP service_proc_three;
D ESCRIPTION
Test the condition of the FI pin of the processor and, if set to one, per-
form the specified jump or call. If FI is zero then perform a no-operation.
Omitting the flag in condition reduces the instruction to a standard JUMP
or CALL.
The JUMP instruction causes program execution to continue at the address
specified by the instruction. The addressing mode for the JUMP on FI must
be direct.
The CALL instruction is intended for calling subroutines. CALL pushes the
PC stack with the return address and causes program execution to con-
tinue at the address specified by the instruction. The addressing mode for
the CALL on FI must be direct.
If JUMP or CALL is the last instruction inside a DO UNTIL loop, you must
ensure that the loop stacks are properly handled.
For direct addressing (using an immediate address value or a label), the
program address is stored directly in the instruction word as a full 14-bit
field.
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
Conditional JUMP or CALL on Flag In Direct Instruction Type 27:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 1 1 Address Addr FIC S
12 LSBs 2 MSB’s
S EE A LSO
• “Jump and Call Codes” on page A-20
• “FI Condition Codes” on page A-16
RESET FL0
TOGGLE FL1
FL2
E XAMPLE
IF MV SET FLAG_OUT, RESET FL1;
D ESCRIPTION
Evaluate the optional condition and if true, set to one, reset to zero, or
toggle the state of the specified flag output pin(s). Otherwise perform a
no-operation and continue with the next instruction. Omitting the condi-
tion performs the operation unconditionally. Multiple flags may be
modified by including multiple clauses, separated by commas, in a single
instruction. This instruction does not directly alter the flow of your pro-
gram—it is provided to signal external devices.
Note that the FO pin is specified by FLAG_OUT in the instruction syntax.
The following flag outputs are present on the ADSP-218x processor: FO,
FL0, FL1, FL2
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
Flag Out Mode Control Instruction Type 28:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 1 0 0 0 0 0 FO FO FO FO COND
S EE A LSO
• IF Condition Codes Table 4-9 on page 4-25
• “Status Condition Codes” on page A-12
• “FO Condition Codes” on page A-16
Permissible conds
EQ NE GT GE LT
E XAMPLE
IF LE RTS ;
D ESCRIPTION
Test the optional condition and, if true, then perform the specified return.
If the condition is not true then perform a no-operation. Omitting the
condition performs the return unconditionally. RTS executes a program
return from a subroutine. The address on top of the PC stack is popped
and is used as the return address. The PC stack is the only stack popped.
If RTS is the last instruction inside a DO UNTIL loop, you must ensure that
the loop stacks are properly handled.
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
Conditional Return, Instruction Type 20:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 COND
COND: Condition
S EE A LSO
• IF Condition Codes Table 4-9 on page 4-25
• “Status Condition Codes” on page A-12
Permissible conds
EQ NE GT GE LT
E XAMPLE
IF MV RTI ;
D ESCRIPTION
Test the optional condition and, if true, then perform the specified return.
If the condition is not true then perform a no-operation. Omitting the
condition performs the return unconditionally. RTI executes a program
return from an interrupt service routine. The address on top of the PC
stack is popped and is used as the return address. The value on top of the
status stack is also popped, and is loaded into the arithmetic status
(ASTAT), mode status (MSTAT) and the interrupt mask ( IMASK) registers.
If RTI is the last instruction inside a DO UNTIL loop, you must ensure that
the loop stacks are properly handled.
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
Conditional Return, Instruction Type 20:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 COND
COND: Condition
S EE A LSO
• IF Condition Codes Table 4-9 on page 4-25
• “Status Condition Codes” on page A-12
Permissible terms
EQ NE GT GE LT FOREVER
AC NOT AC MV NOT MV CE
E XAMPLE
DO loop_label UNTIL CE;
D ESCRIPTION
DO UNTIL sets up looping circuitry for zero-overhead looping. The program
loop begins at the program instruction immediately following the DO
instruction, ends at the address designated in the instruction and repeats
execution until the specified termination condition is met (if one is speci-
fied) or repeats in an infinite loop (if none is specified). The termination
condition is tested during execution of the last instruction in the loop, the
status having been generated upon completion of the previous instruction.
The address (<addr>) of the last instruction in the loop is stored directly
in the instruction word.
If CE is used for the termination condition, the processor’s counter (CNTR
register) is decremented once for each pass through the loop.
When the DO instruction is executed, the address of the last instruction is
pushed onto the loop stack along with the termination condition and the
current program counter value plus 1 is pushed onto the PC stack.
Any nesting of DO loops continues the process of pushing the loop and PC
stacks, up to the limit of the loop stack size (4 levels of loop nesting) or of
the PC stack size (16 levels for subroutines plus interrupts plus loops).
With either or both the loop or PC stacks full, a further attempt to per-
form the DO instruction will set the appropriate stack overflow bit and will
perform a no-operation.
S TATUS G ENERATED (See T a b l e 4 - 1 1 o n p a ge 4 - 3 1 fo r re gi s t e r n ot a t i o n )
SSTAT: 7 6 5 4 3 2 1 0
* 0 – – – – * 0
LSO Loop Stack Overflow: set if the loop stack overflows; otherwise not
affected.
LSE Loop Stack Empty: always cleared (indicating loop stack not
empty).
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 0 1 Addr TERM
ADDR specifies the address of the last instruction in the loop. In the
Instruction Syntax, this field may be a program label or an immediate
address value.
TERM specifies the termination condition, as shown below:
D ESCRIPTION
IDLE causes the processor to wait indefinitely in a low-power state, waiting
for interrupts. When an interrupt occurs it is serviced and execution con-
tinues with the instruction following IDLE. Typically this next instruction
will be a JUMP back to IDLE, implementing a low-power standby loop.
! Note theloop,restrictions
UNTIL
on or
JUMP as the last instruction in a
IDLE
detailed in the ADSP-218x DSP Hardware Reference
DO
When the IDLE (n) instruction is used, it slows the processor’s internal
clock and thus its response time to incoming interrupts—the 1-cycle
response time of the standard IDLE state is increased by n, the clock divi-
sor. When an enabled interrupt is received, the ADSP-218x will remain in
the IDLE state for up to a maximum of n CLKIN cycles (where n =16, 32,
64, or 128) before resuming normal operation.
When the IDLE (n) instruction is used in systems that have an externally
generated serial clock, the serial clock rate may be faster than the proces-
sor’s reduced internal clock rate. Under these conditions, interrupts must
not be generated at a faster rate than can be serviced, due to the additional
time the processor takes to come out of the IDLE state (a maximum of n
CLKIN cycles).
Serial port autobuffering continues during IDLE without affecting the idle
state.
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
Idle, Instruction Type 31:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 DV
Stack Control
S YNTAX
POP
E XAMPLE
POP CNTR, POP PC, POP LOOP;
....
....
D ESCRIPTION
Stack Control pushes or pops the designated stack(s). The entire instruc-
tion executes in one cycle regardless of how many stacks are specified.
The PUSH STS (Push Status Stack) instruction increments the status stack
pointer by one to point to the next available status stack location; and
pushes the arithmetic status ( ASTAT), mode status (MSTAT), and interrupt
mask register (IMASK) onto the processor’s status stack. Note that the PUSH
STS operation is executed automatically whenever an interrupt service rou-
tine is entered.
Any POP pops the value on the top of the designated stack and decrements
the same stack pointer to point to the next lowest location in the stack.
POP STS causes the arithmetic status (ASTAT), mode status (MSTAT), and
interrupt mask (IMASK) to be popped into these same registers. This also
happens automatically whenever a return from interrupt (RTI) is executed.
POP CNTR causes the counter stack to be popped into the down counter.
When the loop stack or PC stack is popped (with POP LOOP or POP PC,
respectively), the information is lost. Returning from an interrupt (RTI) or
subroutine (RTS) also pops the PC stack automatically.
SSTAT 7 6 5 4 3 2 1 0
– * * * – * – *
PSE PC Stack Empty: set if a pop results in an empty program counter stack;
cleared otherwise.
CSE Counter Stack Empty: set if a pop results in an empty counter stack;
cleared otherwise.
SSE Status Stack Empty: for PUSH STS, this bit is always cleared (indicating
status stack not empty). For POP STS, SSE is set if the pop results in an
empty status stack; cleared otherwise.
SSO Status Stack Overflow: for PUSH STS set if the status stack overflows; oth-
erwise not affected.
LSE Loop Stack Empty: set if a pop results in an empty loop stack; cleared oth-
erwise.
Note that once any Stack Overflow occurs, the corresponding stack over-
flow bit is set in SSTAT, and this bit stays set indicating there has been loss
of information. Once set, the stack overflow bit can only be cleared by
resetting the processor.
I NSTRUCTION F ORMAT
Stack Control, Instruction Type 26:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Pp Lp Cp Spp
S EE A LSO
• “Mode Control Codes” on page A-6
TOPPCSTACK
A special version of the register-to-register Move instruction, Type 17, is
provided for reading and popping or writing and pushing the top value of
the PC stack. the normal POP PC instruction does not save the value
popped from the stack. To save this value into a register, you must use the
following special instruction:
reg = TOPPCSTACK; /* pop PC stack into reg */
! instruction
Note that
type.
TOPPCSTACK may not be used as a register in any other
NOP;
AX0 MX0 SI I0 I4 M0 M4 L0 L4
AX1 MX1 SE I1 I5 M1 M5 L1 L5
AR MR2
MR1
MR0
MX0
There are several restrictions on the use of the special TOPPCSTACK instruc-
tions which are described in the ADSP-218x DSP Hardware Reference
Manual, Chapter 3, “Program Control.”
I NSTRUCTION F ORMAT
TOPPCSTACK = reg
Internal Data Move, Instruction Type 17:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 0 1 0 0 0 0 1 1 SRC 1 1 1 1 SOURCE
RGP REG
To choose the source register group (SRC RGP) and the source register
(SOURCE REG), refer to the table “Register Selection Codes” on page A-19.
reg = TOPPCSTACK
Internal Data Move, Instruction Type 17:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 0 1 0 0 0 0 DST 1 1 DEST 1 1 1 1
RGP REG
To choose the destination register group (DST RGP) and the destination
register (DEST REG), refer to the table “Register Selection Codes” on
page A-19.
DIS AV_LATCH
AR_SAT
SEC_REG
G_MODE
M_MODE
TIMER
E XAMPLE
DIS AR_SAT, ENA M_MODE;
D ESCRIPTION
Enables (ENA) or disables (DIS) the designated processor mode. The corre-
sponding mode status bit in the mode status register (MSTAT) is set for ENA
mode and cleared for DIS mode. At reset, MSTAT is set to zero, meaning
that all modes are disabled. Any number of modes can be changed in one
cycle with this instruction. Multiple ENA or DIS clauses must be separated
by commas.
The data register bank select bit (SEC_REG) determines which set of data
registers is currently active (0=primary, 1=secondary).
The bit-reverse mode bit (BIT_REV), when set to 1, causes addresses gener-
ated by Data Address Generator #1 to be output in bit reversed order.
The ALU overflow latch mode bit (AV_LATCH), when set to 1, causes the AV
bit in the arithmetic status register to stay set once an ALU overflow
occurs. In this mode, if an ALU overflow occurs, the AV bit will be set and
will remain set even if subsequent ALU operations do not generate over-
flows. The AV bit can only be cleared by writing a zero into it directly over
the DMD bus.
The AR saturation mode bit, (AR_SAT), when set to 1, causes the AR register
to saturate if an ALU operation causes an overflow, as described in the
ADSP-218x DSP Hardware Reference Manual, Chapter 2, “Computational
Units.”
The MAC result placement mode (M_MODE) determines whether or not the
left shift is made between the multiplier product and the MR register.
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 0 0 TI MM AS OL BR SR GM 0 0
AS: AR Saturation Mode Control OL: ALU Overflow Latch Mode Control
BR: Bit Reverse Mode Control SR: Secondary Register Bank Mode
GM: GO Mode
S EE A LSO
• “Mode Control Codes” on page A-6
DIS INTS ;
D ESCRIPTION
Interrupts are enabled by default at reset. Executing the DIS INTS instruc-
tion causes all interrupts (including the power down interrupt) to be
masked, without changing the contents of the IMASK register.
Executing the ENA INTS instruction allows all unmasked interrupts to be
serviced again.
! Note that disabling interrupts does not affect serial port autobuffer-
ing or ADSP-218x DMA transfers (IDMA or BDMA). These oper-
ations will continue normally whether or not interrupts are enabled.
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
DIS INTS, Instruction Type 26:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0
reg = PMOVLAY;
data:<constant>
M0-M7 DMOVLAY
L0-L7
Permissible constants:
E XAMPLE
PMOVLAY = 5; /* Write to pmovlay register */
AX0 = PMOVLAY;
D ESCRIPTION
The PMOVLAY write instruction switches the context of the hardware pro-
gram memory overlay region to the specific region specified by the
permissible data value written to the PMOVLAY register. The PMOVLAY read
instruction moves the value from the PMOVLAY register into one of the per-
missible registers listed above.
S TATUS G ENERATED
No status bits affected.
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 0 0 D RGP ADDR REG
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 1 RGP DATA REG
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 0 1 0 0 0 0 DST SRC DEST SOURCE
RGP RGP REG REG
To choose the source register group (SRC RGP) and the source register
(SOURCE REG), refer to the table “Register Selection Codes” on page A-19.
To choose the destination register group (DST RGP) and the destination
register (DEST REG), refer to the table “Register Selection Codes” on
page A-19.
reg = DMOVLAY;
data:<constant>
M0-M7 PMOVLAY
L0-L7
E XAMPLE
DMOVLAY = 1; /* Write to dmovlay register */
AX0 = DMOVLAY;
D ESCRIPTION
The DMOVLAY write instruction switches the context of the hardware data
memory overlay region to the specific region specified by the permissible
data value written to the DMOVLAY register. The DMOVLAY read instruction
moves the value from the DMOVLAY register into one of the permissible reg-
isters listed above.
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
Read/Write Data Memory (Immediate Address), Instruction Type 3:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 0 0 D RGP ADDR REG
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 1 RGP DATA REG
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 0 1 0 0 0 0 DST SRC DEST SOURCE
RGP RGP REG REG
To choose the source register group (SRC RGP) and the source register
(SOURCE REG), refer to the table “Register Selection Codes” on page A-19.
To choose the destination register group (DST RGP) and the destination
register (DEST REG), refer to the table “Register Selection Codes” on
page A-19.
MODIFY ( I0 , M0 );
I1 M1
I2 M2
I3 M3
I4 M4
I5 M5
I6 M6
I7 M7
E XAMPLE
MODIFY (I1, M1);
D ESCRIPTION
Add the selected M register (Mn) to the selected I register (Im), then process
the modified address through the modulus logic with buffer length as
determined by the L register corresponding to the selected I register (Lm),
and store the resulting address pointer calculation in the selected I regis-
ter. The I register is modified as if an indexed memory address were taking
place, but no actual memory data transfer occurs. For linear (i.e. non-cir-
cular) indirect addressing, the L register corresponding to the I register
used must be set to zero.
The selection of the I and M registers is constrained to registers within the
same Data Address Generator: selection of I0-I3 in Data Address Genera-
tor #1 constrains selection of the M registers to M0-M3. Similarly, selection
of I4-I7 constrains the M registers to M4-M7.
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
Modify Address Register, Instruction Type 21:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 G I M
D ESCRIPTION
No operation occurs for one cycle. Execution continues with the instruc-
tion following the NOP instruction.
S TATUS G ENERATED
No status bits affected.
I NSTRUCTION F ORMAT
No operation, Instruction Type 30, as shown below:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Multifunction Instructions
<ALU> , dreg = DM ( I0 , M0 ) ;
<MAC> I1 M1
<SHIFT> I2 M2
I3 M3
I4 , M4
I5 M5
I6 M6
I7 M7
PM ( I4 , M4 )
I5 M5
I6 M6
I7 M7
AX0 MX0 SI
AX1 MX1 SE
AR MR0
MR1
MR2
D ESCRIPTION
Perform the designated arithmetic operation and data transfer. The read
operation moves the contents of the source to the destination register. The
addressing mode when combining an arithmetic operation with a memory
read is register indirect with post-modify. For linear (i.e. non-circular)
indirect addressing, the L register corresponding to the I register used
must be set to zero. The contents of the source are always right-justified
in the destination register.
The computation must be unconditional. All ALU, MAC and Shifter
operations are permitted except Shift Immediate and ALU DIVS and DIVQ
instructions.
The fundamental principle governing multifunction instructions is that
registers (and memory) are read at the beginning of the processor cycle
and written at the end of the cycle. The normal left-to-right order of
clauses (computation first, memory read second) is intended to imply this.
In fact, you may code this instruction with the order of clauses reversed.
The assembler produces a warning, but the results are identical at the
opcode level. If you turn off semantics checking in the assembler (using
the –s switch) the warning is not issued.
Because of the read-first, write-second characteristic of the processor,
using the same register as source in one clause and a destination in the
other is legal. The register supplies the value present at the beginning of
the cycle and is written with the new value at the end of the cycle.
For example,
(1) AR = AX0 + AY0, AX0 = DM (I0, M0);
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
- - - * * * * *
<MAC> operation
ASTAT 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
- * - - - - - -
<SHIFT> operation
ASTAT 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
* - - - - - - -
SS Affected only when executing the EXP operation; set if the source
operand is negative. Cleared if the number is positive.
I NSTRUCTION F ORMAT
ALU/MAC operation with Data Memory Read, Instruction Type 4:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 1 G 0 Z AMF Yop Xop Dreg I M
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 0 1 0 Z AMF Yop Xop Dreg I M
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 0 0 1 G 0 SF Xop Dreg I M
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 0 0 0 1 0 SF Xop Dreg I M
M: Modify register
S EE ALSO
<MAC>
<SHIFT>
Permissible dregs
AX0 MX0 SI
AX1 MX1 SE
AR MR0
MR1
MR2
D ESCRIPTION
Perform the designated arithmetic operation and data transfer. The con-
tents of the source are always right-justified in the destination register
after the read.
The computation must be unconditional. All ALU, MAC and Shifter
operations are permitted except Shift Immediate and ALU DIVS and DIVQ
instructions.
The following, therefore, is illegal and not supported, even though assem-
bler semantics checking produces only a warning:
(3) AR = AX0 + AY0, AR = MR1; Illegal!
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
- - - * * * * *
AS Affected only when executing the Absolute Value operation ( ABS). Set if
the source operand is negative.
ASTAT: 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
- * - - - - - -
<SHIFT> operation
ASTAT 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
* - - - - - - -
Affected only when executing the EXP operation; set if the source operand
is negative. Cleared if the number is positive.
I NSTRUCTION F ORMAT
ALU/MAC operation with Data Register Move, Instruction Type 8:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 1 Z AMF Yop Xop Dreg dest Dreg source
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 0 0 0 0 0 SF Xop Dreg dest Dreg source
S EE ALSO
DM ( I0 , M0 ) = dreg, <ALU> ;
I1 M1 <MAC>
I2 M2 <SHIFT>
I3 M3
I4 M4
I5 M5
I6 M6
I7 M7
PM ( I4 , M4 )
I5 M5
I6 M6
I7 M7
Permissible dregs
AX0 MX0 SI
AX1 MX1 SE
AR MR0
MR1
MR2
D ESCRIPTION
Perform the designated arithmetic operation and data transfer. The write
operation moves the contents of the source to the specified memory loca-
tion. The addressing mode when combining an arithmetic operation with
a memory write is register indirect with post-modify.
For linear (i.e. non-circular) indirect addressing, the L register corre-
sponding to the I register used must be set to zero. The contents of the
source are always right-justified in the destination register. The computa-
tion must be unconditional. All ALU, MAC and Shifter operations are
permitted except Shift Immediate and ALU DIVS and DIVQ instructions.
The fundamental principle governing multifunction instructions is that
registers (and memory) are read at the beginning of the processor cycle
and written at the end of the cycle.
ASTAT 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
- - - * * * * *
AS Affected only when executing the Absolute Value operation (ABS). Set
if the source operand is negative.
<MAC> operation
ASTAT 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
- * - - - - - -
<SHIFT> operation
ASTAT 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
* - - - - - - -
SS Affected only when executing the EXP operation; set if the source
operand is negative. Cleared if the number is positive.
I NSTRUCTION F ORMAT
ALU/MAC operation with Data Memory Write, Instruction Type 4:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 1 G 1 Z AMF Yop Xop Dreg I M
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 0 1 1 Z AMF Yop Xop Dreg I M
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 0 0 1 G 1 SF Xop Dreg I M
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 0 0 0 1 1 SF Xop Dreg I M
S EE ALSO
AX1 I1 M1 AY1 I5 M5
MX0 I2 M2 MY0 I6 M6
MX1 I3 M3 MY1 I7 M7
D ESCRIPTION
Perform the designated memory reads, one from data memory and one
from program memory. Each read operation moves the contents of the
memory location to the destination register. For this double data fetch,
the destinations for data memory reads are the X registers in the ALU and
the MAC, and the destinations for program memory reads are the Y regis-
ters. The addressing mode for this memory read is register indirect with
post-modify. For linear (i.e. non-circular) indirect addressing, the L reg-
ister corresponding to the I register used must be set to zero. The
contents of the source are always right-justified in the destination register.
A multifunction instruction requires three items to be fetched from mem-
ory: the instruction itself and two data words. No extra cycle is needed to
execute the instruction as long as only one of the fetches is from external
memory.
If two off-chip accesses are required, however—the instruction fetch and
one data fetch, for example, or data fetches from both program and data
memory—then one overhead cycle occurs. In this case the program mem-
ory access occurs first, then the data memory access. If three off-chip
accesses are required—the instruction fetch as well as data fetches from
both program and data memory—then two overhead cycles occur.
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 1 PD DD AMF 0 0 0 0 0 PM DM DM DM
I M I M
AMF specifies the ALU or MAC function. In this case, AMF = 00000, des-
ignating a no-operation for the ALU or MAC function.
M: Modify register
S EE ALSO
MX0 I2 M2 MY0 I6 M6
MX1 I3 M3 MY1 I7 M7
D ESCRIPTION
This instruction combines an ALU or a MAC operation with a data mem-
ory read and a program memory read. The read operations move the
contents of the memory location to the destination register. For this dou-
ble data fetch, the destinations for data memory reads are the X registers in
the ALU and the MAC, and the destinations for program memory reads
are the Y registers. The addressing mode is register indirect with
post-modify. For linear (i.e. non-circular) indirect addressing, the L reg-
ister corresponding to the I register used must be set to zero. The
contents of the source are always right-justified in the destination register
after the read.
A multifunction instruction requires three items to be fetched from mem-
ory: the instruction itself and two data words. No extra cycle is needed to
execute the instruction as long as only one of the fetches is from external
memory.
If two off-chip accesses are required such as the instruction fetch and one
data fetch or data fetches from both program and data memory, then one
overhead cycle occurs. In this case, the program memory access occurs
first, followed by the data memory access. If three off-chip accesses are
required such as the instruction fetch and data fetches from both program
and data memory, then two overhead cycles occur.
ASTAT 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
- - - * * * * *
<MAC> operation
ASTAT 7 6 5 4 3 2 1 0
SS MV AQ AS AC AV AN AZ
- * - - - - - -
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 1 PD DD AMF Yop Xop PM PM DM DM
I M I M
S EE ALSO
Overview
This appendix gives a summary of the complete instruction set of the
ADSP-218x family processors. This section is divided into two sections:
• “Opcode Definitions” on page A-2 —This section provides the
opcode bits listed by type number. Any instruction codes not shown
are reserved for future use.
• “Opcode Mnemonics” on page A-10 — This section is an alpha-
betic listing that describes the values for each opcode mnemonic.
Opcode Definitions
Type 1: ALU / MAC with Data and Program Memory Read
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 1 PD DD AMF 0 0 0 0 0 PM DM DM DM
I M I M
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 G Data I M
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 0 0 D RGP ADDR REG
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 1 G D Z AMF Yop Xop Dreg I M
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 0 1 D Z AMF Yop Xop Dreg I M
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 0 0 DATA DREG
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 1 RGP DATA REG
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 1 Z AMF Yop Xop Dreg dest Dreg source
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 1 0 AMF* Yop Xop 1 0 1 0 1 0 1 0
* ALU codes only.
xop * yop
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF Yop Xop 0 0 0 0 COND
xop * xop
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF 0 0 Xop 0 0 0 1 COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF YY Xop CC BO COND
BO, CC,and YY specify the constant according the table shown at the end of
this appendix.
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 Z AMF YY Xop CC BO COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 1 S ADDR COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 0 1 Addr TERM
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 0 0 1 G D SF Xop Dreg I M
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 0 0 0 1 D SF Xop Dreg I M
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 0 0 0 0 0 SF Xop Dreg dest Dreg source
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 1 1 0 SF Xop <exp>
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 1 0 0 SF Xop 0 0 0 0 COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 0 1 0 0 0 0 DST SRC DEST SOURCE
RGP RGP REG REG
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 1 0 0 TI MM AS OL BR SR GM 0 0
TI Timer enable
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 I 0 S COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 T COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 G I M
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 1 1 1 0 0 0 1 0 Xop 0 0 0 0 0 0 0 0
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 1 1 0 0 0 0 Yop Xop 0 0 0 0 0 0 0 0
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Pp Lp Cp Spp
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 1 1 Address Addr FIC S
12 LSBs 2 MSB’s
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 1 0 0 0 0 0 FO FO FO FO COND
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 1 D ADDR DREG
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 DV
Opcode Mnemonics
AMF ALU /MAC Function Codes
0 0 0 0 0 No Operation
0 0 0 0 1 X*Y (RND)
0 0 0 1 0 MR + X * Y (RND)
0 0 0 1 1 MR – X * Y (RND)
0 0 1 0 1 X*Y (SU)
0 0 1 1 0 X*Y (US)
0 0 1 1 1 X*Y (UU)
0 1 0 0 0 MR + X * Y (SS)
0 1 0 0 1 MR + X * Y (SU)
0 1 0 1 0 MR + X * Y (US)
0 1 0 1 1 MR + X * Y (UU)
0 1 1 0 0 MR – X * Y (SS)
0 1 1 0 1 MR – X * Y (SU)
0 1 1 1 0 MR – X * Y (US)
0 1 1 1 1 MR – X * Y (UU)
Code Function
1 0 0 0 0 Y Clear when y = 0
1 0 0 1 0 X+Y+C
1 0 0 1 1 X+Y X when y = 0
1 0 1 0 0 NOT Y
1 0 1 0 1 –Y
1 0 1 1 0 X–Y+C–1 X + C – 1 when y = 0
1 0 1 1 1 X–Y
1 1 0 0 1 Y–X – X when y = 0
1 1 0 1 0 Y–X+C–1 –X + C – 1 when y = 0
Code Function
1 1 0 1 1 NOT X
1 1 1 0 0 X AND Y
1 1 1 0 1 X OR Y
1 1 1 1 0 X XOR Y
1 1 1 1 1 ABS X
BO
See “YY, CC, BO ALU / MAC Constant Codes (Type 9)” on
page A-25.
CC
See “YY, CC, BO ALU / MAC Constant Codes (Type 9)” on
page A-25.
0 0 0 1 Not equal NE
0 0 1 0 Greater than GT
0 1 1 0 ALU Overflow AV
1 0 0 0 ALU Carry AC
1 1 0 0 MAC Overflow MV
1 1 1 1 Always true
Code Description
0 No change
1 Pop
D Direction Codes
Code Description
0 Read
1 Write
Code Register
0 0 AX0
0 1 AX1
1 0 MX0
1 1 MX1
Code Register
0 0 0 0 AX0
0 0 0 1 AX1
0 0 1 0 MX0
Code Register
0 0 1 1 MX1
0 1 0 0 AY0
0 1 0 1 AY1
0 1 1 0 MY0
0 1 1 1 MY1
1 0 0 0 SI
1 0 0 1 SE
1 0 1 0 AR
1 0 1 1 MR0
1 1 0 0 MR1
1 1 0 1 MR2
1 1 1 0 SR0
1 1 1 1 SR1
Code Divisor
0 0 0 0 Normal Idle instruction (Divisor=0)
0 0 0 1 Divisor=16
0 0 1 0 Divisor=32
0 1 0 0 Divisor=64
1 0 0 0 Divisor=128
Code Description
0 0 No change
0 1 Toggle
Code Description
1 0 Reset
1 1 Set
1 DAG2
0 1 I1 I5
1 0 I2 I6
1 1 I3 I7
Code Description
0 No change
1 Pop
0 1 M1 M5
1 0 M2 M6
1 1 M3 M7
Code Register
0 0 AY0
0 1 AY1
Code Register
1 0 MY0
1 1 MY1
Code Description
0 No change
1 Pop
0110 MY0 M2 M6 SB
0111 MY1 M3 M7 PX
1000 SI L0 L4 RX0
1001 SE L1 L5 TX0
1010 AR L2 L6 RX1
1110 SR0 – – –
1111 SR1 – – –
S Jump/Call Codes
Code Function
0 Jump
1 Call
Code Function
0 0 0 0 LSHIFT (HI)
0 0 1 0 LSHIFT (LO)
0 1 0 0 ASHIFT (HI)
0 1 1 0 ASHIFT (LO)
1 0 0 0 NORM (HI)
1 0 1 0 NORM (LO)
1 1 0 0 EXP (HI)
1 1 0 1 EXP (HIX)
1 1 1 0 EXP (LO)
Code Description
0 0 No change
0 1 No change
1 0 Push
1 1 Pop
0 0 0 1 Equal EQ
0 1 0 1 Less than LT
0 1 1 1 ALU Overflow AV
1 0 0 1 ALU Carry AC
1 1 0 1 MAC Overflow MV
1 1 1 0 Counter expired CE
1 1 1 1 Always FOREVER
X X Operand Codes
Code Register
0 0 0 X0 SI for shifter
0 1 0 AR
0 1 1 MR0
1 0 0 MR1
1 0 1 MR2
1 1 0 SR0
1 1 1 SR1
YY Operand Codes
Code Register
0 0 Y0
0 1 Y1
1 0 F feedback register
1 1 zero
YY
0 Result register
1 Feedback register
Constant YY CC BO Bit #
(hex)
0001 00 00 01 bit 0
0002 00 01 01 bit 1
0004 00 10 01 bit 2
0008 00 11 01 bit 3
0010 01 00 01 bit 4
0020 01 01 01 bit 5
0040 01 10 01 bit 6
0080 01 11 01 bit 7
Constant YY CC BO Bit #
(hex)
0100 10 00 01 bit 8
0200 10 01 01 bit 9
0400 10 10 01 bit 10
0800 10 11 01 bit 11
1000 11 00 01 bit 12
2000 11 01 01 bit 13
4000 11 10 01 bit 14
8000 11 11 01 bit 15
FFFE 00 00 11 ! bit 0
FFFD 00 01 11 ! bit 1
FFFB 00 10 11 ! bit 2
FFF7 00 11 11 ! bit 3
FFEF 01 00 11 ! bit 4
FFDF 01 01 11 ! bit 5
FFBF 01 10 11 ! bit 6
FF7F 01 11 11 ! bit 7
FEFF 10 00 11 ! bit 8
Constant YY CC BO Bit #
(hex)
FDFF 10 01 11 ! bit 9
FBFF 10 10 11 ! bit 10
F7FF 10 11 11 ! bit 11
EFFF 11 00 11 ! bit 12
DFFF 11 01 11 ! bit 13
BFFF 11 10 11 ! bit 14
7FFF 11 11 11 ! ! bit 15
A B
Absolute value (ABS) 4-16, 4-57, Bit manipulation
4-177, 4-182, 4-187, 4-194 TSTBIT, SETBIT, CLRBIT,
Add/Add with carry 4-32 TGLBIT 4-45
ALU feedback (AF) register 2-7, 4-15– Bit-reverse subroutine 3-21
4-16, 4-21, 4-45–4-72 Bitwise logic
ALU input (AX and AY) registers 1-9, AND, OR, XOR 4-42
2-1, 2-7, 4-8–4-14, 4-30–4-72, Block exponent adjust 4-110
4-116–4-134, 4-159–4-192
ALU instructions 4-32 C
Instruction syntax table 4-15 CALL instruction 2-17, 4-5, 4-23,
Overview 4-14 4-139, 4-141
Summary of ALU instructions 4-1 Cascaded biquad IIR filter example 3-8
ALU result (AR) register 2-7, 4-8, 4-9, Clear 4-90
4-10, 4-14–4-66, 4-72–4-78, 4-82, CLKOUT 2-9, 4-153
4-97, 4-116–4-162, 4-176, 4-181 Computation
ALU/MAC with data and program Units 2-7
memory read 4-192 With data register move 4-10
AMF ALU /MAC function codes A-10 With memory read 4-9, 4-174
Arithmetic shift 4-97 With memory write 4-9, 4-185
Arithmetic shift immediate 4-112 With register to register move 4-180
Arithmetic status (ASTAT) register 2-1, Condition codes A-12
2-6, 2-7, 2-18, 4-46, 4-49, 4-65, Conditional instructions 1-2
4-67, 4-72, 4-95, 4-104, 4-116, Conditional MR saturation 4-95
4-127, 4-147, 4-156 Contact information 1-7
Conventions 1-9
U
Unsigned division 4-67
W
Wait states 4-28
X
X X Operand codes A-24
Y
Y Y Operand codes A-24
YY, CC, BO ALU / MAC constant codes A-25
Z
Z ALU/MAC Result register codes A-25