0880 Spru430e
0880 Spru430e
Chapter 4 Pipeline
This chapter describes the phases and operation of the instruction pipeline.
The chapter is primarily for readers interested in increasing the efficiency of
their programs by preventing pipeline delays.
Appendix G Glossary
This appendix explains abbreviations, acronyms, and special terminology
used throughout this document.
iv
About This Manual / Notational Conventions
Notational Conventions
This document uses the following conventions:
- In most cases, hexadecimal numbers are shown with a subscript of 16. For
example, the hexadecimal number 40 would be shown as 4016. An excep-
tion to this rule is a hexadecimal number in a code example; these hexade-
cimal numbers have the suffix h. For example, the number 40 in the follow-
ing code is a hexadecimal 40.
MOVB AR0,#40h
Similarly, binary numbers usually are shown with a subscript of 2. For ex-
ample, the binary number 4 would be shown as 01002. Binary numbers in
example code have the suffix b. For example, the following code uses a
binary 4.
MOVB AR0,#0100b
- Bus signals and bits are sometimes represented with the following nota-
tions:
- If a signal is from an active-low pin, the name of the signal is qualified with
an overbar (for example, INT1). If a signal is from an active-high pin or from
hardware inside the the device (in which case, the polarity is irrelevant),
the name of the signal is left unqualified (for example, DLOGINT).
vi
Notational Conventions / Related Documentation From Texas Instruments
The following books describe the TMS320C28x DSP and related support
tools. The documents are available for downloading on the Texas Instruments
website (www.ti.com).
Trademarks
320 Hotline On-line is a trademark of Texas Instruments Incorporated.
HP-UX is a trademark of Hewlett-Packard Company.
IBM and PC are trademarks of International Business Machines Corporation.
Intel is a trademark of Intel Corporation.
MS-DOS is a registered trademark of Microsoft Corporation.
PAL® is a registered trademark of Advanced Micro Devices, Inc.
SunOS is a trademark of Sun Microsystems, Inc.
C2xLP, C27x, C28x, TMS320C28x, TMS320F28x, and XDS510 are trademarks of Texas Instruments
Incorporated.
viii
Contents
Contents
ix
Contents
4 Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1
Describes the phases and operation of the instruction pipeline.
4.1 Pipelining of Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
4.1.1 Decoupled Pipeline Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
4.1.2 Instruction-Fetch Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
4.1.3 Address Counters FC, IC, and PC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
4.2 Visualizing Pipeline Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
4.3 Freezes in Pipeline Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
4.3.1 Wait States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
4.3.2 Instruction-Not-Available Condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
4.4 Pipeline Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
4.4.1 Protection During Reads and Writes to the Same Data-Space Location . . . . 4-12
4.4.2 Protection Against Register Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
4.5 Avoiding Unprotected Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
4.5.1 Unprotected Program-Space Reads and Writes . . . . . . . . . . . . . . . . . . . . . . . . 4-16
4.5.2 An Access to One Location That Affects Another Location . . . . . . . . . . . . . . . 4-16
4.5.3 Write Followed By Read Protection Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17
x
Contents
Contents xi
Contents
xii
Contents
F Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-1
Contents xiii
Figures
Figures
1−1 High-Level Conceptual Diagram of the CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
1−2 TMS320C28x High-Level Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8
2−1 Conceptual Block Diagram of the CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
2−2 C28x Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
2−3 Individually Accessible Portions of the Accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
2−4 Individually Accessible Halves of the XT Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
2−5 Individually Accessible Halves of the P Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
2−6 Pages of Data Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
2−7 Address Reach of the Stack Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
2−8 XAR0 − XAR7 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
2−9 XAR0 − XAR7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
2−10 Bit Fields of Status Register (ST0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16
2−11 Bit Fields of Status Register 1 (ST1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34
2−12 Conceptual Diagram of Components Involved in 16 X16-Bit Multiplication . . . . . . . . . . . 2-42
2−13 Conceptual Diagram of Components Involved in 32 X 32-Bit Multiplication . . . . . . . . . . . 2-43
3−1 Interrupt Flag Register (IFR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
3−2 Interrupt Enable Register (IER) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
3−3 Debug Interrupt Enable Register (DBGIER) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
3−4 Standard Operation for CPU Maskable Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
3−5 Functional Flow Chart for an Interrupt Initiated by the TRAP Instruction . . . . . . . . . . . . . 3-18
5−1 Circular Buffer with AMODE = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22
5−2 Circular Buffer with AMODE = 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24
7−1 JTAG Header to Interface a Target to the Scan Controller . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3
7−2 Stop Mode Execution States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8
7−3 Real-time Mode Execution States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
7−4 Stop Mode Versus Real-Time Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12
7−5 Process for Handling a DT-DMA Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17
7−6 ADDRL (at Data-Space Address 00 083816) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-24
7−7 ADDRH (at Data-Space Address 00 083916) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-24
7−8 REFL (at Data-Space Address 00 084A16) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-24
7−9 REFH (at Data-Space Address 00 084B16 ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-24
7−10 Valid Combinations of Analysis Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-30
A−1 Status register ST0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-4
A−2 Status register ST1, Bits15−8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-5
A−3 Status Register ST1, Bits 7−0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-6
A−4 Interrupt flag register (IFR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-7
xiv
Figures
Contents xv
Tables
Tables
1−1 Compatibility Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1−2 Summary of Bus Use During Data-Space and Program-Space Accesses . . . . . . . . . . . . 1-10
1−3 Special Bus Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11
2−1 CPU Register Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
2−2 Available Operations for Shifting Values in the Accumulator . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
2−3 Product Shift Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
2−4 Instructions That Affect OVC/OVCU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17
2−5 Instructions Affected by the PM Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20
2−6 Instructions Affected by V flag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21
2−7 Negative Flag Under Overflow Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24
2−8 Bits Affected by the C Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
2−9 Instructions That Affect the TC Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31
2−10 Instructions Affected by SXM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33
2−11 Shift Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45
3−1 Interrupt Vectors and Priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
3−2 Requirements for Enabling a Maskable Interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
3−3 Register Pairs Saved and SP Positions for Context Saves . . . . . . . . . . . . . . . . . . . . . . . . 3-14
3−4 Register Pairs Saved and SP Positions for Context Saves . . . . . . . . . . . . . . . . . . . . . . . . 3-20
3−5 Registers After Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23
5−1 Addressing Modes for “loc16” or “loc32” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
6−1 Instruction Set Summary (Organized by Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
6−2 Register Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
7−1 14-Pin Header Signal Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
7−2 Selecting Device Operating Modes By Using TRST, EMU0, and EMU1 . . . . . . . . . . . . . . . 7-5
7−3 Interrupt Handling Information By Mode and State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13
7−4 Start Address and DMA Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-25
7−5 End-Address Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-26
7−6 Analysis Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-30
A−1 Reset Values of the Status and Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2
B−1 General Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-2
B−2 C2xLP Product Mode Shifter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-8
B−3 C28x Product Mode Shifter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-8
B−4 Reset Conditions of Internal Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-10
B−5 Status Register Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-11
B−6 B0 Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-14
C−1 Code to Save Contents Of IMR (IER) And Disabling Lower Priority Interrupts At
Beginning Of ISR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-7
xvi
Tables
Contents xvii
Examples
Examples
3−1 Typical ISR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
4−1 Relationship Between Pipeline and Address Counters FC, IC, and PC . . . . . . . . . . . . . . . 4-6
4−2 Diagramming Pipeline Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
4−3 Simplified Diagram of Pipeline Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
4−4 Conflict Between a Read From and a Write to Same Memory Location . . . . . . . . . . . . . . 4-13
4−5 Register Conflict . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14
7−1 Initialization Code for Data Logging With Word Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-28
7−2 Initialization Code for Data Logging With End Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-29
xviii
Chapter 1
Architectural Overview
The C2xLP CPU is used in all TMS320F24xx and TMS320C20x devices and
their derivatives. This document refers to C2xLP as a generic name for the
CPU used in these devices.
Topic Page
1-1
Introduction to the CPU
The modified Harvard architecture of the CPU enables instruction and data
fetches to be performed in parallel. The CPU can read instructions and data
while it writes data simultaneously to maintain the single-cycle instruction op-
eration across the pipeline. The CPU does this over six separate address/data
buses.
The C28x CPU features compatibility modes that minimize the migration effort
from the C27x and C2xLP CPUs. The operating mode of the device is
determined by a combination of the OBJMODE and AMODE bits in status
register 1 (ST1) as shown in Table 1−1. The OBJMODE bit allows you to select
between code compiled for a C28x (OBJMODE == 1) and code compiled for
a C27x (OBJMODE == 0). The AMODE bit allows you to select between
C28x/C27x instruction addressing modes (AMODE == 0) and C2xLP
compatible instruction addressing modes (AMODE == 1).
OBJMODE AMODE
C28x Mode 1 0
- C28x Mode: In C28x mode, you can take advantage of all the C28x native
features, addressing modes, and instructions. To operate in C28x mode
from reset, your code must first set the OBJMODE bit by using the
”C28OBJ” (or ”SETC OBJMODE”) instruction. This book assumes you are
operating in C28x mode unless stated otherwise.
1-2
Introduction to the CPU
C28x CPU
Memory-interface signals
CPU
Clock and control signals
1-4
Components of the CPU
- Arithmetic logic unit (ALU). The 32-bit ALU performs 2s-complement arith-
metic and Boolean logic operations.
- Barrel shifter. This shifter performs all left and right shifts of data. It can shift
data to the left by up to 16 bits and to the right by up to 16 bits.
- Multiple debug events. Any of the following debug events can cause a
break in program execution:
J A breakpoint initiated by the ESTOP0 or ESTOP1 instruction
J An access to a specified program-space or data-space ___location
J A request from the debug host or other hardware
When a debug event causes the C28x to enter the debug-halt state, the
event is called a break event.
- Real-time mode of operation. When the C28x is in this mode and a break
event occurs, the main body of program code comes to a halt, but time-crit-
ical interrupts can still be serviced.
1.2.3 Signals
The CPU has four main types of signals:
- Clock and control signals. These provide clocking for the CPU and the
emulation logic, and they are used to control and monitor the CPU.
- Reset and interrupt signals. These are used for generating a hardware re-
set and interrupts, and for monitoring the status of interrupts.
- Emulation signals. These signals are used for testing and debugging.
1-6
Memory Map
The memory map in Figure 1−2 has been divided into the following segments:
- On-chip program/data
- Reserved
- CPU interrupt vectors
For specific details about each of the map segments, see the data sheet for
your device. See Appendix C for more information on the C2xLP compatible
memory space.
For devices with a peripheral interrupt expansion (PIE) block, the interrupt vec-
tors will reside in the PIE vector table and this memory can be used as program
memory.
Block M0 1 K × 16 Block M0 1 K × 16
3FF <−SP
400
Block M1 1 K × 16 Block M1 1 K × 16 (Reset) Low 64K
C2xLP
Compatible
Data Space
7FF 800
Reserved Reserved
9FF
1000
Memory or
Peripherals Memory or
Peripherals
3F 0000
A000
High 64K
C2xLP
Compatible
Program
Space
Vectors (VMAP = 1)
3F FFFF
FFFF FFFF
See the data sheet for your specific device for details of the exact memory
map.
1-8
Memory Interface
The interface also includes signals that indicate the type of read or write being
requested by the CPU. These signals can select a specified memory block or
peripheral for a given bus transaction. In addition to 16-bit and 32-bit ac-
cesses, the C28x supports special byte-access instructions which can access
the least significant byte (LSByte) or most significant byte (MSByte) of an ad-
dressed word. Strobe signals indicate when such an access is occurring on
a data bus.
PAB Program address bus. The PAB carries addresses for reads and
writes from program space. PAB is a 22-bit bus.
DRAB Data-read address bus. The 32-bit DRAB carries addresses for
reads from data space.
DWAB Data-write address bus. The 32-bit DWAB carries addresses for
writes to data space.
PRDB Program-read data bus. The PRDB carries instructions or data dur-
ing reads from program space. PRDB is a 32-bit bus.
DRDB Data-read data bus. The DRDB carries data during reads from data
space. PRDB is a 32-bit bus.
DWDB Data-/Program-write data bus. The 32-bit DWDB carries data during
writes to data space or program space.
Table 1−2 summarizes how these buses are used during accesses.
Table 1−2. Summary of Bus Use During Data-Space and Program-Space Accesses
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Access Type Address Bus Data Bus
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Read from program space PAB PRDB
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Read from data space DRAB DRDB
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Write to program space PAB DWDB
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Write to data space DWAB DWDB
1-10
Memory Interface
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Table 1−3. Special Bus Operations
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Instruction Special Bus Operation
ÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
PREAD This instruction reads a data value rather than an instruction from pro-
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
gram space. It then transfers that value to data space or a register.
ÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁ
For the read from program space, the CPU places the source address
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
on the program address bus (PAB), sets the appropriate program-
space select signals, and reads the data value from the program-read
ÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
data bus (PRDB).
ÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
PWRITE This instruction writes a data value to program space. The value is
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
read from from data space or a register.
ÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁ
For the write to program space, the CPU places the destination ad-
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
dress on the program address bus (PAB), sets the appropriate pro-
ÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
gram-space select signals, and writes the data value to the data-/pro-
gram-write data bus (DWDB).
ÁÁÁÁ
ÁÁÁÁ
MACÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
DMAC
As part of their operation, these instructions multiply two data values,
one of which is read from program space.
ÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
QMACL
ÁÁÁÁ
For the read from program space, the CPU places the program-space
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
IMACL
source address on the program address bus (PAB), sets the appropri-
ÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
XMAC
ate program-space select signals, and reads the program data value
XMACD
ÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
from the program read data bus (PRDB).
Most instruction fetches from program space are performed as 32-bit read op-
erations and are aligned accordingly. However, alignment of instruction
fetches are effectively invisible to a programmer. When instructions are stored
to program space, they do not have to be aligned to even addresses. Instruc-
tion boundaries are decoded within the CPU.
You need to be concerned with alignment when using instructions that perform
32-bit reads from or writes to data space.
The central processing unit (CPU) is responsible for controlling the flow of a
program and the processing of instructions. It performs arithmetic, Boolean-
logic, multiply, and shift operations. When performing signed math, the CPU
uses 2s-complement notation. This chapter describes the architecture, regis-
ters, and primary functions of the CPU.
Topic Page
2-1
CPU Architecture
- Program and data control logic. This logic stores a queue of instructions
that have been fetched from program memory.
- Atomic arithmetic logic unit (ALU). The 32-bit ALU performs 2s-com-
plement arithmetic and Boolean logic operations. Before doing its calcula-
tions, the ALU accepts data from registers, from data memory, or from the
program control logic. The ALU saves results to a register or to data
memory.
- Interrupt processing
2-2
CPU Architecture
Address
from stack
Immediate
address
Operand bus
XAR7
Immediate
data
Immediate
data
Registers
Multiplier,
XAR0 AH:AL
barrel shifter,
XAR1 PH:PL
and
XAR2 T:TL
ALU
XAR3 IER
ARAU XAR4 DBGIER
XAR5 IFR
XAR6 ST0
XAR7 PC
DP RPC
SP
ST1
Result
RESULTbus BUS
2-4
CPU Registers
SP[16]
DP[16] 6/7-bit
offset†
AR0H[16] AR0[16] XAR0[32]
PC[22]
RPC[22]
ST0[16]
ST1[16]
IER[16]
DBGIER[16]
IFR[16]
† A 6-bit offset is used when operating in C28x mode or C27x object-compatible mode.
A 7-bit offset is used when operating in C2xLP source-compatible mode. The least significant
bit of the DP is ignored when operating in this mode.
2-6
CPU Registers
compare operations from 32-bit-wide data memory. It can also accept the
32-bit result of a multiplication operation.
The halves and quarters of the ACC can also be accessed (see Figure 2−3).
ACC can be treated as two independent 16-bit registers: AH (high 16 bits) and
AL (low 16 bits). The bytes within AH and AL can also be accessed
independently. Special byte-move instructions load and store the most signifi-
cant byte or least significant byte of AH or AL. This enables efficient byte pack-
ing and unpacking.
AH AL
ACC
The accumulator has the following associated status bits. For the details on
these bits, see section 2.3, Status Register ST0.
- Overflow mode bit (OVM)
- Sign-extension mode bit (SXM)
- Test/control flag bit (TC)
- Carry bit (C)
- Zero flag bit (Z)
- Negative flag bit (N)
- Latched overflow flag bit (V)
- Overflow counter bits (OVC)
Table 2−2 shows the ways to shift the content of AH, AL, or ACC.
Rotation ROL
Rotation ROR
Logical LSR
The lower 16-bit portion of the XT register is referred to as the TL register. This
register can be loaded with a signed 16-bit value that is automatically sign-ex-
tended to fill the 32-bit XT register.
The upper 16-bit portion of the XT register is referred to as the T register. The
T register is mainly used to store a 16-bit integer value prior to a 16-bit multiply
operation.
The T register is also used to specify the shift value for some shift operations.
In this case, only a portion of the T register is used, depending on the instruc-
tion.
For example:
2-8
CPU Registers
T = XT(16:31) TL = XT(15:0)
XT
PH = P(31:16) PL = P(15:0)
When some instructions access P, PH, or PL, all 32-bits are copied to the ALU-
shifter block, where the barrel shifter may perform a left shift, a right shift, or
no shift. The action of the shifter for these instructions is determined by the
product shift mode (PM) bits in status register ST0. Table 2−3 shows the pos-
sible PM values and the corresponding product shift modes. When the barrel
shifter performs a left shift, the low order bits are filled with zeros. When the
shifter performs a right shift, the P register value is sign extended. Instructions
that use PH or PL as operands ignore the product shift mode.
For a complete list of instructions affected by PM bits, see Table 2−5 on page
2-20.
0012 No shift
2-10
CPU Registers
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
Range accessible
00000000−0000FFFF
by way of SP
- When 32-bit values are saved to the stack, the least significant 16 bits are
saved first, and the most significant 16 bits are saved to the next higher
address (little endian format).
- When 32-bit operations read or write a 32-bit value, the C28x CPU expects
the memory wrapper or peripheral-interface logic to align that read or write
to an even address. For example, if the SP contains the odd address
0000 008316, a 32-bit read operation reads from addresses 0000 008216
and 0000 008316.
- When values are being saved to the stack, the SP is not forced to align with
even or odd addresses. Alignment is forced by the memory wrapper or pe-
ripheral-interface logic.
2-12
CPU Registers
Modes, on page 5-10 . The auxiliary registers are: XAR0, XAR1, XAR2, XAR3,
XAR4, XAR5, XAR6, and XAR7.
When accessing AR0−AR7, the upper 16 bits of the register (known as AR0H−
AR7H) may or may not be modified, depending on the instruction used (see
Chapter 6 for information on the behavior of particular instructions). AR0H−
AR7H are accessed only as part of XAR0−XAR7 and are not individually ac-
cessible.
XARn(31:0)
n = number 0 through 7
For ACC operations, all 32 bits are valid (@XARn). For 16-bit operations, the
lower 16 bits are used and upper 16 bits are ignored (@ARn).
XAR0 − XAR7 can also be used by some instructions to point to any value in
program memory; see Section 5.6, Indirect Addressing Modes.
Many instructions allow you to access the 16 least significant bits (LSBs) of
XAR0−XAR7. As shown in Figure 2−9, 16 LSBs of XAR0−XAR7 are known
as one auxiliary register of AR0−AR7.
AR0 = XAR0(15:0)
XAR0(32:0)
AR7 = XAR7(15:0)
XAR7(32:0)
These registers handle interrupts at the CPU level. Devices with a peripheral
interrupt expansion (PIE) block will have additional interrupt control as part of
the PIE module.
The IFR contains flag bits for maskable interrupts (those that can be enabled
and disabled with software). When one of these flags is set, by hardware or
2-14
CPU Registers
The C28x CPU interrupts and the interrupt-control registers are described in
detail in Chapter 3, Interrupts. Also, the IFR, IER, and DBGIER are included
in Appendix A, Register Quick Reference.
15 10 9 7 6 5 4 3 2 1 0
OVC/OVCU PM V N Z C TC OVM SXM
R/W-00 0000 R/W−0 RW−0 RW−0 RW−0 RW−0 RW−0 RW−0 RW−0
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Note: R = Read access; W = Write access; value following dash (−) is value after reset.
OVC/OVCU Overflow counter. The overflow counter behaves differently for signed and unsigned op-
Bits15−10 erations.
For signed operations, the overflow counter is a 6-bit signed counter with a range of −32
to 31. When overflow mode is off (OVM = 0), ACC overflows normally, and OVC keeps
track of overflows. When overflow mode is on (OVM = 1) and an overflow occurs in ACC,
the OVC is not affected. Instead, the CPU automatically fills ACC with a positive or negative
saturation value (see the description for OVM on page 2-32).
When ACC overflows in the positive direction (from 7FFFFFFF16 to 8000000016 ), the
OVC is incremented by 1. When ACC overflows in the negative direction (from 8000000016
to 7FFFFFFF16 ) the OVC is decremented by 1. The increment or decrement is performed
as the overflow affects the V flag.
For unsigned operations (OVCU), the counter increments for ADD when a Carry is
generated and decrements for a SUB when a Borrow is generated (similar to a carry
counter).
If OVC increments past its most positive value, 31, the counter wraps around to −32. If OVC
decrements past its most negative value, −32, the counter wraps around to 31. At reset,
OVC is cleared.
OVC is not affected by overflows in registers other than ACC and is not affected by compare
instructions (CMP and CMPL). The table that follows explains how OVC may be affected
by the saturate accumulator (SAT ACC) instruction.
Table 2−4 lists the instructions affecting OVC/OVCU. See the instruction set
in Chapter 6 for a complete description of each instruction.
2-16
Status Register (ST0)
ADD loc16,#16bitSigned
ADDB ACC,#8bit
ADDCL ACC,loc32
ADDCU ACC,loc16
ADDL ACC,loc32
ADDL loc32,ACC
ADDU ACC,loc16
DMAC ACC:P,loc32,*XAR7/++
INC loc16
MAC P,loc16,*XAR7/++
MAC P,loc16,0:pma
MOVA T,loc16
MOVAD T,loc16
MPYA P,loc16,#16bit
MPYA P,T,loc16
QMACL P,loc32,*XAR7/++
QMPYAL P,XT,loc32
SQRA loc16
XMAC P,loc16,*(pma)
XMACD P,loc16,*(pma)
MOVS T,loc16
MPYS P,T,loc16
QMPYSL P,XT,loc32
SBBU ACC,loc16
SQRS loc16
SUBB ACC,#8bit
SUBBL ACC,loc32
SUBL ACC,loc32
SUBL loc32,ACC
SUBRL loc32,ACC
SUBU ACC,loc16
SUBUL ACC,loc32
SUBUL P,loc32
ADDUL P,loc32
IMPYAL P,XT,loc32
IMACL P,loc32,*XAR7/++
SAT64 ACC:P
ZAPA OVC = 0
ZAP OVC
2-18
Status Register (ST0)
OVC > 0 Saturate ACC in the positive direction (fill ACC with 7FFFFFFF16), and clear OVC.
OVC < 0 Saturate ACC in the negative direction (fill ACC with 8000000016), and clear OVC.
PM Product shift mode bits. This 3-bit value determines the shift mode for any output opera-
Bits 9−7 tion from the product (P) register. The shift modes are shown in the following table. The out-
put can be to the ALU or to memory. All instructions that are affected by the product shift
mode will sign extend the P register value during a right shift operation. At reset, PM is
cleared (left shift by 1 bit is the default).
PM is summarized as follows:
000 Left shift by 1. During the shift, the low-order bit is zero filled. At reset, this mode
is selected.
001 No shift
010 Right shift by 1. During the shift, the lower bits are lost, and the shifted value is sign
extended.
011 Right shift by 2. During the shift, the lower bits are lost, and the shifted value is sign
extended.
100 Right shift by 3. During the shift, the lower bits are lost, and the shifted value is sign
extended.
101 Right shift by 4. During the shift, the lower bits are lost, and the shifted value is sign
extended.
Note, if AMODE = 1, then 101 is a left shift by 4.
110 Right shift by 5. During the shift, the lower bits are lost, and the shifted value is sign
extended.
111 Right shift by 6. During the shift, the lower bits are lost, and the shifted value is sign
extended.
Note: For performing unsigned arithmetic, you must use a product shift of 0 (PM = 001) to avoid sign extension and genera-
tion of incorrect results.
Table 2−5 lists instructions that are affected by the PM bits. See the instruction
set in chapter 6 for a complete description of each instruction.
Instruction Effect of PM
CMPL ACC,P << PM flags set on(ACC − P << PM)
2-20
Status Register (ST0)
V Overflow flag. If the result of an operation causes an overflow in the register holding the
Bit 6 result, V is set and latched. If no overflow occurs, V is not modified. Once V is latched, it
remains set until it is cleared by reset or by a conditional branch instruction that tests V.
Such a conditional branch clears V regardless of whether the tested condition (V = 0 or
V = 1) is true.
An overflow occurs in ACC (and V is set) if the result of an addition or subtraction does not
fit within the signed numerical range −231 to (+231 − 1), or 8000000016 to 7FFFFFFF16.
An overflow occurs in AH, AL, or another 16-bit register or data-memory ___location if the result
of an addition or subtraction does not fit within the signed numerical range −215 to (+215 −
1), or 800016 to 7FFF16.
The instructions CMP, CMPB and CMPL do not affect the state of the V flag. Table 2−6 lists
the instructions that are affected by V flag. See Chapter 6 for more details on instructions.
B 16bitOff,COND V = 0 if tested
BF 16bitOff,COND V = 0 if tested
2-22
Status Register (ST0)
SB 8bitOff,COND V = 0 if tested
XB pma,COND V = 0 if tested
N Negative flag. During certain operations, N is set if the result of the operation is a negative
Bit 5 number or cleared if the result is a positive number. At reset, N is cleared.
Results in ACC are tested for the negative condition. Bit 31 of ACC is the sign bit. If bit 31
is a 0, ACC is positive; if bit 31 is a 1, ACC is negative. N is set if a result in ACC is negative
or cleared if a result is positive.
Results in AH, AL, and other 16-bit registers or data-memory locations are also tested for
the negative condition. In these cases bit 15 of the value is the sign bit (1 indicates negative,
0 indicates positive). N is set if the value is negative or cleared if the value is positive.
The TEST ACC instruction sets N if the value in ACC is negative. Otherwise the instruction
clears N.
As shown in Table 2−7, under overflow conditions, the way the N flag is set for compare
operations is different from the way it is set for addition or subtraction operations. For addi-
tion or subtraction operations, the N flag is set to match the most significant bit of the trun-
cated result. For compare operations, the N flag assumes infinite precision. This applies
to operations whose result is loaded to ACC, AH, AL, another register, or a data-memory
___location.
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Á ÁÁÁÁÁÁÁ
Table 2−7. Negative Flag Under Overflow Conditions
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
A† B†
Á ÁÁÁÁÁÁÁ (A − B)
Neg
Subtraction Compare‡
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Pos
Neg Pos (due to overflow in negative direction) N=0 N=1
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
† For 32-bit data: Pos = Positive number from 0000000016 to 7FFFFFFF16
Neg = Negative number from 8000000016 to FFFFFFFF16
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
For 16-bit data: Pos = Positive number from 000016 to 7FFF16
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Neg = Negative number from 800016 to FFFF16
‡ The compare instructions are CMP, CMPB, CMPL, MIN, MAX, MINL, and MAXL.
2-24
Status Register (ST0)
Z Zero flag. Z is set if the result of certain operations is 0 or is cleared if the result is nonzero.
Bit 4 This applies to results that are loaded into ACC, AH, AL, another register, or a data-memory
___location. At reset, Z is cleared.
The TEST ACC instruction sets Z if the value in ACC is 0. Otherwise, it clears Z.
C Carry bit. This bit indicates when an addition or increment generates a carry or when a sub-
Bit 3 traction, compare, or decrement generates a borrow. It is also affected by rotate operations
on ACC and barrel shifts on ACC, AH, and AL.
This bit can be individually set and cleared by the SETC C instruction and CLRC C instruc-
tion, respectively. At reset, C is cleared.
Table 2−8 lists the bits that are affected by the C bit. For more information on
instructions, see Chapter 6.
CLRC C C=0
2-26
Status Register (ST0)
NEG AX if(AX == 0) C = 1
else C = 0
2-28
Status Register (ST0)
SETC C C=1
TC Test/control flag. This bit shows the result of a test performed by either the TBIT (test bit)
Bit 2 instruction or the NORM (normalize) instruction.
The TBIT instruction tests a specified bit. When TBIT is executed, the TC bit is set if the
tested bit is 1 or cleared if the tested bit is 0.
This bit can be individually set and cleared by the SETC TC instruction and CLRC TC
instruction, respectively. At reset, TC is cleared.
Table 2−9 lists the instructions that affect the TC bit. See the instruction set in
Chapter 6 for a complete description of each instruction.
2-30
Status Register (ST0)
CLRC TC TC = 0
CMPR 0/1/2/3 TC = 0
0: if(AR(ARP) == AR0) TC = 1
1: if(AR(ARP) < AR0) TC = 1
2: if(AR(ARP) > AR0) TC = 1
3: if(AR(ARP) != AR0) TC = 1
SETC TC TC = 1
OVM Overflow mode bit. When ACC accepts the result of an addition or subtraction and the
Bit 1 result causes an overflow, OVM determines how the CPU handles the overflow as fol-
lows:.
0 Results overflow normally in ACC. The OVC reflects the overflow (see the de-
scription for the OVC on page 2-16)
1 ACC is filled with either its most positive or most negative value as follows:
If ACC overflows in the positive direction (from 7FFFFFFF16 to 8000000016 ),
ACC is then filled with 7FFFFFFF16.
If ACC overflows in the negative direction (from 8000000016 to 7FFFFFFF16 ),
ACC is then filled with 8000000016.
This bit can be individually set and cleared by the SETC OVM instruction and
CLRC OVM instruction, respectively. At reset, OVM is cleared.
SXM Sign-extension mode bit. SXM affects the MOV, ADD, and SUB instructions that use a
Bit 0 16-bit value in an operation on the 32-bit accumulator. When the 16-bit value is loaded
into (MOV), added to (ADD), or subtracted from (SUB) the accumulator, SXM deter-
mines whether the 16-bit value is sign extended during the operation as follows:
For example:
ADD ACC, loc16 << shift
if SXM = 0, do not sign extend loc16 before adding to the 32-bit ACC.
if SXM = 1, sign extend loc16 before adding to the 32-bit ACC.
SXM also determines whether the accumulator is sign extended when it is shifted right
by the SFR instruction. SXM does not affect instructions that shift the product register
value; all right shifts of the product register value use sign extension.
This bit can be individually set and cleared by the SETC SXM instruction and
CLRC SXM instruction, respectively. At reset, SXM is cleared. Table 2−10 lists the in-
structions that are affected by SXM. See Chapter 6 for more details on instructions.
2-32
Status Register (ST0)
Instruction Description
7 6 5 4 3 2 1 0
IDLESTAT EALLOW LOOP SPA VMAP PAGE0 DBGM INTM
R−0 R/W−0 R−0 R/W−0 R/W−1 R/W−0 R/W−1 R/W−1
ARP Auxiliary register pointer. This 3-bit field points to the current auxiliary register. This is one
Bits 15−13 of the 32-bit auxiliary registers (XAR0−XAR7). The mapping of ARP values to auxiliary reg-
isters is as follows:
001 XAR1
010 XAR2
011 XAR3
100 XAR4
101 XAR5
110 XAR6
111 XAR7
XF XF status bit. This bit reflects the current state of the XFS output signal, which is com-
Bit 12 patible to the C2XLP CPU. This bit is set by the ”SETC XF” instruction. This bit is
cleared by the ”CLRC XF” instruction. The pipeline is not flushed when setting or clear-
ing this bit using the given instructions. This bit can be saved and restored by interrupts
and when restoring the ST1 register. This bit is set to 0 on reset.
M0M1MAP M0 and M1 mapping mode bit. The M0M1MAP bit should always remain set to 1 in
Bit 11 the C28x object mode. This is the default value at reset. The M0M1MAP bit may be set
low when operating in C27x-compatible mode. The effect of this bit, when low, is to
swap the ___location of blocks M0 and M1 only in program space and to set the stack
pointer default reset value to 0x000. C28x mode users should never set this bit to 0.
2-34
Status Register ST1
Reserved Reserved. This bit is reserved. Writes to this bit have no effect.
Bit 10
OBJMODE Object compatibility mode bit. This mode is used to select between C27x object
Bit 9 mode (OBJMODE == 0) and C28x object mode (OBJMODE == 1) compatibility. This bit
is set by the ”C28OBJ” (or ”SETC OBJMODE”) instructions. This bit is cleared by the
”C27OBJ” (or ”CLRC OBJMODE”) instructions. The pipeline is flushed when setting or
clearing this bit using the given instructions. This bit is saved and restored by interrupts
and when restoring the ST1 register. This bit is set to 0 on reset.
AMODE Address mode bit. This mode, in conjunction with the PAGE0 mode bit, is used to se-
Bit 8 lect the appropriate addressing mode decodes. This bit is set by the “LPADDR” (”SETC
AMODE”) instructions. This bit is cleared by the ”C28ADDR” (or ”CLRC AMODE”) in-
structions. The pipeline is not flushed when setting or clearing this bit using the given
instructions. This bit is saved and restored by interrupts and when restoring the ST1
register. This bit is set to 0 on reset.
Note: Setting PAGE0 = AMODE = 1 will generate an illegal instruction trap ONLY for
instructions that decode a memory or register addressing mode field (loc16 or loc32).
IDLESTAT IDLE status bit. This read-only bit is set when the IDLE instruction is executed. It is
Bit 7 cleared by any one of the following events:
- An interrupt is serviced.
- An interrupt is not serviced but takes the CPU out of the IDLE state.
- A valid instruction enters the instruction register (the register that holds the instruction
currently being decoded).
When the CPU services an interrupt, the current value of IDLESTAT is saved on the
stack (when ST1 is saved on the stack), and then IDLESTAT is cleared. Upon return
from the interrupt, IDLESTAT is not restored from the stack.
EALLOW Emulation access enable bit. This bit, when set, enables access to emulation and
Bit 6 other protected registers. Set this bit by using the EALLOW instruction and clear this bit
by using the EDIS instruction. See the data sheet for a particular device to determine
the registers that are protected.
When the CPU services an interrupt, the current value of EALLOW is saved on the
stack (when ST1 is saved on the stack), and then EALLOW is cleared. Therefore, at the
start of an interrupt service routine (ISR), access to protected registers is disabled. If the
ISR must access protected registers, it must include an EALLOW instruction. At the end
of the ISR, EALLOW can be restored by the IRET instruction.
LOOP Loop instruction status bit. LOOP is set when a loop instruction (LOOPNZ or
Bit 5 LOOPZ) reaches the decode 2 phase of the pipeline. The loop instruction does not end
until a specified condition is met. When the condition is met, LOOP is cleared. LOOP is
a read-only bit; it is not affected by any instruction except a loop instruction.
When the CPU services an interrupt, the current value of LOOP is saved on the stack
(when ST1 is saved on the stack), and then LOOP is cleared. Upon return from the in-
terrupt, LOOP is not restored from the stack.
SPA Stack pointer alignment bit. SPA indicates whether the CPU has previously aligned
Bits 4 the stack pointer to an even address by the ASP instruction:
0 The stack pointer has not been aligned to an even address.
1 The stack pointer has been aligned to an even address.
When the ASP (align stack pointer) instruction is executed, if the stack pointer (SP)
points to an odd address, SP is incremented by 1 so that it points to an even address,
and SPA is set. If SP already points to an even address, SP is not changed, but SPA is
cleared. When the NASP (unalign stack pointer) instruction is executed, if SPA is 1, SP
is decremented by 1 and SPA is cleared. If SPA is 0, SP is not changed.
At reset, SPA is cleared.
VMAP Vector map bit. VMAP determines whether the CPU interrupt vectors (including the
Bit 3 reset vector) are mapped to the lowest or highest addresses in program memory:
0 CPU interrupt vectors are mapped to the bottom of program memory, addresses
00 000016−00 003F16.
1 CPU interrupt vectors are mapped to the top of program memory, addresses
3F FFC016−3F FFFF16.
On C28x designs, the VMAP signal is tied high internally, forcing the VMAP bit to be set
high on a reset.
This bit can be individually set and cleared by the SETC VMAP instruction and
CLRC VMAP instruction, respectively.
PAGE0 PAGE0 addressing mode configuration bit. PAGE0 selects between two mutually-ex-
Bit 2 clusive addressing modes: PAGE0 direct addressing mode and PAGE0 stack addres-
sing mode. Selection of the modes is as follows:
0 PAGE0 stack addressing mode
1 PAGE0 direct addressing mode
PAGE0 = 1 is included for compatibility with the C27x. the recommended operating
mode for C28x is PAGE0 = 0.
This bit can be individually set and cleared by the SETC PAGE0 instruction and
CLRC PAGE0 instruction, respectively. At reset, the PAGE0 bit is cleared (PAGE0 stack
addressing mode is selected).
For details about the above addressing modes, see Chapter 5, Addressing Modes.
2-36
Status Register ST1
DBGM Debug enable mask bit. When DBGM is set, the emulator cannot accesss memory or
Bit 1 registers in real time. The debugger cannot update its windows.
In the real-time emulation mode, if DBGM = 1, the CPU ignores halt requests or hard-
ware breakpoints until DBGM is cleared. DBGM does not prevent the CPU from halting
at a software breakpoint. One effect of this may be seen in real-time emulation mode.
If you single-step an instruction in real time emulation mode and that instruction sets
DBGM, the CPU continues to execute instructions until DBGM is cleared.
When you give the TI debugger the REALTIME command (to enter real-time mode),
DBGM is forced to 0. Having DBGM = 0 ensures that debug and test direct memory
accesses (DT-DMAs) are allowed; memory and register values can be passed to the
host processor for updating debugger windows.
Before the CPU executes an interrupt service routine (ISR), it sets DBGM. When
DBGM = 1, halt requests from the host processor and hardware breakpoints are ig-
nored. If you want to single-step through or set breakpoints in a non-time-critical ISR,
you must add a CLRC DBGM instruction at the beginning of the ISR.
DBGM is primarily used in emulation to block debug events in time-critical portions of
program code. DBGM enables or disables debug events as follows:
When the CPU services an interrupt, the current value of DBGM is saved on the stack
(when ST1 is saved on the stack), and then DBGM is set. Upon return from the inter-
rupt, DBGM is restored from the stack.
This bit can be individually set and cleared by the SETC DBGM instruction and
CLRC DBGM instruction, respectively. DBGM is also set automatically during interrupt
operations. At reset, DBGM is set. Executing the ABORTI (abort interrupt) instruction
also sets DBGM.
INTM Interrupt global mask bit. This bit globally enables or disables all maskable CPU inter-
Bit 0 rupts (those that can be blocked by software):
INTM has no effect on the nonmaskable interrupts, including a hardware reset or the
hardware interrupt NMI. In addition, when the CPU is halted in real-time emulation
mode, an interrupt enabled by the IER and the DBGIER will be serviced even if INTM is
set to disable maskable interrupts.
When the CPU services an interrupt, the current value of INTM is saved on the stack
(when ST1 is saved on the stack), and then INTM is set. Upon return from the interrupt,
INTM is restored from the stack.
This bit can be individually set and cleared by the SETC INTM instruction and
CLRC INTM instruction, respectively. At reset, INTM is set. The value in INTM does not
cause modification to the interrupt flag register (IFR), the interrupt enable register (IER),
or the debug interrupt enable register (DBGIER).
2-38
Program Flow
Proper program flow also requires smooth flow at the instruction level. To meet
this need, the ’28x has a protected pipeline and an instruction-fetch mecha-
nism that attempts to keep the pipeline full.
2.5.1 Interrupts
Interrupts are hardware- or software-driven events that cause the CPU to sus-
pend its current program sequence and execute a subroutine called an inter-
rupt service routine. Interrupts are described in detail in Chapter 3.
The following branch instructions are conditional: B, BANZ, BAR, BF, SB, SBF,
XBANZ, XCALL, and XRETC. They are executed only if a certain specified or
predefined condition is met. For detailed descriptions of these instructions,
see Chapter 6, Assembly Language Instructions.
The pipeline and the instruction-fetch mechanism are described in more detail
in Chapter 4, Pipeline.
2-40
Multiply Operations
- One input is from the upper 16 bits of the multiplicand register (T). Most
16 X 16 multiplication instructions require that you load T from a data-
memory ___location or a register before you execute the instruction. Howev-
er, the MAC and some versions of the MPY and MPYA instructions load
T for you before the multiplication.
After the value has been multiplied by the second value, the 32-bit result is
stored in one of two places, depending on the particular multiply instruction:
the 32-bit product register (P) or the 32-bit accumulator (ACC).
One special 16-bit X 16-bit multiplication instruction takes two 32-bit input val-
ues as its operands. This instruction is the 16 X 16 DMAC instruction, which
performs dual 16 X 16 MAC operations in one instruction. In this case, the ACC
contains the result of multiplying and adding the upper word of the 32-bit oper-
ands. The P register contains the result of multiplying and adding the results
of the lower word of the 32-bit operands.
16 16 16
T MUX
16 16
Multiplier
32
MUX
32 32
P ACC
After the two values have ben multiplied, 32 bits of the 64-bit result are stored
in the product register (P). You can control which half is stored (upper 32 bits
or lower 32 Bits) and whether the multiplication is signed or unsigned by the
instruction used.
2-42
Multiply Operations
If you need support for larger data values, the 32 X 32 multiplication instruc-
tions can be combined to implement 32 X 32 = 64-bit or 64 X 64 = 128-bit math.
XT
From
program
memory
32 32
From data
MUX memory or register
32 32
Multiplier
upper 32 lower 32
MUX
32
P
When a value is shifted right by an amount N, the N LSBs of the value are lost
and the bits to the left of the value are filled with all 0s or all 1s. If sign extension
is specified, the bits to the left are filled with copies of the sign bit. If sign exten-
sion is not specified, the bits to the left are filled with 0s, or zero filled.
When a value is shifted left by an amount N, the bits to the right of the shifted
value are zero filled. If the value has 16 bits and sign extension is specified,
the bits to the left are filled with copies of the sign bit. If the value has 16 bits
and sign extension is not specified, the bits to the left are zero filled. If the value
has 32 bits, the N MSBs of the value are lost, and sign extension is irrelevant.
Table 2−11 lists the instructions that use the shifter and provides an illustration
of the corresponding shifter operation. The table uses the following graphical
symbols:
2-44
Shift Operations
16 LSBs to ALU
32 bits to ACC
2-46
Shift Operations
32 bits to ACC
MOVP T, loc
MOVS T, loc For PM from 2−7: P
2-48
Shift Operations
16 LSBs to ALU
For PM = 1: No shift
16 LSBs to ALU
16 LSBs to ALU
For PM = 1: No shift
16 LSBs to ALU
2-50
Chapter 3
This chapter describes the available CPU interrupts and how they are handled
by the CPU. It also explains how to control those interrupts that can be con-
trolled through software. Finally, it describes how a hardware reset affects the
CPU.
Topic Page
3-1
CPU Interrupts Overview
3-2
CPU Interrupts Overview
- Fetch the interrupt vector and load it into the program counter (PC).
For devices with a PIE module, the vector fetched will depend on the
setting of the PIE enable and flag registers.
4) Execute the interrupt service routine. The C28x branches to its corre-
sponding subroutine called an interrupt service routine (ISR). The C28x
branches to the address (vector) you store at a predetermined vector loca-
tion and executes the ISR you have written.
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Table 3−1. Interrupt Vectors and Priorities
ÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Absolute Address (hexadecimal)
Hardware
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Vector VMAP = 0 VMAP = 1† Priority Description
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
RESET 00 0000 3F FFC0 1 (highest) Reset
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT1 00 0002 3F FFC2 5 Maskable interrupt 1
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT2 00 0004 3F FFC4 6 Maskable interrupt 2
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT3 00 0006 3F FFC6 7 Maskable interrupt 3
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT4 00 0008 3F FFC8 8 Maskable interrupt 4
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT5 00 000A 3F FFCA 9 Maskable interrupt 5
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT6 00 000C 3F FFCC 10 Maskable interrupt 6
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT7 00 000E 3F FFCE 11 Maskable interrupt 7
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT8 00 0010 3F FFD0 12 Maskable interrupt 8
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT9 00 0012 3F FFD2 13 Maskable interrupt 9
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT10 00 0014 3F FFD4 14 Maskable interrupt 10
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT11 00 0016 3F FFD6 15 Maskable interrupt 11
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT12 00 0018 3F FFD8 16 Maskable interrupt 12
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT13 00 001A 3F FFDA 17 Maskable interrupt 13
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT14 00 001C 3F FFDC 18 Maskable interrupt 14
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
† For C28x catalog devices, VMAP = 1 at reset.
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
‡ Interrupts DLOGINT and RTOSINT are generated by the emulation logic internal to the CPU.
3-4
CPU Interrupt Vectors and Priorities
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Table 3−1. Interrupt Vectors and Priorities (Continued)
ÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Absolute Address (hexadecimal)
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Hardware
Vector VMAP = 0 VMAP = 1† Priority Description
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
DLOGINT‡ 00 001E 3F FFDE 19 (lowest) Maskable data log interrupt
ÁÁÁÁÁÁÁÁÁÁÁ
RTOSINT‡
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
00 0020 3F FFE0 4 Maskable real-time operating
system interrupt
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Reserved 00 0022 3F FFE2 2 Reserved
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
NMI 00 0024 3F FFE4 3 Nonmaskable interrupt
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ILLEGAL 00 0026 3F FFE6 − Illegal-instruction trap
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
USER1 00 0028 3F FFE8 − User-defined software interrupt
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
USER2 00 002A 3F FFEA − User-defined software interrupt
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
USER3 00 002C 3F FFEC − User-defined software interrupt
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
USER4 00 002E 3F FFEE − User-defined software interrupt
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
USER5 00 0030 3F FFF0 − User-defined software interrupt
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
USER6 00 0032 3F FFF2 − User-defined software interrupt
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
USER7 00 0034 3F FFF4 − User-defined software interrupt
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
USER8 00 0036 3F FFF6 − User-defined software interrupt
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
USER9 00 0038 3F FFF8 − User-defined software interrupt
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
USER10 00 003A 3F FFFA − User-defined software interrupt
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
USER11 00 003C 3F FFFC − User-defined software interrupt
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
USER12 00 003E 3F FFFE − User-defined software interrupt
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
†
‡
For C28x catalog devices, VMAP = 1 at reset.
Interrupts DLOGINT and RTOSINT are generated by the emulation logic internal to the CPU.
The vector table can be mapped to the top or bottom of program space, de-
pending on the value of the vector map bit (VMAP) in status register ST1. (ST1
is described in section 2.4 on page 2-34.) If the VMAP bit is 0, the vectors are
mapped beginning at address 00 000016. If the VMAP bit is 1, the vectors are
mapped beginning at address 3F FFC016. Table 3−1 lists the absolute ad-
dresses for VMAP = 0 and VMAP = 1.
The VMAP bit can be set by the SETC VMAP instruction and cleared by the
CLRC VMAP instruction. The reset value of VMAP is 1.
The 16-bit IFR contains flag bits that indicate which of the corresponding inter-
rupts are pending (waiting for approval from the CPU). The external input lines
INT1−INT14 are sampled at every CPU clock cycle. If an interrupt signal is rec-
ognized, the corresponding bit in the IFR is set and latched. For DLOGINT or
RTOSINT, a signal sent by the CPU on-chip analysis logic causes the corre-
sponding flag bit to be set and latched. You can set one or more of the IFR bits
at the same time by using the OR IFR instruction. More details about the IFR
are given in section 3.3.1. The on-chip analysis resources are introduced in
Chapter 7.
The interrupt enable register (IER) and the debug interrupt enable register
(DBGIER) each contain bits for individually enabling or disabling the maskable
interrupts. To enable one of the interrupts in the IER, you set the corresponding
bit in the IER; to enable the same interrupt in the DBGIER, you set the corre-
sponding bit in the DBGIER. The DBGIER indicates which interrupts can be
serviced when the CPU is in the real-time emulation mode. The IER and the
DBGIER are discussed more in section 3.3.2. Real-time mode is discussed in
section 7.4.2 on page 7-9.
The maskable interrupts also share bit 0 in status register ST1. This bit, the
interrupt global mask bit (INTM), is used to globally enable or globally disable
these interrupts. When INTM = 0, these interrupts are globally enabled. When
INTM = 1, these interrupts are globally disabled. You can set and clear INTM
with the SETC INTM and CLRC INTM instructions, respectively. ST1 is de-
scribed in section 2.4 on page 2-34.
After a flag has been latched in the IFR, the corresponding interrupt is not serv-
iced until it is appropriately enabled by two of the following: the IER, the
DBGIER, and the INTM bit. As shown in Table 3−2, the requirements for enab-
ling the maskable interrupts depend on the interrupt-handling process used.
In the standard process, which occurs in most circumstances, the DBGIER is
ignored. When the C28x is in real-time emulation mode and the CPU is halted,
a different process is used. In this special case, the DBGIER is used and the
INTM bit is ignored. (If the DSP is in real-time mode and the CPU is running,
the standard interrupt-handling process applies.)
3-6
Maskable Interrupts: INT1−INT14, DLOGINT, and RTOSINT
Once an interrupt has been requested and properly enabled, the CPU pre-
pares for and then executes the corresponding interrupt service routine. For
a detailed description of this process, see section 3.4.
DSP in real-time mode and CPU halted Bit in IER is 1 and bit in DBGIER is 1
Notes:
When an interrupt is requested by the TRAP instruction, if the corresponding
IFR bit is set, the CPU does not clear it automatically. If an application re-
quires that the IFR bit be cleared, the bit must be cleared in the interrupt ser-
vice routine.
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Figure 3−1. Interrupt Flag Register (IFR)
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
15 14 13 12 11 10 9 8
Á
ÁÁÁÁÁ ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
RTOSINT DLOGINT INT14 INT13 INT12 INT11 INT10 INT9
Á
ÁÁÁÁÁ ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0
Á
ÁÁÁÁÁ ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
7 6 5 4 3 2 1 0
Á
ÁÁÁÁÁ ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT8 INT7 INT6 INT5 INT4 INT3 INT2 INT1
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0
Á
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Note:
ÁÁ
R = Read access; W = Write access; value following dash (−) is value after reset.
Bits 15 and 14 of the IFR correspond to the interrupts RTOSINT and DLOGINT:
Note:
When an interrupt is requested by the TRAP instruction, if the corresponding
IER bit is set, the CPU does not clear it automatically. If an application re-
quires that the IER bit be cleared, the bit must be cleared in the interrupt ser-
vice routine.
3-8
Maskable Interrupts: INT1−INT14, DLOGINT, and RTOSINT
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Figure 3−2. Interrupt Enable Register (IER)
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
15 14 13 12 11 10 9 8
Á
ÁÁÁÁÁ ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
RTOSINT DLOGINT INT14 INT13 INT12 INT11 INT10 INT9
Á
ÁÁÁÁÁ ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0
Á
ÁÁÁÁÁ ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
7 6 5 4 3 2 1 0
Á
ÁÁÁÁÁ ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT8 INT7 INT6 INT5 INT4 INT3 INT2 INT1
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0
Á
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ ÁÁ
Note: R = Read access; W = Write access; value following dash (−) is value after reset.
Note:
When using the AND IER and OR IER instructions, make sure that they do
not modify the state of bit 15 (RTOSINT) unless a real-time operating system
is present.
Bits 15 and 14 of the IER enable or disable the interrupts RTOSINT and
DLOGINT:
Figure 3−3 shows the DBGIER, which is used only when the CPU is halted in
real-time emulation mode. An interrupt enabled in the DBGIER is defined as
a time-critical interrupt. When the CPU is halted in real-time mode, the only in-
terrupts that are serviced are time-critical interrupts that are also enabled in
the IER. If the CPU is running in real-time emulation mode, the standard inter-
rupt-handling process is used and the DBGIER is ignored.
As with the IER, you can read the DBGIER to identify enabled or disabled inter-
rupts and write to the DBGIER to enable or disable interrupts. To enable an
interrupt, set its corresponding bit to 1. To disable an interrupt, set its corre-
sponding bit to 0. Use the PUSH DBGIER instruction to read from the DBGIER
and the POP DBGIER instruction to write to the DBGIER. At reset, all the
DBGIER bits are set to 0.
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Figure 3−3. Debug Interrupt Enable Register (DBGIER)
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁ ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
15 14 13 12 11 10 9 8
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
RTOSINT DLOGINT INT14 INT13 INT12 INT11 INT10 INT9
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
7 6 5 4 3 2 1 0
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
INT8 INT7 INT6 INT5 INT4 INT3 INT2 INT1
ÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0
Note: R = Read access; W = Write access; value following dash (−) is value after reset.
Bits 15 and 14 of the DBGIER enable or disable the interrupts RTOSINT and
DLOGINT:
3-10
Standard Operation for Maskable Interrupts
No
Interrupt enabled in
IER?
Yes
No
Interrupt enabled by
INTM bit?
Yes
Empty pipeline.
Program continues
3-12
Standard Operation for Maskable Interrupts
- The CPU emulation logic sends to the CPU a signal for DLOGINT or
RTOSINT.
2) Set corresponding IFR flag bit. When the CPU detects a valid interrupt
in step 1, it sets and latches the corresponding flag in the interrupt flag reg-
ister (IFR). This flag stays latched even if the interrupt is not approved by
the CPU in step 3. The IFR is explained in detail in section 3.3.1.
Once an interrupt has been enabled and then approved by the CPU, no
other interrupts can be serviced until the CPU has begun executing the in-
terrupt service routine for the approved interrupt (step 13). The IER is de-
scribed in section 3.3.2. ST1 is described in section 2.4 on page 2-34.
5) Empty the pipeline. The CPU completes any instructions that have
reached or passed their decode 2 phase in the instruction pipeline. Any
instructions that have not reached this phase are flushed from the pipeline.
7) Fetch interrupt vector. The PC is filled with the address of the appropri-
ate interrupt vector, and the vector is fetched from that ___location. To
determine which vector address has been assigned to each of the inter-
rupts, see section 3.2, Interrupt Vectors, on page 3-4 or, if your device
uses a PIE module, see the System and Interrupts Reference Guide for
your specific device.
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
is not affected by this alignment.
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Table 3−3. Register Pairs Saved and SP Positions for Context Saves
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Bit 0 of Storage Address
Save Register
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Operation† Pairs SP Starts at Odd Address SP Starts at Even Address
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
1st ST0
1 ← SP position before step 8
0
1
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
T 1 1
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
2nd AL 0 0
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
3rd
AH
PL‡
1
0
1
PH 1 1
4th AR0 0 0
AR1 1 1
5th ST1 0 0
DP 1 1
3-14
Standard Operation for Maskable Interrupts
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Table 3−3. Register Pairs Saved and SP Positions for Context Saves (Continued)
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ Bit 0 of Storage Address
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Save Register
Operation† Pairs SP Starts at Odd Address SP Starts at Even Address
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
6th IER 0 0
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
DBGSTAT§ 1 1
Return address 1 1
(high half)
10) Clear corresponding IER bit. After the IER register is saved on the stack
in step 9, the CPU clears the IER bit that corresponds to the interrupt being
handled. This prevents reentry into the same interrupt. If you want to nest
occurrences of the interrupt, have the ISR set that IER bit again.
11) Set INTM and DBGM. Clear LOOP, EALLOW, and IDLESTAT. All these
bits are in status register ST1. By setting INTM to 1, the CPU prevents
maskable interrupts from disturbing the ISR. If you wish to nest interrupts,
have the ISR clear the INTM bit. By setting DBGM to 1, the CPU prevents
debug events from disturbing time-critical code in the ISR. If you do not
want debug events blocked, have the ISR clear DBGM.
The CPU clears LOOP, EALLOW, and IDLESTAT so that the ISR operates
within a new context.
12) Load PC with fetched vector. The PC is loaded with the interrupt vector
that was fetched in step 7. The vector forces program control to the ISR.
13) Execute interrupt service routine. Here is where the CPU executes the
program code you have prepared to handle the interrupt. A typical ISR is
shown in Example 3−1.
Although a number of register values are saved automatically in step 10, if
the ISR uses other registers, you may need to save the contents of these
registers at the beginning of the ISR. These values must then be restored
before the return from the ISR. The ISR in Example 3−1 saves and re-
stores auxiliary registers AR1H:AR0H, XAR2−XAR7, and the temporary
register XT.
If you want the ISR to inform a peripheral that the interrupt is being serv-
iced, you can use the IACK instruction to send an interrupt acknowledge
signal. The IACK instruction accepts a 16-bit constant as an operand. For
a detailed description of the IACK instruction, see Chapter 6, C28x As-
sembly Language Instructions.
14) Program continues. If the interrupt is not approved by the CPU, the inter-
rupt is ignored, and the program continues uninterrupted. If the interrupt
is approved, its interrupt service routine is executed and the program con-
tinues where it left off (at the return address).
INTX: ; 8 cycles
PUSH AR1H:AR0H ; 32-bit
PUSH XAR2 ; 32-bit
PUSH XAR3 ; 32-bit
PUSH XAR4 ; 32-bit
PUSH XAR5 ; 32-bit
PUSH XAR6 ; 32-bit
PUSH XAR7 ; 32-bit
PUSH XT ; 32-bit
; +8 = 16 cycles
.
.
.
POP XT
POP XAR7
POP XAR6
POP XAR5
POP XAR4
POP XAR3
POP XAR2
POP XAR1H:AR0H
IRET
; 16 cycles
3-16
Nonmaskable Interrupts
The software interrupt instructions and NMI are described in this section. The
illegal-instruction trap and reset are described in sections 3.6 and 3.7, respec-
tively.
Note:
The TRAP #0 instruction does not initiate a full reset. It only forces execution
of the interrupt service routine that corresponds to the RESET interrupt vec-
tor.
Figure 3−5. Functional Flow Chart for an Interrupt Initiated by the TRAP Instruction
Increment SP by 1.
This sequence
protected from
Perform automatic context save. interrupts
Program continues
3-18
Nonmaskable Interrupts
1) TRAP instruction fetched. The CPU fetches the TRAP instruction from
program memory. The desired interrupt vector has been specified as an
operand and is now encoded in the instruction word. At this stage, no other
interrupts can be serviced until the CPU begins executing the interrupt ser-
vice routine (step 9).
2) Empty the pipeline. The CPU completes any instructions that have
reached or passed the decode 2 phase of the pipeline. Any instructions
that have not reached this phase are flushed from the pipeline.
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Table 3−4. Register Pairs Saved and SP Positions for Context Saves
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ Bit 0 of Storage Address
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Save Register
Operation† Pairs SP Starts at Odd Address SP Starts at Even Address
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
1st ST0
1 ← SP position before step 5
0
1
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
T 1 1
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
2nd AL 0 0
ÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁ
3rd
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁ
AH
ÁÁÁÁÁÁÁÁÁÁ
PL‡
1
0
1
PH 1 1
4th AR0 0 0
AR1 1 1
5th ST1 0 0
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
DP 1 1
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
6th IER 0 0
ÁÁÁÁÁÁÁÁÁÁÁÁ
7th
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
DBGSTAT§
Return address
1
0
1
0
(low half)
Return address 1 1
(high half)
7) Set INTM and DBGM. Clear LOOP, EALLOW, and IDLESTAT. All these
bits are in status register ST1 (described in section 2.4 on page 2-34). By
setting INTM to 1, the CPU prevents maskable interrupts from disturbing
the ISR. If you wish to nest interrupts, have the ISR clear the INTM bit. By
setting DBGM to 1, the CPU prevents debug events from disturbing time-
critical code in the ISR. If you do not want debug events blocked, have the
ISR clear DBGM.
3-20
Nonmaskable Interrupts
The CPU clears LOOP, EALLOW, and IDLESTAT so that the ISR operates
within a new context.
8) Load PC with fetched vector. The PC is loaded with the interrupt vector
that was fetched in step 4. The vector forces program control to the ISR.
9) Execute interrupt service routine. The CPU executes the program code
you have prepared to handle the interrupt. You may wish to have the inter-
rupt service routine (ISR) save register values in addition to those saved
in step 6. A typical ISR is shown in Example 3−1 on page 3-16.
If you want the ISR to inform external hardware that the interrupt is being
serviced, you can use the IACK instruction to send an interrupt acknowl-
edge signal. The IACK instruction accepts a 16-bit constant as an operand
and drives this 16-bit value on the 16 least significant lines of the data-write
bus, DWDB(15:0). For a detailed description of the IACK instruction, see
Chapter 6, C28x Assembly Language Instructions.
10) Program continues. After the interrupt service routine is completed, the
program continues where it left off (at the return address).
3-22
Hardware Reset (RS)
When asserted, the reset input signal (RS) places the CPU into a known state.
As part of a hardware reset, all current operations are aborted, the pipeline is
flushed, and the CPU registers are reset as shown in Table 3−5. Then the
RESET interrupt vector is fetched and the corresponding interrupt service rou-
tine is executed. For the reset condition of signals, see the data sheet for your
particular C28x DSP. Also see the your data sheet for specific information on
the process for resetting your DSP. Although RS cannot be masked, there are
some debug execution states in which RS is not serviced (see section 7.4,
Execution Control Modes, on page 7-7).
Note: The registers listed in this table are introduced in section 2.2, CPU Registers, on page
2-4.
P all 0000000016
2: TC 0
3: C 0
4: Z 0
5: N 0
6: V 0
Note: The registers listed in this table are introduced in section 2.2, CPU Registers, on page
2-4.
3-24
Hardware Reset (RS)
4: SPA 0
5: LOOP 0
7: IDLESTAT 0
10: Reserved 0
11: M0M1MAP 1
Note: The registers listed in this table are introduced in section 2.2, CPU Registers, on page
2-4.
Note: The registers listed in this table are introduced in section 2.2, CPU Registers, on page
2-4.
3-26
Chapter 4
Pipeline
This chapter explains the operation of the C28x instruction pipeline. The pipe-
line contains hardware that prevents reads and writes at the same register or
data-memory ___location from happening out of order. However, you can in-
crease the efficiency of your programs if you take into account the operation
of the pipeline. In addition, you should be aware of two types of pipeline con-
flicts the pipeline does not protect against and how you can avoid them (see
section 4.5).
Topic Page
4-1
Pipelining of Instructions
Fetch 1 In the fetch 1 (F1) phase, the CPU drives a program-memory ad-
(F1) dress on the 22-bit program address bus, PAB(21:0).
Fetch 2 In the fetch 2 (F2) phase, the CPU reads from program memory
(F2) by way of the program-read data bus, PRDB (31:0), and loads
the instruction(s) into an instruction-fetch queue.
Decode 1 The C28x supports both 32-bit and 16-bit instructions and an
(D1) instruction can be aligned to an even or odd address. The
decode 1 (D1) hardware identifies instruction boundaries in the
instruction-fetch queue and determines the size of the next
instruction to be executed. It also determines whether the
instruction is a legal instruction.
4-2
Pipelining of Instructions
Read 2 If data was addressed in the R1 phase, the read 2 (R2) hardware
(R2) fetches that data by way of the appropriate data bus(es).
Execute In the execute (E) phase, the CPU performs all multiplier, shifter,
(E) and ALU operations. This includes all the prime arithmetic and
logic operations involving the accumulator and product register.
For operations that involve reading a value, modifying it, and writ-
ing it back to the original ___location, the modification (typically an
arithmetic or a logical operation) is performed during the E phase
of the pipeline. Any CPU register values used by the multiplier,
shifter, and ALU are read from the registers at the beginning of
the E phase. A result that is to be written to a CPU register is writ-
ten to the register at the end of the E phase.
Pipeline 4-3
Pipelining of Instructions
Although every instruction passes through the eight phases, not every phase
is active for a given instruction. Some instructions complete their operations
in the decode 2 phase, others in the execute phase, and still others in the write
phase. For example, instructions that do not read from memory perform no
operations in the read phases, and instructions that do not write to memory
perform no operation in the write phase.
4-4
Pipelining of Instructions
- Fetch counter (FC). The fetch counter contains the address that is driven
on the program address bus (PAB) in the F1 pipeline phase. The CPU con-
tinually increments the FC until the queue is full or the queue is emptied
by a program-flow discontinuity. Generally, the FC holds an even address
and is incremented by 2, to accommodate 32-bit fetches. The only excep-
tion to this is when the code after a discontinuity begins at an odd address.
In this case, the FC holds the odd address. After performing a16-bit fetch
at the odd address, the CPU increments the FC by 1 and resumes 32-bit
fetching at even addresses.
- Program counter (PC). When a new address is loaded into the IC, the
previous IC value is loaded into the PC. The program counter (PC) always
contains the address of the instruction that has reached its D2 phase.
Example 4−1 shows the relationship between the pipeline and the address
counters. Instruction 1 has reached its D2 phase (it has been passed to the
instruction register). The PC points to the address from which instruction 1
was taken (00005016). Instruction 2 has reached its D1 phase and will be
executed next (assuming no program-flow discontinuity flushes the instruc-
tion-fetch queue). The IC points to the address from which instruction 2 was
taken (00005116). Instruction 3 is in its F2 phase. It has been transferred to
the instruction-fetch queue but has not been decoded. Instructions 4 and 5 are
each in their F1 phase. The FC address (00005416) is being driven on the
PAB. During the next 32-bit fetch, Instructions 4 and 5 will be transferred from
addresses 00005416 and 00005516 to the queue.
Pipeline 4-5
Pipelining of Instructions
Example 4−1. Relationship Between Pipeline and Address Counters FC, IC, and PC
The remainder of this document refers almost exclusively to the PC. The FC
and the IC are visible in only limited ways. For example, when a call is executed
or an interrupt is initiated, the IC value is saved to the stack or to auxiliary regis-
ter XAR7.
4-6
Visualizing Pipeline Activity
The highlighted blocks in Example 4−2 indicate the path taken by the instruc-
tion ADD AL,*AR0++. That path can be summarized as follows:
F2 Read the opcodes F347 and F348 from addresses 00004216 and
00004316, respectively.
W No activity
Pipeline 4-7
Visualizing Pipeline Activity
F1 F2 D1 Instruction D2 R1 R2 E W
000040
F346:F345
000042 F345
0005 − −
AL = 1239 000205
1234
4-8
Visualizing Pipeline Activity
F1 F2 D1 Instruction D2 R1 R2 E W
−
Note: The opcodes shown in the F2 and D1 columns were chosen for illustrative purposes; they are not the actual opcodes of
the instructions shown.
The pipeline activity in Example 4−2 can also be represented by the simplified
diagram in Example 4−3. This type of diagram is useful if your focus is on the
path of each instruction rather than on specific pipeline events. In cycle 8, the
pipeline is full: there is an instruction in every pipeline phase. Also, the effective
execution time for each of these instructions is one cycle. Some instructions
finish their activity at the D2 phase, some at the E phase, and some at the W
phase. However, if you choose one phase as a reference, you can see that
each instruction is in that phase for one cycle.
F1 F2 D1 D2 R1 R2 E W Cycle
I1 1
I2 I1 2
I3 I2 I1 3
I4 I3 I2 I1 4
I5 I4 I3 I2 I1 5
I6 I5 I4 I3 I2 I1 6
I7 I6 I5 I4 I3 I2 I1 7
I8 I7 I6 I5 I4 I3 I2 I1 8
I8 I7 I6 I5 I4 I3 I2 9
I8 I7 I6 I5 I4 I3 10
I8 I7 I6 I5 I4 11
I8 I7 I6 I5 12
I8 I7 I6 13
I8 I7 14
I8 15
Pipeline 4-9
Freezes in Pipeline Activity
When the CPU requests a read from or write to a memory device or peripheral
device, that device may take more time to finish the data transfer than the CPU
allots by default. Each device must use one of the CPU ready signals to insert
wait states into the data transfer when it needs more time. The CPU has three
independent sets of ready signals: one set for reads from and writes to pro-
gram space, a second set for reads from data space, and a third set for writes
to data space. Wait-state requests freeze a portion of the pipeline if they are
received during the F1, R1, or W phase of an instruction:
- Wait states in the R1 phase. All D2−W activities of the pipeline freeze.
This is necessary because subsequent instructions can depend on the
data-read taking place. Instruction fetching continues until the instruction-
fetch queue is full or a wait-state request is received during an F1 phase.
- Wait states in the W phase. All D2−W activity in the pipeline freezes. This
is necessary because subsequent instructions may depend on the write
operation happening first. Instruction fetching continues until the instruc-
tion-fetch queue is full or a wait-state request is received during an F1
phase.
4-10
Freezes in Pipeline Activity
One time that an instruction-not-available condition will occur is when the first
instruction after a discontinuity is at an odd address and has 32 bits. A
discontinuity is a break in sequential program flow, generally caused by a
branch, a call, a return, or an interrupt. When a discontinuity occurs, the
instruction-fetch queue is emptied, and the CPU branches to a specified
address. If the specified address is an odd address, a 16-bit fetch is performed
at the odd address, followed by 32-bit fetches at subsequent even addresses.
Thus, if the first instruction after a discontinuity is at an odd address and has
32 bits, two fetches are required to get the entire instruction. The D2−W hard-
ware ceases until the instruction is ready to enter the D2 phase.
To avoid the delay where possible, you can begin each block of code with one
or two (preferably two) 16-bit instructions:
FunctionA:
16-bit instruction ; First instruction
16-bit instruction ; Second instruction
32-bit instruction ; 32-bit instructions can start here
.
.
.
Pipeline 4-11
Pipeline Protection
4.4.1 Protection During Reads and Writes to the Same Data-Space Location
Consider two instructions, A and B. Instruction A writes a value to a memory
___location during its W phase. Instruction B must read that value from the same
___location during its R1 and R2 phases. Because the instructions are being
executed in parallel, it is possible that the R1 phase of instruction B could occur
before the W phase of instruction A. Without pipeline protection, instruction B
could read too early and fetch the wrong value. The C28x pipeline prevents
that read by holding instruction B in its D2 phase until instruction A is finished
writing.
Example 4−4 shows a conflict between two instructions that are accessing the
same data-memory ___location. The pipeline activity shown is for an unprotected
pipeline. For convenience, the F1−D1 phases are not shown. I1 writes to VarA
during cycle 5. Data memory completes the store in cycle 6. I2 should not read
the data-memory ___location any sooner than cycle 7. However, I2 performs the
read during cycle 4 (three cycles too early). To prevent this kind of conflict, the
pipeline-protection mechanism would hold I2 in the D2 phase for 3 cycles.
During these pipeline-protection cycles, no new operations occur.
4-12
Pipeline Protection
Example 4−4. Conflict Between a Read From and a Write to Same Memory Location
I1: MOV @VarA,AL ; Write AL to data−memory ___location
I2: MOV AH,@VarA ; Read same ___location, store value in AH
DZ Kl RZ E W Cycle
I1 1
I2 I1 2
I2 I1 3
I2 I1 4
I2 I1 5
I2 6
I2 7
I2 8
You can reduce or eliminate these types of pipeline-protection cycles if you can
take other instructions in your program and insert them between the instruc-
tions that conflict. Of course, the inserted instructions must not cause conflicts
of their own or cause improper execution of the instructions that follow them.
For example, the code in Example 4−4 could be improved by moving a CLRC
instruction to the position between the MOV instructions (assume that the
instructions following CLRC SXM operate correctly with SXM = 0):
I1: MOV @VarA,AL ; Write AL to data−memory ___location
CLRC SXM ; SXM = 0 (sign extension off)
I2: MOV AH,@VarA ; Read same ___location, store value in AH
Inserting the CLRC instruction between I1 and I2 reduces the number of pipe-
line-protection cycles to two. Inserting two more instructions would remove the
need for pipeline protection. As a general rule, if a read operation occurs within
three instructions from a write operation to the same memory ___location, the
pipeline protection mechanism adds at least one inactive cycle.
Pipeline 4-13
Pipeline Protection
D2 R1 R2 E W Cycle
I1 1
I2 I1 2
I2 I1 3
I2 I1 4
I2 I1 5
I2 6
I2 7
4-14
Pipeline Protection
need for pipeline protection. As a general rule, if a read operation occurs within
three instructions from a write operation to the same register, the pipeline-
protection mechanism adds at least one inactive cycle.
Pipeline 4-15
Avoiding Unprotected Operations
The operands @Data1 and *XAR7 are referencing the same ___location, but the
pipeline cannot interpret this fact. The PREAD instruction reads from the
memory ___location (in the R2 phase) before the ADD writes to the memory loca-
tion (in the W phase).
However, the PREAD is not necessary in this program. Because the ___location
can be accessed by an instruction that reads from data space, you can use
another instruction, such as a MOV instruction:
ADD @Data1,AH ; Store AH to memory ___location Data1.
MOV AR1,*XAR7 ; Load AR1 from memory ___location
; given by XAR7.
4-16
Avoiding Unprotected Operations
This program causes a misread. The TBIT instruction reads bit 15 (in the R2
phase) before the MOV instruction writes to bit 15 (in the W phase). If the TBIT
instruction reads a 1, the code prematurely ends the loop. Because DataA and
DataB reference different data-memory locations, the pipeline does not identi-
fy this conflict.
However, you can correct this type of error by inserting two or more NOP (no
operation) instructions to allow for the delay between the write to DataA and
the change to bit 15 of DataB. For example, if a 2-cycle delay is sufficient, you
can fix the previous code as follows:
MOV @DataA,#4 ; This write to DataA causes a
; peripheral to clear bit 15 of DataB.
NOP ; Delay by 1 cycle.
NOP ; Delay by 1 cycle.
$10: TBIT @DataB,#15 ; Test bit 15 of DataB.
SB $10,NTC ; Loop until bit 15 is set.
The CPU contains a write followed by read protection mode to ensure that any
read operation that follows a write operation within a protected address range
is executed as written by delaying the read operation until the write is initiated.
See your device data sheet for device-specific information about which
memory region is write-followed-by-read protected.
The ENPROT signal enables this feature (when set high), it disables this fea-
ture (when set low)
All of the above signals are latched on every cycle. The above signals are con-
nected to registers and can be changed within the application program.
The above mechanism only works for reads that follow writes to the protected
area. Reads and write sequences to unprotected areas are not affected, as
shown in the following examples.
Pipeline 4-17
Avoiding Unprotected Operations
4-18
Chapter 5
This chapter describes the addressing modes of the C28x and provides exam-
ples.
Topic Page
5-1
Types of Addressing Modes
DP (data page pointer): In this mode, the 16-bit DP register behaves like a
fixed page pointer. The instruction supplies a 6-bit or 7-bit offset field,
which is concatenated with the value in the DP register. This type of ad-
dressing is useful for accessing fixed address data structures, such as pe-
ripheral registers and global or static variables in C/C++.
XAR0 to XAR7 (auxiliary register pointers): In this mode, the 32-bit XARn
registers behave as generic data pointers. The instruction can direct to
post-increment, pre/post-decrement, or index from the current register
contents with either a 3-bit immediate offset field or with the contents of
another 16-bit register.
On most C28x instructions, an 8-bit field in the instruction op-code selects the
addressing mode to use and what modification to make to that mode. In the
C28x instruction set, this field is referred to as:
- loc16
- loc32
5-2
Types of Addressing Modes
An example C28x instruction description, which uses the above, would be:
- ADD AL,loc16
Take the 16-bit contents of AL register, add the contents of 16-bit ___location
specified by the ”loc16” field and store the contents in AL register.
- ADDL loc32,ACC
Take the 32-bit contents of the ___location pointed to by the ”loc32” field, add
the contents of the 32-bit ACC register, and store the result back into the
___location specified by the ”loc32” field.
In this mode, the address of the memory operand is embedded in the in-
struction.
Only a small number of instructions use the above modes and typically they
are in combination with the ”loc16/loc32” modes.
- AMODE = 0
This is the default mode on reset and is the mode used by the C28x C/C++
compiler. This mode is not fully compatible to the C2xLP CPU addressing
modes. The data page pointer offset is 6-bits (it is 7-bits on the C2xLP) and
not all of the indirect addressing modes are supported.
- AMODE = 1
This mode contains addressing modes that are fully compatible to the
C2xLP device. The data page pointer offset is increased to 7-bits and all of
the indirect addressing modes available on the C2xLP are supported.
The available addressing modes, for the ”loc16” or ”loc32” field, are summa-
rized in Table 5−1.
5-4
Addressing Modes Select Bit (AMODE)
In the ”C28x Indirect” addressing modes, the auxiliary register pointer used in
the addressing mode is implicitly specified. In the ”C2xLP Indirect” addressing
modes, a 3-bit pointer called the auxiliary register pointer (ARP) is used to se-
lect which of the auxiliary registers is currently used and which pointer is used
in the next operation.
The examples below illustrate the differences between the ”C28x Indirect” and
”C2xLP Indirect” addressing modes:
- ADD AL,*XAR4++
- ADD AL,*++
Assume ARP pointer in ST1 contains the value 4. Read the contents of
16-bit memory ___location pointed to by register XAR4, add the contents to
AL register. Post-increment the contents of XAR4 by 1.
- ADD AL,*++,ARP5
Assume ARP pointer in ST1 contains the value 4. Read the contents of
16-bit memory ___location pointed to by register XAR4, add the contents to
AL register. Post-increment the contents of XAR4 by 1. Set the ARP point-
er to 5. Now it points to XAR5.
On the C28x instruction syntax, the destination operand is always on the left
and the source operands are always on the right.
5-6
Assembler/Compiler Tracking of AMODE Bit
.c28_amode Tells assembler that any code that follows assumes AMODE =
0 (C28x addressing modes).
.lp_amode Tells assembler that any code that follows assumes AMODE =
1 (full C2xLP compatible addressing modes)
The above directives cannot be nested. The above directives can be used as
follows within an assembly program:
Example(s):
MOVW DP,#VarA ; Load DP pointer with page value containing VarA
ADD AL,@VarA ; Add memory ___location VarA to register AL
MOV @VarB,AL ; Store AL into memory ___location VarB
; VarB is located in the same 64−word page as VarA
MOVW DP,#VarC ; Load DP pointer with page value containing VarC
SUB AL,@VarC ; Subtract memory ___location VarC from register AL
MOV @VarD,AL ; Store AL into memory ___location VarD
; VarC is located in the same 64−word page as VarD
; VarC & D are in different pages than VarA & B
Example(s):
SETC AMODE ; Make sure AMODE = 1
.lp_amode ; Tell assembler that AMODE = 1
MOVW DP,#VarA ; Load DP pointer with page value containing VarA
ADD AL,@@VarA ; Add memory ___location VarA to register AL
MOV @@VarB,AL ; Store AL into memory ___location VarB
; VarB is located in the same 128−word page as VarA
MOVW DP,#VarC ; Load DP pointer with page value containing VarC
SUB AL,@@VarC ; Subtract memory ___location VarC from register AL
MOV @@VarD,AL ; Store AL into memory ___location VarD
; VarC is located in the same 128−word page as VarD
; VarC & D are in different pages than VarA & B
Note: The direct addressing mode can access only the lower 4M of data address space on the C28x device.
5-8
Stack Addressing Modes (SP)
Example(s):
ADD AL,*−SP[5] ; Add 16-bit contents from stack ___location
; −5 words from top of stack to AL register
MOV *-SP[8],AL ; Store 16-bit AL register to stack ___location
; -8 words from top of stack
ADDL ACC,*−SP[12] ; Add 32-bit contents from stack ___location
; −12 words from top of stack to ACC register.
MOVL *-SP[34],ACC ; Store 32-bit ACC register to stack ___location
; −34 words from top of stack
Example(s):
MOV *SP++,AL ; Push contents of 16-bit AL register onto top
; of stack
MOVL *SP++,P ; Push contents of 32-bit P register onto top
; of stack
Example(s):
ADD AL,*−−SP ; Pop contents from top of stack and add to 16-bit
; AL register
MOVL ACC,*−−SP ; Pop contents from top of stack and store in
; 32-bit ACC register
Note: This addressing mode can only access the lower 64K of data address space on the C28x device.
Example(s):
MOVL XAR2,#Array1 ; Load XAR2 with start address of Array1
MOVL XAR3,#Array2 ; Load XAR3 with start address of Array2
MOV @AR0,#N−1 ; Load AR0 with loop count N
Loop:
MOVL ACC,*XAR2++ ; Load ACC with ___location pointed to by XAR2,
; post−increment XAR2
MOVL *XAR3++,ACC ; Store ACC into ___location pointed to by XAR3,
; post−increment XAR3
BANZ Loop,AR0−− ; Loop until AR0 == 0, post−decrement AR0
Example(s):
MOVL XAR2,#Array1+N*2 ; Load XAR2 with end address of Array1
MOVL XAR3,#Array2+N*2 ; Load XAR3 with end address of Array2
MOV @AR0,#N−1 ; Load AR0 with loop count N
Loop:
MOVL ACC,*−−XAR2 ; Pre−decrement XAR2,
; load ACC with ___location pointed to by XAR2
MOVL *−−XAR3,ACC ; Pre−decrement XAR3,
; store ACC into ___location pointed to by XAR3,
BANZ Loop,AR0−− ; Loop until AR0 == 0, post−decrement AR0
5-10
Indirect Addressing Modes
Example(s):
MOVW DP,#Array1Ptr ; Point to Array1 Pointer ___location
MOVL XAR2,@Array1Ptr ; Load XAR2 with pointer to Array1
MOVB XAR0,#16 ; AR0 = 16, AR0H = 0
MOVB XAR1,#68 ; AR1 = 68, AR1H = 0
MOVL ACC,*+XAR2[AR0] ;; Swap contents of ___location Array1[16]
MOVL P,*+XAR2[AR1] ;; with the contents of ___location Array1[68]
MOVL *+XAR2[AR1],ACC ;;
MOVL *+XAR2[AR0],P ;;
Example(s):
MOVW DP,#Array1Ptr ; Point to Array1 Pointer ___location
MOVL XAR2,@Array1Ptr ; Load XAR2 with pointer to Array1
MOVB XAR0,#16 ; AR0 = 16, AR0H = 0
MOVB XAR1,#68 ; AR1 = 68, AR1H = 0
MOVL ACC,*+XAR2[AR0] ;; Swap contents of ___location Array1[16]
MOVL P,*+XAR2[AR1] ;; with the contents of ___location Array1[68]
MOVL *+XAR2[AR1],ACC ;;
MOVL *+XAR2[AR0],P ;;
Example(s):
MOVW DP,#Array1Ptr ; Point to Array1 Pointer ___location
MOVL XAR2,@Array1Ptr ; Load XAR2 with pointer to Array1
MOVL ACC,*+XAR2[2] ;; Swap contents of ___location Array1[2]
MOVL P,*+XAR2[5] ;; with the contents of ___location Array1[5]
MOVL *+XAR2[5],ACC ;;
MOVL *+XAR2[2],P ;;
Note: The assembler also accepts ”*XARn” as an addressing mode. This is the same encoding as the ”*+XARn[0]” mode.
Example(s):
MOVZ DP,#RegAPtr ; Load DP with page address containing RegAPtr
MOVZ AR2,@RegAPtr ; Load AR2 with contents of RegAPtr, AR2H = 0
MOVZ AR3,@RegBPtr ; Load AR3 with contents of RegBPtr, AR3H = 0
; RegAPtr and RegBPtr are located in the same
; 128 word data page. Both are located in
; the low 64K of data memory space.
NOP *,ARP2 ; Set ARP pointer to point to XAR2
MOV *,#0x0404 ; Store 0x0404 into ___location pointed by XAR2
NOP *,ARP3 ; Set ARP pointer to point to XAR3
MOV *,#0x8000 ; Store 0x8000 into ___location pointed by XAR3
Example(s):
MOVZ DP,#RegAPtr ; Load DP with page address containing RegAPtr
MOVZ AR2,@RegAPtr ; Load AR2 with contents of RegAPtr, AR2H = 0
MOVZ AR3,@RegBPtr ; Load AR3 with contents of RegBPtr, AR3H = 0
; RegAPtr and RegBPtr are located in the same
; 128 word data page. Both are located in
; the low 64K of data memory space.
NOP *,ARP2 ; Set ARP pointer to point to XAR2
MOV *,#0x0404,ARP3 ; Store 0x0404 into ___location pointed by XAR2,
; Set ARP pointer to point to XAR3
MOV *,#0x8000 ; Store 0x8000 into ___location pointed by XAR3
5-12
Indirect Addressing Modes
Example(s):
MOVL XAR2,#Array1 ; Load XAR2 with start address of Array1
MOVL XAR3,#Array2 ; Load XAR3 with start address of Array2
MOV @AR0,#N−1 ; Load AR0 with loop count N
Loop:
NOP *,ARP2 ; Set ARP pointer to point to XAR2
MOVL ACC,*++ ; Load ACC with ___location pointed to by XAR2,
; post−increment XAR2
NOP *,ARP3 ; Set ARP pointer to point to XAR3
MOVL *++,ACC ; Store ACC into ___location pointed to by XAR3,
; post−increment XAR3
NOP *,ARP0 ; Set ARP pointer to point to XAR0
XBANZ Loop,*−− ; Loop until AR0 == 0, post−decrement AR0
Example(s):
MOVL XAR2,#Array1 ; Load XAR2 with start address of Array1
MOVL XAR3,#Array2 ; Load XAR3 with start address of Array2
MOV @AR0,#N−1 ; Load AR0 with loop count N
NOP *,ARP2 ; Set ARP pointer to point to XAR2
SETC AMODE ; Make sure AMODE = 1
.lp_amode ; Tell assembler that AMODE = 1
Loop:
MOVL ACC,*++,ARP3 ; Load ACC with ___location pointed to by XAR2,
; post−increment XAR2, set ARP to point to XAR3
MOVL *++,ACC,ARP0 ; Store ACC into ___location pointed to by XAR3,
; post−increment XAR3, set ARP to point to XAR0
XBANZ Loop,*−−,ARP2 ; Loop until AR0 == 0, post−decrement AR0,
; set ARP pointer to point to XAR2
Example(s):
MOVL XAR2,#Array1+(N−1)*2 ; Load XAR2 with end address of Array1
MOVL XAR3,#Array2+(N−1)*2 ; Load XAR3 with end address of Array2
MOV @AR0,#N−1 ; Load AR0 with loop count N
Loop:
NOP *,ARP2 ; Set ARP pointer to point to XAR2
MOVL ACC,*−− ; Load ACC with ___location pointed to by XAR2,
; post−decrement XAR2
NOP *,ARP3 ; Set ARP pointer to point to XAR3
MOVL *−−,ACC ; Store ACC into ___location pointed to by XAR3,
; post−decrement XAR3
NOP *,ARP0 ; Set ARP pointer to point to XAR0
XBANZ Loop,*−− ; Loop until AR0 == 0, post−decrement AR0
5-14
Indirect Addressing Modes
Example(s):
MOVL XAR2,#Array1 ; Load XAR2 with start address of Array1
MOVL XAR3,#Array2 ; Load XAR3 with start address of Array2
MOV @AR0,#4 ; Set AR0 to copy every fourth value from
; Array1 to Array2
MOV @AR1,#N−1 ; Load AR1 with loop count N
Loop:
NOP *,ARP2 ; Set ARP pointer to point to XAR2
MOVL ACC,*0++ ; Load ACC with ___location pointed to by XAR2,
; post−increment XAR2 by AR0
NOP *,ARP3 ; Set ARP pointer to point to XAR3
MOVL *++,ACC ; Store ACC into ___location pointed to by XAR3,
; post−increment XAR3
NOP *,ARP1 ; Set ARP pointer to point to XAR1
XBANZ Loop,*−− ; Loop until AR1 == 0, post−decrement AR1
Example(s):
MOVL XAR2,#Array1 ; Load XAR2 with start address of Array1
MOVL XAR3,#Array2 ; Load XAR3 with start address of Array2
MOV @AR0,#4 ; Set AR0 to copy every fourth value from
; Array1 to Array2
MOV @AR1,#N−1 ; Load AR1 with loop count N
NOP *,ARP2 ; Set ARP pointer to point to XAR2
SETC AMODE ; Make sure AMODE = 1
.lp_amode ; Tell assembler that AMODE = 1
Loop:
MOVL ACC,*0++,ARP3 ; Load ACC with ___location pointed to by XAR2,
; post−increment XAR2 by AR0, set ARP pointer
; to point to XAR3
MOVL *++,ACC,ARP1 ; Store ACC into ___location pointed to by XAR3,
; post−increment XAR3, set ARP pointer to point
; to XAR1
XBANZ Loop,*−−,ARP2 ; Loop until AR1 == 0, post−decrement AR1,
; set ARP to point to XAR2
Example(s):
MOVL XAR2,#Array1+(N−1)*8 ; Load XAR2 with end address of Array1
MOVL XAR3,#Array2+(N−1)*2 ; Load XAR3 with end address of Array2
MOV @AR0,#4 ; Set AR0 to copy every fourth value from
; Array1 to Array2
MOV @AR1,#N−1 ; Load AR1 with loop count N
Loop:
NOP *,ARP2 ; Set ARP pointer to point to XAR2
MOVL ACC,*0−− ; Load ACC with ___location pointed to by
; XAR2, post−decrement XAR2 by AR0
NOP *,ARP3 ; Set ARP pointer to point to XAR3
MOVL *−−,ACC ; Store ACC into ___location pointed to by
; XAR3, post−decrement XAR3
NOP *,ARP1 ; Set ARP pointer to point to XAR1
XBANZ Loop,*−− ; Loop until AR1 == 0, post−decrement AR1
Example(s):
MOVL XAR2,#Array1+(N−1)*8 ; Load XAR2 with end address of Array1
MOVL XAR3,#Array2+(N−1)*2 ; Load XAR3 with end address of Array2
MOV @AR0,#4 ; Set AR0 to copy every fourth value from
; Array1 to Array2
MOV @AR1,#N−1 ; Load AR1 with loop count N
NOP *,ARP2 ; Set ARP pointer to point to XAR2
SETC AMODE ; Make sure AMODE = 1
.lp_amode ; Tell assembler that AMODE = 1
Loop:
MOVL ACC,*0−−,ARP3 ; Load ACC with ___location pointed to by
; XAR2, post−decrement XAR2 by AR0, set ARP
; pointer to point to XAR3
MOVL *−−,ACC,ARP1 ; Store ACC into ___location pointed to by
; XAR3, post−decrement XAR3, set ARP
; pointer to point to XAR1
XBANZ Loop,*−−,ARP2 ; Loop until AR1 == 0, post−decrement AR1,
; set ARP to point to XAR2
5-16
Indirect Addressing Modes
Example(s):
; Transfer contents of Array1 to Array2 in bit reverse order:
MOVL XAR2,#Array1 ; Load XAR2 with start address of Array1
MOVL XAR3,#Array2 ; Load XAR3 with start address of Array2
MOV @AR0,#N ; Load AR0 with size of array,
; N must be a multiple of 2 (2,4,8,16,...)
MOV @AR1,#N−1 ; Load AR1 with loop count N
Loop:
NOP *,ARP2 ; Set ARP pointer to point to XAR2
MOVL ACC,*++ ; Load ACC with ___location pointed to by XAR2,
; post−increment XAR2
NOP *,ARP3 ; Set ARP pointer to point to XAR3
MOVL *BR0++,ACC ; Store ACC into ___location pointed to by XAR3,
; post−increment XAR3 with AR0 reverse carry add
NOP *,ARP1 ; Set ARP pointer to point to XAR1
XBANZ Loop,*−− ; Loop until AR1 == 0, post−decrement AR1
Example(s):
; Transfer contents of Array1 to Array2 in bit reverse order:
MOVL XAR2,#Array1 ; Load XAR2 with start address of Array1
MOVL XAR3,#Array2 ; Load XAR3 with start address of Array2
MOV @AR0,#N ; Load AR0 with size of array,
; N must be a multiple of 2 (2,4,8,16,...)
MOV @AR1,#N−1 ; Load AR1 with loop count N
NOP *,ARP2 ; Set ARP pointer to point to XAR2
SETC AMODE ; Make sure AMODE = 1
.lp_amode ; Tell assembler that AMODE = 1
Loop:
MOVL ACC,*++,ARP3 ; Load ACC with ___location pointed to by XAR2,
; post−increment XAR2, set ARP pointer to point
; to XAR3
Example(s):
; Transfer contents of Array1 to Array2 in bit reverse order:
MOVL XAR2,#Array1+(N−1)*2 ; Load XAR2 with end address of Array1
MOVL XAR3,#Array2+(N−1)*2 ; Load XAR3 with end address of Array2
MOV @AR0,#N ; Load AR0 with size of array,
; N must be a multiple of 2 (2,4,8,16,...)
MOV @AR1,#N−1 ; Load AR1 with loop count N
Loop:
NOP *,ARP2 ; Set ARP pointer to point to XAR2
MOVL ACC,*−− ; Load ACC with ___location pointed to by
; XAR2, post−decrement XAR2
NOP *,ARP3 ; Set ARP pointer to point to XAR3
MOVL *BR0−−,ACC ; Store ACC into ___location pointed to by
; XAR3, post−decrement XAR3 with AR0
; reverse borrow subtract
NOP *,ARP1 ; Set ARP pointer to point to XAR1
XBANZ Loop,*−− ; Loop until AR1 == 0, post−decrement AR1
5-18
Indirect Addressing Modes
Example(s):
; Transfer contents of Array1 to Array2 in bit reverse order:
MOVL XAR2,#Array1+(N−1)*2 ; Load XAR2 with end address of Array1
MOVL XAR3,#Array2+(N−1)*2 ; Load XAR3 with end address of Array2
MOV @AR0,#N ; Load AR0 with size of array,
; N must be a multiple of 2 (2,4,8,16,...)
MOV @AR1,#N−1 ; Load AR1 with loop count N
NOP *,ARP2 ; Set ARP pointer to point to XAR2
SETC AMODE ; Make sure AMODE = 1
.lp_amode ; Tell assembler that AMODE = 1
Loop:
MOVL ACC,*−−,ARP3 ; Load ACC with ___location pointed to by
; XAR2, post−decrement XAR2, set ARP
; pointer to point to XAR3
MOVL *BR0−−,ACC,ARP1 ; Store ACC into ___location pointed to by
; XAR3, post−decrement XAR3 with AR0
; reverse borrow subtract, set ARP pointer
; to point to XAR1
XBANZ Loop,*−−,ARP2 ; Loop until AR1 == 0, post−decrement AR1,
; set ARP pointer to point to XAR2
5-20
Indirect Addressing Modes
XAR6 points to the current address in the buffer. The top of the buffer must be
at an address where the 8 LSBs are all 0s.
If one of the instructions accessing the circular buffer performs a 32-bit opera-
tion, make sure XAR6 and AR1 are both even before the buffer is accessed.
Buffer size = 8 + 1 = 9
31 8 7 0
Top of buffer XAR6 X X X X X X 0 0
Must be zero
31 8 7 0
Bottom of buffer XAR6 X X X X X X 0 8
Matches AR1[7:0]
Example(s):
; Calculate FIR filter (X[N] = data array, C[N] = coefficient array):
MOVW DP,#Xpointer ; Load DP with page address of Xpointer
MOVL XAR6,@Xpointer ; Load XAR6 with current X pointer
MOVL XAR7,#C ; Load XAR7 with start address of C array
MOV @AR1,#N ; Load AR1 with size of data array N,
SPM −4 ; Set product shift mode to “>> 4”
ZAPA ; Zero ACC, P, OVC
RPT #N−1 ; Repeat next instruction N times
||QMACL P,*AR6%++,*XAR7++ ; ACC = ACC + P >> 4,
; P = (*AR6%++ * *XAR7++) >> 32
ADDL ACC,P << PM ; Final accumulate
MOVL @Xpointer,XAR6 ; Store XAR6 into current X pointer
MOVL @Sum,ACC ; Store result into sum
5-22
Indirect Addressing Modes
As seen in Figure 5−2, buffer size is determined by the upper 16 bits of XAR1
or XAR1[31:16]. Specifically, the size is XAR1[31:16] + 1.
If the instructions that access the circular buffer perform 32-bit operations,
make sure XAR6 and XAR1[31:16] are even.
31 16 15 0
XAR1 0 0 0 9 0 0 0 0
31 0
XAR6 003F8010
0x0000
Matches
XAR1[31:16]
Example(s):
; Calculate FIR filter (X[N] = data array, C[N] = coefficientv array):
MOVW DP,#Xindex ; Load DP with page address of Xindex
MOVL XAR6,#X ; Load XAR6 with start address of X array
MOV @AH,#N ; Load AH with size of array X (N)
MOV AL,@Xindex ; Load AL with current circular index
MOVL XAR1,@ACC ; Load parameters into XAR1
MOVL XAR7,#C ; Load XAR7 with start address of C array
SPM −4 ; Set product shift mode to “>> 4”
ZAPA ; Zero ACC, P, OVC
RPT #N−1 ; Repeat next instruction N times
||QMACL P,*+XAR6[AR1%++],*XAR7++ ; ACC = ACC + P >> 4,
; P = (*AR6%++ * *XAR7++) >> 32
ADDL ACC,P << PM ; Final accumulate
MOV @Xindex,AR1 ; Store AR1 into current X index
MOVL @Sum,ACC ; Store result into sum
5-24
Register Addressing Modes
Example(s):
MOVL XAR6,@ACC ; Load XAR6 with contents of ACC
MOVL @ACC,XT ; Load ACC with contents of XT register
ADDL ACC,@ACC ; ACC = ACC + ACC
Example(s):
MOVL XAR6,@P ; Load XAR6 with contents of P
MOVL @P,XT ; Load P with contents of XT register
ADDL ACC,@P ; ACC = ACC + P
Example(s):
MOVL XAR6,@XT ; Load XAR6 with contents of XT
MOVL P,@XT ; Load P with contents of XT register
ADDL ACC,@XT ; ACC = ACC + XT
Example(s):
MOVL XAR6,@XAR2 ; Load XAR6 with contents of XAR2
MOVL P,@XAR2 ; Load P with contents of XAR2 register
ADDL ACC,@XAR2 ; ACC = ACC + XAR2
Note: When writing assembly code, the “@” symbol in front of the register is optional. For example: “MOVL ACC,@P” or
“MOVL ACC,P”. The disassembler will use the @ to indicate operands that are “loc16” or “loc32”. For example,
MOVL ACC, @P is the MOVL ACC, loc32 instruction and MOVL @ACC, P is the MOVL loc32, P instruction.
Example(s):
MOV PH,@AL ; Load PH with contents of AL
ADD AH,@AL ; AH = AH + AL
MOV T,@AL ; Load T with contents of AL
Example(s):
MOV PH,@AH ; Load PH with contents of AH
ADD AL,@AH ; AL = AL + AH
MOV T,@AH ; Load T with contents of AH
Example(s):
MOV PH,@PL ; Load PH with contents of PL
ADD AL,@PL ; AL = AL + PL
MOV T,@PL ; Load T with contents of PL
5-26
Register Addressing Modes
Example(s):
MOV PL,@PH ; Load PL with contents of PH
ADD AL,@PH ; AL = AL + PH
MOV T,@PH ; Load T with contents of PH
Example(s):
MOV PL,@T ; Load PL with contents of T
ADD AL,@T ; AL = AL + T
MOVZ AR4,@T ; Load AR4 with contents of T, AR4H = 0
Example(s):
MOVZ AR4,@SP ; Load AR4 with contents of SP, AR4H = 0
MOV AL,@SP ; Load AL with contents of SP
MOV @SP,AH ; Load SP with contents of AH
Example(s):
MOVZ AR4,@AR2 ; Load AR4 with contents of AR2, AR4H = 0
MOV AL,@AR3 ; Load AL with contents of AR3
MOV @AR5,AH ; Load AR5 with contents of AH, AR5H = unchanged
Syntax Description
*(PA) 32BitDataAddr(31:16) = 0
32BitDataAddr(15:0) = PA 16−bit immediate value
Note: If instruction is repeated, the address is post−incremented on each iteration. The I/O
strobe signal is toggled when accessing I/O space with this addressing mode. The
data space address lines are used for accessing I/O space.
Syntax Description
0:pma 22BitProgAddr(21:16) = 0
22BitProgAddr(15:0) = pma 16−bit immediate value
5-28
Data/Program/IO Space Immediate Addressing Modes
Syntax Description
*(pma) 22BitProgAddr(21:16) = 0x3F
22BitProgAddr(15:0) = pma 16−bit immediate value
Note: If instruction is repeated, the address in AL is copied to a shadow register and the
value post−incremented on each iteration. The AL register is not modified. This ad-
dressing mode can only access the upper 64K of program space.
Syntax Description
*XAR7 22BitProgAddr(21:0) = XAR7
Note: If instruction is repeated, only in the XPREAD and XPWRITE instructions, is the ad-
dress contained in XAR7 copied to a shadow register and the value post−increm-
ented on each iteration. The XAR7 register is not modified. For all other instructions,
the address is not incremented even when repeated.
Syntax Description
*XAR7++ 22BitProgAddr(21:0) = XAR7,
if(16−bit operation) XAR7 = XAR7 + 1,
if(32−bit operation) XAR7 = XAR7 + 2
5-30
Byte Addressing Modes
5-32
Alignment of 32-Bit Operations
The programmer must take the above into account when generating address-
es that are not aligned to an even boundary.
32-bit operands are stored in the following order; low order bits, 0 to 15, fol-
lowed by the high order bits, 16 to 31, on the next highest 16-bit address incre-
ment (little-endian format).
This chapter presents summaries of the instruction set, defines special sym-
bols and notations used, and describes each instruction in detail in alphabeti-
cal order.
Topic Page
6-1
Instruction Set Summary (Organized by Function)
# Immediate operand
PC Program counter
~ Bitwise compliment
6-2
Instruction Set Summary (Organized by Function)
{} Optional field
= Assignment
== Equivalent to
Note: Cycle Counts assume the instruction is executed from zero-wait (single-cycle)
memory and there are no pipeline stalls.
MOVL XARn,#22bit Load 32-bit auxiliary register with constant value 6-215
MOVZ ARn,loc16 Load lower half of XARn and clear upper half 6-225
SBRK #8bit Subtract 8-bit constant from current auxiliary register 6-319
DP Register Operations
MOVZ DP,#10bit Load data page and clear high bits 6-226
SP Register Operations
6-4
Register Operations
POP AR1H:AR0H Pop AR1H & AR0H registers from stack 6-269
POP AR3:AR2 Pop AR3 & AR2 registers from stack 6-268
POP AR5:AR4 Pop AR5 & AR4 registers from stack 6-268
SUBB SP,#7bit Subtract 7-bit constant from the stack pointer 6-341
6-6
Register Operations
MOV loc16,ACC << 1..8 Save low word of shifted accumulator 6-167
MOVH loc16,ACC << 1..8 Save high word of shifted accumulator 6-202
SUB ACC,loc16 {<< 0..16} Subtract shifted value from accumulator 6-333
SUB ACC,#16bit {<< 0..15} Subtract shifted value from accumulator 6-337
6-8
Register Operations
NORM ACC,XARn++/−− Normalize ACC and modify selected auxiliary register. 6-253
6-10
Register Operations
MOVA T,loc16 Load the T register and add the previous product 6-183
MOVP T,loc16 Load the T register and store P in the accumulator 6-217
IMACL P,loc32,*XAR7/++ Signed 32 X 32-bit multiply and accumulate (lower half) 6-100
IMPYAL P,XT,loc32 Signed 32-bit multiply (lower half) and add previous P 6-103
IMPYSL P,XT,loc32 Signed 32-bit multiply (lower half) and subtract P 6-107
QMACL P,loc32,*XAR7/++ Signed 32 X 32-bit multiply and accumulate (upper half) 6-300
QMPYAL P,XT,loc32 Signed 32-bit multiply (upper half) and add previous P 6-302
QMPYSL P,XT,loc32 Signed 32-bit multiply (upper half) and subtract pre- 6-306
vious P
6-12
Register Operations
IO Space Operations
Branch/Call/Return Operations
6-14
Register Operations
Miscellaneous Operations
6-16
Register Operations
Operands None
Description Abort interrupt. This instruction is available for emulation purposes. Generally,
a program uses the IRET instruction to return from an interrupt. The IRET
instruction restores all of the values that were saved to the stack during the
automatic context save. In restoring status register ST1 and the debug status
register (DBGSTAT), IRET restores the debug context that was present before
the interrupt.
In some target applications, you might have interrupts that must not be returned
from by the IRET instruction. Not using IRET can cause a problem for the
emulation logic, because the emulation logic assumes that the original debug
context will be restored. The abort interrupt (ABORTI) instruction is provided
as a means to indicate that the debug context will not be restored and the debug
logic needs to be reset to its default state. As part of its operation, the ABORTI
instruction:
- Sets the DBGM bit in ST1. This disables debug events.
- Modifies select bits in the DBGSTAT register. This effect is a resetting of
the debug context. If the CPU was in the debug-halt state before the inter-
rupt occurred, the CPU does not halt when the interrupt is aborted.
The ABORTI instruction does not modify the DBGIER, the IER, the INTM bit or
any analysis registers (for example, registers used for breakpoints, watch
points, and data logging).
Repeat This instruction is not repeatable. If this instruction follows the RPT instruction,
it resets the repeat counter (RPTC) and executes only once.
6-18
ABS ACC
Description The content of the ACC register is replaced with its absolute value:
if(ACC = 0x8000 0000)
V = 1;
If (OVM = 1)
ACC = 0x7FFF FFFF;
else
ACC = 0x8000 0000;
else
if(ACC < 0)
ACC = −ACC;
Flags and N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes
Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
C C is cleared by this operation.
V If (ACC = 0x8000 0000) at the start of the operation, this is considered an
overflow value and V is set. Otherwise, V is not affected.
OVM If (ACC = 0x8000 0000) at the start of the operation, this is considered an
overflow value, and the ACC value after the operation depends on the state
of OVM: If OVM is cleared, ACC will be filled with 0x8000 0000. If OVM is
set ACC will be saturated to 0x7FFF FFFF.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-19
ABSTC ACC
Description Replace the content of the ACC register with its absolute value and load the
test control (TC) bit with the sign bit XORed with the previous value of the
test control bit:
if(ACC = 0x8000 0000)
{
If (OVM = 1)
ACC = 0x7FFF FFFF;
else
ACC = 0x8000 0000;
V = 1;
TC = TC XOR 1;
{
else
{
if(ACC < 0)
ACC = −ACC;
TC = TC XOR 1;
}
C = 0;
Flags and N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes
Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
C The C flag bit is cleared.
V If (ACC = 0x8000 0000) at the start of the operation, this is considered an
overflow value and V is set; otherwise, V is not affected.
TC If (ACC < 0) at the start of the operation, then TC = TC XOR 1; otherwise,
TC is not affected.
OVM If at the start of the operation, ACC = 0x8000 0000, then this is considered
an overflow value and the ACC value after the operation depends on OVM.
If OVM is cleared and TC == 1, ACC will be filled with 0x8000 0000. If OVM
is set and TC = 1, ACC will be saturated to 0x7FFF FFFF.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-20
ABSTC ACC
6-21
ADD ACC,#16bit<<#0..15
Description Add the left shifted 16-bit immediate constant value to the ACC register.
The shifted value is sign extended if sign extension mode is turned on (SXM
= 1) else the shifted value is zero extended (SXM = 0). The lower bits of the
shifted value are zero filled:
if(SXM = 1) // sign extension mode enabled
ACC = ACC + S:16bit << shift value;
else // sign extension mode disabled
ACC = ACC + 0:16bit << shift value;
Smart Encoding:
If #16bit is an 8-bit number and the shift is 0, then the assembler will encode
this instruction as ADDB ACC, #8bit to improve efficiency. To override this
encoding, use the ADDW ACC, #16bit instruction alias.
Flags and Z After the addition, the Z flag is set if the ACC value is zero, else the flag is
Modes cleared.
N After the addition, the N flag is set if bit 31 of the ACC is 1, else the flag is
cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If (OVM = 0, disabled) then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented. If (OVM = 1, enabled) then the
counter is not affected by the operation.
SXM If sign extension mode bit is set; then the 16-bit immediate constant will be
sign-extended before the addition. Else, the value will be zero extended.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the
operation overflowed.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-22
ADD ACC,#16bit<<#0..15
Example ; Calculate signed value: ACC = (VarB << 10) + (23 << 6);
SETC SXM ; Turn sign extension mode on
MOV ACC,@VarB << #10 ; Load ACC with VarB left shifted by 10
ADD ACC,#23 << #6 ; Add 23 left shifted by 6 to ACC
6-23
ADD ACC,loc16 << T
6-24
ADD ACC,loc16 << #0..16
6-25
ADD ACC,loc16 << #0..16
6-26
ADD AX, loc16
Description Add the contents of the ___location pointed to by the “loc16” addressing mode
to the specified AX register (AH or AL) and store the result in the AX register:
Flags and N After the addition, AX is tested for a negative condition. If bit 15 of AX is 1, then
Modes the negative flag bit is set, otherwise it is cleared.
Z After the addition, AX is tested for a zero condition. The zero flag bit is set if
the operation results in AX = 0; otherwise it is cleared.
C If the addition generates a carry, C is set; otherwise, C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected. Signed positive
overflow occurs if the result crosses the max positive value (0x7FFF) in the
positive direction. Signed negative overflow occurs if the result crosses the
max negative value (0x8000) in the negative direction.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Add the contents of VarA with VarB and store in VarC
MOV AL,@VarA ; Load AL with contents of VarA
ADD AL,@VarB ; Add to AL contents of VarB
MOV @VarC,AL ; Store result in VarC
6-27
ADD loc16, AX
Description Add the contents of the specified AX register (AH or AL) to the ___location
pointed to by the “loc16” addressing mode and store the results in ___location
pointed to by “loc16”:
[loc16] = [loc16] + AX;
This is a read-modify-write operation.
Flags and N After the addition, [loc16] is tested for a negative condition. If bit 15 of [loc16]
Modes is 1, then the negative flag bit is set, otherwise it is cleared.
Z After the addition, [loc16] is tested for a zero condition. The zero flag bit is set
if the operation generates [loc16] = 0; otherwise it is cleared
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected. Signed positive
overflow occurs if the result crosses the max positive value (0x7FFF) in the
positive direction. Signed negative overflow occurs if the result crosses the
max negative value (0x8000) in the negative direction.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-28
ADD loc16,#16bitSigned
Description Add the specified signed 16-bit immediate constant to the signed 16-bit
content of the ___location pointed to by the “loc16” addressing mode and
store the 16-bit result in the ___location pointed to by “loc16”:
[loc16] = [loc16] + 16bitSigned;
Smart Encoding:
If loc16 = AL or AH and #16bitSigned is an 8-bit number then the
assembler will encode this instruction as ADDB AX, #16bitSigned to
improve efficiency. To override this encoding, use the ADDW loc16,
#16bitSigned instruction alias.
Flags and N After the addition, if bit 15 of [loc16] is 1, then the N bit is set; else N
Modes cleared.
Z After the addition, if [loc16] is zero, the Z is set, else Z is cleared.
C If the addition generates a carry, C is set; otherwise, C is cleared.
V If an overflow occurs, V is set; otherwise, V is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Calculate:
; VarA = VarA + 10
; VarB = VarB − 3
ADD @VarA,#10 ; VarA = VarA + 10
ADD @VarB,#−3 ; VarB = VarB − 3
6-29
ADDB ACC,#8bit
Flags and Z After the addition, the Z flag is set if ACC is zero, else Z is cleared.
Modes
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If (OVM = 0, disabled) then if the operation generates a positive overflow, then
the counter is incremented and if the operation generates a negative overflow,
then the counter is decremented. If (OVM = 1, enabled) then the counter is
not affected by the operation.
OVM If overflow mode bit is set; then the ACC value will saturate maximum positive
(0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-30
ADDB AX, #8bitSigned
Description Add the sign extended 8-bit constant to the specified AX register (AH or
AL) and store the result in the AX register:
AX = AX + S:8bit;
Flags and N After the addition, AX is tested for a negative condition. If bit 15 of AX is
Modes 1, then the negative flag bit is set; otherwise it is cleared.
Z After the addition, AX is tested for a zero condition. The zero flag bit is set
if the operation results in AX = 0, otherwise it is cleared
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected. Signed positive
overflow occurs if the result crosses the max positive value (0x7FFF) in
the positive direction. Signed negative overflow occurs if the result
crosses the max negative value (0x8000) in the negative direction.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-31
ADDB SP, #7bit
Description Add a 7-bit unsigned constant to SP and store the result in SP:
SP = SP + 0:7bit;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once
.
.
.
SUBB SP, #N ; Deallocate reserved stack space.
LRETR ; Return from function.
6-32
ADDB XARn, #7bit
Description Add a 7-bit unsigned constant to XARn and store the result in XARn:
XARn = XARn + 0:7bit;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-33
ADDCL ACC,loc32
Description Add to the ACC register the 32-bit content of the ___location pointed to by the
“loc32” addressing mode:
ACC = ACC + [loc32] + C;
Flags and Z After the addition, the Z flag is set if the ACC is zero, else Z is cleared.
Modes
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C The state of the carry bit before execution is included in the addition. If the
addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If (OVM = 0, disabled) then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented. If (OVM = 1, enabled) then the
counter is not affected by the operation.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflows.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Add two 64-bit values (VarA and VarB) and store result in VarC:
MOVL ACC,@VarA+0 ; Load ACC with contents of the low
; 32 bits of VarA
ADDUL ACC,@VarB+0 ; Add to ACC the contents of the low
; 32 bits of VarB
MOVL @VarC+0,ACC ; Store low 32-bit result into VarC
MOVL ACC,@VarA+2 ; Load ACC with contents of the high
; 32 bits of VarA
ADDCL ACC,@VarB+2 ; Add to ACC the contents of the high
; 32 bits of VarB with carry
MOVL @VarC+2,ACC ; Store high 32-bit result into VarC
6-34
ADDCU ACC,loc16
Description Add the 16-bit contents of the ___location pointed to by the “loc16” addressing
mode, zero extended, plus the content of the carry flag bit to the ACC
register:
ACC = ACC + 0:[loc16] + C;
Flags and Z After the addition, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C The state of the carry bit before execution is included in the addition. If the
addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If (OVM = 0, disabled) then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented. If (OVM = 1, enabled) then the
counter is not affected by the operation.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the
operation overflowed.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-35
ADDL ACC,loc32
Description Add to the ACC register the 32-bit content of the ___location pointed to by the
“loc32” addressing mode:
ACC = ACC + [loc32];
Flags and N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes
Z After the addition, the Z flag is set if the ACC is zero, else Z is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OCV If (OVM = 0, disabled) then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented. If (OVM = 1, enabled) then the
counter is not affected by the operation.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflows.
Repeat If this operation is repeated, then the instruction will be executed N+1 times.
The state of the Z, N, C flags will reflect the final result. The V flag will be set
if an intermediate overflow occurs. The OVC flag will count intermediate
overflows, if overflow mode is disabled.
6-36
ADDL ACC,P << PM
Description Add to the ACC register the contents of the P register, shifted as specified
by the product shift mode (PM):
ACC = ACC + P << PM
Flags and Z After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OCV If (OVM = 0, disabled) then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented. If (OVM = 1, enabled) then the
counter is not affected by the operation.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
PM The value in the PM bits sets the shift mode for the output operation from
the product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat If this operation is repeated, then the instruction will be executed N+1 times.
The state of the Z, N, C flags will reflect the final result. The V flag will be set
if an intermediate overflow occurs. The OVC flag will count intermediate
overflows if overflow mode is disabled.
6-37
ADDL loc32,ACC
Description Add to the ACC register the 32-bit content of the ___location pointed to by the
“loc32” addressing mode:
[loc32] = [loc32] + ACC;
Flags and N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes Z After the addition, the Z flag is set if the ACC is zero, else Z is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OCV If (OVM = 0, disabled) then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented. If (OVM = 1, enabled) then the
counter is not affected by the operation.
OVM If overflow mode bit is set, the ACC value will saturate maximum positive
(0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflows.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-38
ADDU ACC,loc16
Description Add the 16-bit contents of the ___location pointed to by the “loc16” addressing
mode to the ACC register. The addressed ___location is zero extended before
the add:
ACC = ACC + 0:[loc16];
Flags and Z After the addition, the Z flag is set if ACC is zero, else Z is cleared.
Modes N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If (OVM = 0, disabled) then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented. If (OVM = 1, enabled) then the
counter is not affected by the operation.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
Repeat If this operation is repeated, then the instruction will be executed N+1 times.
The state of the Z, N, C flags will reflect the final result. The V flag will be set
if an intermediate overflow occurs. The OVC flag will count intermediate
overflows, if overflow mode is disabled.
6-39
ADDUL P,loc32
Description Add to the P register the 32-bit content of the ___location pointed to by the
“loc32” addressing mode. The addition is treated as an unsigned ADD
operation:
P = P + [loc32]; // unsigned add
Note: The difference between a signed and unsigned 32-bit add is in the treatment
of the overflow counter (OVC). For a signed ADD, the OVC counter monitors
positive/negative overflow. For an unsigned ADD, the OVC unsigned
(OVCU) counter monitors the carry.
Flags and N After the addition, if bit 31 of the P register is 1, then set the N flag; otherwise
Modes clear N.
Z After the addition, if the value of the P register is 0, then set the Z flag;
otherwise clear Z.
C If the addition generates a carry, set C; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVCU The overflow counter is incremented when the addition operation generates
an unsigned carry. The OVM mode does not affect the OVCU counter.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-40
ADDUL ACC, loc32
Description Add to the ACC register the unsigned 32-bit content of the ___location pointed
to by the “loc32” addressing mode:
ACC = ACC + [loc32]; // unsigned add
Note: The difference between a signed and unsigned 32-bit add is in the treatment
of the overflow counter (OVC). For a signed ADD, the OVC counter monitors
positive/negative overflow. For an unsigned ADD, the OVC unsigned
(OVCU) counter monitors the carry.
Flags and Z After the addition, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVCU The overflow counter is incremented when the addition operation generates
an unsigned carry. The OVM mode does not affect the OVCU counter.
Repeat If this operation is repeated, then the instruction will be executed N+1 times.
The state of the Z, N, C flags will reflect the final result. The V flag will be set
if an intermediate overflow occurs. The OVCU will count intermediate
carries.
Example ; Add two 64-bit values (VarA and VarB) and store result in VarC:
MOVL ACC,@VarA+0 ; Load ACC with contents of the low
; 32 bits of VarA
ADDUL ACC,@VarB+0 ; Add to ACC the contents of the low
; 32 bits of VarB
MOVL @VarC+0,ACC ; Store low 32-bit result into VarC
MOVL ACC,@VarA+2 ; Load ACC with contents of the high
; 32 bits of VarA
ADDCL ACC,@VarB+2 ; Add to ACC the contents of the high
; 32 bits of VarB with carry
MOVL @VarC+2,ACC ; Store high 32-bit result into VarC
6-41
ADRK #8bit
Description Add the 8-bit unsigned constant to the XARn register pointed to by ARP:
XAR(ARP) = XAR(ARP) + 0:8bit;
Flags and ARP The 3-bit ARP points to the current valid Auxiliary Register, XAR0 to XAR7.
Modes This pointer determines which Auxiliary register is modified by the operation.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once
FuncA:
MOVL XAR1,#TableA ; Initialize XAR1 pointer
MOVZ AR2,*XAR1 ; Load AR2 with the 16-bit value
; pointed to by XAR1 (0x1111)
; Set ARP = 1
6-42
AND ACC,#16bit << #0..16
Description Perform a bitwise AND operation on the ACC register with the given 16-bit
unsigned constant value left shifted as specified. The value is zero extended
and lower order bits are zero filled before the AND operation. The result is
stored in the ACC register:
ACC = ACC AND (0:16bit << shift value);
Flags and N The load to ACC is tested for a negative condition. If bit 31 of ACC is 1, then
Modes the negative flag bit is set; otherwise it is cleared.
Z The load to ACC is tested for a zero condition. The zero flag bit is set if the
operation generates ACC = 0; otherwise it is cleared
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-43
AND ACC, loc16
Description Perform a bitwise AND operation on the ACC register with the zero-extended
content of the ___location pointed to by the “loc16” address mode. The result
is stored in the ACC register:
ACC = ACC AND 0:[loc16];
Repeat This operation is repeatable. If the operation follows a RPT instruction, then
the AND instruction will be executed N+1 times. The state of the Z and N
flags will reflect the final result.
6-44
AND AX, loc16, #16bit
Description Perform a bitwise AND operation on the 16-bit contents of the ___location
pointed to by the “loc16” addressing mode with the specified 16-bit
immediate constant. The result is stored in the specified AX register:
AX = [loc16] AND 16bit;
Flags and N The load to AX is tested for a negative condition. If bit 15 of AX is 1, then the
Modes negative flag bit is set; otherwise it is cleared.
Z The load to AX is tested for a zero condition. The zero flag bit is set if the
operation generates AX = 0; otherwise it is cleared
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-45
AND IER,#16bit
Description Disable specific interrupts by performing a bitwise AND operation with the
IER register and the 16-bit immediate value. The result is stored in the IER
register:
IER = IER AND #16bit;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Disable INT1 and INT6 only. Do not modify state of other
; interrupts enable:
AND IER,#0xFFDE ; Disable INT1 and INT6
6-46
AND IFR,#16bit
Description Clear specific pending interrupts by performing a bitwise AND operation with
the IFR register and the 16-bit immediate value. The result of the AND
operation is stored in the IFR register:
IFR = IFR AND #16bit;
Note: Interrupt hardware has priority over CPU instruction operation in cases
where the interrupt flag is being simultaneously modified by the hardware
and the instruction.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-47
AND loc16, AX
Description Perform a bitwise AND operation on the contents of the ___location pointed to
by the “loc16” addressing mode with the specified AX register. The result is
stored in ___location pointed to by ”loc16”:
[loc16] = [loc16] AND AX;
Flags and N The load to [loc16] is tested for a negative condition. If bit 15 of [loc16] is 1,
Modes then the negative flag bit is set; otherwise it is cleared.
Z The load to [loc16] is tested for a zero condition. The zero flag bit is set if the
operation generates ([loc16] = 0); otherwise it is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; AND the contents of VarA with VarB and store in VarB:
MOV AL,@VarA ; Load AL with contents of VarA
AND @VarB,AL ; VarB = VarB AND AL
6-48
AND AX, loc16
Description Perform a bitwise AND operation on the contents of the specified AX register
with the 16-bit contents of the ___location pointed to by the “loc16” addressing
mode. The result is stored in the AX register:
AX = AX AND 16bit;
Flags and N The load to AX is tested for a negative condition. If bit 15 of AX is 1, then the
Modes negative flag bit is set; otherwise it is cleared.
Z The load to AX is tested for a zero condition. The zero flag bit is set if the
operation generates AX = 0; otherwise it is cleared
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; AND the contents of VarA and VarB and branch if non-zero:
MOV AL,@VarA ; Load AL with contents of VarA
AND AL,@VarB ; AND AL with contents of VarB
SB Dest,NEQ ; Branch if result is non-zero
6-49
AND loc16,#16bitSigned
Description Perform a bitwise AND operation on the 16-bit content of the ___location
pointed to by the “loc16” addressing mode and the specified 16-bit
immediate constant. The result is stored in the ___location pointed to by
“loc16”:
[loc16] = [loc16] AND 16bit;
Smart Encoding:
If loc16 = AH or AL and #16bitSigned is an 8-bit number, then the
assembler will encode this instruction as ANDB AX, #8-bit to
improve efficiency. To override this, use the ANDW AX,
#16bitSigned instruction alias.
Flags and N After the operation if bit 15 of [loc16] 1, set N; otherwise, clear N.
Modes
Z After the operation if [loc16] is zero, set Z; otherwise, clear Z.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only
once.
6-50
ANDB AX, #8bit
Description Perform a bitwise AND operation with the content of the specified AX register
(AH or AL) with the given 8-bit unsigned immediate constant zero extended.
The result is stored in AX:
AX = AX AND 0:8bit;
Flags and N The load to AX is tested for a negative condition. If bit 15 of AX is 1, then the
Modes negative flag bit is set; otherwise it is cleared.
Z The load to AX is tested for a zero condition. The zero flag bit is set if the
operation generates AX = 0; otherwise it is cleared
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Add VarA to VarB, keep LSByte and store result in VarC:
MOV AL,@VarA ; Load AL with contents of VarA
ADD AL,@VarB ; Add to AL contents of VarB
ANDB AL,#0xFF ; AND contents of AL with 0x00FF
MOV @VarC,AL ; Store result in VarC
6-51
ASP
Operands None
Description Ensure that the stack pointer (SP) is aligned to an even address. If the least
significant bit of SP is 1, SP points to an odd address and must be moved
by incrementing SP by 1. The SPA bit is set as a record of this alignment. If
instead the ASP instruction finds that the SP already points to an even
address, SP is left unchanged and the SPA bit is cleared to indicate that no
alignment has taken place. In either case, the change to the SPA bit is made
in the decode 2 phase of the pipeline.
if(SP = odd)
SP = SP + 1;
SPA = 1;else
SPA = 0;
If you wish to undo a previous alignment by the ASP instruction, use the
NASP instruction.
Flags and SPA If SP holds an odd address before the operation, SPA is set; otherwise, SPA
Modes is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
INTxService:
ASP ; Align stack pointer
.
.
.
NASP ; Re-align stack pointer
IRET ; Return from interrupt.
6-52
ASR AX,#1...16
Description Perform an arithmetic right shift on the content of the specified AX register
(AH or AL) by the amount given in the “shift value” field. During the shift, the
value is sign extended and the last bit to be shifted out of the AX register is
stored in the carry status flag bit:
Discard
other bits
AX
Flags and N After the shift, if bit 15 of AX is 1 then the negative flag bit is set; otherwise
Modes it is cleared.
Z After the shift, if AX is 0, then the Z bit is set; otherwise it is cleared.
C The last bit to be shifted out of AH or AL is stored in C.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-53
ASR AX,T
Description Perform an arithmetic shift right on the content of the specified AX register
as specified by the four least significant bits of the T register, T(3:0) = shift
value = 0…15. The contents of higher order bits are ignored. During the
shift, the value is sign extended. If the T(3:0) register bits specify a shift of
0, then C is cleared; otherwise, C is filled with the last bit to be shifted out of
AX:
AX Last bit out or cleared
C
Right shift
SIGN
(Contents of T [3:0])
Flags and N After the shift, if bit 15 of AX is 1 then the negative flag bit is set; otherwise
Modes it is cleared. Even if the T(3:0) register bits specify a shift of 0, the value of
AH or AL is still tested for the negative condition and N is affected.
Z After the shift, if AX is 0, then the Z bit is set, otherwise it is cleared. Even if
the T(3:0) register bits specify a shift of 0, the value of AH or AL is still tested
for the zero condition and Z is affected.
C If T(3:0) specifies a shift of 0, then C is cleared; otherwise, C is filled with the
last bit to be shifted out of AH or AL.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-54
ASR64 ACC:P,#1..16
Description Arithmetic shift right the 64-bit combined value of the ACC:P registers by the
amount specified in the shift value field. As the value is shifted, the most
significant bits are sign extended and the last bit shifted out is stored in the
carry bit flag:
ACC:P
Flags and N After the shift, if bit 31 of the ACC register is 1 then ACC:P is negative and
Modes the N bit is set; otherwise N is cleared.
Z After the shift, the Z flag is set if the combined 64-bit value of the ACC:P is
zero; otherwise, Z is cleared.
C The last bit shifted out of the combined 64-bit value is loaded into the C bit.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-55
ASR64 ACC:P,T
Description Arithmetic shift right the 64-bit combined value of the ACC:P registers by the
amount specified in six least significant bits of the T register, T(5:0) = 0…63.
Higher order bits are ignored. As the value is shifted, the most significant bits
are sign extended. If T specifies a shift of 0, then C is cleared; otherwise, C
is filled with the last bit to be shifted out of the ACC:P registers:
ACC:P Last bit out or cleared
C
Right shift
SIGN
Contents of T[5:0]
ACC:P
Flags and N After the shift, if bit 31 of the ACC register is 1 then ACC:P is negative and
Modes the N bit is set; otherwise N is cleared.
Z After the shift, the Z flag is set if the combined 64-bit value of the ACC:P is
zero; otherwise, Z is cleared.
C If (T[5:0] = 0) clear C; otherwise, the last bit shifted out of the combined 64-bit
value is loaded into the C bit.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-56
ASRL ACC,T
Description Perform an arithmetic shift right on the content of the ACC register as
specified by the five least significant bits of the T register, T(4:0) = 0…31.
Higher order bits are ignored. During the shift, the value is sign extended.
If T specifies a shift of 0, then C is cleared; otherwise, C is filled with the last
bit to be shifted out of the ACC register:
Last bit out or cleared
ACC
C
Right shift
SIGN
(Contents of T[4:0]
Flags and Z After the shift, the Z flag is set if the ACC value is zero, else Z is cleared. Even
Modes if the T register specifies a shift of 0, the content of the ACC register is still
tested for the zero condition and Z is affected.
N After the shift, the N flag is set if bit 31 of the ACC is 1, else N is cleared. Even
if the T register specifies a shift of 0, the content of the ACC register is still
tested for the negative condition and N is affected.
C If (T(4:0) = 0) then C is cleared; otherwise, the last bit shifted out is loaded
into the C flag bit.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-57
B 16bitOffset,COND
B 16bitOffset,COND Branch
Operands 16bit- 16-bit signed immediate constant offset value (−32768 to +32767 range)
Offset
COND Conditional codes:
COND Syntax Description Flags Tested
0000 NEQ Not Equal To Z = 0
0001 EQ Equal To Z = 1
0010 GT Greater Then Z = 0 AND N = 0
0011 GEQ Greater Then Or Equal To N = 0
0100 LT Less Then N = 1
0101 LEQ Less Then Or Equal To Z = 1 OR N = 1
0110 HI Higher C = 1 AND Z = 0
0111 HIS, C Higher Or Same, Carry Set C = 1
1000 LO, NC Lower, Carry Clear C = 0
1001 LOS Lower Or Same C = 0 OR Z = 1
1010 NOV No Overflow V = 0
1011 OV Overflow V = 1
1100 NTC Test Bit Not Set TC = 0
1101 TC Test Bit Set TC = 1
1110 NBIO BIO Input Equal To Zero BIO = 0
1111 UNC Unconditional −
Description Conditional branch. If the specified condition is true, then branch by adding
the signed 16-bit constant value to the current PC value; otherwise continue
execution without branching:
If (COND = true) PC = PC + signed 16-bit offset;
If (COND = false) PC = PC + 2;
Note: If (COND = true) then the instruction takes 7 cycles.
If (COND = false) then the instruction takes 4 cycles.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-58
BANZ 16bitOffset,ARn− −
Description If the 16-bit content of the specified auxiliary register is not equal to 0, then
the 16-bit sign offset is added to the PC value. This forces program control
to the new address (PC + 16bitOffset). The 16-bit offset is sign extended to
22 bits before the addition. Then, the content of the auxiliary register is
decremented by 1. The upper 16 bits of the auxiliary register (ARnH) is not
used in the comparison and is not affected by the post decrement:
if( ARn != 0 )
PC = PC + signed 16-bit offset;
ARn = ARn – 1;
ARnH = unchanged;
Note: If branch is taken, then the instruction takes 4 cycles
If branch is not taken, then the instruction takes 2 cycles
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-59
BAR 16bitOffset,ARn,ARm,EQ/NEQ
Operands 16bit- 16-bit signed immediate constant offset value (−32768 to +32767 range)
Offset
ARn Lower 16 bits of auxiliary registers XAR0 to XAR7
ARm Lower 16 bits of auxiliary registers XAR0 to XAR7
Syntax Description Condition Tested
NEQ Not Equal To ARn != ARm
EQ Equal To ARn = ARm
Description Compare the 16-bit contents of the two auxiliary registers ARn and ARm
registers and branch if the specified condition is true; otherwise continue
execution without branching:
If (tested condition = true) PC = PC + signed 16-bit offset;
If (tested condition = false) PC = PC + 2;
Note: If (tested condition = true) then the instruction takes 4 cycles.
If (tested condition = false) then the instruction takes 2 cycles.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-60
BF 16bitOffset,COND
Operands 16bit- 16-bit signed immediate constant offset value (−32768 to +32767 range)
Offset
COND Conditional codes:
COND Syntax Description Flags Tested
0000 NEQ Not Equal To Z = 0
0001 EQ Equal To Z = 1
0010 GT Greater Then Z = 0 AND N = 0
0011 GEQ Greater Then Or Equal To N = 0
0100 LT Less Then N = 1
0101 LEQ Less Then Or Equal To Z = 1 OR N = 1
0110 HI Higher C = 1 AND Z = 0
0111 HIS, C Higher Or Same, Carry Set C = 1
1000 LO, NC Lower, Carry Clear C = 0
1001 LOS Lower Or Same C = 0 OR Z = 1
1010 NOV No Overflow V = 0
1011 OV Overflow V = 1
1100 NTC Test Bit Not Set TC = 0
1101 TC Test Bit Set TC = 1
1110 NBIO BIO Input Equal To Zero BIO = 0
1111 UNC Unconditional −
Description Fast conditional branch. If the specified condition is true, then branch by
adding the signed 16-bit constant value to the current PC value; otherwise
continue execution without branching:
If (COND = true) PC = PC + signed 16-bit offset;
If (COND = false) PC = PC + 2;
Note: The branch fast (BF) instruction takes advantage of dual prefetch queue on
the C28x core that reduces the cycles for a taken branch from 7 to 4:
If (COND = true) then the instruction takes 4 cycles.
If (COND = false) then the instruction takes 4 cycles.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-61
C27MAP
Operands None
Description Clear the M0M1MAP status bit, configuring the mapping of the M0 and M1
memory blocks for C27x object-compatible operation. The memory blocks
are mapped as follows:
00 0400 00 0400
M1 M1 M0 M1
00 07FF 00 07FF
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Set the device mode from reset to C27x object-compatible mode:
Reset:
C27OBJ ; Enable C27x Object Mode
C28ADDR ; Enable C27x/C28x Address Mode
.c28_amode ; Tell assembler we are using C27x/C28x addressing
C27MAP ; Enable C27x Mapping Of M0 and M1 blocks
.
.
6-62
C27OBJ
Operands None
Description Clear the OBJMODE status bit in Status Register ST1, configuring the
device to execute C27x object code. This is the default mode of the
processor after reset.
Note: The pipeline is flushed when this instruction is executed.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-63
C28ADDR
Operands None
Description Clear the AMODE status bit in Status Register ST1, putting the device in
C27x/C28x addressing mode (see Chapter 5).
Note: This instruction does not flush the pipeline.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-64
C28MAP
Operands None
Description Set the M0M1MAP status bit in Status register ST1, configuring the
mapping of the M0 and M1 memory blocks for C28x operation. The
memory blocks are mapped as follows:
00 0400 00 0400
M1 M1 M0 M1
00 07FF 00 07FF
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-65
C28OBJ
Operands None
Description Set the OBJMODE status bit, putting the device in C28x object mode
(supports C2xLP source):
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-66
CLRC AMODE
Description Clear the AMODE status bit in Status Register ST1, enabling C27x/C28x
addressing (see Chapter 5).
Note: This instruction does not flush the pipeline.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-67
CLRC M0M1MAP
Description Clear the M0M1MAP status bit in Status Register ST1, configuring the
mapping of the M0 and M1 memory blocks for C27x operation. The
memory blocks are mapped as follows:
00 0400 00 0400
M1 M1 M0 M1
00 07FF 00 07FF
Note: The pipeline is flushed when this instruction is executed. This bit is provided for compatibility for users
migrating from C27x. The M0M1MAP bit should always remain set to 1 for users operating in C28x mode
and C2xLP source-compatible mode.
Example ; Set the device mode from reset to C27x object-compatible mode:
Reset:
CLRC OBJMODE ; Enable C27x Object Mode
CLRC AMODE ; Enable C27x/C28x Address Mode
.c28_amode ; Tell assembler we are in C27x/C28x addr mode
CLRC M0M1MAP ; Enable C27x Mapping Of M0 and M1 blocks
.
.
6-68
CLRC OBJMODE
Description Clear the OBJMODE status bit, enabling the device to execute C27x
object code.
Note: The pipeline is flushed when this instruction is executed.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Set the device mode from reset to C27x object-compatible mode:
Reset:
CLRC OBJMODE ; Enable C27x Object Mode
CLRC AMODE ; Enable C27x/C28x Address Mode
.c28_amode ; Tell assembler we are in C27x/C28x addr mode
CLRC M0M1MAP ; Enable C27x Mapping Of M0 and M1 blocks
.
.
6-69
CLRC OVC
Flags and OVC The 6-bit overflow counter bits (OVC) are cleared.
Modes
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-70
CLRC XF
Description Clear the XF status bit and pull the corresponding output signal low.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-71
CLRC Mode
Description Clear the specified status bits. The mode operand is a mask value that
relates to the status bits in this way:
Note: The assembler accepts any number of flag names in any order.
Flags and SXM Any of the specified bits can be cleared by the instruction.
Modes OVM
TC
C
INTM
DBGM
PAGE0
VMAP
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-72
CLRC Mode
6-73
CMP AX, loc16
Description The content of the specified AX register (AH or AL) is compared with the
16-bit content of the ___location pointed to by the “loc16” addressing mode. The
result of (AX−- [loc16] ) is evaluated and the status flag bits set accordingly.
The AX register and content of the ___location pointed to by “loc16” are left
unchanged:
Set Flags On (AX − [loc16]);
Flags and N If the result of the operation is negative, then N is set; otherwise it is cleared.
Modes The CMP instruction assumes infinite precision when it determines the sign
of the result. For example, consider the subtraction 0x8000 − 0x0001. If the
precision were limited to 16 bits, the result would cause an overflow to the
positive number 0x7FFF and N would be cleared. However, because the
CMP instruction assumes infinite precision, it would set N to indicate that
0x8000 − 0x0001 actually results in a negative number.
Z The comparison is tested for a zero condition. The zero flag bit is set if the
operation ( AX − [loc16] ) = 0, otherwise it is cleared.
C If the subtraction generates a borrow, then C is cleared; otherwise C is set.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-74
CMP loc16,#16bit
Description Compare the 16-bit contents of the ___location pointed to by the “loc16”
addressing mode to the signed 16-bit immediate constant value. To
perform the comparison, the result of ([loc16] − #16bitSigned ) is
evaluated and the status flag bits are set accordingly. The content of
“loc16” is left unchanged:
Modify flags on ([loc16] − 16bitSigned);
Smart Encoding:
If loc16 = AL or AH and #16bitSigned is an 8-bit number, then the
assembler will encode this instruction as CMPB AX, #8bit, to override
this encoding, use the CMPW AX, #16bitSigned instruction alias.
Flags and N If the result of the operation is negative, then N is set; otherwise it is
Modes cleared. The CMP instruction assumes infinite precision when it
determines the sign of the result. For example, consider the
subtraction 0x8000 − 0x0001. If the precision were limited to 16 bits,
the result would cause an overflow to the positive number 0x7FFF
and N would be cleared. However, because the CMP instruction
assumes infinite precision, it would set N to indicate that 0x8000 −
0x0001 actually results in a negative number.
Z The comparison is tested for a zero condition. The zero flag bit is set
if the operation ([loc16] − 16bitSigned ) = 0, otherwise it is cleared.
C If the subtraction generates a borrow, then C is cleared; otherwise C
is set.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only
once.
Note: The examples in this chapter assume that the device is already
operating in C28x Mode (OBJMODE = 1, AMODE = 0). To put the
device into C28x mode following a reset, you must first set the
OBJMODE bit in ST1 by executing the “C28OBJ” (or “SETC
OBJMODE”) instruction.
6-75
CMP loc16,#16bit
Example ; Calculate:
; if( VarA > 20 )
; VarA = 0;
CMP @VarA,#20 ; Set flags on (VarA − 20)
MOVB @VarA,#0,GT ; Zero VarA if greater then
6-76
CMP64 ACC:P
Description The 64-bit content of the combined ACC:P registers is compared against
zero and the flags are set appropriately:
if((V = 1) & (ACC(bit 31) = 1))
N = 0;
else
N = 1;
if((V = 1) & (ACC(bit 31) = 0))
N = 1;
else
N = 0;
if(ACC:P = 0x8000 0000 0000 0000)
Z = 1;
else
Z = 0;
V = 0;
Note: This operation should be used as follows:
CMP64 ACC:P ; Clear V flag
perform 64-bit operation
CMP64 ACC:P ; Set Z,N flags, V=0
conditionally branch
Flags and N The content of the ACC register is tested to determine if the 64-bit ACC:P
Modes value is negative. The CMP64 instruction takes into account the state of the
overflow flag (V) to increase precision when determining if ACC is negative.
For example, consider the subtraction on ACC of 0x8000 0000 − 0x0000
0001. This results in an overflow to a positive number (0x7FFF FFFF) and
V would be set. Because the CMP64 instruction takes into account the
overflow, it would interpret the result as a negative number and not a positive
number. If the value is ACC is found to be negative, then N is set; otherwise
N is cleared.
Z The zero flag bit is set if the combined 64 bits of ACC:P is zero, otherwise
it is cleared.
V The state of the V flag is used along with bit 31 of the ACC register to
determine if the value in the ACC:P register is negative. V is cleared by the
operation.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-77
CMP64 ACC:P
6-78
CMPB AX, #8bit
Description Compare the content of the specified AX register (AH or AL) with the
zero-extended 8-bit unsigned immediate constant. The result of (AX − 0:8bit)
is evaluated and the status flag bits are set accordingly. The content of the
AX register is left unchanged:
Set Flags On (AX − 0:8bit);
Flags and N If the result of the operation is negative, then N is set; otherwise it is cleared.
Modes The CMPB instruction assumes infinite precision when it determines the
sign of the result. For example, consider the subtraction 0x8000 − 0x0001.
If the precision were limited to 16 bits, the result would cause an overflow to
the positive number 0x7FFF and N would be cleared. However, because the
CMPB instruction assumes infinite precision, it would set N to indicate that
0x8000 − 0x0001 actually results in a negative number.
Z The comparison is tested for a zero condition. The zero flag bit is set if the
operation (AX − [0:8bit]) = 0, otherwise it is cleared.
C If the subtraction generates a borrow, then C is cleared; otherwise C is set.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Check if VarA is within range 0x80 <= VarA <= 0xF0:
MOV AL,@VarA ; Load AL with contents of VarA
CMPB AL,#0xF0 ; Set Flags On (AL − 0x00F0)
SB OutOfRange,GT ; Branch if VarA greater then 0x00FF
CMPB AL,#0x80 ; Set Flags On (AL − 0x0080)
SB OutOfRange,LT ; Branch if VarA less then 0x0080
6-79
CMPL ACC,loc32
Description The content of the ACC register is compared with the 32-bit ___location pointed
to by the “loc32” addressing mode. The status flag bits are set according to
the result of (ACC − [loc32]). The ACC register and the contents of the
___location pointed to by “loc32” are left unchanged:
Modify flags on (ACC − [loc32]);
Flags and N If the result of the operation is negative, then N is set; otherwise it is cleared.
Modes The CMPL instruction assumes infinite precision when it determines the sign
of the result. For example, consider the subtraction 0x8000 0000 − 0x0000
0001. If the precision were limited to 32 bits, the result would cause an
overflow to the positive number 0x7FFF FFFF and N would be cleared.
However, because the CMPL instruction assumes infinite precision, it would
set N to indicate that 0x8000 0000 − 0x0000 0001 actually results in a
negative number.
Z The comparison is tested for a zero condition. The zero flag bit is set if the
operation (AX − [loc32]) = 0, otherwise it is cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Swap the contents of 32-bit VarA and VarB if VarB is higher:
MOVL ACC,@VarB ; ACC = VarB
MOVL P,@VarA ; P = VarA
CMPL ACC,@P ; Set flags on (VarB - VarA)
MOVL @VarA,ACC,HI ; VarA = ACC if higher
MOVL @P,ACC,HI ; P = ACC if higher
MOVL @VarA,P ; VarA = P
6-80
CMPL ACC,P << PM
Description The content of the ACC register is compared with the content of the P
register, shifted by the amount specified by the product shift mode (PM). The
status flag bits are set according to the result of (ACC −[ P << PM]). The
content of the ACC register and the P register are left unchanged:
Modify flags on (ACC − [P << PM]);
Flags and N If the result of the operation is negative, then N is set; otherwise it is cleared.
Modes The CMPL instruction assumes infinite precision when it determines the sign
of the result. For example, consider the subtraction 0x8000 0000 − 0x0000
0001. If the precision were limited to 32 bits, the result would cause an
overflow to the positive number 0x7FFF FFFF and N would be cleared.
However, because the CMPL instruction assumes infinite precision, it would
set N to indicate that 0x8000 0000 − 0x0000 0001 actually results in a
negative number.
Z The comparison is tested for a zero condition. The zero flag bit is set if the
operation (AX − [P<<PM]) = 0, otherwise, it is cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-81
CMPR 0/1/2/3
Operands None
Description Compare AR0 to the 16-bit auxiliary register pointed to by ARP. The
comparison type is determined by the instruction.
CMPR 0: if(AR0 = AR[ARP]) TC = 1, else TC = 0
CMPR 1: if(AR0 > AR[ARP]) TC = 1, else TC = 0
CMPR 2: if(AR0 < AR[ARP]) TC = 1, else TC = 0
CMPR 3: if(AR0 != AR[ARP]) TC = 1, else TC = 0
Flags and ARP The 3-bit ARP points to the current valid Auxiliary Register, XAR0 to XAR7.
Modes This pointer determines which Auxiliary register is compared to AR0.
TC If the test is true, TC is set, else TC is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-82
CSB ACC
Description Count the sign bits in the ACC register by determining the number of leading
0s or 1s in the ACC register and storing the result, minus one, in the T
register:
T = 0, 1 sign bit
T = 1, 2 sign bits
.
.
T = 31, 32 sign bits
Note: The count sign bit operation is often used in normalization operations and is
particularly useful for algorithms such as; calculating Square Root of a
number, calculating the inverse of a number, searching for the first ”1” bit in a
word.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-83
DEC loc16
Description Subtract 1 from the signed content of the ___location pointed to by the “loc16”
addressing mode:
Flags and N After the operation if bit 15 of [loc16] is 1, set N; otherwise, clear N.
Modes
Z After the operation if [loc16] is zero, set Z; otherwise, clear Z.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-84
DINT
Operands None
Description Disable all maskable CPU interrupts by setting the INTM status bit. DINT has
no effect on the unmaskable reset or NMI interrupts.
Flags and INTM The instruction sets this bit to disable interrupts.
Modes
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-85
DMAC ACC:P,loc32,*XAR7/++
Description Dual 16-bit x 16-bit signed multiply and accumulate. The first
multiplication takes place between the upper words of the 32-bit locations
pointed to by the “loc32” and *XAR7/++ addressing modes and second
multiplication takes place with the lower words.
16−bits 16−bits
loc32 VarA_1 XAR7 VarB_1
VarA_2 VarB_2
XT Temp
VarA_1 VarA_2 VarB_1 VarB_2
After the operation the ACC contains the result of multiplying and adding
the upper word of the addressed 32-bit operands. The P register contains
the result of multiplying and adding the lower word of the addressed 32-bit
operands.
XT = [loc32];
Temp = Prog[*XAR7 or *XAR7++];
ACC = ACC + (XT.MSW * Temp.MSW) << PM;
P = P + (XT.LSW * Temp.LSW) << PM;
6-86
DMAC ACC:P,loc32,*XAR7/++
On the C28x devices, memory blocks are mapped to both program and
data space (unified memory), hence the ”*XAR7/++” addressing mode
can be used to access data space variables that fall within the program
space address range.
Flags and Z After the addition, the Z flag is set if the ACC value is zero, else Z is
Modes cleared.
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the
operation overflowed. Note that OVM only affects the ACC operation.
PM The value in the PM bits sets the shift mode for the output operation from
the product register. The PM mode affects both the ACC and P register
accumulates. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign
extended.
6-87
DMAC ACC:P,loc32,*XAR7/++
6-88
DMOV loc16
Description Copy the contents pointed to by ”loc16” into the next highest address:
[loc16 + 1] = [loc16];
6-89
EALLOW
Operands None
To again protect against writes to the registers, use the EDIS instruction.
EALLOW only controls write access; reads are allowed even if EALLOW
has not been executed.
On an interrupt or trap, the current state of the EALLOW bit is saved off onto
the stack within ST1 and the EALLOW bit is autocratically cleared.
Therefore, at the start of an interrupt service routine access to the protected
registers is disabled. The IRET instruction will restore the current state of
the EALLOW bit saved on the stack.
The EALLOW bit is overridden via the JTAG port, allowing full control of
register accesses during debug from Code Composer Studio.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Enable access to RegA and RegB which are EALLOW protected:
EALLOW ; Enable access to selected registers
AND @RegA,#0x4000 ; RegA = RegA AND 0x0400
MOV @RegB,#0 ; RegB = 0
EDIS ; Disable access to selected registers
6-90
EDIS
Operands None
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Enable access to RegA and RegB which are EALLOW protected:
EALLOW ; Enable access to selected registers
NOP ; Wait 2 cycles for enable to take
; effect. The number of cycles is device
; and/or register dependant.
NOP
AND @RegA,#0x4000 ; RegA = RegA AND 0x0400
MOV @RegB,#0 ; RegB = 0
EDIS ; Disable access to selected registers
6-91
EINT
Operands None
Flags and INTM This bit is cleared by the instruction to enable interrupts.
Modes
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-92
ESTOP0
Operands None
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-93
ESTOP1
Operands None
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-94
FFC XAR7,22bit
Description Fast function call. The return PC value is stored into the XAR7 register and
the 22-bit immediate destination address is loaded into the PC:
XAR7(21:0) = PC + 2;
XAR7(31:22) = 0;
PC = 22 bit;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
FuncA: ; Function A:
.
.
LB *XAR7 ; Return: branch to address in XAR7
6-95
FLIP AX
Description Bit reverse the contents of the specified AX register (AH or AL):
temp = AX;
AX(bit 0) = temp(bit 15);
AX(bit 1) = temp(bit 14);
.
.
AX(bit 14) = temp(bit 1);
AX(bit 15) = temp(bit 0);
Flags and N After the operation, if bit 15 of AX is 1 then the negative flag bit is set;
Modes otherwise it is cleared.
Z After the operation, if AX is 0, then the Z bit is set, otherwise it is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-96
IACK #16bit
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-97
IDLE
Operands None
Description Put the processor into idle mode and wait for enabled or nonmaskable
interrupt. Devices using the 28x CPU may use the IDLE instruction in
combination with external logic to achieve different low-power modes. See
the device-specific datasheets for more detail. The idle instruction causes
the following sequence of events:
1) The pipeline is flushed.
2) All outstanding memory cycles are completed.
3) The IDLESTAT bit of status register ST1 is set.
4) Clocks to the CPU are stopped after the entire instruction buffer is full,
placing the device in the idle state. In the idle state, CLKOUT (the
clock output from the CPU) and all clocks to blocks outside the CPU
(including the emulation block) continue to operate as long as CLKIN
(the clock input to the CPU) is driven. The PC continues to hold the
address of the IDLE instruction; the PC is not incremented before the
CPU enters the idle state.
5) The IDLE output CPU signal is activated (driven high).
6) The device waits for an enabled or nonmaskable hardware interrupt.
If such an interrupt occurs, the IDLESTAT bit is cleared, the PC is
incremented by 1, and the device exits the idle state.
If the interrupt is maskable, it must be enabled in the interrupt enable
register (IER). However, the device exits the idle state regardless of the
value of the interrupt global mask bit (INTM) of status register ST1.
After the device exits the idle mode, the CPU must respond to the interrupt
request. If the interrupt can be disabled by the INTM bit in status register
ST1, the next event depends on INTM:
- If (INTM = 0), then the interrupt is enabled, and the CPU executes the
corresponding interrupt service routine. On return from the interrupt,
execution begins at the instruction following the IDLE instruction.
- If (INTM = 1), then the interrupt is blocked and program execution
continues at the instruction immediately following the IDLE.
If the interrupt cannot be disabled by INTM, the CPU executes the
corresponding interrupt service routine. On return from the interrupt,
execution begins at the instruction following the IDLE.
6-98
IDLE
Flags and IDLESTAT Before entering the idle mode, IDLESTAT is set; after exiting the idle mode
Modes IDLESTAT is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-99
IMACL P,loc32,*XAR7/++
Description 32-bit x 32-bit signed multiply and accumulate. First, add the unsigned
previous product (stored in the P register), ignoring the product shift mode
(PM), to the ACC register. Then, multiply the signed 32-bit content of the
___location pointed to by the “loc32” addressing mode by the signed 32-bit
content of the program-memory ___location pointed to by the XAR7 register.
The product shift mode (PM) then determines which part of the lower 38
bits of the 64-bit result are stored in the P register. If specified,
post-increment the XAR7 register by 1:
ACC = ACC + unsigned P;
temp(37:0) = lower_38 bits(signed [loc32]
* signed Prog[*XAR7 or XAR7++]);
if( PM = +4 shift )
P(31:4) = temp(27:0), P(3:0) = 0;
if( PM = +1 shift )
P(31:1) = temp(30:0), P(0) = 0;
if( PM = 0 shift )
P(31:0) = temp(31:0);
if( PM = −1 shift )
P(31:0) = temp(32:1);
if( PM = −2 shift )
P(31:0) = temp(33:2);
if( PM = −3 shift )
P(31:0) = temp(34:3);
if( PM = −4 shift )
P(31:0) = temp(35:4);
if( PM = −5 shift )
P(31:0) = temp(36:5);
if( PM = −6 shift )
P(31:0) = temp(37:6);
6-100
IMACL P,loc32,*XAR7/++
On the C28x devices, memory blocks are mapped to both program and
data space (unified memory), hence the ”*XAR7/++” addressing mode
can be used to access data space variables that fall within the program
space address range. With some addressing mode combinations, you can
get conflicting references. In such cases, the C28x will give the
“loc16/loc32” field priority on changes to XAR7.
For example:
IMACL P,*−−XAR7,*XAR7++ ; −−XAR7 given priority
IMACL P,*XAR7++,*XAR7 ; *XAR7++ given priority
IMACL P,*XAR7,*XAR7++ ; *XAR7++ given priority
Flags and Z After the addition, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVCU The overflow counter is incremented when the addition operation
generates an unsigned carry. The OVM mode does not affect the OVCU
counter.
PM The value in the PM bits sets the shift mode that determines which portion
of the lower 38 bits of the 64-bit results are stored in the P register.
6-101
IMACL P,loc32,*XAR7/++
6-102
IMPYAL P,XT,loc32
IMPYAL P,XT,loc32 Signed 32-Bit Multiply (Lower Half) and Add Previous P
Description Add the unsigned content of the P register, ignoring the product shift mode
(PM), to the ACC register. Multiply the signed 32-bit content of the XT
register by the signed 32-bit content of the ___location pointed to by the “loc32”
addressing mode. The product shift mode (PM) then determines which part
of the lower 38 bits of the 64-bit result are stored in the P register:
ACC = ACC + unsigned P;
temp(37:0) = lower_38 bits(signed XT * signed [loc32]);
if( PM = +4 shift )
P(31:4) = temp(27:0), P(3:0) = 0;
if( PM = +1 shift )
P(31:1) = temp(30:0), P(0) = 0;
if( PM = 0 shift )
P(31:0) = temp(31:0);
if( PM = −1 shift )
P(31:0) = temp(32:1);
if( PM = −2 shift )
P(31:0) = temp(33:2);
if( PM = −3 shift )
P(31:0) = temp(34:3);
if( PM = −4 shift )
P(31:0) = temp(35:4);
if( PM = −5 shift )
P(31:0) = temp(36:5);
if( PM = −6 shift )
P(31:0) = temp(37:6);
Flags and Z After the addition, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVCU The overflow counter is incremented when the addition operation generates
an unsigned carry. The OVM mode does not affect the OVCU counter.
PM The value in the PM bits sets the shift mode that determines which portion
of the lower 38 bits of the 64-bit results are stored in the P register.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-103
IMPYAL P,XT,loc32
6-104
IMPYL ACC,XT,loc32
Description Multiply the signed 32-bit content of the XT register by the signed 32-bit
content of the ___location pointed to by the “loc32” addressing mode and store
the lower 32 bits of the 64-bit result in the ACC register:
ACC = signed XT * signed [loc32];
Flags and Z After the operation, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-105
IMPYL P,XT,loc32
Description Multiply the signed 32-bit content of the XT register by the signed 32-bit
content of the ___location pointed to by the “loc32” addressing mode. The
product shift mode (PM) then determines which part of the lower 38 bits of
the 64-bit result gets stored in the P register as shown in the diagram below:
temp(37:0) = lower_38 bits(signed XT * signed [loc32]);
if( PM = +4 shift )
P(31:4) = temp(27:0), P(3:0) = 0;
if( PM = +1 shift )
P(31:1) = temp(30:0), P(0) = 0;
if( PM = 0 shift )
P(31:0) = temp(31:0);
if( PM = −1 shift )
P(31:0) = temp(32:1);
if( PM = −2 shift )
P(31:0) = temp(33:2);
if( PM = −3 shift )
P(31:0) = temp(34:3);
if( PM = −4 shift )
P(31:0) = temp(35:4);
if( PM = −5 shift )
P(31:0) = temp(36:5);
if( PM = −6 shift )
P(31:0) = temp(37:6);
Flags and PM The value in the PM bits sets the shift mode that determines which portion
Modes of the lower 38 bits of the 64-bit results are stored in the P register.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-106
IMPYSL P,XT,loc32
Description Subtract the unsigned content of the P register, ignoring the product shift
mode (PM), from the ACC register. Multiply the signed 32-bit content of the
XT register by the signed 32-bit content of the ___location pointed to by the
“loc32” addressing mode. The product shift mode (PM) then determines
which part of the lower 38 bits of the 64-bit result are stored in the P register:
ACC = ACC - unsigned P;
temp(37:0) = lower_38 bits(signed XT * signed [loc32]);
if( PM = +4 shift )
P(31:4) = temp(27:0), P(3:0) = 0;
if( PM = +1 shift )
P(31:1) = temp(30:0), P(0) = 0;
if( PM = 0 shift )
P(31:0) = temp(31:0);
if( PM = −1 shift )
P(31:0) = temp(32:1);
if( PM = −2 shift )
P(31:0) = temp(33:2);
if( PM = −3 shift )
P(31:0) = temp(34:3);
if( PM = −4 shift )
P(31:0) = temp(35:4);
if( PM = −5 shift )
P(31:0) = temp(36:5);
if( PM = −6 shift )
P(31:0) = temp(37:6);
Flags and Z After the subtraction, the Z flag is set if the ACC value is zero, else Z is
Modes cleared.
N After the subtraction, the N flag is set if bit 31 of the ACC is 1, else N is
cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected.
OVCU The overflow counter is decremented when the subtraction operation
generates an unsigned borrow. The OVM mode does not affect the OVCU
counter.
6-107
IMPYSL P,XT,loc32
PM The value in the PM bits sets the shift mode that determines which portion
of the lower 38 bits of the 64-bit results are stored in the P register.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-108
IMPYXUL P,XT,loc32
Description Multiply the signed 32-bit content of the XT register by the unsigned 32-bit
content of the ___location pointed to by the “loc32” addressing mode. The
product shift mode (PM) then determines which part of the lower 38 bits of
the 64-bit result are stored in the P register:
temp(37:0) = lower_38 bits(signed XT * unsigned [loc32]);
if( PM = +4 shift )
P(31:4) = temp(27:0), P(3:0) = 0;
if( PM = +1 shift )
P(31:1) = temp(30:0), P(0) = 0;
if( PM = 0 shift )
P(31:0) = temp(31:0);
if( PM = −1 shift )
P(31:0) = temp(32:1);
if( PM = −2 shift )
P(31:0) = temp(33:2);
if( PM = −3 shift )
P(31:0) = temp(34:3);
if( PM = −4 shift )
P(31:0) = temp(35:4);
if( PM = −5 shift )
P(31:0) = temp(36:5);
if( PM = −6 shift )
P(31:0) = temp(37:6);
Flags and PM The value in the PM bits sets the shift mode that determines which portion
Modes of the lower 38 bits of the 64-bit results are stored in the P register.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-109
IMPYXUL P,XT,loc32
6-110
IN loc16,*(PA)
Flags and N If (loc16 = @AX), then after the move AX is tested for a negative condition.
Modes The negative flag bit is set if bit 15 of AX is 1, otherwise it is cleared.
Z If (loc16 = @AX), then after the move, AX is tested for a zero condition. The
zero flag bit is set if AX = 0, otherwise it is cleared.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. When repeated, the “(PA)” I/O space address
is post-incremented by 1 during each repetition.
Example ; IORegA address = 0x0300;
; IOREgB address = 0x0301;
; IOREgC address = 0x0302;
; IORegA = 0x0000;
; IORegB = 0x0400;
; IORegC = VarA;
; if( IORegC = 0x2000 )
; IORegC = 0x0000;
IORegA .set 0x0300 ; Define IORegA address
IORegB .set 0x0301 ; Define IORegB address
IORegC .set 0x0302 ; Define IORegC address
MOV @AL,#0 ; AL = 0
UOUT *(IORegA),@AL ; IOspace[IORegA] = AL
MOV @AL,#0x0400 ; AL = 0x0400
UOUT *(IORegB),@AL ; IOspace[IORegB] = AL
OUT *(IORegC),@VarA ; IOspace[IORegC] = VarA
IN @AL,*(IORegC) ; AL = IOspace[IORegC]
CMP @AL,#0x2000 ; Set flags on (AL − 0x2000)
SB $10,NEQ ; Branch if not equal
6-111
IN loc16,*(PA)
MOV @AL,#0 ; AL = 0
UOUT *(IORegC),@AL ; IOspace[IORegC] = AL
$10:
6-112
INC loc16
Description Add 1 to the signed content of the ___location pointed to by the “loc16”
addressing mode:
[loc16] = [loc16] + 1;
Flags and N After the operation if bit 15 of [loc16] 1, set N; otherwise, clear N.
Modes
Z After the operation if [loc16] is zero, set Z; otherwise, clear Z.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-113
INTR
6-114
INTR
Part of the operation involves saving pairs of 16-bit CPU registers onto the
stack pointed to by the SP register. Each pair of registers is saved in a
single 32-bit operation. The register forming the low word of the pair is
saved first (to an even address); the register forming the high word of the
pair is saved next (to the following odd address). For example, the first
value saved is the concatenation of the T register and the status register
ST0 (T:ST0). ST0 is saved first, then T.
This instruction should not be used with vectors 1−12 when the peripheral
interrupt expansion (PIE) block is enabled.
Flags and DBGM Debug events are disabled by setting the DBGM bit.
Modes
INTM Setting the INTM bit disables maskable interrupts.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-115
IRET
Operands None
Description Return from an interrupt. The IRET instruction restores the PC value and
other register values that were automatically saved by an interrupt
operation. The order in which the values are restored is opposite to the order
in which they were saved. All values are popped from the stack using 32-bit
operations. The stack pointer is not forced to align to an even address during
the register restore operations:
SP = SP – 2;
PC = [SP];
SP = SP – 2;
DBGSTAT:IER = [SP];
SP = SP − 2;
DP:ST1 = [SP];
SP = SP – 2;
AR1:AR0 = [SP];
SP = SP – 2;
PH:PL = [SP];
SP = SP – 2;
AH:AL = [SP];
SP = SP – 2;
T:ST0 = [SP];
SP = SP – 1;
Note: Interrupts cannot be serviced until the IRET instruction completes execution.
Flags and SXM The operation restores the state of all flags and modes of the ST0 register.
Modes
OVM
TC
C
Z
N
V
PM
OVC
INTM The operation restores the state of the specified flags and modes of the ST1
register. The following bits are not affected: LOOP, IDLESTAT, M0M1MAP
6-116
IRET
DBGM
PAGEO
VMAP
SPA
EAL-
LOW
AMODE
OBJ-
MODE
XF
ARP
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-117
IRET
6-118
LB *XAR7
Operands *XAR7 indirect program-memory addressing using auxiliary register XAR7, can
access full 4Mx16 program space range (0x000000 to 0x3FFFFF)
Description Long branch indirect. Load the PC with the lower 22 bits of the XAR7 register:
PC = XAR7(21:0);
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Switch0: ; Function A:
.
.
LB SwitchReturn ; Return: long branch
Switch1: ; Function B:
.
.
LB SwitchReturn ; Return: long branch
6-119
LB 22bit
Description Long branch. Load the PC with the selected 22-bit program address:
PC = 22bit;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Switch0: ; Function A:
.
.
LB SwitchReturn ; Return: long branch
Switch1: ; Function B:
.
.
LB SwitchReturn ; Return: long branch
6-120
LC *XAR7
Operands *XAR7 indirect program-memory addressing using auxiliary register XAR7, can
access full 4Mx16 program space range (0x000000 to 0x3FFFFF)
Description Indirect long call. The return PC value is pushed onto the software stack,
pointed to by SP register, in two 16-bit operations. Next, the destination
address stored in the XAR7 register is loaded into the PC:
temp(21:0) = PC + 1;
[SP] = temp(15:0);
SP = SP + 1;
[SP] = temp(21:16);
SP = SP + 1;
PC = XAR7(21:0);
Note: For more efficient function calls when operating with OBJMODE = 1, use the
LCR and LRETR instructions instead of the LC and LRET instructions.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Switch1: ; Subroutine 1:
.
.
LRET ; Return
6-121
LC 22bit
Description Long function call. The return PC value is pushed onto the software stack,
pointed to by SP register, in two 16-bit operations. Next, the immediate 22-bit
destination address is loaded onto the PC:
temp(21:0) = PC + 2;
[SP] = temp(15:0);
SP = SP + 1;
[SP] = temp(21:16)
SP = SP + 1;
PC = 22bit;
Note: For more efficient function calls when operating with OBJMODE = 1, use the
LCR and LRETR instructions instead of the LC and LRET instructions.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
FuncA: ; Function A:
.
.
LRET ; Return from address on stack
6-122
LCR #22bit
Description Long call using return PC pointer (RPC). The current RPC value is pushed
onto the software stack, pointed to by SP register, in two 16-bit operations.
Next, the RPC register is loaded with the return address. Next, the 22-bit
immediate destination address is loaded into the PC:
[SP] = RPC(15:0);
SP = SP + 1;
[SP] = RPC(21:16);
SP = SP + 1;
RPC = PC + 2;
PC = 22bit;
Note: The LCR and LRETR operations, enable 4 cycle call and 4 cycle return. The
standard LC and LRET operations only enable a 4 cycle call and 8 cycle
return. The LCR and LRETR operations can be nested and can freely replace
the LC and LRET operations. This is the case on interrupts also. Only on a
task switch operation, does the RPC need to be manually saved and
restored.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
FuncA: ; Function A:
.
.
LRETR ; RPC return
6-123
LCR *XARn
6-124
LOOPNZ loc16,#16bit
The LOOPNZ instruction uses a bitwise AND operation to compare the value
referenced by the “loc16” addressing mode and the 16-bit mask value. The
instruction performs this comparison repeatedly for as long as the result of
the operation is not 0. The process can be described as follows:
6-125
LOOPNZ loc16,#16bit
The LOOPNZ instruction does not flush prefetched instructions from the
pipeline. However, when an interrupt occurs, prefetched instructions are
flushed.
When any interrupt occurs, the current state of the LOOP bit is saved as ST1
is saved on the stack. The LOOP bit in ST1 is then cleared by the interrupt.
The LOOP bit is a passive status bit. The LOOPNZ instruction changes
LOOP, but LOOP does not affect the instruction.
You can abort the LOOPNZ instruction within an interrupt service routine.
Test the LOOP bit saved on the stack. If it is set, then increment (by 2) the
return address on the stack. Upon return from the interrupt, this incremented
address is loaded into the PC and the instruction following the LOOPNZ is
executed.
Flags and N If bit 15 of the result of the AND operation is 1, set N; otherwise, clear N.
Modes
Z If the result of the AND operation is 0, set Z; otherwise, clear Z.
LOOP LOOP is repeatedly set while the result of the AND operation is not 0. LOOP
is cleared when the result is 0. If an interrupt occurs before the LOOPNZ
instruction enters the decode 2 phase of the pipeline, the instruction is
flushed from the pipeline and, thus, does not affect the LOOP bit.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-126
LOOPZ loc16,#16bit
The LOOPZ instruction uses a bitwise AND operation to compare the value
referenced by the “loc16” addressing mode and the 16-bit mask value. The
instruction performs this comparison repeatedly for as long as the result of
the operation is 0. The process can be described as follows:
6-127
LOOPZ loc16,#16bit
The LOOPZ instruction does not flush prefetched instructions fr4om the
pipeline. However, when an interrupt occurs, prefetched instructions are
flushed.
When any interrupt occurs, the current state of the LOOP bit is saved as ST1
is saved on the stack. The LOOP bit in ST1 is then cleared by the interrupt.
The LOOP bit is a passive status bit. The LOOPZ instruction changes LOOP,
but LOOP does not affect the instruction.
You can abort the LOOPZ instruction within an interrupt service routine. Test
the LOOP bit saved on the stack. If it is set, then increment (by 2) the return
address on the stack. Upon return from the interrupt, this incremented
address is loaded into the PC and the instruction following the LOOPZ is
executed.
Flags and N If bit 15 of the result of the AND operation is 1, set N; otherwise, clear N.
Modes
Z If the result of the AND operation is 0, set Z; otherwise, clear Z.
LOOP LOOP is repeatedly set while the result of the AND operation is 0. LOOP is
cleared when the result is not 0. If an interrupt occurs before the LOOPZ
instruction enters the decode 2 phase of the pipeline, the instruction is
flushed from the pipeline and, thus, does not affect the LOOP bit.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-128
LPADDR
Operands None
Description Set the AMODE status bit, putting the device in C2xLP compatible
addressing mode (see Chapter 5).
Note: This instruction does not flush the pipeline.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Execute the operation ”VarC = VarA + VarB” written in C2xLP syntax:
LPADDR ; Full C2xLP address compatible mode
.lp_amode ; Tell assembler we are in C2XLP mode
LDP #VarA ; Initialize DP (low 64K only)
LACL VarA ; ACC = VarA (ACC high = 0)
ADDS VarB ; ACC = ACC + VarB (unsigned)
SACL VarC ; Store result into VarC
C28ADDR ; Return to C28x address mode
.c28_amode ; Tell assembler we are in C28x mode
6-129
LRET
Operands None
Description Long return. The return address is popped, from the software stack into the
PC, in two 16-bit operations:
SP = SP – 1;
temp(31:16) = [SP];
SP = SP − 1;
temp(15:0) = [SP];
PC = temp(21:0);
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
FuncA: ; Function A:
.
.
LRET ; Return from address on stack
6-130
LRETE
Operands None
Description Long return and enable interrupts. The return address is popped, from the
software stack into the PC, in two 16-bit operations. Next, the global interrupt
flag (INTM) is cleared. This enables global maskable interrupts:
SP = SP – 1;
temp(31:16) = [SP];
SP = SP − 1;
temp(15:0) = [SP];
PC = temp(21:0);
INTM = 0;
Flags and INTM This instruction enables interrupts by clearing the INTM bit.
Modes
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
FuncA: ; Function A:
SETC INTM ; Disable interrupts
.
.
LRETE ; Return from address on stack,
; Enable interrupts
6-131
LRETR
Operands None
Description Long return using return PC pointer (RPC). The return address stored in the
RPC register is loaded onto the PC. Next, the RPC register is loaded from
the software stack in two 16-bit operations:
PC = RPC;
SP = SP – 1;
temp(31:16) = [SP];
SP = SP − 1;
temp(15:0) = [SP];
RPC = temp(21:0);
Note: The LCR and LRETR operations, enable 4 cycle call and 4 cycle return. The
standard LC and LRET operations only enable a 4 cycle call and 8 cycle
return. The LCR and LRETR operations can be nested and can freely replace
the LC and LRET operations. This is the case on interrupts also. Only on a
task switch operation, does the RPC need to be manually saved and
restored.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
FuncA: ; Function A:
.
.
LRETR ; RPC return
6-132
LSL ACC,#1..16
Description Perform a logical shift left on the content of the ACC register by the amount
specified by the shift value. During the shift, the low order bits of the ACC
register are zero filled and the last bit shifted out is stored in the carry flag bit:
Last bit out ACC
C
Left shift 0
(Immediate value)
Discard
other bits
ACC
Flags and N After the shift, if bit 31 of ACC is 1 then the negative flag bit is set; otherwise
Modes it is cleared.
Z After the shift, if ACC is 0, then the Z bit is set, otherwise it is cleared.
C The last bit to be shifted out of ACC is stored in C.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
the LSL instruction will be executed N+1 times. The state of the Z, N, and C
flags will reflect the final result.
6-133
LSL ACC,T
Description Perform a logical shift left on the content of the ACC register by the amount
specified by the four least significant bits of the T register, T(3:0) = 0…15.
Higher order bits are ignored. During the shift, the low order bits of the ACC
register are zero filled. If T specifies a shift of 0, then C is cleared; otherwise,
C is filled with the last bit to be shifted out of the ACC register:
Left shift
0
(Contents T(3:0)
Flags and Z After the shift, the Z flag is set if the ACC value is zero, else Z is cleared. Even
Modes if the T register specifies a shift of 0, the content of the ACC register is still
tested for the zero condition and Z is affected.
N After the shift, the N flag is set if bit 31 of the ACC is 1, else N is cleared. Even
if the T register specifies a shift of 0, the content of the ACC register is still
tested for the negative condition and N is affected.
C If (T(3:0) = 0) then C is cleared; otherwise, the last bit shifted out is loaded
into the C flag bit.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-134
LSL AX,#1...16
Description Perform a logical shift left on the content of the specified AX register (AH or
AL) by the amount given “shift value” field. During the shift, the low order bits
of the AX register are zero filled and the last bit to be shifted out is stored in
the carry bit flag:
Left shift
(Immediate value) 0
Discard
other bits
AX
Flags and N After the shift, if bit 15 of AX is 1 then the negative flag bit is set; otherwise
Modes it is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-135
LSL AX,T
Description Perform a logical shift left on the content of the specified AX register by the
amount specified by the four least significant bits of the T register, T(3:0). The
contents of higher order bits are ignored. During the shift, the low order bits
of the AX register are zero filled. If the T(3:0) register bits specify a shift of
0, then C is cleared; otherwise, C is filled with the last bit to be shifted out of
AX:
Last bit out or cleared AX
C
Left shift
0
(Contents of T(3:0)
Discard
other bits
AX
Flags and N After the shift, if bit 15 of AX is 1 then the negative flag bit is set; otherwise
Modes it is cleared. Even if the T(3:0) register bits specify a shift of 0, the value of
AH or AL is still tested for the negative condition and N is affected.
Z After the shift, if AX is 0, then the Z bit is set, otherwise it is cleared. Even if
the T(3:0) register bits specify a shift of 0, the value of AH or AL is still tested
for the zero condition and Z is affected.
C If T(3:0) specifies a shift of 0, then C is cleared; otherwise, C is filled with the
last bit to be shifted out of AH or AL.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-136
LSL64 ACC:P,#1..16
Description Logical shift left the 64-bit combined value of the ACC:P registers by the
amount specified in the shift value field. During the shift, the low order bits
are zero-filled and the last bit shifted out is stored in the carry bit flag:
Last bit out
ACC:P
C
Left shift
0
(Immediate value)
Flags and- N After the shift, if bit 31 of the ACC register is 1 then ACC:P is negative and
Modes the N bit is set; otherwise N is cleared.
Z After the shift, the Z flag is set if the combined 64-bit value of the ACC:P is
zero; otherwise, Z is cleared.
C The last bit shifted out of the combined 64-bit value is loaded into the C bit.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-137
LSL64 ACC:P,T
Description Logical shift left the 64-bit combined value of the ACC:P registers by the
amount specified in the six least significant bits of the T register,
T(5:0) = 0…63. Higher order bits are ignored. During the shift, the low order
bits are zero-filled. If T specifies a shift of 0, then C is cleared; otherwise, C
is filled with the last bit to be shifted out of the ACC:P registers:
Last bit out or cleared
ACC:P
C
Left shift
0
contents of T (5:0)
Discard
other bits
ACC:P
Flags and N After the shift, if bit 31 of the ACC register is 1 then ACC:P is negative and
Modes the N bit is set; otherwise N is cleared.
Z After the shift, the Z flag is set if the combined 64-bit value of the ACC:P is
zero; otherwise, Z is cleared.
C If (T(5:0) = 0) clear C; otherwise, the last bit shifted out of the combined 64-bit
value is loaded into the C bit.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-138
LSLL ACC,T
Description Perform a logical shift left on the content of the ACC register by the amount
specified by the five least significant bits of the T register, T(4:0) = 0…31.
Higher order bits are ignored. During the shift, the low order bits of the ACC
register are zero filled. If T specifies a shift of 0, then C is cleared; otherwise,
C is filled with the last bit to be shifted out of the ACC register:
Last bit out or cleared ACC
C
Left shift
(Contents of T (4:0) 0
Discard
other bits
ACC
Flags and Z After the shift, the Z flag is set if the ACC value is zero, else Z is cleared. Even
Modes if the T register specifies a shift of 0, the content of the ACC register is still
tested for the zero condition and Z is affected.
N After the shift, the N flag is set if bit 31 of the ACC is 1, else N is cleared. Even
if the T register specifies a shift of 0, the content of the ACC register is still
tested for the negative condition and N is affected.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-139
LSR AX,#1...16
Description Perform a logical right shift on the content of the specified AX register by the
amount given by the “shift value” field. During the shift, the high order bits
of the AX register are zero filled and the last bit to be shifted out is stored in
the carry flag bit:
Right shift
0
(Immediate value)
Discard
other bits
AX
Flags and N After the shift, if bit 15 of AX is 1 then the negative flag bit is set; otherwise
Modes it is cleared.
Z After the shift, if AX is 0, then the Z bit is set, otherwise it is cleared.
C The last bit to be shifted out of AH or AL is stored in C.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-140
LSR AX,T
Description Perform a logical shift right on the content of the specified AX register (AH
or AL) as specified by the four least significant bits of the T register, T(3:0).
The contents of higher order bits are ignored. During the shift, the high order
bits of the AX register are zero filled If the T(3:0) register bits specify a shift
of 0, then C is cleared; otherwise, C is filled with the last bit to be shifted out
of AX:
Right shift
0 Contents of T (3:0)
Discard
other bits
AX
Flags and N After the shift, if bit 15 of AX is 1 then the negative flag bit is set; otherwise
Modes it is cleared. Even if the T(3:0) register bits specify a shift of 0, the value of
AH or AL is still tested for the negative condition and N is affected.
Z After the shift, if AX is 0, then the Z bit is set, otherwise it is cleared. Even if
the T(3:0) register bits specify a shift of 0, the value of AH or AL is still tested
for the zero condition and Z is affected.
C If T(3:0) specifies a shift of 0, then C is cleared; otherwise, C is filled with the
last bit to be shifted out of AH or AL.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-141
LSR64 ACC:P,#1..16
Description Logical shift right the 64-bit combined value of the ACC:P registers by the
amount specified in the shift value field. As the value is shifted, the most
significant bits are zero filled and the last bit shifted out is stored in the carry
bit flag:
Right shift
0
(Immediate value)
Discard
other bits
ACC:P
Flags and N After the shift, if bit 31 of the ACC register is 1 then ACC:P is negative and
Modes the N bit is set; otherwise N is cleared.
Z After the shift, the Z flag is set if the combined 64-bit value of the ACC:P is
zero; otherwise, Z is cleared.
C The last bit shifted out of the combined 64-bit value is loaded into the C bit.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-142
LSR64 ACC:P,T
Description Logical shift right the 64-bit combined value of the ACC:P registers by the
amount specified by the six least significant bits of the T register,
T(5:0) = 0…63. Higher order bits are ignored. As the value is shifted, the
most significant bits are zero filled. If T specifies a shift of 0, then C is cleared;
otherwise, C is filled with the last bit to be shifted out of the ACC:P registers:
Right shift
0 (Contents of T(5:0)
Discard
other bits
ACC:P
Flags and N After the shift, if bit 31 of the ACC register is 1 then ACC:P is negative and
Modes the N bit is set; otherwise N is cleared.
Z After the shift, the Z flag is set if the combined 64-bit value of the ACC:P is
zero; otherwise, Z is cleared.
C If (T(5:0) = 0) clear C; otherwise, the last bit shifted out of the combined 64-bit
value is loaded into the C bit.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-143
LSRL ACC,T
Description Perform a logical shift right on the content of the ACC register as specified
by the five least significant bits of the T register, T(4:0) = 0…31. Higher order
bits are ignored. During the shift, the high order bits of ACC are zero-filled.
If T specifies a shift of 0, then C is cleared; otherwise, C is filled with the last
bit to be shifted out of the ACC register:
Last bit out or cleared
ACC
C
Right shift
0 Contents of T (4:0)
Discard
other bits
ACC
Flags and Z After the shift, the Z flag is set if the ACC value is zero, else Z is cleared. Even
Modes if the T register specifies a shift of 0, the content of the ACC register is still
tested for the zero condition and Z is affected.
N After the shift, the N flag is set if bit 31 of the ACC is 1, else N is cleared. Even
if the T register specifies a shift of 0, the content of the ACC register is still
tested for the negative condition and N is affected.
C If (T(4:0) = 0) then C is cleared; otherwise, the last bit shifted out is loaded
into the C flag bit.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-144
MAC P,loc16,0:pma
Description 1) Add the previous product (stored in the P register), shifted as specified
by the product shift mode (PM), to the ACC register.
2) Load the T register with the content of the ___location pointed to by the
“loc16” addressing mode.
3) Multiply the signed 16-bit content of the T register by the signed 16-bit
content of the addressed program memory ___location and store the 32-bit
result in the P register:
ACC = ACC + P << PM;
T = [loc16];
P = signed T * signed Prog[0x00:pma];
The C28x forces the upper 6 bits of the program memory address, specified
by the “0:pma” addressing mode, to 0x00 when using this form of the MAC
instruction. This limits the program memory address to the low 64K of
program address space (0x000000 to 0x00FFFF). On the C28x devices,
memory blocks are mapped to both program and data space (unified
memory), hence the “0:pma” addressing mode can be used to access data
space variables that fall within its address range.
Flags and Z After the addition, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If overflow mode is disabled; and if the operation generates a positive
overflow, then the counter is incremented. If overflow mode is disabled; and
if the operation generates a negative overflow, then the counter is
decremented.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
6-145
MAC P,loc16,0:pma
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. The state of the Z, N, C and OVC flags will
reflect the final result. The V flag will be set if an intermediate overflow
occurs. When repeated, the program-memory address is incremented by 1
during each repetition.
6-146
MAC P ,loc16,*XAR7/++
On the C28x devices, memory blocks are mapped to both program and data
space (unified memory), hence the “XAR7/++” addressing mode can be
used to access data space variables that fall within the program space
address range.
6-147
MAC P ,loc16,*XAR7/++
Flags and Z After the addition, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If overflow mode is disabled; and if the operation generates a positive
overflow, then the counter is incremented. If overflow mode is disabled; and
if the operation generates a negative overflow, then the counter is
decremented.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. The state of the Z, N, C and OVC flags will
reflect the final result. The V flag will be set if an intermediate overflow
occurs.
6-148
MAX AX, loc16
Description Compare the signed contents of the specified AX register (AH or AL) with the
signed content of the ___location pointed to by the “loc16” addressing mode and
load the AX register with the larger of these two values:
if(AX < [loc16]), AX = [loc16];
if(AX >= [loc16]), AX = unchanged;
Flags and N If AX is less than the contents of the addressed ___location (AX < [loc16]) then
Modes the negative flag bit will be set; otherwise, it will be cleared.
Z If AX and the contents of the addressed ___location are equal (AX = [loc16]) then
the zero flag bit will be set; otherwise, it will be cleared.
V If AX is less than the contents of the addressed ___location (AX < [loc16]) then
the overflow flag bit will be set. This instruction cannot clear the V flag.
Repeat If the operation is follows a RPT instruction, the instruction will be executed
N+1 times. The state of the N, Z, and V flags will reflect the final result.
6-149
MAXCUL P,loc32
Description Based on the state of the N and Z flags, conditionally compare the unsigned
contents of the P register with the 32-bit, unsigned content of the ___location
pointed to by the “loc32” addressing mode and load the P register with the
larger of the two numbers:
if( (N=1) & (Z=0) )
P = [loc32];
if( (N=0) & (Z=1) & (P < [loc32]) )
V=1, P = [loc32];
if( (N=0) & (Z=0) )
P = unchanged;
Note: The “P < [loc32]” operation is treated like a 32-bit unsigned compare.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-150
MAXCUL P,loc32
6-151
MAXL ACC,loc32
Description Compare the content of the ACC register with the ___location pointed to by the
“loc32” addressing mode and load the ACC register with the larger of these
two values:
if(ACC < [loc32]), ACC = [loc32];
if(ACC >= [loc32]), ACC = unchanged;
Flags and Z If ACC is equal to the contents of the addressed ___location (ACC = [loc32]), set
Modes Z; otherwise, clear Z.
N If ACC is less than the contents of the addressed ___location, (ACC < [loc32]),
set N; otherwise clear N. The MAXL instruction assumes infinite precision
when it determines the sign of the result. For example, consider the
subtraction 0x8000 0000 − 0x0000 0001. If the precision were limited to 32
bits, the result would cause an overflow to the positive number 0x7FFF FFFF
and N would be cleared. However, because the MAXL instruction assumes
infinite precision, it would set N to indicate that 0x8000 0000 − 0x0000 0001
actually results in a negative number.
C If (ACC − [loc32]) generates a borrow, clear the C bit; otherwise set C.
V If ACC is less than the contents of the addressed ___location (ACC < [loc32]),
set V. This instruction cannot clear the V flag.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
the MAXL instruction will be executed N+1 times. The state of the Z, N, and
C flags will reflect the final result. The V flag will be set if an intermediate
overflow occurs.
6-152
MIN AX, loc16
Description Compare the signed content of the specified AX register (AH or AL) with the
content of the signed ___location pointed to by the “loc16” addressing mode and
load the AX register with the smaller of these two values:
if(AX > [loc16]), AX = [loc16];
if(AX <= [loc16]), AX = unchanged;
Flags and N If AX is less than the contents of the addressed ___location (AX < [loc16]) then
Modes the negative flag bit will be set; otherwise, it will be cleared.
Z If AX and the contents of the addressed ___location are equal (AX = [loc16]) then
the zero flag bit will be set; otherwise, it will be cleared.
V If AX is greater then the contents of the addressed ___location (AX > [loc16])
then the overflow flag bit will be set. This instruction cannot clear the V flag.
Repeat If the operation is follows a RPT instruction, the instruction will be executed
N+1 times. The state of the N, Z and V flags will reflect the final result.
6-153
MINCUL P,loc32
Description Based on the state of the N and Z flags, conditionally compare the unsigned
contents of the P register with the 32-bit, unsigned content of the ___location
pointed to by the “loc32” addressing mode and load the P register with the
smaller of the two numbers:
if( (N = 0) & (Z = 0) )
P = [loc32];
if( (N = 0) & (Z = 1) & (P > [loc32]) )
V=1, P = [loc32];
if( (N = 1) & (Z = 0) )
P = unchanged;
Note: The “p < [loc32]” operation is treated like a 32-bit unsigned compare.
This instruction is typically combined with the MINL instruction to form a
64-bit minimum function. It is assumed that the N and Z flags will first be set
by using a MINL instruction to compare the upper 32 bits of a 64-bit value.
The MINCUL instruction is then used to conditionally compare the lower 32
bits based on the results of the upper 32-bit comparison.
Flags and N If (N = 1 AND Z = 0), then load the P register with [loc32].
Modes Z
If (N = 0 AND Z =1), compare unsigned and load P with the smaller P register
to [loc32].
If (N = 0 AND Z = 0), do nothing.
V If (N = 0 AND Z = 1 AND P < [loc32] ) then V is set; otherwise, V is unchanged.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-154
MINL ACC,loc32
Description Compare the content of the ACC register with the ___location pointed to by the
“loc32” addressing mode and load the ACC register with the smaller of these
two values:
if(ACC <= [loc32]), ACC = unchanged;
if(ACC > [loc32]), ACC = [loc32];
Flags and Z If ACC is equal to the contents of the addressed ___location (ACC = [loc32]), set
Modes Z; otherwise clear Z.
N If ACC is less than the contents of the addressed ___location, (ACC < [loc32]),
set N; otherwise clear N. The MINL instruction assumes infinite precision
when it determines the sign of the result. For example, consider the
subtraction 0x8000 0000 − 0x0000 0001. If the precision were limited to 32
bits, the result would cause an overflow to the positive number 0x7FFF FFFF
and N would be cleared. However, because the MINL instruction assumes
infinite precision, it would set N to indicate that 0x8000 0000 − 0x0000 0001
actually results in a negative number.
C If (ACC − [loc32]) generates a borrow, clear the C bit; otherwise set C.
V If ACC is greater than the contents of the addressed ___location (ACC < [loc32]),
set V. This instruction cannot clear the V flag.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
the MINL instruction will be executed N+1 times. The state of the Z, N, and
C flags will reflect the final result. The V flag will be set if an intermediate
overflow occurs.
6-155
MOV *(0:16bit), loc16
Operands *(0:16bit) Immediate direct memory address, access low 64K range of data space
only (0x00000000 to 0x0000FFFF)
loc16 Addressing mode (see Chapter 5)
Description Move the content of the ___location pointed to by the “loc16” addressing
mode to the memory ___location specified by the ”0:16bit” constant address:
[0x0000:16bit] = [loc16];
Example
MOVL XAR2,#Array1 ; XAR2 = pointer to Array1
RPT #(N−1) ; Repeat next instruction N times
||MOV *(0:Array2),*XAR2++ ; Array2[i] = Array1[i],
; i++
6-156
MOV ACC,#16bit<<#0..15
Description Load the ACC register with the left shifted contents of the 16-bit immediate
value. The shifted value is sign extended if sign extension mode is turned
on (SXM = 1) else the shifted value is zero extended (SXM = 0). The lower
bits of the shifted value are zero filled:
if(SXM = 1) // sign extension mode enabled
ACC = S:16bit << shift value;
else // sign extension mode disabled
ACC = 0:16bit << shift value;
Flags and N After the load, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes
Z After the load, the Z flag is set if the ACC value is zero, else Z is cleared.
SXM If sign extension mode bit is set; then the 16-bit constant operand will be sign
extended before the load; else, the value will be zero extended.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-157
MOV ACC,loc16<<T
Description Load the ACC register with the left-shifted contents of the 16-bit ___location
pointed to by the “loc16” addressing mode. The shift value is specified by the
four least significant bits of the T register, T(3:0) = shift value = 0..15. Higher
order bits are ignored. The shifted value is sign extended if sign extension
mode is turned on (SXM = 1) else the shifted value is zero extended
(SXM = 0). The lower bits of the shifted value are zero filled:
if(SXM = 1) // sign extension mode enabled
ACC = S:[loc16] << T(3:0);
else // sign extension mode disabled
ACC = 0:[loc16] << T(3:0);
Flags and N After the load, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes
Z After the load, the Z flag is set if the ACC value is zero, else Z is cleared.
SXM If sign extension mode bit is set; then the 16-bit operand, addressed by the
“loc16” field, will be sign extended before the load; else the value will be zero
extended.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Calculate signed value: ACC = (VarA << SB) + (VarB << SB)
SETC SXM ; Turn sign extension mode on
MOV T,@SA ; Load T with shift value in SA
MOV ACC,@VarA << T ; Load in ACC shifted contents of VarA
MOV T,@SB ; Load T with shift value in SB
ADD ACC,@VarB << T ; Add to ACC shifted contents of VarB
6-158
MOV ACC, loc16<<#0..16
Description Load the ACC register with the left shifted contents of the addressed ___location
pointed to by the “loc16” addressing mode. The shifted value is sign
extended if sign extension mode is turned on (SXM = 1) else the shifted value
is zero extended (SXM = 0). The lower bits of the shifted value are zero filled:
if(SXM = 1) // sign extension mode enabled
ACC = S:[loc16] << shift value;
else // sign extension mode disabled
ACC = 0:[loc16] << shift value;
Flags and N After the load, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes
Z After the load, the Z flag is set if the ACC is zero, else Z is cleared.
SXM If sign extension mode bit is set; then the 16-bit operand, addressed by the
”loc16” field, will be sign extended before the load; else the value will be zero
extended.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-159
MOV AR6/7, loc16
Description Load AR6 or AR7 with the contents of the 16-bit ___location and leave the upper
16 bits of XAR6 and XAR7 unchanged:
AR6/7 = [loc16];
AR6/7H = unchanged;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-160
MOV AX, loc16
Description Load accumulator high register (AH) or accumulator low register (AL)
register with the 16-bit contents of the ___location pointed to by the “loc16”
addressing mode, leaving the other half of the accumulator register
unchanged:
AX = [loc16];
Flags and N The load to AX is tested for a negative condition. If bit 15 of AX is 1, then this
Modes flag is set; otherwise it is cleared.
Z The load to AX is tested for a zero condition. The bit is set if the operation
results in AX = 0, otherwise it is cleared
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-161
MOV DP, #10bit
Description Load the data page register with a 10-bit constant leaving the upper 6 bits
unchanged:
DP(9:0) = 10bit;
DP(15:10) = unchanged;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example MOV DP, #VarA ; Load DP with the data page that
; contains VarA. Assumes VarA is in
; the lower 0x0000 FFC0 of memory.
; DP(15:10) is left unchanged.
6-162
MOV IER,loc16
Description Enable and disable selected interrupts by loading the content of the ___location
pointed to by the “loc16” addressing mode into the IER register:
IER = [loc16];
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Push the contents of IER on the stack and load IER with the
; contents of VarA:
MOV *SP++,IER ; Save IER on stack
MOV IER,@VarA ; Load IER with contents of VarA
6-163
MOV loc16, #16bit
Description Load the ___location pointed to by the “loc16” addressing mode with the 16-bit
constant immediate value:
[loc16] = 16bit;
Note: For #16bit = #0, see the MOV loc16, #0 instruction on page 6-166.
Smart Encoding:
If loc16 = AL or AH and #16bit is an 8-bit number, then the assembler will
encode this instruction as MOVB AX, #8bit to improve efficiency. To override
this, use the MOVW AX, #16bit alias instruction.
Flags and N If (loc16 = @AX), then the load to AX is tested for a negative condition. The
Modes negative flag bit is set if bit 15 of AX is 1, otherwise it is cleared.
Z If (loc16 = @AX), then the load to AX is tested for a zero condition. The bit
is set if the result of the operation on the AX register generates a 0 value,
otherwise it is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-164
MOV loc16, *(0:16bit)
Description Move the content of the ___location specified by the constant direct memory
address “0:16bit” into the ___location pointed to by the “loc16” addressing
mode:
[loc16] = [0x0000:16bit];
Flags and N If (loc16 = @AX), then the load to AX is tested for a negative condition. The
Modes negative flag bit is set if bit 15 of AX is 1, otherwise it is cleared.
Z If (loc16 = @AX), then the load to AX is tested for a zero condition. The
bit is set if the result of the operation on the AX register generates a 0
value, otherwise it is cleared.
Example
MOVL XAR2,#Array2 ; XAR2 = pointer to Array2
RPT #(N−1) ; Repeat next instruction N times
||MOV *XAR2++,*(0:Array1) ; Array2[i] = Array1[i],
; i++
6-165
MOV loc16, #0
Flags and N If (loc16 = @AX), then the load to AX is tested for a negative condition. The
Modes negative flag bit is set if bit 15 of AX is 1, otherwise it is cleared.
Z If (loc16 = @AX), then the load to AX is tested for a zero condition. The bit
is set if the result of the operation on the AX register generates a 0 value,
otherwise it is cleared.
6-166
MOV loc16,ACC << 1..8
Description Load the content of the ___location pointed to by the “loc16” addressing mode
with the low word of the ACC register after left−shifting by the specified value.
The ACC register is not modified:
[loc16] = ACC >> (16 − shift value); [loc16] = low (ACC
<<1...8)
Flags and N If (loc16 = @AX), then after the load AX is checked for a negative condition.
Modes The N flag is set if bit 15 of the AX is 1; else N is cleared.
Z If (loc16 = @AX) then after the load AX is checked for a zero condition. The
Z flag is set if AX is zero; else Z is cleared.
Repeat If the operation is repeatable, then the instruction will be executed N+1
times. The state of the Z and N flags will reflect the final result. If the operation
is not repeatable, the instruction will execute only once.
Example ; Multiply two Q15 numbers (VarA and VarB) and store result in
; VarC as a Q15 number:
MOV T,@VarA ; T = VarA (Q15)
MPY ACC,T,@VarB ; ACC = VarA * VarB (Q30)
MOVH @VarC,ACC << 1 ; VarC = ACC >> (16−1) (Q15)
; VarC as a Q31 number:
MOV T,@VarA ; T = VarA (T = Q14)
MPY ACC,T,@VarB ; ACC = VarA * VarB (ACC = Q28)
MOV @VarC+0,ACC << 3 ; VarC low = ACC << 3
MOVH @VarC+1,ACC << 3 ; VarC high = ACC >> (16−1) (VarC = Q31)
6-167
MOV loc16, ARn
If(loc16 = @ARn), then only the lower 16 bits of the selected auxiliary register
is modified. The upper 16 bits is unchanged.
Flags and N If (loc16 = @AX), then the load to AX is tested for a negative condition. Bit-15
Modes of the AX register is the sign bit, 0 for positive, 1 for negative. The negative
flag bit is set if the operation on the AX register generates a negative value,
otherwise it is cleared.
Z If (loc16 = @AX), then the load to AX is tested for a zero condition. The bit
is set if the result of the operation on the AX register generates a 0 value,
otherwise it is cleared
6-168
MOV loc16, AX
Description Load the addressed ___location pointed to by the “loc16” addressing mode with
the 16-bit content of the specified AX register (AH or AL):
[loc16] = AX;
Flags and N If (loc16 = @AX), then the load to AX is tested for a negative condition. The
Modes negative flag bit is set if bit 15 of AX is 1, otherwise it is cleared.
Z If (loc16 = @AX), then the load to AX is tested for a zero condition. The bit
is set if the result of the operation on the AX register generates a 0 value,
otherwise it is cleared.
Repeat If this operation follows a RPT instruction, then it will be executed N+1 times.
The state of the N and Z flags will reflect the final result.
6-169
MOV loc16, AX, COND
Description If the specified condition being tested is true, then the ___location pointed to by
the “loc16” addressing mode will be loaded with the contents of the specified
AX register (AH or AL):
if(COND = true) [loc16] = AX;
Flags and N If (COND = true AND loc16 = @AX), AX is tested for a negative condition after
Modes the move and if bit 15 of AX is 1, the negative flag bit is set.
Z If (COND = true AND loc16 = @AX), after the move, AX is tested for a zero
condition and the zero flag bit is set if AX = 0, otherwise, it is cleared.
V If the V flag is tested by the condition, then V is cleared.
6-170
MOV loc16, AX, COND
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Swap the contents of VarA and VarB if VarB is higher then VarA:
MOV AL,@VarA ; AL = VarA, XAR2 points to VarB
MOV AH,@VarB ; AH = VarB, XAR2 points to VarA
CMP AH,@AL ; Compare AH and AL
MOV @VarA,AH,HI ; Store AH in VarA if higher
MOV @VarB,AL,HI ; Store AL in VarB if higher
6-171
MOV loc16,IER
Description Save the content of the IER register in the ___location pointed to by the “loc16”
addressing mode:
[loc16] = IER;
Flags and N If (loc16 = @AX) and bit 15 of AX is 1, then N is set; otherwise N is cleared.
Modes
Z If (loc16 = @AX) and the value of AX is zero, then Z is set; otherwise Z is
cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Push the contents of IER on the stack and load IER with the
; contents of VarA:
MOV *SP++,IER ; Save IER on stack
MOV IER,@VarA ; Load IER with contents of VarA
6-172
MOV loc16,OVC
Description Store the 6 bits of the overflow counter (OVC) into the upper 6 bits of the
___location pointed to by the “loc16” addressing mode and zero the lower 10 bits
of the addressed ___location:
[loc16(15:10)] = OVC;
[loc16(9:0)] = 0;
Flags and N If (loc16 = @AX) and bit 15 of AX is 1, then set N; otherwise clear N.
Modes
Z If (loc16 = @AX) and AX is zero, then set Z; otherwise clear Z.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-173
MOV loc16,P
Description The contents of the P register are shifted by the amount specified in the
product shift mode (PM), and the lower half of the shifted value is stored into
the 16-bit ___location pointed to by the “loc16” addressing mode. The P register
is not modified by the operation:
[loc16] = P << PM;
Flags and N If (loc16 = @AX) and bit 15 of the AX register is 1, then the N bit is set;
Modes otherwise, N is cleared.
Z If (loc16 = @AX) and the value of AX after the load is zero, then the Z bit is
set; otherwise Z is cleared.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. The state of the Z, and N flags will reflect the
final result.
6-174
MOV loc16, T
Description Store the 16-bit T register contents into the ___location pointed to by the “loc16”
addressing mode:
[loc16] = T;
Flags and N If (loc16 = @AX) and bit 15 of the AX register is 1, then the N bit is set;
Modes otherwise, N is cleared.
Z If (loc16 = @AX) and the value of AX after the load is zero, then the Z bit is
set; otherwise Z is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-175
MOV OVC, loc16
Description Load the overflow counter (OVC) with the upper 6 bits of the ___location pointed
to by the “loc16” addressing mode:
OVC = [loc16(15:10)];
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-176
MOV PH, loc16
Description Load the high 16 bits of the P register (PH) with the 16-bit ___location pointed
to by the “loc16” addressing mode; leave the lower 16 bits (PL) unchanged:
PH = [loc16];
PL = unchanged;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-177
MOV PL, loc16
Description Load the high 16 bits of the P register (PL) with the 16-bit ___location pointed
to by the “loc16” addressing mode; leave the lower 16 bits (PH) unchanged:
PL = [loc16];
PH = unchanged;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-178
MOV PM, AX
Description Load the product shift mode (PM) bits with the 3 least significant bits of
register AX.
PM = AX(2:0);
Flags and PM The product shift mode bits are loaded with the 3 least significant bits of AX.
Modes
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-179
MOV T, loc16
Description Load the T register with the 16-bit contents of the ___location pointed to by the
“loc16” addressing mode:
T = [loc16];
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-180
MOV TL, #0
Description Load the lower half of the multiplicand register (TL) with zero, leaving the
upper half (T) unchanged:
TL = 0x0000;
T = unchanged;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Calculate and keep low 32-bit result: Y32 = M32*X16 >> 32
MOV TL,#0 ; TL = 0
MOV T,@X16 ; T = X16
IMPYL P,XT,@M32 ; P = XT * M32 (high 32-bit of result)
MOVL @Y32,P ; Store result into Y32
6-181
MOV XARn, PC
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-182
MOVA T,loc16
Description Load the T register with the 16-bit content of the ___location pointed to by the
“loc16” addressing mode. Also, the content of the P register, shifted by the
amount specified by the product shift mode (PM) bits, is added to the content
of the ACC register:
T = [loc16];
ACC = ACC + P << PM;
Flags and N After the operation, if bit 31 of the ACC register is 1, the N bit is set; otherwise,
Modes N is cleared.
Z After the operation, if the value of ACC is zero, the Z bit is set; otherwise Z
is cleared.
C If the addition generates a carry, then C is set; otherwise, C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected
OVC If overflow mode is disabled; and if the operation generates a positive
overflow, the counter is incremented. If overflow mode is disabled; and if the
operation generates a negative overflow, the counter is decremented.
OVM If overflow mode bit is set; the ACC value will saturate maximum positive
(0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflows.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, it will
be executed N+1 times. The state of the Z, N, C and OVC flags reflect the
final result. The V flag will be set if an intermediate overflow occurs.
6-183
MOVA T,loc16
6-184
MOVAD T, loc16
Description Load the T register with the 16-bit content of the ___location pointed to by the
“loc16” addressing mode and then load the next highest 16-bit ___location
pointed to by “loc16” with the content of T. In addition, add the content of the
P register, shifted by the amount specified by the product shift mode (PM)
bits, to the content of the ACC register:
T = [loc16];
[loc16 + 1] = T;
ACC = ACC + P << PM;
Flags and N After the operation, if bit 31 of the ACC register is 1, then the N bit is set;
Modes otherwise, N is cleared.
Z After the operation, if the value of ACC is zero, then the Z bit is set; otherwise
Z is cleared.
C If the addition generates a carry, the C bit is set; otherwise, C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected
OVC If overflow mode is disabled; and if the operation generates a positive
overflow, then the counter is incremented. If overflow mode is disabled; and
if the operation generates a negative overflow, then the counter is
decremented.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflows.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-185
MOVAD T, loc16
6-186
MOVB ACC,#8bit
Description Load the ACC register with the specified 8-bit, zero-extended immediate
constant:
ACC = 0:8bit;
Flags and N After the load, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Flags and Z After the load, the Z flag is set if the ACC value is zero, else Z is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-187
MOVB AR6/7, #8bit
Description Load AR6 or AR7 with an 8-bit unsigned constant and upper 16 bits of XAR6
and XAR7 are unchanged:
AR6/7 = 0:8bit;
AR6/7H = unchanged;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once
6-188
MOVB AX, #8bit
Description Load accumulator high register (AH) or accumulator low register (AL) with
an unsigned 8-bit constant zero extended, leaving the other half of the
accumulator register unchanged:
AX = 0:8bit;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-189
MOVB AX.LSB, loc16
Operands AX.LSB Least significant byte of accumulator high (AH.LSB) or accumulator low
(AL.LSB) register
loc16 Addressing mode (see Chapter 5)
Description Load the least significant byte of the specified AX register (AH.LSB or
AL.LSB) with 8 bits from the ___location pointed to by the “loc16” addressing
mode. The most significant byte of AX is cleared. The form of the “loc16”
operand determines which of its 8 bits are used to load AX.LSB:
if(loc16 = *+XARn[offset])
{
if(offset is an even number)
AX.LSB = [loc16.LSB];
if(offset is an odd value)
AX.LSB = [loc16.MSB];
}
else
AX.LSB = [loc16.LSB];
AX.MSB = 0x00;
Note: offset = 3-bit immediate or AR0 or AR1 indexed addressing modes only.
Flags and Z After the move, AX is tested for a zero condition. The zero flag bit is set if
Modes AX = 0; otherwise it is cleared
N After the move, AX is tested for a negative condition. The bit is set if bit 15
of AX is 1; otherwise it is cleared.
6-190
MOVB AX.LSB, loc16
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-191
MOVB AX.MSB, loc16
Operands AX.MS Most significant byte of accumulator high (AH.MSB) or accumulator low
B (AL.MSB) register
loc16 Addressing mode (see Chapter 5)
Description Load the most significant byte of the specified AX register (AH.MSB or
AH.LSB) with 8 bits from the ___location pointed to by the “loc16” addressing
mode. The least significant byte of AX is left unchanged. The form of the
“loc16” operand determines which of its 8 bits are used to load AX.MSB
if(loc16 = *+XARn[offset])
{
if(offset is an even value)
AX.MSB = [loc16.LSB];
if(offset is an odd value)
AX.MSB = [loc16.MSB];
}
else
AX.MSB = [loc16.LSB];
AX.LSB = unchanged;
Note: offset = 3-bit immediate or AR0 or AR1 indexed addressing modes only.
Flags and N After the move AX is tested for a negative condition. The negative flag bit is
Modes set if bit 15 of AX is 1; otherwise it is cleared.
Z After the move, AX is tested for a zero condition. The zero flag bit is set if
AX = 0; otherwise it is cleared.
6-192
MOVB AX.MSB, loc16
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-193
MOVB loc16,#8bit,COND
Description If the specified condition being tested is true, then the 8-bit zero extended
constant is stored in the ___location pointed to by the “loc16” addressing mode:
if(COND = true) [loc16] = 0:8bit;
Flags and N If (COND = true AND loc16 = @AX), then after the move AX is tested for a
Modes negative condition. The negative flag bit is set if bit 15 of AX is 1, otherwise
it is cleared.
Z If (COND = true AND loc16 = @AX), then after the move, AX is tested for a
zero condition. The zero flag bit is set if AX = 0, otherwise it is cleared.
V If the V flag is tested by the condition, then V is cleared.
6-194
MOVB loc16,#8bit,COND
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Calculate:
; if( VarA > 20 )
; VarA = 0;
CMP @VarA,#20 ; Set flags on (VarA − 20)
MOVB @VarA,#0,GT ; Zero VarA if greater then
6-195
MOVB loc16, AX.LSB
Description Load 8 bits of the ___location pointed to by the “loc16” addressing mode with
the least significant byte of the specified AX register (AH.LSB or AL.LSB).
The form of the “loc16” operand determines which of its 8 bits are loaded and
which of its 8 bits are left unchanged:
if(loc16 = *+XARn[offset])
{
if(offset is an even value)
[loc16.LSB] = AX.LSB;
[loc16.MSB] = unchanged;
if(offset is an odd value)
[loc16.LSB] = unchanged;
[loc16.MSB] = AX.LSB;
}
else
[loc16.LSB] = AX.LSB;
[loc16.MSB] = unchanged;
Note: offset = 3-bit immediate or AR0 or AR1 indexed addressing modes only.
Flags and N If (loc16 = @AX), then after the move AX is tested for a negative condition.
Modes The negative flag bit is set if bit 15 of AX is 1, otherwise it is cleared.
Z If (loc16 = @AX), then after the move, AX is tested for a zero condition. The
zero flag bit is set if AX = 0, otherwise it is cleared.
6-196
MOVB loc16, AX.LSB
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-197
MOVB loc16, AX.MSB
Description Load 8 bits of the ___location pointed to by the “loc16” addressing mode with
the most significant byte of the specified AX register (AH.MSB or AL.MSB).
The form of the “loc16” operand determines which of its 8 bits are loaded and
which of its 8 bits are left unchanged:
if(loc16 = *+XARn[offset])
{
if( offset is an even number )
[loc16.LSB] = AX.MSB;
[loc16.MSB] = unchanged;
if( offset is an odd number )
[loc16.LSB] = unchanged;
[loc16.MSB] = AX.MSB;
}
else
[loc16.LSB] = AX.MSB;
[loc16.MSB] = unchanged;
Note: offset = 3-bit immediate or AR0 or AR1 indexed addressing modes only.
Flags and N If (loc16 = @AX), then after the move AX is tested for a negative condition.
Modes The negative flag bit is set if bit 15 of AX is 1, otherwise it is cleared.
Z If (loc16 = @AX), then after the move, AX is tested for a zero condition. The
zero flag bit is set if AX = 0, otherwise it is cleared.
6-198
MOVB loc16, AX.MSB
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-199
MOVB XARn, #8bit
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-200
MOVDL XT,loc32
Description Load the XT register with the 32-bit content of the ___location pointed to by the
“loc32” addressing mode and then load the next highest 32-bit ___location
pointed to by “loc32” with the content of XT:
XT = [loc32];
[loc32 + 2] = XT;
Repeat This instruction is repeatable. If this instruction follows the RPT instruction,
then it will be executed N+1 times.
6-201
MOVH loc16,ACC << 1..8
Description Load the content of the ___location pointed to by the “loc16” addressing mode
with the high word of the ACC register after left−shifting by the specified
value. The ACC register is not modified:
[loc16] = ACC >> (16 − shift value);
Flags and N If (loc16 = @AX), then after the load AX is checked for a negative condition.
Modes The N flag is set if bit 15 of the AX is 1; else N is cleared.
Z If (loc16 = @AX) then after the load AX is checked for a zero condition. The
Z flag is set if AX is zero; else Z is cleared.
Repeat If the operation is repeatable, then the instruction will be executed N+1
times. The state of the Z and N flags will reflect the final result. If the operation
is not repeatable, the instruction will execute only once.
Example ; Multiply two Q15 numbers (VarA and VarB) and store result in
; VarC as a Q15 number:
MOV T,@VarA ; T = VarA (Q15)
MPY ACC,T,@VarB ; ACC = VarA * VarB (Q30)
MOVH @VarC,ACC << 1 ; VarC = ACC >> (16−1) (Q15)
; VarC as a Q31 number:
MOV T,@VarA ; T = VarA (T = Q14)
MPY ACC,T,@VarB ; ACC = VarA * VarB (ACC = Q28)
MOV @VarC+0,ACC << ; VarC low = ACC << 3
3
MOVH @VarC+1,ACC << ; VarC high = ACC >> (16−1) (VarC = Q31)
3
6-202
MOVH loc16, P
Description The contents of the P register are shifted by the amount specified in the
product shift mode (PM), and the upper half of the shifted value is stored into
the 16-bit ___location pointed to by the “loc16” addressing mode. The P register
is not modified by the operation:
[loc16] = (P << PM) >> 16;
Flags and N If (loc16 = @AX) and bit 15 of the AX register is 1, then the N bit is set;
Modes otherwise, N is cleared.
Z If (loc16 = @AX) and the value of AX after the load is zero, then the Z bit is
set; otherwise Z is cleared.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. The state of the Z, and N flags will reflect the
final result.
6-203
MOVL ACC,loc32
Description Load the ACC register with the content of the ___location pointed to by the
“loc32” addressing mode.
ACC = [loc32];
Flags and N After the load, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes
Z After the load, the Z flag is set if the ACC is zero, else Z is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-204
MOVL ACC,P << PM
Description Load the ACC register with the content of the P register shifted as specified
by the product shift mode (PM):
ACC = P << PM;
Flags and N After the load, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes
Z After the load, the Z flag is set if the ACC is zero, else Z is cleared.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-205
MOVL loc32, ACC
Description Store the contents of the ACC register into the ___location pointed to by the
“loc32” addressing mode:
[loc32] = ACC;
Flags and N If (loc32 = @ACC) then after the load, the N flag is set if bit 31 of the ACC
Modes is 1, else N is cleared.
Z If (loc32 = @ACC) then after the load, the Z flag is set if ACC is zero, else
Z is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-206
MOVL loc32,ACC,COND
Description If the specified condition being tested is true, then the ___location pointed to by
the “loc32” addressing mode will be loaded with the contents of the ACC
register:
if(COND = true) [loc32] = ACC;
6-207
MOVL loc32,ACC,COND
Flags and N If (COND = true AND loc32 = @ACC), then after the move if bit 31 of ACC
Modes is 1, N is set; otherwise N cleared.
Z If (COND = true AND loc32 = @ACC), then after the move if (ACC = 0), then
the Z bit is set; otherwise it is cleared.
V If the V flag is tested by the condition, then V is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Swap the contents of 32-bit VarA and VarB if VarB is higher:
MOVL ACC,@VarB ; ACC = VarB
MOVL P,@VarA ; P = VarA
CMPL ACC,@P ; Set flags on (VarB − VarA)
MOVL @VarA,ACC,HI ; VarA = ACC if higher
MOVL @P,ACC,HI ; P = ACC if higher
MOVL @VarA,P ; VarA = P
6-208
MOVL loc32,P
Description Store the P register contents into the ___location pointed to by the “loc32”
addressing mode:
[loc32] = P;
Flags and N If (loc32 = @ACC) and bit 31 of the ACC register is 1, then the N bit is set;
Modes otherwise, N is cleared.
Z If (loc32 = @ACC) and the value of ACC after the load is zero, then the Z bit
is set; otherwise Z is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Add 64-bit VarA, VarB and VarC, and store result in VarD:
MOVL P,@VarA+0 ; Load P with low 32 bits of VarA
MOVL ACC,@VarA+2 ; Load ACC with high 32 bits of VarA
ADDUL P,@VarB+0 ; Add to P unsigned low 32 bits of VarB
ADDCL ACC,@VarB+2 ; Add to ACC with carry high 32 bits of VarB
ADDUL P,@VarC+0 ; Add to P unsigned low 32 bits of VarC
ADDCL ACC,@VarC+2 ; Add to ACC with carry high 32 bits of VarC
MOVL @VarD+0,P ; Store low 32-bit result into VarD
MOVL @VarD+2,ACC ; Store high 32-bit result into VarD
6-209
MOVL loc32, XARn
Description Load the contents of the 32-bit addressed ___location with the contents of
XARn:
[loc32] = XARn;
Flags and N If (loc32 = @ACC), then the load to ACC is tested for a negative condition.
Modes Bit-31 of the ACC register is the sign bit, 0 for positive, 1 for negative. The
negative flag bit is set if the operation on the ACC register generates a
negative value, otherwise it is cleared.
Z If (loc32 = @ACC), then the load to ACC is tested for a zero condition. The
bit is set if the result of the operation on the ACC register generates a 0 value,
otherwise it is cleared
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example MOVL @ACC, XAR0 ; Move the 32-bit contents of XAR0 into ACC.
; If bit 31 of the ACC is 1 set N. If
; ACC = 0, set Z.
MOVL *XAR1, XAR7 ; Move the 32-bit contents of XAR7 into the
; ___location pointed to by XAR1.
MOVL *XAR6++,XAR6 ; Move the 32-bit contents of XAR6 into the
; ___location pointed to by XAR6. Post-increment
; the contents of XAR6.
MOVL *−−XAR5,XAR5 ; Predecrement the contents of XAR5. Move the
; 32-bit contents of XAR5 into the ___location
; pointed to by ; XAR5.
6-210
MOVL loc32,XT
Description Store the XT register into 32-bit ___location pointed to by the “loc32” addressing
mode:
[loc32] = XT;
Flags and N If (loc32 = @ACC) and bit 31 of the ACC register is 1, then the N bit is set;
Modes otherwise, N is cleared.
Z If (loc32 = @ACC) and the value of ACC after the load is zero, then the Z bit
is set; otherwise Z is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-211
MOVL P,ACC
Description Load the P register with the content of the ACC register:
P = ACC;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-212
MOVL P,loc32
Description Load the P register with the 32-bit ___location pointed to by the “loc32”
addressing mode:
P = [loc32];
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Add 64-bit VarA, VarB and VarC, and store result in VarD:
MOVL P,@VarA+0 ; Load P with low 32 bits of VarA
MOVL ACC,@VarA+2 ; Load ACC with high 32 bits of VarA
ADDUL P,@VarB+0 ; Add to P unsigned low 32 bits of VarB
ADDCL ACC,@VarB+2 ; Add to ACC with carry high 32 bits of VarB
ADDUL P,@VarC+0 ; Add to P unsigned low 32 bits of VarC
ADDCL ACC,@VarC+2 ; Add to ACC with carry high 32 bits of VarC
MOVL @VarD+0,P ; Store low 32-bit result into VarD
MOVL @VarD+2,ACC ; Store high 32-bit result into VarD
6-213
MOVL XARn, loc32
Description Load XARn with the contents of the 32-bit addressed ___location:
XARn = [loc32];
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-214
MOVL XARn, #22bit
MOVL XARn, #22bit Load 32-bit Auxiliary Register With Constant Value
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-215
MOVL XT,loc32
Description Load the XT register with the 32-bit content of the ___location pointed to by the
“loc32” addressing mode:
XT = [loc32];
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-216
MOVP T,loc16
Description Load the T register with the 16-bit content of the ___location pointed to by the
“loc16” addressing mode. Also, the content of the P register, shifted by the
amount specified by the product shift mode (PM) bits, is loaded into the ACC
register:
T = [loc16];
ACC = P << PM;
Flags and N After the operation if bit 31 of the ACC register is 1, then the N bit is set;
Modes otherwise, N is cleared.
Z After the operation, if the value of ACC is zero, then the Z bit is set; otherwise
Z is cleared.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-217
MOVS T,loc16
Description Load the T register with the 16-bit content of the ___location pointed to by the
“loc16” addressing mode. Also, the content of the P register, shifted by the
amount specified by the product shift mode (PM) bits, is subtracted from the
content of the ACC register:
T = [loc16];
ACC = ACC − P << PM;
Flags and N After the operation, if bit 31 of the ACC register is 1, then the N bit is set;
Modes otherwise, N is cleared.
Z After the operation, if the value of ACC is zero, then the Z bit is set; otherwise
Z is cleared.
C If the subtraction generates a borrow, the C bit is cleared; otherwise, C is set.
V If an overflow occurs, V is set; otherwise V is not affected
OVC If overflow mode is disabled; and if the operation generates a positive
overflow, then the counter is incremented. If overflow mode is disabled; and
if the operation generates a negative overflow, then the counter is
decremented.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflows.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. The state of the Z, N, C and OVC flags will
reflect the final result. The V flag will be set if an intermediate overflow
occurs.
6-218
MOVS T,loc16
6-219
MOVU ACC,loc16
Description Load the low half of the accumulator (AL) with the 16-bit contents of the
addressed ___location pointed to by the “loc16” addressing mode and fill the
high half of the accumulator (AH) with 0s:
AL = [loc16];
AH = 0x0000;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-220
MOVU loc16,OVC
Description Store the 6 bits of the overflow counter (OVC) into the lower 6 bits of the
___location pointed to by the “loc16” addressing mode and zero the upper 10
bits of the addressed ___location:
[loc16(15:6)] = 0;
[loc16(5:0)] = OVC;
Flags and N If (loc16 = @AX) and bit 15 of AX is 1, then set N; otherwise clear N.
Modes
Z If (loc16 = @AX) and AX is zero, then set Z; otherwise clear Z.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-221
MOVU OVC,loc16
Description Load the overflow counter (OVC) with the lower 6 bits of the ___location pointed
to by the “loc16” addressing mode:
OVC = [loc16(5:0)]
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-222
MOVW DP, #16bit
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example MOVW DP, #VarA ; Load DP with the data page that
; contains VarA. Assumes VarA is in the
; lower 0x003F FFC0 of memory
MOVW DP, #0F012h ; Load DP with data page number 0xF012
6-223
MOVX TL,loc16
Description Load the lower 16 bits of the multiplicand register (TL) with the 16-bit
contents of the ___location pointed to by the “loc16” addressing mode and then
sign extend that value into the upper upper 16 bits of XT:
TL = [loc16];
T = sign extension of TL;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-224
MOVZ ARn, loc16
MOVZ ARn, loc16 Load Lower Half of XARn and Clear Upper Half
OBJ-
SYNTAX OPTIONS OPCODE MODE RPT CYC
MOVZ AR0…5, loc16 0101 1nnn LLLL LLLL X − 1
MOVZ AR6, loc16 1000 1000 LLLL LLLL 1 − 1
MOVZ AR7, loc16 1000 0000 LLLL LLLL 1 − 1
Description Load ARn with the contents of the 16-bit ___location and clear ARnH:
ARn = [loc16];
ARnH = 0;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-225
MOVZ DP, #10bit
MOVZ DP, #10bit Load Data Page and Clear High Bits
Description Load the data page register with a 10-bit constant and clear the upper 6 bits:
DP(9:0) = 10bit;
DP(15:10) = 0;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example MOVZ DP, #VarA ; Load DP with the data page that contains
; VarA. Assumes VarA is in the lower
; 0x0000 FFC0 of memory
MOVZ DP, #3FFh ; Load DP with page number 0x03FF.
6-226
MPY ACC,loc16, #16bit
Description Load the T register with the 16-bit content of the ___location pointed to by the
“loc16” addressing mode; then, multiply the signed 16-bit content of the T
register by the specified signed 16-bit constant value:
T = [loc16];
ACC = signed T * signed 16bit;
Flags and Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
Modes
N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-227
MPY ACC, T, loc16
Description Multiply the signed 16-bit content of the T register by the signed 16-bit
contents of the ___location pointed to by the “loc16” addressing mode and store
the result in the ACC register:
ACC = signed T * signed [loc16];
Flags and Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
Modes
N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-228
MPY P,loc16,#16bit
Description Multiply the signed 16-bit contents of the ___location pointed to by the “loc16”
addressing mode by the 16-bit immediate value and store the 32-bit result
in the P register:
P = signed [loc16] * signed 16bit;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-229
MPY P,T,loc16
Description Multiply the signed 16-bit content of the T register by the signed 16-bit
contents of the ___location pointed to by the “loc16” addressing mode and store
the 32-bit result in the P register:
P = signed T * signed [loc16];
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-230
MPYA P,loc16,#16bit
Description Add the previous product (stored in the P register), shifted as specified by
the product shift mode (PM) bits, to the ACC register. Load the T register with
the content of the ___location pointed to by the “loc16” addressing mode.
Multiply the signed 16-bit content of the T register by the signed 16-bit
constant value and store the 32-bit result in the P register:
ACC = ACC + P << PM;
T = [loc16];
P = signed T * signed 16bit;
Flags and Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
Modes
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If overflow mode is disabled; and if the operation generates a positive
overflow, then the counter is incremented. If overflow mode is disabled; and
if the operation generates a negative overflow, then the counter is
decremented.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-231
MPYA P,loc16,#16bit
6-232
MPYA P,T,loc16
Description Add the previous product (stored in the P register), shifted as specified by
the product shift mode (PM), to the ACC register. Multiply the signed 16-bit
content of T by the signed 16-bit content of the ___location pointed to by the
“loc16” addressing mode and store the 32-bit result in the P register:
ACC = ACC + P << PM;
P = signed T * signed [loc16];
Flags and Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
Modes
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If overflow mode is disabled; and if the operation generates a positive
overflow, then the counter is incremented. If overflow mode is disabled; and
if the operation generates a negative overflow, then the counter is
decremented.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. The state of the Z, N, C and OVC flags will
reflect the final result. The V flag will be set if an intermediate overflow
occurs.
6-233
MPYA P,T,loc16
6-234
MPYB ACC,T,#8bit
Description Multiply the signed 16-bit content of the T register by the unsigned 8-bit
constant value zero extended and store the result in the ACC register:
ACC = signed T * 0:8bit
Flags and Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
Modes
N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-235
MPYB P,T,#8bit
Description Multiply the signed 16-bit content of the T register by the unsigned 8-bit
immediate constant value zero extended and store the 32-bit result in the P
register:
P = signed T * 0:8bit;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-236
MPYS P,T,loc16
Description Subtract the previous product (stored in the P register), shifted as specified
by the product shift mode (PM), from the ACC register. In addition, multiply
the signed 16-bit content of the T register by the signed 16-bit constant value
and store the result in the P register:
ACC = ACC − P << PM;
P = signed T * signed [loc16];
Flags and Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
Modes
N After the subtraction, the N flag is set if bit 31 of the ACC is 1, else N is
cleared.
C If the subtraction generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If overflow mode is disabled; and if the operation generates a positive
overflow, then the counter is incremented. If overflow mode is disabled; and
if the operation generates a negative overflow, then the counter is
decremented.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. The state of the Z, N, C and OVC flags will
reflect the final result. The V flag will be set if an intermediate overflow
occurs.
6-237
MPYS P,T,loc16
6-238
MPYU P,T,loc16
Description Multiply the signed 16-bit content of the T register by the signed 16-bit
contents of the ___location pointed to by the “loc16” addressing mode and store
the 32-bit result in the P register:
P = unsigned T * unsigned [loc16];
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-239
MPYU ACC,T,loc16
Description Multiply the unsigned 16-bit content of the T register by the unsigned 16-bit
content of the ___location pointed to by the “loc16” addressing mode and store
the 32-bit results in the ACC register:
ACC = unsigned T * unsigned [loc16];
Flags and Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
Modes
N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-240
MPYXU ACC, T, loc16
Description Multiply the signed 16-bit content of the T register by the unsigned 16-bit
content of the ___location pointed to by the “loc16” addressing mode and store
the result in the ACC register:
ACC = signed T * unsigned [loc16];
Flags and Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
Modes
N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-241
MPYXU P,T,loc16
Description Multiply the signed 16-bit content of the T register by the signed 16-bit
contents of the ___location pointed to by the “loc16” addressing mode and store
the 32-bit result in the P register:
P = signed T * unsigned [loc16];
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-242
NASP
Operands None
Description If the SPA bit is 1, the NASP instruction decrements the stack pointer (SP)
by 1 and then clears the SPA status bit. This undoes a stack pointer
alignment performed earlier by the ASP instruction. If the SPA bit is 0, then
the NASP instruction performs no operation.
if( SPA = 1 )
{
SP = SP − 1;
SPA = 0;
}
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-243
NEG ACC
Flags and N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes
Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
C If (ACC = 0), set C; otherwise, clear C.
V If (ACC = 0x8000 0000) at the start of the operation, this is considered an
overflow value and V is set. Otherwise, V is not affected.
OVM If (ACC = 0x8000 0000) at the start of the operation, this is considered an
overflow value, and the ACC value after the operation depends on the state
of OVM: If OVM is cleared, ACC will be filled with 0x8000 0000. If OVM is
set ACC will be saturated to 0x7FFF FFFF.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-244
NEG AX
Description Replace the contents of the specified AX register with the negative of AX:
if(AX = 0x8000)
{
AX = 0x8000;
V flag = 1;
}
else
AX = −AX;
if(AX = 0x0000)
C flag = 1;
else
C flag = 0;
Flags and N After the operation, if bit 15 of AX is 1, then the negative flag bit is set;
Modes otherwise, it is cleared.
Z After the operation, if AX is 0, then the Z bit is set, otherwise it is cleared.
C If AX is 0, C is set; otherwise, it is cleared.
V If AX is 0x8000 at the start of the operation, then this is considered an
overflow and V is set. Otherwise V is not affected.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-245
NEG64 ACC:P
Flags and N After the shift, if bit 31 of the ACC register is 1 then ACC:P is negative and
Mode the N bit is set; otherwise N is cleared.
Z After the operation, the Z flag is set if the combined 64-bit value of the ACC:P
is zero; otherwise, Z is cleared.
C If (ACC:P= = 0) then the C bit is set; otherwise C is cleared.
V if(ACC:P = 0x8000 0000 0000 0000) then the V flag is set; otherwise, V is
not modified.
OVM If at the start of the operation, ACC:P = 0x8000 0000 0000 0000, then this
is considered an overflow value and the ACC:P value after the operation
depends on OVM. If (OVM = 1) ACC:P is filled with its greatest positive
number (0x7FFF FFFF FFFF FFFF). If (OVM = 0) then ACC:P is not
modified.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-246
NEG64 ACC:P
6-247
NEGTC ACC
Description Based on the state of the test control (TC) bit, conditionally replace the
content of the ACC register with its negative:
if( TC = 1 )
{
if(ACC = 0x8000 0000)
{
V = 1;
if(OVM = 1)
ACC = 0x7FFF FFFF;
else
ACC = 0x8000 0000
}
else
ACC = −ACC;
if(ACC = 0x0000 0000)
C = 1;
else
C = 0;
}
Flags and N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes
Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
C If (TC = 1 AND ACC = 0) set C; if (TC = 1 AND ACC != 0) clear C; otherwise
C is not modified.
V If (TC = 1 AND ACC = 0x8000 0000) at the start of the operation, this is
considered an overflow value and V is set. Otherwise, V is not affected.
TC The state of the TC bit is used as a test condition for the operation.
OVM If at the start of the operation, ACC = 0x8000 0000, then this is considered
an overflow value and the ACC value after the operation depends on OVM.
If OVM is cleared and TC = 1, ACC will be filled with 0x8000 0000. If OVM
is set and TC = 1, ACC will be saturated to 0x7FFF FFFF.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-248
NEGTC ACC
6-249
NOP {*ind}{ARPn}
Description Modify the indirect address operand as specified and change the auxiliary
register pointer (ARP) to the given auxiliary register. If no operands are
given, then do nothing.
Repeat This instruction is repeatable. If this instruction follows the RPT instruction,
it will execute N+1 times.
6-250
NORM ACC, *ind
NORM ACC, *ind Normalize ACC and Modify Selected Auxiliary Register
Description Normalize the signed content of the ACC register and modify, as specified
by the indirect addressing mode, the auxiliary register (XAR0 to XAR7)
pointed to by the auxiliary register pointer (ARP):
Note: The NORM instruction normalizes a signed number in the ACC register by
finding the magnitude of the number. An XOR operation is performed on
ACC bits 31 and 30. If the bits are the same, then the content of the ACC
register is logically shifted left by 1 to eliminate the extra sign bit and the
selected pointer is modified. If the bits are different, the ACC is not shifted and
the selected pointer is not modified. The selected pointer does not access
any memory ___location.
Flags and Z After the operation, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
TC If the operation set TC, no normalization was needed (ACC did not need to
be modified). If the operation cleared TC, bits 31 and 30 were the same and,
as a result, the ACC register was logically shifted left by 1.
ARP Auxiliary register pointer selects which pointer to modify as part of the
operation (XAR0 to XAR7).
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
the NORM instruction will be executed N+1 times. The state of the Z, N, and
TC flags will reflect the final result. Note: If you only want the NORM
instruction to execute until normalization is done, you can create a loop that
checks the value of the TC bit. When TC = 1, normalization is complete.
6-251
NORM ACC, *ind
6-252
NORM ACC,XARn++/− −
Description Normalize the signed content of the ACC register and modify the specified
auxiliary register (XAR0 to XAR7):
if(ACC != 0x0000 0000)
{
if((ACC(31) XOR ACC(30)) = 0)
{
ACC = ACC << 1, TC = 0;
if(XARn++ addressing mode) XARn += 1;
if(XARn−− addressing mode) XARn −= 1;
}
else
TC = 1;
}
else
TC = 1;
Note: The NORM instruction normalizes a signed number in the ACC register by
finding the magnitude of the number. An XOR operation is performed on
ACC bits 31 and 30. If the bits are the same, then the content of the ACC
register is logically shifted left by 1 to eliminate the extra sign bit and the
selected pointer is modified. If the bits are different, the ACC is not shifted and
the selected pointer is not modified. The selected pointer does not access
any memory ___location.
Flags and Z After the operation, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
TC If the operation set TC, no normalization was needed (ACC did not need to
be modified). If the operation cleared TC, bits 31 and 30 were the same and,
as a result, the ACC register was logically shifted left by 1.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
the NORM instruction will be executed N+1 times. The state of the Z, N, and
TC flags will reflect the final result. Note: If you only want the NORM
instruction to execute until normalization is done, you can create a loop that
checks the value of the TC bit. When TC = 1, normalization is complete.
6-253
NORM ACC,XARn++/− −
6-254
NOT ACC
Description The content of the ACC register is replaced with its complement:
ACC = ACC XOR 0xFFFFFFFF;
Flags and N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes
Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-255
NOT AX
Description Replace the contents of the specified AX register (AH or AL) with its
complement:
AX = AX XOR 0xFFFF;
Flags and N After the operation, if bit 15 of AX is 1 then the negative flag bit is set;
Modes otherwise it is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-256
OR ACC, loc16
Description Perform a bitwise OR operation on the ACC register with the zero-extended
content of the ___location pointed to by the “loc16” address mode. The result
is stored in the ACC register:
ACC = ACC OR 0:[loc16];
Flags and N The load to ACC is tested for a negative condition. If bit 31 of ACC is 1, then
Modes the negative flag bit is set; otherwise it is cleared.
Z The load to ACC is tested for a zero condition. The zero flag bit is set if the
operation generates ACC = 0; otherwise it is cleared
Repeat This operation is repeatable. If the operation follows a RPT instruction, then
the OR instruction will be executed N+1 times. The state of the Z and N flags
will reflect the final result.
6-257
OR ACC,#16bit << #0..16
Description Perform a bitwise OR operation on the ACC register with the given 16-bit
unsigned constant value left shifted as specified. The value is zero extended
and lower order bits are zero filled before the OR operation. The result is
stored in the ACC register:
Flags and N The load to ACC is tested for a negative condition. If bit 31 of ACC is 1, then
Modes the negative flag bit is set; otherwise it is cleared.
Z The load to ACC is tested for a zero condition. The zero flag bit is set if the
operation generates ACC = 0; otherwise it is cleared
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-258
OR AX, loc16
Flags and N The load to AX is tested for a negative condition. If bit 15 of AX is 1, then the
Modes negative flag bit is set; otherwise it is cleared.
Z The load to AX is tested for a zero condition. The zero flag bit is set if the
operation generates AX = 0, otherwise it is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-259
OR IER,#16bit
OR IER,#16bit Bitwise OR
Description Enable specific interrupts by performing a bitwise OR operation with the IER
register and the 16-bit immediate value. The result is stored in the IER
register:
IER = IER OR #16bit;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Enable INT1 and INT6 only. Do not modify state of other
; interrupt’s enable:
OR IER,#0x0061 ; Enable INT1 and INT6
6-260
OR IFR,#16bit
OR IFR,#16bit Bitwise OR
Description Enable specific interrupts by performing a bitwise OR operation with the IFR
register and the 16-bit immediate value. The result of the OR operation is
stored in the IFR register.
IFR = IFR OR #16bit;
Note: Interrupt hardware has priority over CPU instruction operation in cases
where the interrupt flag is being simultaneously modified by the hardware
and the instruction.
This instruction should not be used with interrupts 1−12 when the peripheral
interrupt expansion (PIE) block is enabled.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Trigger INT1 and INT6 only. Do not modify state of other
; interrupt’s flags:
OR IFR,#0x0061 ; Trigger INT1 and INT6
6-261
OR loc16,#16bit
OR loc16,#16bit Bitwise OR
Flags and N After the operation if bit 15 of [loc16] 1, set N; otherwise, clear N.
Modes
Z After the operation if [loc16] is zero, set Z; otherwise, clear Z.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-262
OR loc16, AX
OR loc16, AX Bitwise OR
Flags and N The load to [loc16] is tested for a negative condition. If bit 15 of [loc16] is 1,
Modes then the negative flag bit is set; otherwise it is cleared.
Z The load to [loc16] is tested for a zero condition. The zero flag bit is set if the
operation generates [loc16] = 0, otherwise it is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-263
ORB AX,#8bit
Description Perform a bitwise OR operation on the specified AX register with the 8-bit
unsigned immediate constant zero extended. The result is stored in AX:
AX = AX OR 0x00:8bit;
Flags and N The load to AX is tested for a negative condition. If bit 15 of AX is 1, then the
Modes negative flag bit is set; otherwise it is cleared.
Z The load to AX is tested for a zero condition. The zero flag bit is set if the
operation generates AX = 0, otherwise it is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-264
OUT *(PA),loc16
Description Store the 16-bit value from the ___location pointed to by the “loc16” addressing
mode into the I/O space ___location pointed to by the *(PA) operand):
IOspace[0x0000PA] = [loc16];
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-265
OUT *(PA),loc16
6-266
POP ACC
Description Predecrement SP by 2. Load ACC with the 32-bit value pointed to by SP:
SP −= 2;
ACC = [SP];
Flags and N The load to ACC is tested for a negative condition. Bit-31 of the ACC register
Modes is the sign bit, 0 for positive, 1 for negative. The negative flag bit is set if the
operation on the ACC register generates a negative value, otherwise it is
cleared.
Z The load to ACC is tested for a zero condition. The bit is set if the result of
the operation on the ACC register generates a 0 value, otherwise it is cleared
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-267
POP ARn:ARm
POP AR3:AR2
SP −= 2;
AR2 = [SP];
AR3 = [SP+1];
AR3H:AR2H = unchanged;
POP AR5:AR4
SP −= 2;
AR4 = [SP];
AR5 = [SP+1];
AR5H:AR4H = unchanged;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-268
POP AR1H:AR0H
Description Predecrement SP by 2. Load the contents of AR0H with the value pointed
to by SP and AR1H with the value pointed to by SP+1. The lower 16 bits of
the auxiliary registers (AR0 and AR1) are left unchanged.
SP −= 2;
AR0H = [SP];
AR1H = [SP+1];
AR1:AR0 = unchanged;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-269
POP DBGIER
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-270
POP DP
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-271
POP DP:ST1
Description Predecrement SP by 2. Load ST1 with the value pointed to by SP and load
DP with the value pointed to by SP+1:
SP −= 2;
ST1 = [SP];
DP = [SP+1];
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-272
POP IFR
Description Predecrement SP by 1. Load the contents of IFR with the value pointed to
by SP:
SP −= 1;
IFR = [SP];
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-273
POP loc16
Description Predecrement SP by 1. Load the contents of loc16 with the 16-bit value
pointed to by SP.
SP -= 1;
[loc16] = [SP];
Flags and N If (loc16 = @AX), then the load to AX is tested for a negative condition. Bit-15
Modes of the AX register is the sign bit, 0 for positive, 1 for negative. The negative
flag bit is set if the operation on the AX register generates a negative value,
otherwise it is cleared.
Z If (loc16 = @AX), then the load to AX is tested for a zero condition. The bit
is set if the result of the operation on the AX register generates a 0 value,
otherwise it is cleared
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-274
POP P
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-275
POP RPC
Description Predecrement SP by 2. Load the contents of RPC with the value pointed to
by SP:
SP −= 2;
RPC = [SP];
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-276
POP ST0
Description Predecrement SP by 1. Load the contents of ST0 with the value pointed to
by SP:
SP −= 1;
ST0 = [SP];
Flags and C The bit value of each flag and mode listed is replaced by the value popped
Modes off of the stack
N
V
Z
TC
SXM
OVC
PM
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-277
POP ST1
Description Predecrement SP by 1. Load the contents of ST0 with the value pointed
to by SP:
SP −= 1;
ST1 = [SP];
Flags and DBGM The bit values for each flag and mode listed is replaced by the value
Modes popped off of the stack
INTM
VMAP
SPA
PAGE0
AMODE
ARP
EALLOW
OBJMODE
XF
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-278
POP T:ST0
Operands T:ST0 The upper 16-bits of the multiplicand register and status register 0
Description Predecrement SP by 2. Load ST0 with the value pointed to by SP and load
T with the value pointed to by SP+1. The low 16 bits of the XT Register (TL)
are left unchanged:
SP −= 2;
T = [SP];
ST0 = [SP+1];
TL = unchanged;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-279
POP XARn
Description Predecrement SP by 2. Load XARn with the 32-bit value pointed to by SP:
SP −= 2;
XARn = [SP];
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-280
POP XT
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-281
PREAD loc16,*XAR7
Description Load the data memory−___location pointed to by the “loc16” addressing mode
with the 16-bit content of the program−memory ___location pointed to by
”*XAR7”:
[loc16] = Prog[*XAR7];
On the C28x devices, memory blocks are mapped to both program and data
space (unified memory), hence the ”*XAR7” addressing mode can be used
to access data space variables that fall within the program space address
range.
Flags and N If (loc16 = @AX) and bit 15 of AX is 1, then N is set; otherwise N is cleared.
Modes
Z If (loc16 = @AX) and the value of AX is zero, then Z is set; otherwise Z is
cleared.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. When repeated, the ”*XAR7”
program−memory address is copied to an internal shadow register and the
address is post−incremented by 1 during each repetition.
6-282
PREAD loc16,*XAR7
6-283
PUSH ACC
Description Push the 32-bit contents of ACC onto the stack pointed to by SP.
Post-increment SP by 2:
[SP] = ACC;
SP += 2;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-284
PUSH ARn:ARm
Description Push the contents of two 16-bit auxiliary registers (ARn and ARm) onto the
stack pointed to by SP.
Post-increment SP by 2:
PUSH AR1:AR0
[SP] = AR0;
[SP+1] = AR1;
SP += 2;
PUSH AR3:AR2
[SP] = AR2;
[SP+1] = AR3;
SP += 2;
PUSH AR5:AR4
[SP] = AR4;
[SP+1] = AR5;
SP += 2;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-285
PUSH AR1H:AR0H
Description Push the contents of AR0H followed by the contents of AR1H onto the stack
pointed to by SP.
Post-increment SP by 2:
[SP] = AR0H;
[SP+1] = AR1H;
SP += 2;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-286
PUSH DBGIER
Description Push the 16-bit contents of DBGIER onto the stack pointed to by SP.
Post-increment SP by 1:
[SP] = DBGIER;
SP += 1;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-287
PUSH DP
Description Push the 16-bit contents of DP onto the stack pointed to by SP.
Post-increment SP by 1:
[SP] = DP;
SP += 1;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-288
PUSH DP:ST1
Description Push the 16- bit contents of ST1 followed by the 16-bit contents of DP onto
the stack pointed to by SP.
Post-increment SP by 2:
[SP] = ST1;
[SP+1] = DP;
SP += 2;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-289
PUSH IFR
Description Push the 16-bit contents of IFR onto the stack pointed to by SP.
Post-increment SP by 1:
[SP] = IFR;
SP += 1;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-290
PUSH loc16
Description Push a 16-bit value pointed to by the “loc16” operand on the stack pointed
to by SP.
Post-increment SP by 1:
[SP] = [loc16];
SP += 1;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-291
PUSH P
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example MOVL XAR5, #VarA ; Initialize XAR5 pointer with the
; 22-bit address of VarA
MOVL P, *+XAR5[0] ; Load the 32-bit contents of VarA
; into P
PUSH P ; Push the 32-bit P into the
; ___location pointed to by SP.
; Post-increment SP by 2
6-292
PUSH RPC
Description Push the contents of the RPC register onto the stack pointed to by SP.
Post-increment SP by 2:
[SP] = RPC;
SP += 2;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-293
PUSH ST0
Description Push the 16-bit contents of ST0 onto the stack pointed to by SP.
Post-increment SP by 1:
[SP] = ST0;
SP += 1;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-294
PUSH ST1
Description Push the 16-bit contents of ST1 onto the stack pointed to by SP.
Post-increment SP by 1:
[SP] = ST1;
SP += 1;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-295
PUSH T:ST0
Operands T:ST0 The upper 16-bits of the multiplicand register and status register 0
Description Push the 16- bit contents of ST0 followed by the 16-bit contents of T onto the
stack pointed to by SP. Post-increment SP by 2:
[SP] = ST0;
[SP+1] = T;
SP += 2;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-296
PUSH XARn
Description Push the 32-bit contents of XARn onto the stack pointed to by SP.
Post-increment
SP by 2:
[SP] = XARn;
SP += 2;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
PUSH AR1H:AR0H
PUSH XAR2 ; 16-bit AR1H and 16-bit AR0H store
PUSH XAR3
; 32-bit store of XAR2
PUSH XAR4
PUSH XAR5 ; 32-bit store of XAR3
PUSH XAR6 ; 32-bit store of XAR4
PUSH XAR7
; 32-bit store of XAR5
PUSH XT
. ; 32-bit store of XAR6
. ; 32-bit store of XAR7
.
; 32-bit store of XT
6-297
PUSH XT
Description Push the 32-bit contents of XT onto the stack pointed to by SP.
Post-increment SP by 2:
[SP] = XT;
SP += 2;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-298
PWRITE *XAR7,loc16
Description Load the program−memory ___location pointed to by the ”*XAR7” with the
content of the ___location pointed to by the “loc16” addressing mode:
Prog[*XAR7] = [loc16];
On the C28x devices, memory blocks are mapped to both program and data
space (unified memory), hence the ”*XAR7” addressing mode can be used
to access data space variables that fall within the program space address
range.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. When repeated, the ”*XAR7”
program−memory address is copied to an internal shadow register and the
address is post−incremented by 1 during each repetition.
6-299
QMACL P,loc32,*XAR7/++
Description 32-bit x 32-bit signed multiply and accumulate. First, add the previous
product (stored in the P register), shifted as specified by the product shift
mode (PM), to the ACC register. Then, multiply the signed 32-bit content of
the ___location pointed to by the “loc32” addressing mode by the signed 32-bit
content of the program−memory ___location pointed to by the XAR7 register
and store the upper 32−bits of the 64-bit result in the P register. If specified,
post-increment the XAR7 register by 2:
ACC = ACC + P << PM;
P = (signed T * signed Prog[*XAR7 or *XAR7++]) >> 32;
On the C28x devices, memory blocks are mapped to both program and data
space (unified memory), hence the ”*XAR7/++” addressing mode can be
used to access data space variables that fall within the program space
address range.
Flags and Z After the addition, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
6-300
QMACL P,loc32,*XAR7/++
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. The state of the Z, N, C and OVC flags will
reflect the final result in the ACC. The V flag will be set if an intermediate
overflow occurs in the ACC.
6-301
QMPYAL P,XT,loc32
QMPYAL P,XT,loc32 Signed 32-bit Multiply (Upper Half) and Add Previous P
Description Signed 32-bit x 32-bit multiply and accumulate the previous product. Add the
previous signed product (stored in the P register), shifted as specified by the
product shift mode (PM), to the ACC register. In addition, multiply the signed
32-bit content of the XT register by the signed 32-bit content of the ___location
pointed to by the “loc32” addressing mode and store the upper 32−bits of the
64-bit result in the P register:
ACC = ACC + P << PM;
P = (signed T * signed [loc32]) >> 32;
Flags and Z After the addition, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If overflow mode is disabled; and if the operation generates a positive
overflow, then the counter is incremented. If overflow mode is disabled; and
if the operation generates a negative overflow, then the counter is
decremented.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-302
QMPYAL P,XT,loc32
6-303
QMPYL P,XT,loc32
Description Multiply the signed 32-bit content of the XT register by the signed 32-bit
content of the ___location pointed to by the “loc32” addressing mode and store
the upper 32−bits of the 64-bit result (a Q30 number) in the P register:
P = (signed XT * signed [loc32]) >> 32;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-304
QMPYL ACC,XT,loc32
Description Multiply the signed 32-bit content of the XT register by the signed 32-bit
content of the ___location pointed to by the “loc32” addressing mode and store
the upper 32-bits of the 64-bit result (a Q30 number) in the ACC register:
ACC = (signed XT * signed [loc32]) >> 32;
Flags and Z After the operation, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-305
QMPYSL P,XT,loc32
QMPYSL P,XT,loc32 Signed 32-bit Multiply (Upper Half) and Subtract Previous P
Description Signed 32-bit x 32-bit multiply and subtract the previous product. Subtract
the previous signed product (stored in the P register), shifted as specified by
the product shift mode (PM), from the ACC register. In addition, multiply the
signed 32-bit content of the XT register by the signed 32-bit constant value
and store the upper 32−bits of the 64-bit result in the P register:
ACC = ACC − P << PM;
P = (signed T * signed [loc32]) >> 32;
Flags and Z After the subtraction, the Z flag is set if the ACC value is zero, else Z is
Modes cleared.
N After the subtraction, the N flag is set if bit 31 of the ACC is 1, else N is
cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If overflow mode is disabled; and if the operation generates a positive
overflow, then the counter is incremented. If overflow mode is disabled; and
if the operation generates a negative overflow, then the counter is
decremented.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-306
QMPYSL P,XT,loc32
6-307
QMPYUL P,XT,loc32
Description Multiply the unsigned 32-bit content of the XT register by the unsigned 32-bit
content of the ___location pointed to by the “loc32” addressing mode and store the
upper 32−bits of the 64-bit result in the P register:
P = (unsigned XT * unsigned [loc32]) >> 32;
Repeat This instruction is not repeatable. If this instruction follows the RPT instruction,
it resets the repeat counter (RPTC) and executes only once.
6-308
QMPYXUL P,XT,loc32
Description Multiply the signed 32-bit content of the XT register by the unsigned 32-bit
content of the ___location pointed to by the “loc32” addressing mode and store
the upper 32−bits of the 64-bit result in the P register:
P = (signed XT * unsigned [loc32]) >> 32;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-309
ROL ACC
Description Rotate the content of the ACC register left by one bit, filling bit 0 with the
content of the carry flag and loading the carry flag with the bit shifted out:
ACC
C Rotate Left
ACC
Flags and N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes
Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
C The value in bit 31 of the ACC register is transferred to C. The value in C
before the rotation is transferred to bit 0 of the ACC.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
the ROL instruction will be executed N+1 times. The state of the Z, N, and
C flags will reflect the final result.
6-310
ROR ACC
Description Rotate the content of the ACC register right by one bit, filling bit 31 with the
content of the carry flag and loading the carry flag with the bit shifted out:
ACC
Rotate Right C
ACC
Flags and N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes
Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
C The value in bit 0 of the ACC register is transferred to C. The value in C
before the rotation is transferred to bit 31 of the ACC.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
the ROR instruction will be executed N+1 times. The state of the Z, N, and
C flags will reflect the final result.
6-311
RPT #8bit/loc16
Description Repeat the next instruction. An internal repeat counter (RPTC) is loaded with
a value N that is either the specified #8bit constant value or the content of
the ___location pointed to by the “loc16” addressing mode. After the instruction
that follows the RPT is executed once, it is repeated N times; that is, the
instruction following the RPT executes N + 1 times. Because the RPTC
cannot be saved during a context switch, repeat loops are regarded as
multicycle instructions and are not interruptible.
Note on syntax:
Parallel bars (||) before the repeated instruction are used as a reminder that
the instruction is repeated and is not interruptable.
When writing inline assembly, use the syntax
asm(|| RPT #8bt/ loc16 || instruction”);
Not all instructions are repeatable. If an instruction that is not repeatable
follows the RPT instruction, the RPTC counter is reset to 0 and the
instruction only executes once. The 28x Assembly Language tools check for
this condition and issue warnings.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-312
SAT ACC
Description Saturate the ACC register to reflect the net overflow represented in the 6-bit
overflow counter (OVC):
if( OVC > 0 )
ACC = 0x7FFF FFFF;
V = 1;
if( OVC < 0 )
ACC = 0x8000 0000;
V = 1;
if( OVC = 0 )
ACC = unchanged;
OVC = 0;
V = 0;
Flags and N After the operation, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
Modes
Z After the operation, the Z flag is set if the ACC is zero, else Z is cleared.
C C is cleared.
V If (OVC != 0) at the start of the operation, V is set; otherwise, V is cleared
OVC If (OVC > 0) then ACC is saturated to its maximum positive value.
If (OVC < 0) then ACC is saturated to its maximum negative value.
if (OVC = 0) then ACC is not modified.
After the operation, OVC is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Add VarA, VarB and VarC and saturate result and store in VarD:
ZAP OVC ; Clear overflow counter
MOVL ACC,@VarA ; Load ACC with contents of VarA
ADDL ACC,@VarB ; Add to ACC contents of VarB
ADDL ACC,@VarC ; Add to ACC contents of VarC
SAT ACC ; Saturate ACC based on OVC value
MOVL @VarD,ACC ; Store result into VarD
6-313
SAT64 ACC:P
Description Saturate the 64-bit content of the combined ACC:P registers to reflect the
net overflow represented in the overflow counter (OVC):
if(OVC > 0)
ACC:P = 0x7FFF FFFF FFFF FFFF;
V=1;
if(OVC < 0)
ACC:P = 0x8000 0000 0000 0000;
V=1;
if(OVC = 0)
ACC:P = unchaged;
OVC = 0;
Flags and N After the shift, if bit 31 of the ACC register is 1 then ACC:P is negative and
Modes the N bit is set; otherwise N is cleared.
Z After the operation, the Z flag is set if the combined 64-bit value of the ACC:P
is zero; otherwise, Z is cleared.
C The C bit is cleared.
V At the start of the operation, if (OVC = 0) then V is cleared; otherwise, V is
set.
OVC If (OVC = 0), then no saturation takes place:
ACC:P is unchanged.
If(OVC > 0), then saturate ACC:P the maximum positive value:
ACC:P = 0x7FFF FFFF FFFF FFFF
If( OVC < 0), then saturate ACC:P to the maximum negative value:
ACC = 0x8000 0000 or ACC:P = 0x8000 0000 0000 0000
At the end of the operation, OVC is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-314
SAT64 ACC:P
Example ; Add 64-bit VarA, VarB and VarC, sat and store result in VarD:
ZAP OVC ; Clear overflow counter
MOVL P,@VarA+0 ; Load P with low 32-bits of VarA
ADDUL P,@VarB+0 ; Add to P unsigned low 32-bits of VarB
ADDUL P,@VarC+0 ; Add to P unsigned low 32-bits of VarC
MOVU @AL,OVC ; Store overlow (repeated carry) in the ACC
; and then add higher portion of the 64 bit
; variables
MOVB AH,#0 ; Store overlow (repeated carry) in the ACC
; and then add higher portion of the 64 bit
; variables
ZAP OVC ; Clear overflow counter
ADDL ACC,@VarA+2 ; Add to ACC with carry high 32-bits of VarA
ADDL ACC,@VarB+2 ; Add to ACC with carry high 32-bits of VarB
ADDL ACC,@VarC+2 ; Add to ACC with carry high 32-bits of VarC
SAT64 ACC:P ; Saturate ACC:P based on OVC value
MOVL @VarD+0,P ; Store low 32-bit result into VarD
MOVL @VarD+2,ACC ; Store high 32-bit result into VarD
6-315
SB 8bitOffset,COND
SB 8bitOffset,COND
Description Short conditional branch. If the specified condition is true, then branch
by adding the signed 8-bit constant value to the current PC value;
otherwise continue execution without branching:
If (COND = true) PC = PC + signed 8-bit offset;
If (COND = false) PC = PC + 1;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-316
SBBU ACC,loc16
Description Subtract the 16-bit contents of the ___location pointed to by the “loc16”
addressing mode, zero extended, and subtract the compliment of the carry
flag bit from the ACC register:
ACC = ACC − 0:[loc16] − ~C;
Flags and Z After the subtraction, the Z flag is set if ACC is zero, else Z is cleared.
Modes
N After the subtraction, the N flag is set if bit 31 of the ACC is 1, else N is
cleared.
C The state of the carry bit before execution is included in the subtraction. If
the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If(OVM = 0, disabled) then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented. If(OVM = 1, enabled) then the
counter is not affected by the operation.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-317
SBF 8bitOffset,EQ/NEQ/TC/NTC
Operands 8bitOffset 8-bit signed immediate constant offset value (−128 to +127 range)
Syntax Description Flags Tested
NEQ Not Equal To Z=0
EQ Equal To Z=1
NTC Test Bit Not Set TC = 0
TC Test Bit Set TC = 1
Description Short fast conditional branch. If the specified condition is true, then
branch by adding the signed 8-bit constant value to the current PC value;
otherwise continue execution without branching:
If (tested condition = true) PC = PC + signed 8-bit off-
set;
If (tested condition = false) PC = PC + 1;
Note: The short branch fast (SBF) instruction takes advantage of dual
pre−fetch queue on the C28x core that reduces the cycles for a taken
branch from 7 to 4:
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-318
SBRK #8bit
Description Subtract the 8-bit unsigned constant from the XARn register pointed to by
ARP:
XAR(ARP) = XAR(ARP) − 0:8bit;
Flags and ARP The 3-bit ARP points to the current valid auxiliary register, XAR0 to XAR7.
Modes This pointer determines which auxiliary register is modified by the operation.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once
; Decrement XAR1 by 2
SBRK #2
; Load AR3 with the 16−bit value
MOVZ AR3,*XAR1 ; pointed to by XAR1 (0xEEEE)
6-319
SETC Mode
Description Set the specified status bits. The ”mode” operand is a mask value that relates
to the status bits in this way:
Flags and SXM Any of the specified bits can be set by the instruction.
Modes
OVM
TC
C
INTM
DBGM
PAGE0
VMAP
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once
6-320
SETC Mode
6-321
SETC M0M1MAP
Description Set the M0M1MAP status bit, configuring the mapping of the M0 and M1
memory blocks for C28x/C2XLP operation. The memory blocks are
mapped as follows:
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-322
SETC OBJMODE
Description Set the OBJMODE status bit, putting the device in C28x object mode
(supports C2XLP source):
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-323
SETC XF
Description Set the XF status bit and pull the corresponding output signal high.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-324
SFR ACC,#1..16
Description Right shift the content of the ACC register by the amount specified in the shift
field. The type of shift (arithmetic or logical) is determined by the state of the
sign extension mode (SXM) bit:
if(SXM = 1) // sign extension mode enabled
ACC = S:ACC >> shift value; // arithmetic shift right
else //sign extension mode disabled
ACC = 0:ACC >> shift value; // logical shift right
Flags and Z After the shift, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the shift, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C The last bit shifted out is loaded into the C flag bit.
SXM If (SXM = 1), then the operation behaves like an arithmetic right shift.
If (SXM = 0), then the operation behaves like a logical right shift.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
the SFR instruction will be executed N+1 times. The state of the Z, N and C
flags will reflect the final result.
6-325
SFR ACC,T
Description Right shift the content of the ACC register by the amount specified in the four
least significant bits of the T register, T(3:0) = 0..15. Higher order bits are
ignored. The type of shift (arithmetic or logical) is determined by the state of
the sign extension mode (SXM) bit:
if(SXM = 1) // sign extension mode enabled
ACC = S:ACC >> T(3:0); // arithmetic shift right
else // sign extension mode disabled
ACC = 0:ACC >> T(3:0); // logical shift right
Flags and Z After the shift, the Z flag is set if the ACC value is zero, else Z is cleared. Even
Modes if the T register specifies a shift of 0, the content of the ACC register is still
tested for the zero condition and Z is affected.
N After the shift, the N flag is set if bit 31 of the ACC is 1, else N is cleared. Even
if the T register specifies a shift of 0, the content of the ACC register is still
tested for the negative condition and N is affected.
C If (T(3:0) = 0) then C is cleared; otherwise, the last bit shifted out is loaded
into the C flag bit.
SXM if (SXM = 1), then the operation behaves like an arithmetic right shift.
If (SXM = 0), then the operation behaves like a logical right shift.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
the SFR instruction will be executed N+1 times. The state of the Z, N and C
flags will reflect the final result.
6-326
SPM shift
Operands shift Product shift mode (+4, +1, 0, −1, −2, −3, −4, −5, −6)
Description Specify a product shift mode. A negative value indicates an arithmetic right
shift; positive numbers indicate a logical left shift. The following table shows
the relationship between the “shift” operand and the 3-bit value that gets
loaded into the product shift mode (PM) bits in ST0. The address mode bit
(AMODE) selects between two types of shift decodes as shown in the table
below:
Flags and PM PM is loaded with the 3-bit value specified by the selected ”shift” value.
Modes
Repeat This instruction is not repeatable. If the operation follows a RPT instruction,
it resets the repeat counter (RPTC) and executes once.
6-327
SPM shift
6-328
SQRA loc16
Description Add the previous product (stored in the P register), shifted by the amount
specified by the product shift mode (PM), to the ACC register. Then the
content of the ___location pointed to by the “loc16” addressing mode is loaded
into the T register, squared, and stored in the P register:
ACC = ACC + P << PM;
T = [loc16];
P = T * [loc16];
Flags and Z After the addition, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If overflow mode is disabled; and if the operation generates a positive
overflow, then the counter is incremented. If overflow mode is disabled; and
if the operation generates a negative overflow, then the counter is
decremented.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. The state of the Z, N, C and OVC flags will
reflect the final result. The V flag is set if an intermediate overflow occurs.
6-329
SQRA loc16
6-330
SQRS loc16
Description Subtract the previous product (stored in the P register), shifted by the
amount specified by the product shift mode (PM), from the ACC register.
Then the content of the ___location pointed to by the “loc16” addressing mode
is loaded into the T register, squared, and stored in the P register:
ACC = ACC − P << PM;
T = [loc16];
P = T * [loc16];
Flags and Z After the addition, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the subtraction, the N flag is set if bit 31 of the ACC is 1, else N is
cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If overflow mode is disabled; and if the operation generates a positive
overflow, then the counter is incremented. If overflow mode is disabled; and
if the operation generates a negative overflow, then the counter is
decremented.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. The state of the Z, N, C and OVC flags will
reflect the final result. The V flag will be set if an intermediate overflow
occurs.
6-331
SQRS loc16
6-332
SUB ACC,loc16 << #0...16
Description Subtract the left-shifted 16-bit ___location pointed to by the ”loc16” addressing
mode from the ACC register. The shifted value is sign extended if sign
extension mode is turned on (SXM=1) else the shifted value is zero extended
(SXM= 0). The lower bits of the shifted value are zero filled:
if(SXM = 1) // sign extension mode enabled
ACC = ACC − S:[loc16] << shift value;
else // sign extension mode disabled
ACC = ACC − 0:[loc16] << shift value;
Flags and Z After the subtraction, the Z flag is set if ACC is zero, else Z is cleared.
Modes
N After the subtraction, the N flag is set if bit 31 of the ACC is 1, else Z is
cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
Exception: If a shift of 16 is used, the SUB instruction can clear C but not
set it.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If(OVM = 0, disabled) then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented. If(OVM = 1, enabled) then the
counter is not affected by the operation.
SXM If sign extension mode bit is set; then the 16-bit operand, addressed by the
”loc16” field, will be sign extended before the addition. Else, the value will be
zero extended.
6-333
SUB ACC,loc16 << #0...16
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFF FFFF) or maximum negative (0x8000 0000) if the
operation overflowed.
Repeat If the operation is repeatable, then the instruction will be executed N+1
times. The state of the Z, N, C flags will reflect the final result. The V flag will
be set if an intermediate overflow occurs. The OVC flag will count
intermediate overflows, if overflow mode is disabled. If the operation is not
repeatable, the instruction will execute only once.
Example ; Calculate signed value: ACC = (VarA << 10) − (VarB << 6);
SETC SXM ; Turn sign extension mode on
MOV ACC,@VarA << #10 ; Load ACC with VarA left shifted by 10
SUB ACC,@VarB << #6 ; Subtract VarB left shifted by 6 to
ACC0
6-334
SUB ACC,loc16 <<T
Description Subtract from the ACC register the left−shifted contents of the 16-bit ___location
pointed to by the “loc16” addressing mode. The shift value is specified by the
four least significant bits of the T register, T(3:0) = shift value = 0..15. Higher
order bits are ignored. The shifted value is sign extended if sign extension
mode is turned on (SXM=1) else the shifted value is zero extended (SXM=0).
The lower bits of the shifted value are zero filled:
if(SXM = 1) // sign extension mode enabled
ACC = ACC − S:[loc16] << T(3:0);
else // sign extension mode disabled
ACC = ACC − 0:[loc16] << T(3:0);
Flags and Z After the subtraction, the Z flag is set if the ACC value is zero, else Z is
Modes cleared.
N After the subtraction, the N flag is set if bit 31 of the ACC is 1, else N is
cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If(OVM = 0, disabled) then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented. If(OVM = 1, enabled) then the
counter is not affected by the operation.
SXM If sign extension mode bit is set; then the 16-bit operand, addressed by the
”loc16” field, will be sign extended before the addition. Else, the value will be
zero extended.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFF FFFF) or maximum negative (0x8000 0000) if the
operation overflowed.
Repeat If this operation is repeated, then the instruction will be executed N+1 times.
The state of the Z, N, C flags will reflect the final result. The V flag will be set
if an intermediate overflow occurs. The OVC flag will count intermediate
overflows, if overflow mode is disabled.
6-335
SUB ACC,loc16 <<T
Example ; Calculate signed value: ACC = (VarA << SB) − (VarB << SB)
SETC SXM ; Turn sign extension mode on
MOV T,@SA ; Load T with shift value in SA
MOV ACC,@VarA << T ; Load in ACC shifted contents of VarA
MOV T,@SB ; Load T with shift value in SB
SUB ACC,@VarB << T ; Subtract from ACC shifted contents
; of VarB
6-336
SUB ACC,#16bit << #0..15
Description Subtract the left shifted 16-bit immediate constant value from the ACC
register. The shifted value is sign extended if sign extension mode is turned
on (SXM=1) else the shifted value is zero extended (SXM=0). The lower bits
of the shifted value are zero filled:
if(SXM = 1) // sign extension mode enabled
ACC = ACC − S:16bit << shift value;
else // sign extension mode disabled
ACC = ACC − 0:16bit << shift value;
Smart Encoding:
If #16bit is an 8-bit number and the shift is zero, then the assembler will
encode this instruction as SUBB ACC, #8bit for improved efficiency. To
override this encoding, use the SUBW ACC, #16bit instruction alias.
Flags and Z After the subtraction, the Z flag is set if ACC is zero, else Z is cleared.
Modes N After the subtraction, the N flag is set if bit 31 of the ACC is 1, else N is
cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If(OVM = 0, disabled) then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented. If(OVM = 1, enabled) then the
counter is not affected by the operation.
SXM If sign extension mode bit is set; then the 16-bit operand, addressed by the
”loc16” field, will be sign extended before the addition. Else, the value will be
zero extended.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Calculate signed value: ACC = (VarB << 10) − (23 << 6);
SETC SXM ; Turn sign extension mode on
MOV ACC,@VarB << #10 ; Load ACC with VarB left shifted by 10
SUB ACC,#23 << #6 ; Subtract from ACC 23 left shifted by 6
6-337
SUB AX, loc16
Description Subtract the 16−bit content of the ___location pointed to by the “loc16”
addressing mode from the specified AX register (AH or AL) and store the
results in AX:
AX = AX − [loc16];
Flags and N After the subtraction, AX is tested for a negative condition. If bit 15 of AX is
Modes 1, then the negative flag bit is set; otherwise it is cleared.
Z After the subtraction, AX is tested for a zero condition. The zero flag bit is set
if the operation generates AX = 0, otherwise it is cleared
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected. Signed positive
overflow occurs if the result crosses the max positive value (0x7FFF) in the
positive direction. Signed negative overflow occurs if the result crosses the
max negative value (0x8000) in the negative direction.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Subtract the contents of VarA with VarB and store in VarC
MOV AL,@VarA ; Load AL with contents of VarA
SUB AL,@VarB ; Subtract from AL contents of VarB
MOV @VarC,AL ; Store result in VarC
6-338
SUB loc16, AX
Description Subtract the content of the specified AX register (AH or AL) from the 16-bit
content of the ___location pointed to by the “loc16” addressing mode and store
the result in ___location pointed to by ”loc16”:
[loc16] = [loc16] − AX;
Flags and N After the subtraction, [loc16] is tested for a negative condition. If bit 15 of
Modes [loc16]
is 1, then the negative flag bit is set; otherwise it is cleared.
Z After the subtraction, [loc16] is tested for a zero condition. The zero flag bit
is set if the operation generates [loc16] = 0; otherwise it is cleared
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected. Signed positive
overflow occurs if the result crosses the max positive value (0x7FFF) in the
positive direction. Signed negative overflow occurs if the result crosses the
max negative value (0x8000) in the negative direction.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-339
SUBB ACC,#8bit
Description Subtract the zero−extended, 8-bit constant from the ACC register:
ACC = ACC − 0:8bit;
Flags and Z After the subtraction, the Z flag is set if ACC is zero, else Z is cleared.
Modes
N After the subtraction, the N flag is set if bit 31 of the ACC is 1, N is cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise, V is not affected.
OVC If(OVM = 0, disabled) then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented. If(OVM = 1, enabled) then the
counter is not affected by the operation.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-340
SUBB SP,#7bit
SUBB SP,#7bit
Description Subtract a 7-bit unsigned constant from SP and store the result in SP:
SP = SP − 0:7bit;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-341
SUBB XARn,#7bit
Description Subtract the 7−bit unsigned constant from XARn and store the result in
XARn:
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-342
SUBBL ACC, loc32
Description Subtract from the ACC the 32-bit ___location pointed to by the “loc32”
addressing mode and the logical inversion of the value in the carry flag bit:
Flags and Z After the subtraction, the Z flag is set if the ACC value is zero, else Z is
Modes cleared.
N After the subtraction, the N flag is set if bit 31 of the ACC is 1, else N is
cleared.
C The state of the carry bit before execution is included in the subtraction. If
the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If(OVM = 0, disabled) then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented. If(OVM = 1, enabled) then the
counter is not affected by the operation.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-343
SUBBL ACC, loc32
Example ; Subtract two 64-bit values (VarA and VarB) and store result
; in VarC:
MOVL ACC,@VarA+0 ; Load ACC with contents of the low
; 32-bits of VarA
SUBUL ACC,@VarB+0 ; Subtract from ACC the contents of
; the low 32-bits of VarB
MOVL @VarC+0,ACC ; Store low 32-bit result into VarC
MOVL ACC,@VarA+2 ; Load ACC with contents of the high
; 32-bits of VarA
SUBBL ACC,@VarB+2 ; Subtract from ACC the contents of
; the high 32-bits of VarB with borrow
MOVL @VarC+2,ACC ; Store high 32-bit result into VarC
6-344
SUBCU ACC,loc16
Description Perform 16-bit conditional subtraction, which can be used for unsigned
modulus division:
temp(32:0) = ACC << 1 − [loc16] << 16
if( temp(32:0) >= 0 )
ACC = temp(31:0) + 1
else
ACC = ACC << 1
To perform 16-bit unsigned modulus division, the AH register is zeroed and
the AL register is loaded with the ”Numerator” value prior to executing the
SUBCU instruction. The value pointed to be the ”loc16” addressing mode
contains the ”Denominator” value. After executing the SUBCU instruction 16
times, the AH register will contain the ”Remainder” and the AL register will
contain the ”Quotient” results. To perform signed modulus division, the
”Numerator” and ”Denominator” values must be converted to unsigned
quantities, before executing the SUBCU instruction. The final ”Quotient”
result must be negated if the ”Numerator” and ”Denominator” values were
of different sign else the quotient is left unchanged.
Flags and Z At the end of the operation, the Z flag is set if the ACC value is zero, else Z
Modes is cleared. The calculation of temp(32:0) has no effect on the Z bit.
N At the end of the operation, the N flag is set if bit 31 of the ACC is 1, else N
is cleared. The calculation of temp(32:0) has no effect on the N bit.
C If the calculation of temp(32:0) generates a borrow, C is cleared; otherwise
C is set.
Note: The V and OVC flags are not affected by the operation.
Repeat If this operation is repeated, then the instruction will be executed N+1 times.
The state of the Z, N, C flags will reflect the final result. The V flag will be set
if an intermediate overflow occurs. The OVC flag will count intermediate
overflows, if overflow mode is disabled.
6-345
SUBCU ACC,loc16
6-346
SUBCUL ACC,loc32
Description Perform 32-bit conditional subtraction, which can be used for unsigned
modulus division:
To perform 32-bit unsigned modulus division, the ACC register is zeroed and
the P register is loaded with the ”Numerator” value prior to executing the
SUBCUL instruction. The value pointed to be the ”loc32” addressing mode
contains the ”Denominator” value. After executing the SUBCUL instruction
32 times, the ACC register will contain the ”Remainder” and the P register
will contain the ”Quotient” results. To perform signed modulus division, the
”Numerator” and ”Denominator” values must be converted to unsigned
quantities, before executing the SUBCUL instruction. The final ”Quotient”
result must be negated if the ”Numerator” and ”Denominator” values were
of different sign else the quotient is left unchanged.
Flags and Z At the end of the operation, the Z flag is set if the ACC value is zero, else Z
Modes is cleared. The calculation of temp(32:0) has no effect on the Z bit.
N At the end of the operation, the N flag is set if bit 31 of the ACC is 1, else N
is cleared. The calculation of temp(32:0) has no effect on the N bit.
C If the calculation of temp(32:0) generates a borrow, C is cleared; otherwise
C is set.
Note: The V and OVC flags are not affected by the operation.
Repeat If this operation is repeated, then the instruction will be executed N+1 times.
The state of the Z, N, C flags will reflect the final result. The V flag will be set
if an intermediate overflow occurs. The OVC flag will count intermediate
overflows, if overflow mode is disabled.
6-347
SUBCUL ACC,loc32
6-348
SUBCUL ACC,loc32
6-349
SUBL ACC, loc32
Description Subtract the 32-bit ___location pointed to by the “loc32” addressing mode from
the ACC register :
ACC = ACC − [loc32];
Flags and Z After the subtraction, the Z flag is set if the ACC value is zero, else Z is
Modes cleared.
N After the subtraction, the N flag is set if bit 31 of the ACC is 1, else N is
cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If OVM = 0 (disabled), then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented.
If OVM = 1 (enabled), then the counter is not affected by the operation.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-350
SUBL ACC,P << PM
Description Subtract the content of the P register, shifted as specified by the product shift
mode (PM), from the content of the ACC register:
ACC = ACC − P << PM;
Flags and Z After the subtraction, the Z flag is set if the ACC value is zero, else Z is
Modes cleared.
N After the subtraction, the N flag is set if bit 31 of the ACC is 1, else N is
cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If OVM = 0 (disabled) and the operation generates a positive overflow, the
counter is incremented; if the operation generates a negative overflow, the
counter is decremented.
If OVM = 1 (enabled), the counter is not affected by the operation.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat If this operation is repeated, then the instruction will be executed N+1 times.
The state of the Z, N, C flags will reflect the final result. The V flag will be set
if an intermediate overflow occurs. The OVC flag will count intermediate
overflows, if overflow mode is disabled.
6-351
SUBL ACC,P << PM
6-352
SUBL loc32, ACC
Description Subtract the content of the ACC register from the ___location pointed to by the
“loc32” addressing mode:
[loc32] = [loc32] − ACC;
Flags and Z After the subtraction, the Z flag is set if the ACC value is zero, else Z is
Modes cleared.
N After the subtraction, the N flag is set if bit 31 of the [loc32] is 1, else N is
cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If OVM = 0 (disabled) and the operation generates a positive overflow, the
counter is incremented and if the operation generates a negative overflow,
the counter is decremented.
If OVM = 1 (enabled) the counter is not affected by the operation.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-353
SUBR loc16,AX
Description Subtract the 16−bit content of the ___location pointed to by the “loc16”
addressing mode from the specified AX register (AH or AL), and store the
result in ___location pointed to by ”loc16”:
[loc16] = AX − [loc16]
Flags and N After the subtraction, [loc16] is tested for a negative condition. If bit 15 of
Modes [loc16] is 1, then the negative flag bit is set; otherwise it is cleared.
Z After the subtraction, [loc16] is tested for a zero condition. The zero flag bit
is set if the operation generates [loc16] = 0, otherwise it is cleared
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected. Signed positive
overflow occurs if the result crosses the max positive value (0x7FFF) in the
positive direction. Signed negative overflow occurs if the result crosses the
max negative value (0x8000) in the negative direction.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Subtract index register AR0 from VarA and store in AR0:
MOV AL,@VarA ; Enable ; Load AL with contents of VarA
sign extensio ;
with a left shift of 3
SUBR @AR0,AL ; AR0 = AL − AR0
; Subtract the contents of VarC from VarB and store in VarC:
MOV AH,@VarB ; Load AH with contents of VarB
SUBR @VarC,AH ; VarC = AH − VarC
6-354
SUBRL loc32, ACC
Description Subtract from the ACC register the 32-bit ___location pointed to by the “loc32”
addressing mode and store the result in the ___location pointed to by “loc32”:
[loc32] = ACC − [loc32];
Flags and Z After the subtraction, the Z flag is set if the ACC value is zero, else Z is
Modes cleared.
N After the subtraction, the N flag is set if bit 31 of the ACC is 1, else N is
cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If(OVM = 0, disabled) then if the operation generates a positive overflow,
then the counter is incremented and if the operation generates a negative
overflow, then the counter is decremented. If(OVM = 1, enabled) then the
counter is not affected by the operation.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-355
SUBU ACC, loc16
Description Subtract the 16-bit contents of the ___location pointed to by the “loc16”
addressing mode from the ACC register. The addressed ___location is zero
extended before the add:
ACC = ACC − 0:[loc16];
Flags and Z After the subtraction, the Z flag is set if ACC is zero, else Z is cleared.
Modes
N After the subtraction, the N flag is set if bit 31 of the ACC is 1, else N is
cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If OVM = 0 (disabled) and the operation generates a positive overflow, the
counter is incremented and if the operation generates a negative overflow,
the counter is decremented.
If OVM = 1 (enabled), the counter is not affected by the operation.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
Repeat If this operation is repeated, then the instruction will be executed N+1 times.
The state of the Z, N, C flags will reflect the final result. The V flag will be set
if an intermediate overflow occurs. The OVC flag will count intermediate
overflows, if overflow mode is disabled.
6-356
SUBUL ACC, loc32
Description Subtract from the ACC register the 32-bit the ___location pointed to by the
“loc32” addressing mode. The subtraction is treated as an unsigned SUBL
operation:
ACC = ACC − [loc32]; // unsigned subtraction
Note: The difference between a signed and unsigned 32-bit subtract is in the
treatment of the overflow counter (OVC). For a signed SUBL, the OVC
counter monitors positive/negative overflow. For an unsigned SUBL, the
OVC unsigned (OVCU) counter monitors the borrow.
Flags and Z After the subtraction, the Z flag is set if the ACC value is zero, else Z is
Modes cleared.
N After the subtraction, the N flag is set if bit 31 of the ACC is 1, else N is
cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If an overflow occurs, V is set; otherwise V is not affected.
OVCU The overflow counter is decremented whenever a subtraction operation
generates an unsigned borrow. The OVM mode does not affect the OVCU
counter.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Subtract two 64-bit values (VarA and VarB) and store result
; in VarC:
MOVL ACC,@VarA+0 ; Load ACC with contents of the low
; 32-bits of VarA
SUBUL ACC,@VarB+0 ; Subtract from ACC the contents of
; the low 32-bits of VarB
MOVL @VarC+0,ACC ; Store low 32-bit result into VarC
MOVL ACC,@VarA+2 ; Load ACC with contents of the high
; 32-bits of VarA
SUBBL ACC,@VarB+2 ; Subtract from ACC the contents of
; the high 32-bits of VarB with borrow
MOVL @VarC+2,ACC ; Store high 32-bit result into VarC
6-357
SUBUL P,loc32
Description Subtract from the P register the 32-bit content of the ___location pointed to by
the “loc32” addressing mode. The addition is treated as an unsigned SUB
operation:
P = P − [loc32]; // unsigned subtract
Note: The difference between a signed and unsigned 32-bit subtract is in the
treatment of the overflow counter (OVC). For a signed SUBL, the OVC
counter monitors positive/negative overflow. For an unsigned SUBL, the
OVC unsigned (OVCU) counter monitors the borrow.
Flags and Z After the subtraction, the Z flag is set if the P value is zero, else Z is cleared.
Modes
N After the subtraction, the N flag is set if bit 31 of P is 1, else N is cleared.
C If the subtraction generates a borrow, C is cleared; otherwise C is set.
V If a signed overflow occurs, V is set; otherwise V is not affected.
OVCU The overflow counter is decremented whenever a subtraction operation
generates an unsigned borrow. The OVM mode does not affect the OVCU
counter.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-358
TBIT loc16,#bit
Description Test the specified bit of the data value in the ___location pointed to by the
“loc16” addressing mode:
TC = [loc16(bit)];
The value specified for the #bit immediate operand directly corresponds
to the bit number. For example, if #bit = 0, you will access bit 0 (least
significant bit) of the addressed ___location; if #bit = 15, you will access bit
15 (most significant bit).
Flags and TC If the bit tested is 1, TC is set; if the bit tested is 0, TC is cleared.
Modes
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-359
TBIT loc16,T
Description Test the bit specified by the four least significant bits of the T register,
T(3:0) = 0…15 of the data value in the ___location pointed to by the “loc16”
addressing mode. Upper bits of the T register are ignored:
bit = 15 − T(3:0);
TC = [loc16(bit)];
Flags and TC If the bit tested is 1, TC is set; if the bit tested is 0, TC is cleared.
Modes
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-360
TCLR loc16,#bit
Description Test the specified bit of the data value in the ___location pointed to by the “loc16”
addressing mode and then clear that same bit to 0:
TC = [loc16(bit)];
[loc16(bit)] = 0;
The value specified for the #bit immediate operand directly corresponds to
the bit number. For example, if #bit = 0, you will access bit 0 (least significant
bit) of the addressed ___location; if #bit = 15, you will access bit 15 (most
significant bit).
TCLR performs a read-modify-write operation.
Flags and N If (loc16 = @AX) and bit 15 (MSB) of @AX is 1, then N flag is set..
Modes
Z If (loc16 = @AX) and @AX gets zeroed out, then Z flag is set.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-361
TEST ACC
Description Compare the ACC register to zero and set the status flag bits accordingly:
Modify flags on (ACC − 0x00000000);
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-362
TRAP #VectorNumber
Description The TRAP instruction transfers program control to the interrupt service
routine that corresponds to the vector specified in the instruction. It does
not affect the interrupt flag register (IFR) or the interrupt enable register
(IER), regardless of whether the chosen interrupt has corresponding bits
in these registers. The TRAP instruction is not affected by the interrupt
global mask bit (INTM) in status register ST1. It also is not affected by the
enable bits in the IER or the debug interrupt enable register (DBGIER).
Once the TRAP instruction reaches the decode phase of the pipeline,
hardware interrupts cannot be serviced until the TRAP instruction is done
executing (until the interrupt service routine begins).
The following table indicates which interrupt vector is associated with a
chosen value for the VectorNumber operand:
Vector Interrupt Vector Interrupt
Number Vector Number Vector
0 RESET 16 RTOSINT
1 INT1 17 Reserved
2 INT2 18 NMI
3 INT3 19 ILLEGAL
4 INT4 20 USER1
5 INT5 21 USER2
6 INT6 22 USER3
7 INT7 23 USER4
8 INT8 24 USER5
9 INT9 25 USER6
10 INT10 26 USER7
11 INT11 27 USER8
12 INT12 28 USER9
13 INT13 29 USER10
14 INT14 30 USER11
15 DLOGINT 31 USER12
6-363
TRAP #VectorNumber
Part of the operation involves saving pairs of 16-bit core registers onto the
stack pointed to by the SP register. Each pair of registers is saved in a
single 32-bit operation. The register forming the low word of the pair is
saved first (to an even address); the register forming the high word of the
pair is saved next (to the following odd address). For example, the first
value saved is the concatenation of the T register and the status register
ST0 (T:ST0). ST0 is saved first, then T.
This instruction should not be used with vectors 1−12 when the peripheral
interrupt expansion (PIE) is enabled.
Note: The TRAP #0 instruction does not initiate a full reset. It only forces
execution of the interrupt service routine that corresponds to the RESET
interrupt vector.
Flush the pipeline;
temp = PC + 1;
Fetch specified vector;
SP = SP + 1;
[SP] = T:ST0;
SP = SP + 2;
[SP] = AH:AL;
SP = SP + 2;
[SP] = PH:PL;
SP = SP + 2;
[SP] = AR1:AR0;
SP = SP + 2;
[SP] = DP:ST1;
SP = SP + 2;
[SP] = DBGSTAT:IER;
SP = SP + 2;
[SP] = temp;
SP = SP = 2;
INTM = 0; // disable INT1−INT14, DLOGINT, RTOSINT
DBGM = 1; // disable debug events
EALLOW = 0; // disable access to emulation registers
LOOP = 0; // clear loop flag
IDLESTAT = 0; // clear idle flag
PC = fetched vector;
Flags and DBGM Debug events are disabled by setting the DBGM bit.
Modes
INTM Setting the INTM bit disables maskable interrupts.
EALLOW EALLOW is cleared to disable access to protected registers.
LOOP The loop flag is cleared.
IDLESTAT The idle flag is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-364
TSET loc16,#16bit
Description Test the specified bit of the data value in the ___location pointed to by the “loc16”
addressing mode and then set the same bit to 1:
TC = [loc16(bit)];
[loc16(bit)] = 1;
The value specified for the #bit immediate operand directly corresponds to
the bit number. For example, if #bit = 0, you will access bit 0 (least significant
bit) of the addressed ___location; if #bit = 15, you will access bit 15 (most
significant bit).
TSET performs a read-modify-write operation.
Flags and N If (loc16 = = @AX) and bit 15 (MSB) of @AX is 1, then N flag is set..
Modes
Z If (loc16 = = @AX) and @AX gets zeroed out, then Z flag is set.
TC If the bit tested is 1, TC is set; if the bit tested is 0, TC is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-365
UOUT *(PA),loc16
Description Store the 16-bit value from the ___location pointed to by the “loc16” addressing
mode into the I/O space ___location pointed to by ”*(PA):
IOspace[0x000:PA] = loc16;
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. When repeated, the ”*(PA)” I/O space address
is post-incremented by 1 during each repetition.
6-366
UOUT *(PA),loc16
6-367
XB *AL
Operands *AL Indirect program-memory addressing using register AL, can only access
high 64K of program space range (0x3F0000 to 0x3FFFFF)
Description Unconditional indirect branch by loading the low 16 bits of PC with the
contents of register AL and forcing the upper 6 bits of the PC to 0x3F:
PC = 0x3F:AL;
Note: This branch instruction can only branch to a ___location located in the upper 64K
range of program space (0x3F0000 to 0x3FFFFF).
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Switch0: ; Subroutine 0:
.
.
XB SwitchReturn,UNC ; Return: branch
Switch1: ; Subroutine 1:
.
.
XB SwitchReturn,UNC ; Return: branch
6-368
XB pma,*,ARPn
Description Unconditional branch with ARP modification by loading the low 16 bits of PC
with the 16-bit immediate value ”pma” and forcing the upper 6 bits of the PC
to 0x3F. Also, change the auxiliary register pointer as specified by the
“ARPn” operand:
PC = 0x3F:pma;
ARP = n;
Note: This branch instruction can only branch to a ___location located in the upper 64K
range of program space (0x3F0000 to 0x3FFFFF).
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Branch to SubA and set ARP. Load ACC with pointer pointed to
; by ARP and return to. This example only works for code
; located in upper 64K of program space:
XB SubA,*,ARP1 ; Branch to SubA with ARP pointing
; to XAR1
SubReturn:
.
SubA: ; Subroutine A:
MOVL ACC,* ; Load ACC with contents
; pointed to by XAR(ARP)
XB SubReturn,UNC ; Return unconditionally
6-369
XB pma,COND
Operands pma 16-bit immediate program-memory address, can only access high 64K of
program space range (0x3F0000 to 0x3FFFFF)
COND Conditional codes:
COND Syntax Description Flags Tested
0000 NEQ Not Equal To Z = 0
0001 EQ Equal To Z = 1
0010 GT Greater Then Z = 0 AND N = 0
0011 GEQ Greater Then Or Equal To N = 0
0100 LT Less Then N = 1
0101 LEQ Less Then Or Equal To Z = 1 OR N = 1
0110 HI Higher C = 1 AND Z = 0
0111 HIS, C Higher Or Same, Carry C = 1
Set
1000 LO, NC Lower, Carry Clear C = 0
1001 LOS Lower Or Same C = 0 OR Z = 1
1010 NOV No Overflow V = 0
1011 OV Overflow V = 1
1100 NTC Test Bit Not Set TC = 0
1101 TC Test Bit Set TC = 1
1110 NBIO BIO Input Equal To Zero BIO = 0
1111 UNC Unconditional −
Description Conditional branch. If the specified condition is true, then branch by loading
the low 16 bits of PC with the 16-bit immediate value ”pma” and forcing the
upper 6 bits of the PC to 0x3F.; otherwise continue execution without
branching:
If (COND = true) PC(15:0) = pma;
If (COND = false) PC(15:0) = PC(15:0) + 2;
PC(21:16) = 0x3F;
Note: If (COND = true) then the instruction takes 7 cycles.
If (COND = false) then the instruction takes 4 cycles.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-370
XB pma,COND
Switch0: ; Subroutine 0:
.
.
XB SwitchRe- ; Return: branch
turn,UNC
Switch1: ; Subroutine 1:
.
.
XB SwitchRe- ; Return: branch
turn,UNC
6-371
XBANZ pma,*ind{,ARPn}
Description If the lower 16 bits of the auxiliary register pointed to by the current auxiliary
register pointer (ARP) is not equal to 0, then a branch is taken by loading the
lower 16 bits of the PC with the 16-bit immediate “pma” value and forcing the
upper 6 bits of the PC to 0x3F. Then, the current auxiliary register, pointed
to by the ARP, is modified as specified by the indirect mode. Then,, if
indicated, the ARP pointer value is changed to point a new auxiliary register:
if( AR[ARP] != 0 )
PC = 0x3F:pma
if(*++ indirect mode) XAR[ARP] = XAR[ARP] + 1;
if(*−− indirect mode) XAR[ARP] = XAR[ARP] – 1;
if(*0++ indirect mode) XAR[ARP] = XAR[ARP] + AR0;
if(*0−− indirect mode) XAR[ARP] = XAR[ARP] − AR0;
if(ARPn specified) ARPn = n;
Note: This instruction can only transfer program control to a ___location located in the
upper 64K range of program space (0x3F0000 to 0x3FFFFF). The cycle
times for this operation are:
If branch is taken, then the instruction takes 4 cycles
If branch is not taken, then the instruction takes 2 cycles
6-372
XBANZ pma,*ind{,ARPn}
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-373
XCALL *AL
Description Indirect call with destination address in AL. The lower 16 bits of the current
PC address are saved onto the software stack. Then, the low 16 bits of PC
is loaded with the contents of register AL and the upper 6 bits of the PC are
loaded with 0x3F:
temp(21:0) = PC + 1;
[SP] = temp(15:0);
SP = SP + 1;
C = 0x3F:AL;
Note: This instruction can only transfer program control to a ___location located in the
upper 64K range of program space (0x3F0000 to 0x3FFFFF). To return from
a call made by XCALL, the XRETC instruction must be used.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
FuncB: ; Function B:
.
.
XRETC UNC ; Return unconditionally
6-374
XCALL pma,*,ARPn
Description Unconditional call with ARP modification. The lower 16 bits of the return
address are pushed onto the software stack. Then, the lower 16 bits of the
PC are loaded with the 16-bit immediate ”pma” value and the upper 6 bits
of the PC are forced to 0x3F. Then, the 3-bit ARP pointer will be set to the
”ARPn” field value:
temp(21:0) = PC + 1;
[SP] = temp(15:0);
SP = SP + 1;
PC = 0x3F:pma;
ARP = n;
Note: This instruction can only transfer program control to a ___location located in the
upper 64K range of program space (0x3F0000 to 0x3FFFFF). To return from
a call made by XCALL, the XRETC instruction must be used.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Call FuncA and set ARP. Load ACC with pointer pointed to by ARP.
; This example only works for code located in upper 64K of program
; space:
XCALL FuncA,*,ARP1 ; Call FuncA with ARP pointing to XAR1
.
FuncA: ; Function A:
MOVL ACC,* ; Load ACC with contents pointed to
; by XAR(ARP)
XRETC UNC ; Return unconditionally
6-375
XCALL pma,COND
Description Conditional call. If the specified condition is true, then the low 16 bits of the
return address is pushed onto the software stack and the low 16 bits of the
PC are loaded with the 16-bit immediate ”pma” value and the upper 6 bits
of the PC are forced to 0x3F; otherwise continue execution with instruction
following the XCALL operation:
if(COND = true)
{
temp(21:0) = PC + 2;
[SP] = temp(15:0);
SP = SP + 1;
PC = 0x3F:pma;
}
else
PC = PC + 2;
Note: This instruction can only transfer program control to a ___location located in the
upper 64K range of program space (0x3F0000 to 0x3FFFFF). To return from
a call made by XCALL, the XRETC instruction must be used. The cycle times
for this operation are:
If (COND = true) then the instruction takes 7 cycles.
If (COND = false) then the instruction takes 4 cycles.
6-376
XCALL pma,COND
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Call FuncA if VarA does not equal zero. This example only
; works for code located in upper 64K of program space:
MOV AL,@VarA ; Load AL with VarA
XCALL FuncA,NEQ ; Call FuncA if not equal to zero
.
.
FuncA: ; Function A:
.
.
XRETC UNC ; Return unconditionally
6-377
XMAC P,loc16,*(pma)
Description Add the previous product (stored in the P register), shifted as specified by
the product shift mode (PM), to the ACC register. Next, load the T register
with the content of the ___location pointed to by the “loc16” addressing mode.
Last, multiply the signed 16-bit content of the T register by the signed 16-bit
content of the addressed program memory ___location and store the 32-bit
result in the P register:
ACC = ACC + P << PM;
T = [loc16];
P = signed T * signed Prog[0x3F:pma];
The C28x forces the upper 6 bits of the program memory address, specified
by the ”*(pma)” addressing mode, to 0x3F when using this form of the MAC
instruction. This limits the program memory address to the high 64K of
program address space (0x3F0000 to 0x3FFFFF). On the C28x devices,
memory blocks are mapped to both program and data space (unified
memory), hence the ”*(pma)” addressing mode can be used to access data
space variables that fall within its address range.
Flags and Z After the addition, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
OVC If overflow mode is disabled; and if the operation generates a positive
overflow, then the counter is incremented. If overflow mode is disabled; and
if the operation generates a negative overflow, then the counter is
decremented.
OVM If overflow mode bit is set; then the ACC value will saturate maximum
positive (0x7FFFFFFF) or maximum negative (0x80000000) if the operation
overflowed.
6-378
XMAC P,loc16,*(pma)
PM The value in the PM bits sets the shift mode for the output operation from the
product register. If the product shift value is positive (logical left shift
operation), then the low bits are zero filled. If the product shift value is
negative (arithmetic right shift operation), the upper bits are sign extended.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. The state of the Z, N, C and OVC flags will
reflect the final result. The V flag will be set if an intermediate overflow
occurs. When repeated, the program-memory address is incremented by 1
during each repetition.
6-379
XMACD P,loc16,*(pma)
XMACD P,loc16,*(pma) C2xLP Source-Compatible Multiply and Accumulate With Data Move
*(pma) Immediate program memory address, access high 64K range of program
space only (0x3F0000 to 0x3FFFFF)
Description The XMACD instruction functions in the same manner as the XMAC, with the
addition of a data move. Add the previous product (stored in the P register),
shifted as specified by the product shift mode (PM), to the ACC register. Next,
load the T register with the content of the ___location pointed to by the “loc16”
addressing mode. Then, multiply the signed 16-bit content of the T register
by the signed 16-bit content of the addressed program memory ___location and
store the 32-bit result in the P register. Last, store the content in the T register
onto the next highest memory address pointed to by ”loc16” addressing
mode:
ACC = ACC + P << PM;
T = [loc16];
P = signed T * signed Prog[0x3F:pma];
[loc16 + 1] = T;
The C28x forces the upper 6 bits of the program memory address, specified
by the ”*(pma)” addressing mode, to 0x3F when using this form of the MAC
instruction. This limits the program memory address to the high 64K of
program address space (0x3F0000 to 0x3FFFFF). On the C28x devices,
memory blocks are mapped to both program and data space (unified
memory), therefore, the “(pma)” addressing mode can be used to access
data-space variables that fall within its address range.
Flags and Z After the addition, the Z flag is set if the ACC value is zero, else Z is cleared.
Modes
N After the addition, the N flag is set if bit 31 of the ACC is 1, else N is cleared.
C If the addition generates a carry, C is set; otherwise C is cleared.
V If an overflow occurs, V is set; otherwise V is not affected.
6-380
XMACD P,loc16,*(pma)
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. The state of the Z, N, C and OVC flags will
reflect the final result. The V flag will be set if an intermediate overflow occurs.
When repeated, the program-memory address is incremented by 1 during
each repetition.
6-381
XOR ACC,loc16
Description Perform a bitwise XOR operation on the ACC register with the
zero-extended content of the ___location pointed to by the “loc16” address
mode. The result is stored in the ACC register:
ACC = ACC XOR 0:[loc16];
Flags and N The load to ACC is tested for a negative condition. If bit 31 of ACC is 1, then
Modes the negative flag bit is set; otherwise it is cleared.
Z The load to ACC is tested for a zero condition. The zero flag bit is set if the
operation generates ACC = 0; otherwise it is cleared
Repeat This operation is repeatable. If the operation follows a RPT instruction, then
the XOR instruction will be executed N+1 times. The state of the Z and N
flags will reflect the final result.
6-382
XOR ACC,#16bit << #0..16
Description Perform a bitwise XOR operation on the ACC register with the given 16-bit
unsigned constant value left shifted as specified. The value is zero extended
and lower order bits are zero filled before the XOR operation. The result is
stored in the ACC register:
ACC = ACC XOR (0:16bit << shift value);
Flags and N The load to ACC is tested for a negative condition. If bit 31 of ACC is 1, then
Modes the negative flag bit is set; otherwise it is cleared.
B The load to ACC is tested for a zero condition. The zero flag bit is set if the
operation generates ACC = 0; otherwise it is cleared
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-383
XOR AX,loc16
Flags and N The load to AX is tested for a negative condition. If bit 15 of AX is 1, then
Modes the negative flag bit is set; otherwise it is cleared.
Z The load to AX is tested for a zero condition. The zero flag bit is set if the
operation generates AX = 0, otherwise it is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; XOR the contents of VarA and VarB and store in VarC:
MOV AL,@VarA ; Load AL with contents of VarA
XOR AL,@VarB ; XOR AL with contents of VarB
MOV @VarC,AL ; Store result in VarC
6-384
XOR loc16, AX
Flags and N The load to [loc16] is tested for a negative condition. If bit 15 of [loc16] is 1,
Modes then the negative flag bit is set; otherwise it is cleared.
Z The load to [loc16] is tested for a zero condition. The zero flag bit is set if the
operation generates [loc16] = 0, otherwise it is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; XOR the contents of VarA with VarB and store in VarB:
MOV AL,@VarA ; Load AL with contents of VarA
XOR @VarB,AL ; VarB = VarB XOR AL
6-385
XOR loc16,#16bit
Description Perform a bitwise XOR operation on the content of the ___location pointed to
by the “loc16” addressing mode and the 16-bit immediate constant value.
The result is stored in the ___location pointed to by “loc16”:
[loc16] = [loc16] XOR 16bit;
Smart Encoding:
If loc16 = AH or AL and #16bit is an 8-bit number, then the assembler will
encode this instruction as XO”RB AX,#8bt. To override this encoding, use
the XORW AX,#16bit instruction alias.
Flags and N After the operation if bit 15 of [loc16] 1, set N; otherwise, clear N.
Modes
Z After the operation if [loc16] is zero, set Z; otherwise, clear Z.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-386
XORB AX, #8bit
Flags and N The load to AX is tested for a negative condition. If bit 15 of AX is 1, then
Modes the negative flag bit is set; otherwise it is cleared.
Z The load to AX is tested for a zero condition. The zero flag bit is set if the
operation generates [loc16] = 0, otherwise it is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-387
XPREAD loc16, *(pma)
Description Load the 16-bit data-memory ___location pointed to by the “loc16” addressing
mode with the 16-bit content of the program-memory ___location pointed to by
”*(pma)” addressing mode:
[loc16] = Prog[0x3F:pma];
The C28x forces the upper 6 bits of the program memory address, specified
by the ”*(pma)” addressing mode, to 0x3F when using this form of the
XPREAD instruction. This limits the program memory address to the high
64K of program address space (0x3F0000 to 0x3FFFFF). On the C28x
devices, memory blocks are mapped to both program and data space
(unified memory), hence the ”*(pma)” addressing mode can be used to
access data space variables that fall within its address range.
Flags and N If (loc16 = @AX) and bit 15 of AX is 1, then N is set; otherwise N is cleared.
Modes
Z If (loc16 = @AX) and the value of AX is zero, then Z is set; otherwise Z is
cleared.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. When repeated, the ”*(pma)”
program-memory address is copied to an internal shadow register and the
address is post-incremented by 1 during each repetition.
6-388
XPREAD loc16, *AL
Description Load the 16-bit data-memory ___location pointed to by the “loc16” addressing
mode with the 16-bit content of the program-memory ___location pointed to by
”*AL” addressing mode:
[loc16] = Prog[0x3F:AL];
The C28x forces the upper 6 bits of the program memory address, specified
by the ”*AL” addressing mode, to 0x3F when using this form of the XPREAD
instruction. This limits the program memory address to the high 64K of
program address space (0x3F0000 to 0x3FFFFF). On the C28x devices,
memory blocks are mapped to both program and data space (unified
memory), hence the ”*AL” addressing mode can be used to access data
space variables that fall within its address range.
Flags and N If (loc16 = @AX) and bit 15 of AX is 1, then N is set; otherwise N is cleared.
Modes
Z If (loc16 = @AX) and the value of AX is zero, then Z is set; otherwise Z is
cleared.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. When repeated, the ”*AL” program-memory
address is copied to an internal shadow register and the address is
post-incremented by 1 during each repetition.
6-389
XPWRITE *A,loc16
Operands *AL Indirect program-memory addressing using register AL, can only access
high 64K of program space range (0x3F0000 to 0x3FFFFF)
loc16 Addressing mode (see Chapter 5)
The C28x forces the upper 6 bits of the program memory address, specified
by the ”*AL” addressing mode, to 0x3F when using this form of the XPWRITE
instruction. This limits the program memory address to the high 64K of
program address space (0x3F0000 to 0x3FFFFF). On the C28x devices,
memory blocks are mapped to both program and data space (unified
memory), hence the ”*AL” addressing mode can be used to access data
space variables that fall within its address range.
Repeat This instruction is repeatable. If the operation follows a RPT instruction, then
it will be executed N+1 times. When repeated, the ”*AL” program-memory
address is copied to an internal shadow register and the address is
post-incremented by 1 during each repetition.
6-390
XRET
Operands None
Note: This instruction can transfer program control only to a ___location located in the
upper 64K range of program space (0x3F0000 to 0x3FFFFF). To return from
a call made by XCALL, the XRET instruction must be used.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Return from FuncA if VarA does not equal zero, else set VarB
; to zero and return. This example only works for code located
; in upper 64K of program space:
XCALL FuncA ; Call FuncA
.
FuncA: ; Function A:
.
.
.
.
MOV AL,@VarA ; Load AL with contents of VarA
XRET NEQ ; Return if VarA does not equal 0
MOV @VarA,#0 ; Store 0 into VarB
XRETC UNC ; Return unconditionally
6-391
XRETC COND
6-392
XRETC COND
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example ; Return from FuncA if VarA does not equal zero, else set VarB
; to zero and return. This example only works for code located
; in upper 64K of program space:
XCALL FuncA ; Call FuncA
.
FuncA: ; Function A:
.
.
.
.
MOV AL,@VarA ; Load AL with contents of VarA
XRETC NEQ ; Return if VarA does not equal 0
MOV @VarA,#0 ; Store 0 into VarB
XRETC UNC ; Return unconditionally
6-393
ZALR ACC,loc16
Description Load low accumulator (AL) with the value 0x8000 and load high accumulator
(AH) with the 16-bit contents pointed to by the ”loc16” addressing mode.
AH = [loc16];
AL = 0x8000;
Flags and N The load to ACC is tested for a negative condition. If bit 31 of ACC is 1, then
Modes the negative flag bit is set; otherwise it is cleared.
Z The load to ACC is tested for a zero condition. The zero flag bit is set if the
operation generates ACC = 0; otherwise it is cleared
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-394
ZAP OVC
Description Clear the overflow counter (OVC) bits in Status Register 0 (ST0).
Flags and OVC The 6-bit overflow counter bits (OVC) are cleared.
Modes
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-395
ZAPA
Operands None
Description Zero the ACC and P registers as well as the overflow counter (OVC):
ACC = 0;
P = 0;
OVC = 0;
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
6-396
Chapter 7
Emulation Features
The CPU in the C28x contains hardware extensions for advanced emulation
features that can assist you in the development of your application system
(software and hardware). This chapter describes the emulation features that
are available on all C28x devices using only the JTAG port (with TI exten-
sions).
Topic Page
- Rapid transfer of memory contents between the device and a host (data
logging)
7-2
Debug Interface
As shown in the figure, the header requires more than the five JTAG signals
and the TI extensions. It also requires a test clock return signal (TCK_RET),
the target supply (VCC ) and ground (GND). TCK_RET is a test clock out of the
scan controller and into the target system. The target system uses TCK_RET
if it does not supply its own test clock (in which case TCK would simply not be
used). In many target systems, TCK_RET is simply connected to TCK and
used as the test clock.
Emulator Target
Signal Description State† State†
EMU0 Emulation pin 0 I I/O
GND Ground
The state of the TRST, EMU0, and EMU1 signals at device power up deter-
mine the operating mode of the device. The operating mode takes effect as
soon as the device has sufficient power to operate. Should the TRST signal
rise, the EMU0 and EMU1 signals are sampled on its rising edge and the\at
operating mode is latched. Some of these modes are reserved for test pur-
poses, but those that can be of use in a target system are detailed in Table 7−2.
A target system is not required to support any mode other than normal mode.
7-4
Debug Interface
Table 7−2. Selecting Device Operating Modes By Using TRST, EMU0, and EMU1
JTAG Cable
TRST EMU1 EMU0 Device Operating Mode Active?
Low Low Low Slave mode. Disables the CPU and No
memory portions of the C28x.
Another processor treats the C28x
as a peripheral.
High Low or High Low or High Normal mode with emulation en- Yes
abled. This is the setting to use on
target systems when a scan control-
ler is attached (the scan controller
will control TRST). TRST should not
be high during device power-up.
- Background code. The body of code that can be halted during debug-
ging because it is not time-critical.
- Debug-halt state. The state in which the device does not execute back-
ground code.
- Break event. A debug event that causes the device to enter the debug-
halt state.
7-6
Execution Control Modes
The CPU can service all interrupts in this state. When an interrupt occurs
simultaneously with a debug event, the debug event has priority; however,
if interrupt processing began before the debug event occurred, the debug
event cannot be processed until the interrupt service routine begins.
Figure 7−2 illustrates the relationship among the three states. Notice that the
C28x cannot pass directly between the single-instruction and run states. No-
tice also that the CPU can be observed only in the debug-halt state. In practical
terms, this means the contents of CPU registers and memory are not updated
in the debugger display in the single-instruction state or the run state. Mask-
able interrupts occurring in any state are latched in the interrupt flag register
(IFR).
Debugger command
Debugger command,
After executing Debugger command breakpoint, or analysis stop
one instruction
Debug-halt state
Can observe CPU
Cannot service interrupts
† If you use a RUN 1 command to execute a single instruction, an interrupt can be serviced in the single-instruction state. If you use
a STEP 1 command for the same purpose, an interrupt cannot be serviced.
7-8
Execution Control Modes
- Debug-halt state. This state is entered through a break event such as the
decoding of a software breakpoint instruction or the occurrence of an anal-
ysis breakpoint/watchpoint. This state can also be enter by a request from
the host processor. You can place the device into one of the other two
states by giving the appropriate command to the debugger.
In this state, only time-critical interrupts can be serviced. No other code can
be executed. Maskable interrupts are considered time-critical if they are en-
abled in the debug interrupt enable register (DBGIER). If they are also en-
abled in the interrupt enable register (IER), they are serviced. The interrupt
global mask bit (INTM) is ignored. NMI and RS are also considered time-criti-
cal, and are always serviced once requested. It is possible for multiple inter-
rupts to occur and be serviced while the device is in the debug-halt state.
Suspending execution adds only one cycle to interrupt latency. When the
C28x returns from a time-critical ISR, it reenters the debug-halt state.
If a CPU reset occurs (initiated by RS), the device runs the corresponding
interrupt service routine until that routine clears the debug enable mask bit
(DBGM) in status register ST1. When a reset occurs, DBGM is set, disab-
ling debug events. To reenable debug events, the interrupt service routine
must clear DBGM. Only then will the outstanding emulation-suspend con-
dition be recognized.
Note:
Should a time-critical interrupt occur in real-time mode at the precise mo-
ment that the debugger receives a RUN command, the time-critical interrupt
will be taken and serviced in its entirety before the CPU changes states.
- Single-instruction state. This state is entered when you you tell the de-
bugger to execute a single instruction by using a RUN 1 command or a
STEP 1 command. The CPU executes the single instruction pointed to by
the PC and then returns to the debug-halt state (it executes from one inter-
rupt boundary to the next).
If an interrupt occurs in this state, the command used to enter this state deter-
mines whether that interrupt can be serviced. If a RUN 1 command was
used, the CPU can service the interrupt. If a STEP 1 command was used, the
CPU cannot, even if the interrupt is NMI or RS. In real-time mode, if the
DBGM bit is 1 (debug events are disabled), a RUN 1 or STEP 1 command
forces continuous execution of instructions until DBGM is cleared.
Note: If you single-step an instruction in real−time emulation mode and that
instruction sets DBGM, the CPU continues to execute instructions until DBGM
is cleared. If you want to single-step through a non-time-critical interrupt ser-
vice routine (ISR), you must initiate a CLRC DBGM instruction at the beginning
of the ISR. Once you clear DBGM, you can single-step or place breakpoints.
- Run state. This state is entered when you use a run command from the
debugger interface. The CPU executes instructions until a debugger com-
mand or a debug event returns the CPU to the debug-halt state.
The CPU can service all interrupts in this state. When an interrupt occurs
simultaneously with a debug event, the debug event has priority; however,
if interrupt processing began before the debug event occurred, the debug
event cannot be processed until the interrupt service routine begins.
Figure 7−3 illustrates the relationship among the three states. Notice that the
C28x cannot pass directly between the single-instruction and run states. No-
tice also that the CPU can be observed in the debug-halt state and in the run
state. In the single-instruction state, the contents of CPU registers and
memory are not updated in the debugger display. In the debug-halt and run
states, register and memory values are updated unless DBGM = 1. Maskable
interrupts occurring in any state are latched in the interrupt flag register (IFR).
Debugger command
Debugger command,
After executing Debugger command breakpoint, or analysis stop
one instruction
Debug-halt state
Can observe CPU
Can service time-critical interrupts
(including NMI and RS)
† If you use a RUN 1 command to execute a single instruction, an interrupt can be serviced in the single-instruction state. If you use
a STEP 1 command for the same purpose, an interrupt cannot be serviced.
7-10
Execution Control Modes
Do not use breakpoints within time-critical interrupt service routines. They will
cause the device to enter the debug-halt state, just as if the breakpoint were
located in normal code. Once in the debug-halt state, the CPU services re-
quests for RS, NMI, and those interrupts enabled in the DBGIER and the IER.
After approving a maskable interrupt, the CPU disables the interrupt in the
IER. This prevents subsequent occurrences of the interrupt from being ser-
viced until the IER is restored by a return from interrupt (IRET) instruction or
until the interrupt is deliberately re-enabled in the interrupt service routine
(ISR). Do not reenable that interrupt’s IER bit while using breakpoints within
the ISR. If you do so and the interrupt is triggered again, the CPU performs
a new context save and restarts the interrupt service routine.
Debugger command
Debugger command,
After executing Debugger command breakpoint, or analysis stop
one instruction
Debug-halt state
Can observe CPU
Cannot service interrupts
Debugger command
Real-time mode
Debug-halt state
Can observe CPU
Can service time-critical interrupts
(including NMI and RS)
After executing
one instruction
Single-instruction state Run state
Cannot observe CPU Can observe CPU
Can service an interrupt Can service interrupts
if RUN 1 used†
† If you use a RUN 1 debugger command to execute a single instruction, an interrupt can be serviced in the single-instruction state.
If you use a STEP 1 debugger command for the same purpose, an interrupt cannot be serviced.
7-12
Execution Control Modes
Note:
Unless you are using a real-time operating system, do not enable the real-
time operating system interrupt (RTOSINT). RTOSINT is completely dis-
abled when bit 15 in the IER is 0 and bit 15 in the DBGIER is 0.
7-14
Aborting Interrupts With the ABORTI Instruction
In some target applications, you might have interrupts that must not be re-
turned from by the IRET instruction. Not using IRET can cause a problem for
the emulation logic, because the emulation logic assumes the original debug
context will be restored. The abort interrupt (ABORTI) instruction is provided
as a means to indicate that the debug context will not be restored and the de-
bug logic needs to be reset to its default state. As part of its operation, the
ABORTI instruction:
The ABORTI instruction does not modify the DBGIER, the IER, the INTM bit,
or any analysis registers (for example, registers used for breakpoints, watch-
points, and data logging).
Figure 7−5 summarizes the process for handling a request from the DT-DMA
mechanism.
7-16
DT-DMA Mechanism
DT-DMA mechanism
requests access
Request Rude
polite or rude?
Polite
No
DBGM = 0?
Mode Preemptive
nonpreemptive or
preemptive?
Force a hole
Nonpreemptive
Access performed
- In stop mode, DBGM is ignored, and the DT-DMA mode is set to preemp-
tive. This ensures that you can gain visibility to and control of your system
if an otherwise unrecoverable error occurs (for example, if ST1 is changed
to an undesired value due to stack corruption).
- A DT-DMA request awakens the device from the idle state (initiated by the
IDLE instruction). However, unlike returning from an interrupt, the CPU re-
turns to the idle state upon completion of the DT-DMA.
Note:
The information shown on the debugger screen is gathered at different times
from the target; therefore, it does not represent a snapshot of the target
state, but rather a composite. It also takes the host time to process and dis-
play the data. The data does not correspond to the current target state, but
rather, the target state as of a few milliseconds ago.
7-18
Analysis Breakpoints, Watchpoints, and Counter(s)
Consider the following example. If a hardware breakpoint is set at T0, the CPU
stops after returning from the T1 subroutine, with the instruction counter (IC)
pointing to T0.
NOP
CALL T1
T0: MOVB AL, #0x00
SB TIMINGS, UNC
T1: NOP
RET
T2: NOP
7.7.2 Watchpoints
A hardware watchpoint triggers a debug event when either an address or an
address and data match a compare value. The address portion is compared
against a reference address and bit mask, and the data portion is compared
against a reference data value and a bit mask.
When comparing two addresses, you can set two watchpoints. When comparing
an address and a data value, you can set only one watchpoint. When performing
a read watchpoint, the address is available a few cycles earlier than the data; the
watchpoint logic accounts for this.
The point where execution stops depends on whether the watchpoint was a
read or write watchpoint, and whether it was an address or an address/data
read watchpoint. In the following example, a read address watchpoint occurs
when the address X is accessed, and the CPU stops with the instruction count-
er (IC) pointing three instructions after that point:
MOV AR4,#X
MOV AL,*+AR4[0] ; Data read
nop
nop
nop ; The IC will point here
For a read watchpoint that requires both an address and data match, the CPU
stops with the IC pointing six instructions after that point:
MOV AR4,#X
MOV AL,*+AR4[0] ; Data read
nop
nop
nop
nop
nop
nop ; The IC will point here
In the following example, a write address watchpoint occurs when the address
Y is accessed, and the CPU stops with the IC pointing six instructions after that
point:
MOV AR4,#Y
MOV *+AR4[0],AL ; Data write
nop
nop
nop
nop
nop
nop ; The IC will point here
7-20
Analysis Breakpoints, Watchpoints, and Counter(s)
code 2 pipeline phase. The counter counts wait states caused by instructions
that are fetched but not executed. In most cases, these effects cancel each
other out. Benchmarking is best used for larger portions of code. Do not rely
heavily on the precision of the benchmarking. (For more information about the
pipeline, see Chapter 4.)
Alternatively, you can configure the 40-bit performance counter as two 16-bit
or one 32-bit event counter if you want to generate a debug event when the
counter equals a match value. The comparison between the counter value and
the match value is done before the count value is incremented. For example,
suppose you initialize a counter to 0. A match value of 0 causes an immediate
debug event (when the action to be counted occurs), and the counter holds
1 afterward.
You can also clear the counter when a hardware breakpoint or address watch-
point occurs. With this feature, you can implement a mechanism similar to a
watchdog timer: if a certain address is not seen on the address bus within a
certain number of CPU clock cycles, a debug event occurs.
The benchmark counter is only available with analysis unit 1. This counter
can be used as a benchmark counter to count cycles or instructions. It can
also be used to count AU2 events.
7-22
Data Logging
To perform data logging, you must create a linear buffer of 32-bit words to hold
a packet of information. Your application code controls the size, format, and
___location of this buffer and also determines when to send a buffer’s contents
to the host. You can control the size of a data logging buffer in two ways:
- Specify a count value in the upper eight bits of ADDRH (when the number
of 32-bit words you want to log is between 1 and 256)
Note:
When the debugger is not active, the data logging transfers are considered
complete as soon as they are enabled to prevent the application software
from getting stuck when there is nothing to receive the data.
2) Specify the start address of the buffer in ADDRL and the six LSBs of
ADDRH (see Figure 7−6 and Figure 7−7). The address in ADDRL and
ADDRH is called the transfer address.
3) Use either of the following methods to specify when data logging is to end:
a) If the number of words you want to log is between 1 and 256, specify
a count value in the upper eight bits of ADDRH (see Figure 7−7). The
form of the count value is 256−n, where n is the number of 32-bit words
you want to log. As each word is transferred, both the transfer address
and the count value are decremented.
b) If the number of words you want to log is greater than 256, specify a
data logging end address in REFL and the six LSBs of REFH (see
Figure 7−8 and Figure 7−9). Load the ten MSBs of REFH with 0s.
When using this method, be sure to set the data logging end address
control register (EVT_CNTRL) first, and then the DMA control register
Note:
The application must not read from the end address of the buffer during the
data logging operation. When the end address appears on the address bus,
the C28x ends the transfer.
See Table 7−4 and Table 7−5 on the following pages for descriptions of the
registers associated with data logging.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
16 LSBs of transfer address
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Word counter Reserved 6 MSBs of transfer address
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
16 LSBs of end address
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 6 MSBs of end address
7-24
Data Logging
00 084A16 REFL R/W Data logging end reference address (lower 16 bits)
15:0 Lower 16 bits of start address
00 084B16 REFH R/W Data logging end reference address (upper 6 bits)
15:6 Set to 0
5:0 Upper 6 bits of start address
2) Write to the appropriate control register to claim the resource you want to
use. The resource for data logging transfers uses DMA_CNTRL (see
Table 7−4 on page 7-25). The resource for detecting the data logging end
address uses EVT_CNTRL (see Table 7−5).
7-26
Data Logging
3) Wait at least three cycles so that the write to the control register (done in
the write phase of the pipeline) occurs before the read from the ID register
in step 4. You can fill in the extra cycles with NOP (no operation) instruc-
tions or with other instructions that do not involve accessing the emulation
registers.
4) Read the appropriate ID register and verify that the application is the own-
er. The resource for data logging transfers uses DMA_ID (see Table 7−4
on page 7-25). The resource for detecting the data logging end address
uses EVT_ID (see Table 7−5 on page 7-26). If the application is not the
owner, then go back to step 2 until this succeeds (you may want a time-out
function to prevent an endless loop). This step is optional. The application
would fail to become the owner only if the debugger already owns the re-
source.
5) If the application is the owner, the remaining registers for that function can
be programmed, and the control register written to again, to enable the
function. However, if the application is not the owner, then all of its writes
are ignored.
If an interrupt occurs between the EALLOW instruction in step 1 and the EDIS
instruction in step 6, access to emulation registers are automatically disabled
by the CPU before the interrupt service routine begins and automatically reen-
abled when the CPU returns from the interrupt. This means that there is no
need to disable interrupts between the EALLOW instruction and the EDIS in-
struction.
The debugger can, at your request, seize ownership of a register from the ap-
plication; however, that is not the normal mode of operation.
This interrupt capability is most useful when there are multiple buffers of data
to be transferred through data logging and the completion of one transfer
should begin the next.
Example 7−1. Initialization Code for Data Logging With Word Counter
; Base addresses
ADMA .set 0838h
; Offsets
DMA_ADDRL .set 0
DMA_ADDRH .set 1
DMA_CNTRL .set 6
DMA_ID .set 7
EALLOW
MOV AR4, #ADMA ; AR4 pointing to register base addr
MOV *+AR4[#DMA_CNTRL],#1 ; Attempt to claim resource
NOP
NOP
NOP
CMP *+AR4[#DMA_ID],#7001h ; Value expected in ID register
B FAIL, NEQ ; If we don’t see the correct ID, then we
; failed (the resource is already in use)
MOV *+AR4[DMA_CNTRL],#3E62h
EDIS
Example 7−2 shows how to log from address 00 010016 to address 00 02FF16
in data memory. The accesses are nonpreemptive (they have lower priority
than the CPU), and are polite (they are not performed when the DBGM bit is
0). The data logging cannot occur when a time-critical interrupt is being ser-
viced. An end address of 00 02FF16 is used to end the transfer. The applica-
tion must not read from 00 02FF16 during the data logging; a read from that
address stops the data logging. As in Example 7−1, the application can poll
the LSB of DMA_CNTRL for a 1 to determine whether the data logging opera-
tion is complete.
7-28
Data Logging
Example 7−2. Initialization Code for Data Logging With End Address
; Base addresses
ADMA .set 0838h
DEVT .set 0848h
; Offsets
DMA_ADDRL .set 0
DMA_ADDRH .set 1
DMA_CNTRL .set 6
DMA_ID .set 7
MASKL .set 0
MASKH .set 1
REFL .set 2
REFH .set 3
EVT_CNTRL .set 6
EVT_ID .set 7
EALLOW
MOV AR5, #DEVT ; AR5 pointing to End Address registers
MOV AR4, #ADMA ; AR4 pointing to Start/Control base
MOV *+AR5[#EVT_CNTRL],#1 ; Attempt to claim End Address
MOV *+AR4[#DMA_CNTRL],#1 ; Attempt to claim Start/Control
NOP
NOP
NOP
CMP *+AR5[#EVT_ID],#5002h ; Value expected in ID register
B FAIL, NEQ ; If we don’t see the correct ID, FAIL
MOV *+AR4[#DMA_ADDRL],#0100h ; Set buffer start address and then the count
MOV *+AR4[DMA_ADDRH],#0
MOV *+AR4[DMA_CNTRL],#3066h
EDIS
When the application owns analysis resources, they will be cleared (made un-
owned and set to the completed state) by a reset. When the debugger owns
the resources, they are not cleared by reset but by the JTAG test-logic reset.
This ensures that when you are using the debugger, the resources can be
used even while the target system undergoes a reset.
Resource Purpose
BD No No Yes No No
† The data logging mode that uses the word counter allows this combination, but not the data logging mode that
uses the end address (see section 7.8, Data Logging).
7-30
Diagnostics and Recovery
- RS being asserted
7-32
Appendix
AppendixAA
For the status and control registers of the ’28x, this appendix summarizes:
- Their reset values
- The instructions available for accessing them
- The functions of their bits
Topic Page
A.1 Reset Values of and Instructions for Accessing the Registers . . . . A-2
A.2 Register Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
A-1
Reset Values of and Instructions for Accessing the Registers
IER Interrupt enable register 0000 0000 0000 00002 MOV, AND, OR
Note: V: Bit 3 of ST1 (the VMAP bit) depends on the level of the VMAP input signal at reset. If the VMAP signal is low, the
VMAP bit is 0 after reset; if the VMAP signal is high, the VMAP bit is 1 after reset. For C28x devices that do not pin out
VMAP, the signal is tied high internal to the device.
M: Bit 11 of ST1 (the M0M1MAP bit) depends on the level of the M0M1MAP input signal at reset. If the M0M1MAP
signal is low, the bit is 0, high bit is 1. For C28x devices that do not pinout MOM1MAP, the signal is tied high internal to
the device.
Register Figures
- Each unreserved bit field or set of bits has a callout that very briefly de-
scribes its effect on the processor.
- Each nonreserved bit field or set of bits is labeled with one of the following
symbols:
J R indicates that your software can read the bit field but cannot write to
it.
J R/W indicates that your software can read the bit field and write to it.
ÉÉÉ
Figure A−1. Status register ST0
ÉÉÉ
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
OVC/OVCU PM V N Z C TC OVM SXM
Note: For more details about ST0, see section 2.3 on page 2-16.
Register Figures
ÉÉÉÉÉ
Figure A−2. Status register ST1, Bits15−8
ÉÉÉÉÉ
15 14 13 12 11 10 9 8
ÉÉÉÉÉ
0 0 0 0 0 0 0 0
ARP XF MOM1MAP CNF OBJMODE AMODE
R/W R/W R R/W R/W R/W
XF status bit
0 XFS output signal low Address mode bit
1 XFS output signal is high 0 C28x/C27x processing mode
1 C2xLP addressing modes
ÉÉÉÉÉÉÉÉÉ
Figure A−3. Status Register ST1, Bits 7−0
ÉÉÉÉÉÉÉÉÉ
7 6 5 4 3 2 1 0
ÉÉÉÉÉÉÉÉÉ
0 0 0 0 X‡ 0 1 1
IDLESTAT EALLOW LOOP SPA VMAP PAGE0 DBGM INTM
R R/W R R/W R/W R/W R/W R/W
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Figure A−4. Interrupt flag register (IFR)
Á
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
15 14 13 12 11 10 9 8
Á
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
0 0 0 0 0 0 0 0
RTOSINT DLOGINT INT14 INT13 INT12 INT11 INT10 INT9
R/W R/W R/W R/W R/W R/W R/W R/W
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Á
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
7 6 5 4 3 2 1 0
Á
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
0
INT8
0
INT7
0
INT6
0
INT5
0
INT4
0
INT3 INT2
0 0
INT1
R/W R/W R/W R/W R/W R/W R/W R/W
Note: For more details about the IFR, see section 3.3.1 on page 3-7.
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Figure A−5. Interrupt enable register (IER)
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
15 14 13 12 11 10 9 8
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
0 0 0 0 0 0 0 0
RTOSINT DLOGINT INT14 INT13 INT12 INT11 INT10 INT9
R/W R/W R/W R/W R/W R/W R/W R/W
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
7 6 5 4 3 2 1 0
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
0
INT8
0
INT7
0
INT6
0
INT5
0
INT4
0
INT3
0
INT2
0
INT1
R/W R/W R/W R/W R/W R/W R/W R/W
Note: For more details about the IER, see section 3.3.2 on page 3-8.
Register Figures
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Figure A−6. Debug interrupt enable register (DBGIER)
Á
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
15 14 13 12 11 10 9 8
Á
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
0 0 0 0 0 0 0 0
RTOSINT DLOGINT INT14 INT13 INT12 INT11 INT10 INT9
R/W R/W R/W R/W R/W R/W R/W R/W
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Á
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
7 6 5 4 3 2 1 0
Á
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
0
INT8
0
INT7
0
INT6
0
INT5
0
INT4
0
INT3
0
INT2
0
INT1
R/W R/W R/W R/W R/W R/W R/W R/W
Note: For more details about the DBGIER, see section 3.3.2 on page 3-8.
Topic Page
B-1
Summary of Architecture Differences Between C2xLP and C28x
Data memory space 64K (16 address signals) 4G (32 address signals)
When you first recompile your C2xLP code set for C28x, you will not be able
to take advantage of every enhancement since you are limited by the original
source code. Once you begin migrating your code, however, you will quickly
begin to take advantage of the full capabilities the C28x offers. See
Appendix D for help with migration to C28x.
Registers
B.2 Registers
The register modifications to the C2xLP are shown in Figure B−1. Registers
that are shaded show the changes or enhancements on the C28x. The itali-
cized names on the left are the original C2xLP names for the registers. The
names on the right are the C28x names for the registers.
32 bits
C2xLP 16 16 C28x
Names bits bits Names
TREG T or TH TL XT
PREG PH PL P
ACC AH AL ACC
SP
DP 9 DP
AR0 AR0H AR0 XAR0
AR1 AR1H AR1 XAR1
AR2 AR2H AR2 XAR2
AR3 AR3H AR3 XAR3
AR4 AR4H AR4 XAR4
AR5 AR5H AR5 XAR5
AR6 AR6H AR6 XAR6
AR7 AR7H AR7 XAR7
PC PC
RPC
22 bits
IMR† IER
DBGIER
IFR† IFR
ST0 ST0
ST1 ST1
†On the C2xLP, IMR and IFR were memory mapped. On the C28x, they are registers.
ST0/ST1 Status Registers. The C28x status register bit positions are different
compared to the C2xLP. Figure B−3 shows the differences.
DP Data Page Pointer. On the C2xLP the DP is part of status register
ST0. The DP on the C28x is a separate register and is increased
from 9 to 16 bits.
B.2.2.2 C28x DP
The C28x also supports the direct addressing mode using the DP register;
however, the following changes and enhancements have been made:
- Supports 22-bit address reach
- DP increased from 9 to 16 bits
- DP is a separate 16-bit register
- When AMODE == 0, page size is 64 words and DP(15:0) is used
- When AMODE == 1, page size is 128 words and DP(15:1) is used, bit 0
of DP is ignored
When AMODE == 1, the DP and the direct addressing mode behaves identi-
cally to the C2xLP but are enhanced to 22-bit address reach from 16. When
AMODE == 0, the page size is reduced by half. This was done to accommo-
date other useful addressing modes.
The mapping of the direct addressing modes between the C2xLP and the
C28x is as shown in Figure B−2.
22 bit address
21 2 0
C28x
21 15 7 6 5 2 0
Using the previous example, the assembler/linker will initialize the DP and
offset values as follows on the C28x:
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ARP OV OVM 1 INTM DP
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
R/W−X R/W−0 R/W−X R/W−1 R/W−X
Note: R = Read access; W = Write access; value following dash (−) is value after reset.
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
OVC/OVCU PM V N Z C TC OVM SXM
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
R/W−000000 R/W−000 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0 R/W−0
Note: R = Read access; W = Write access; value following dash (−) is value after reset.
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
C2xLP Status Register ST1
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ARB CNF TC SXM C 1 1 1 1 XF 1 1 PM
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
R/W−X R/W−0 R/W−X R/W−1 R/W−1 R/W−1 R/W−00
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Note: R = Read access; W = Write access; value following dash (−) is value after reset.
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
C28x Status Register ST1
ÁÁÁÁÁÁÉÉÉÉÉ
ÉÉÉÉÉÉ ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
7 6 5 4 3 2 1 0
ÉÉÉÉÉÉÁÁÁÁÁ
ÁÁÁÁÁÁ ÉÉÉÉÉÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
IDLESTAT EALLOW LOOP SPA VMAP PAGE0 DBGM INTM
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
R−0 R/W−0 R−0 R/W−0 R/W−1 R/W−0 R/W−1 R/W−1
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
15−13 12 11 10 9 8
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ARP XF M0M1MAP Reserved OBJMODE AMODE
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
R/W−000 R/W−0 R−1 R/W−0 R/W−0 R/W−0
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Notes: 1) R = Read access; W = Write access; value following dash (−) is value after reset; reserved bits are always 0s
and are not affected by writes.
The functionality of the remaining bits is the same on C28x as they are on
C2xLP. It should be noted that although the functionality did not change, the
bit position in the registers did. These bits are:
- Sign extension mode (SXM)
- Overflow mode (OVM)
- Test/control flag (TC)
- Carry bit (C)
- Interrupt global mask bit (INTM)
Vectors. On the C2xLP, only one vector table is present at address 0x0000.
These vectors were generally branch instructions to different interrupt service
routines. On the C28x, the vector table can be placed in two different locations
depending on the state of the VMAP input pin. On devices that do not pin out
the VMAP signal, it is tied internal to the device. Generally, vectors will be lo-
cated in non-volatile memory at 0x3FFFC0−0x3FFFFF. To take advantage of
relocatable vectors or fetching vectors from fast internal memory space, place
the vectors at address 0x000000−0x00003F. Often the C28x CPU interrupt
vectors are expanded using external hardware logic. In such cases, see the
related documents for the expanded vector map.
Memory space. On the C2xLP, the memory space for program, data, and I/O
space is each 64K words. On the C28x, the program memory space is 4M
words (22 address signals). The data memory space is 4G words (32 address
signals). The global space (32K) and I/O space (64K) is generally used for
C2xLP compatibility.
Program space. On the C2xLP CPU, program space could be mapped any-
where from (0x0−0xFFFF). With the extended address reach of the C28x (22
bits), the compatible region in program space for the C2xLP is
0x3F0000−0x3FFFF. Thus, any program memory on the C2xLP must be re-
mapped to this upper region on the C28x. When the processor accesses pro-
gram memory, the upper bits (bits 16−22) will be forced to all 1’s when C2xLP-
compatible instructions are used (See Appendix E).
Memory Map
Block Start C28x memory map for C2xLP C2xLP memory map
Address
Data Space Program Space Data Space - 64K I/O space − 64K
0x0000-0000 VECTORS (32 x 32) Memory
(enabled if VMAP = 0) Registers
0x0000-0040
0x0000-0060 B2 Block
M0 SARAM (1K x 16)
0x0000-0200 B1 Block
0x0000-0300 B0 Block
Low 6K (C2xLP Data, I/O Space)
0x0000-0400
M1 SARAM (1K x 16) Reserved
0x0000-2000
0x0000-8000
Global Space
0−32K
0x0000-FFFF
0x001−0000
Reserved for only C28x
addressing
0x03E−FFFF Program Space - 64K
High 64K (C2xLP Program Space)
0x03F−0000
Vectors 32 x 16
4K SARAM
Pon = 1
Data memory. The C2xLP has three internal memory regions (B0, B1, B2)
totaling 544 words. The C28x has two internal memory regions (M0,M1) total-
ing 1K words each. Note that for strict C2xLP compatibility, the memory re-
gions are placed at the same addresses as noted in Table B−6.
I/O space. I/O space has remained on the C28x for compatibility reasons, and
can only be accessed using IN and OUT/UOUT instructions. Not all C28x de-
vices will support I/O space. See the data sheet of your particular device for
details.
Global space. Global space is not supported on all C28x devices. See the
data sheet specific to your device for details.
Stack space. The C28x has a dedicated software stack pointer. This pointer
is initialized to address 0x0400 (the beginning of block M1) at reset, and it
grows upward in address. It is up to the user to move this stack pointer if need-
ed in firmware.
Appendix
AppendixCA
The C28x DSP is source-code compatible with C2xLP DSP based devices.
The C28x DSP assembler accepts all C2xLP mnemonics with the exception
of a few instructions. This chapter provides guidelines for C2xLP code migra-
tion to a C28x device. C2xLP refers to the CPU used in all TMS320C24x,
TMS320C24xx, and TMS320C20x DSP devices.
Topic Page
C-1
Introduction
C.1 Introduction
This chapter provides guidelines that are intended for conversion from C2xLP
assembly source to C28x object code. The conversion steps highlight the ar-
chitectural changes between C2xLP and C28x operating modes. Future re-
leases of documents will contain code conversion examples and software li-
brary modules facilitating the conversion from C2xLP mixed C and assembly
source to C28x object code.
This chapter will be best understood if the reader has prior knowledge of Ap-
pendix C and Appendix E, as they explain the architectural and instructional
enhancements between the C2xLP and C28x DSPs.
Recommended Migration Flow
1) Install the latest development tools for the C28x DSP (e.g. Code Compos-
er Studiot version 2.x or higher)
3) Memory map:
Define your C28x device memory map with C2xLP compatible memory
sections. Build a linker command file (*.cmd). See Table C−8.
Select a C2xLP assembly source code *.asm for migration to C28x archi-
tecture.
4) Boot Code:
Add the C2xLP mode conversion code segment shown in section C.4.1 as
the first set of instructions after reset.
After reset, the C28x powers up in C27x object−compatible mode. Adding
these few lines of initialization code will place the device in the proper oper-
ating mode for executing reassembled C2xLP code.
Note: The C27x object-compatible mode is for use only for migration from the C27x
CPU. It is a reserved operating mode for all C28x and C2xLP applications.
5) This step will facilitate faster code conversion. In the C2xLP source file
modify the interrupt section with suggestions from the reference table in
section D.5.
In particular, modify the following types of code:
a) IMR and IFR − See the example code in section C.4.2.
b) Context Save/Restore − See the example code in section C.4.3
c) Comment all the known incompatible instructions or map with equiva-
lent instructions. See Table D−2 in Appendix D.
Start
Step 1
Migrate to Code Composer Studio
for the C28x DSP
Step 2
Configure your project with −m20, −mw, and −g assembler
options to enable acceptance of C2xLP mnemonics. Also
build a linker command file *.cmd for your C28x device.
Step 3
Select the C2xLP assembler source code for C28x
migration *.asm
Step 4
Add the initialization code segment to enable C2xLP
compatible mode in the beginning of the code.
Step 5
Comment or fix incompatible instructions in
C2xLP source, if any
Yes
Assembly
errors
?
No
Step 7 Fix Linker errors. See the tables in
Invoke the C28x Linker with assembled .obj files Section C.5 if required.
Linker Yes
errors
?
No
Step 8
Linker outputs C28x COFF file *.out
Migrated code ready for Debug
End
6) Link the assembled code with the linker command file generated in
Step 2. Relink if necessary to avoid any linker related errors.
8) The Linker output COFF file, *.out, will be the migrated code and should
be ready for Debug and integration.
The .c28_amode and .lp_amode directives tell the assembler to override the
assembler mode.
.c28_amode The .c28_amode directive tells the assembler to operate in the C28x object
mode (−v28).
.lp_amode The .lp_amode directive tells the assembler to operate in C28x object − ac-
cept C2xLP syntax mode (−m20).
For example, if a file is assembled with the −m20 option, the assembler begins
the assembly in the C28x object − accept C2xLP syntax mode. When it en-
counters the .c28_amode directive, it changes the mode to C28x object mode
and remains in that mode until it encounters an .lp_amode directive or the end
of file.
Example In this example, C28x code is inserted in the existing C2xLP code.
Note: The following code fragment must be placed in your code just after
reset. This code will place the device in the proper operating mode to execute
C2xLP converted code:
Code Explanation
SETC OBJMODE ;C28OBJ = 1 enable 28x object mode
CLRC PAGE0 ;PAGE0 = 0 not relevant for 28x mode,
;cleared to zero
SETC AMODE ;AMODE = 1 enable C2xLP compatible
;addressing mode
SETC SXM ;SXM = 1 for C2xLP at reset, SXM = 0
;for 28x at reset
SETC C ;Carry bit =1 for C2xLP at reset,
;Carry bit = 0 for 28x at reset
SPM 0 ;Set product shift mode zero, that
is PM bits = 001 compatible to
;C2xLP PM reset;mode
Table C−1. Code to Save Contents Of IMR (IER) And Disabling Lower Priority Interrupts At
Beginning Of ISR
C2xLP C28x
INTx: . INTx: .
MAR *,AR1 AND IER,#~INT_MASK
LDP #0 .
LACL IMR
SACL *+ Note: C28x saves IER as part of auto-
AND #~INT_MASK matic context save operation and dis-
SACL IMR ables the current interrupt automati-
. cally to prevent recursive interrupts.
.
C2xLP C28x
SETC INTM AND IER,#~INTx
LDP #0
LACL IMR ;operation is atomic and
AND #~INTx ;will not be interrupted.
SACL IMR
CLRC INTM
C2xLP C28x
SETC INTM
LDP #0 OR IER,#INTx
LACL IMR
OR #INTx ;operation is atomic and
SACL IMR ;will not be interrupted.
CLRC INTM
C2xLP C28x
;write 1 to clear ;write 0 to clear
SETC INTM AND IFR,#~INTx
LDP #0
SPLK #0FFFFh,IFR ;operation is atomic and
CLRC INTM ;will not be interrupted
Table C−6 through Table C−10 explain the major differences between the
C2xLP and C28x architectures and in their respective code generation pro-
cess. These tables are organized to highlight the differences in interrupts, CPU
registers, memory maps, instructions, registers, and syntax. While migrating
the C2xLP code, check the tables for these key differences to make the neces-
sary changes to the source to avoid assembler or linker errors.
1 Interrupt flag register IFR − Memory mapped register IFR is a CPU register
Write 1 to clear bits set in IFR Write 0 to clear bits set in IFR
2 Interrupt enable register IMR – Memory mapped register Renamed as IER and is a CPU regis-
ter
6 CLRC INTM instruction CLRC INTM instruction blocks Interrupts enabled after the instruc-
all interrupts until the next in- tion
struction is executed.
CLRC INTM
CLRC INTM
next_instn ;interrupts
;blocked
;until this
;executed
10 Context save No automatic context save Automatic context save of CPU regis-
ters T, ST0, AH, AL, PH, PL, AR1,
See section D.3 for a full context
AR0, DP, ST1, DBGSTAT, IER, PC
save/restore example
See Table C−5 for a full context save/
restore example
2 ST0/ST1 bit differences ST0/ST1 bits have CPU registers ST0/ST1 bits are rearranged
and status bits compared to C2xLP registers.
4 Data page pointer DP save/restored along with DP is a register, hence explicit store/
ST0. restore is required.
DP save
SST #0,mem ;store ST0 PUSH DP ;store DP
;to stack
LST #0,mem ;load ST0 PUSH DP:ST1 ; 32−bit
; save
POP DP ;load DP from
;stack
POP DP:ST1 ; 32−bit
; restore
9 CNF bit mapping of B0 CNF bit maps B0 in data and Not applicable
Block program memory
CNF =0 − B0 in data memory
Range: 0x0300−0x03FF
: 0x0400−0x04FF
CNF =1 − B0 in program memory
Range: 0xFE00−0xFEFF
: 0xFF00−0xFFFF
11 Internal SARAM mapping Mapped as internal memory map Reserved for emulation registers
in data memory
Range : 0x0800 −0x1000h
5 I/O space Range : 0x0000 −0xFFFFh Range : 0x0x00 000 −0x00 FFFFh
I/O Space may or may not be imple-
mented on a particular device. See
the device datasheet for details.
1 Conditional Instructions Can take more than one condi- The C28x assembler will automatical-
tion in these instructions ly break the instructions into multiple
Branches, Calls, Returns
instructions.
2 When are CPU Flags up- Conditional flags update on Ac- Conditional flags update on Accumu-
dated? cumulator operation only lator, register and memory operations
3 Repeat instructions Many instructions are repeatable Same instructions are repeatable.
For additional repeatable instructions
see Table D−3.
Table C−9. C2xLP and C28x Differences in Instructions and Registers (Continued)
Migration topic C2xLP C28x
5 ARx registers ARx registers are 16−bit only XARn registers are 32 bits. Some in-
structions access only the lower
16 bits known as ARn
LAR AR1, #0FFFFh
ADRK #1 MOV XAR1, #0FFFFh
ADD XAR1,#1
Result:
Result:
AR1 = 0x0000h
XAR1 = 0x10000h
8 Stack Uses 8−deep Hardware stack Uses software stack pointer register
(SP)
C2xLP Compiler uses AR1 as
Stack Pointer Compiler will use SP register, as
stack pointer
1 Mnemonic Source or destination not always Instructions are always of the form
specified.
mnemonic destination, source
LACL, source
MOV destination,source
SACL, destination
2 Direct addressing syntax LACL dma MOV ACC, @@dma ; C2xLP mode
−@ symbol
MOV ACC, @dma ; 28x mode
@@ − means 128 word data page
6 Reserved register names ST0, ST1, IFR, IMR, GREG ST0, ST1, AH, AL, PH, PL,T, TL,
Application code should XAR0, XAR1, XAR2, XAR3, XAR4,
not use these reserved
XAR5, XAR6, XAR7, DP, ST1,
words
DBGSTAT, IER, PC, RPC
This appendix highlights the differences in syntax between the C2xLP and the
C28x instructions, and details which C2xLP compatible instructions are re-
peatable on the C28x. The C28x assembler accepts both C28x and C2xLP as-
sembly source syntax. This enables you to quickly port C2xLP code with mini-
mal effort. Additionally, all compatible C2xLP instructions have an equivalent
C28x style syntax. The C28x disassembler will show the C28x equivalent syn-
tax.
Topic Page
D-1
Condition Tests on Flags
EQ == 0 ACC == 0
HI higher −
NOV no overflow OV == 0
OV overflow OV == 1
NTC TC == 0 TC == 0
TC TC == 1 TC == 1
On the C28x, the Z and N flags are set on all ACC operations. That includes
ACC loads. Therefore, the Z and N flags reflect the current state of the ACC
immediately after an operation on the ACC.
Condition Tests on Flags
B pma 4 32 XB pma,UNC 7 32
B pma,*,ARn 4 32 XB pma,*,ARPn 4 32
† True/False
IDLE 1 16 IDLE 5 16
OR #16bit,16 2 32 OR ACC,#16bit<<16 1 32
SPM 0 1 16 SPM 0 1 16
† True/False
Repeatable Instructions
Table D−3 shows which C2xLP operations are repeatable, and which ones are
repeatable on the C28x.
C2xLP C28x
C2xLP Instruction Repeatable Repeatable
ABS X
ADD mem,shift1 X X
ADDC mem X
ADDS mem X X
ADDT mem X X
AND mem X X
APAC X X
BIT mem,bit_code X
BITT mem X
BLDD #addr,mem X X
BLDD mem,#addr X X
BLPD #pma,mem X X
CLRC CNF/XF/INTM/OVM/SXM/TC/C X
CMPL X
CMPR constant X
DMOV mem X X
IN mem,PA X X
INTR K X
LACC mem[,shift1] X
LACL mem X
Table D−3. Repeatable Instructions for the C2xLP and C28x (Continued)
C2xLP C28x
C2xLP Instruction Repeatable Repeatable
LACT mem X
LAR AR,mem X
LDP mem X
LPH mem X
LST #n,mem X
LT mem X
LTA mem X X
LTD mem X
LTP mem X
LTS mem X X
MAC pma,mem X X
MACD pma,mem X X
MAR {ind}[,nextARP] X X
MPY mem X
MPY #k X
MPYA mem X X
MPYS mem X X
MPYU mem X
NEG X
NOP X X
NORM {ind} X X
OR mem X X
OUT mem,PA X X
PAC X
POP X
POPD mem X
Repeatable Instructions
Table D−3. Repeatable Instructions for the C2xLP and C28x (Continued)
C2xLP C28x
C2xLP Instruction Repeatable Repeatable
PSHD mem X
PUSH X
ROL X X
ROR X X
SACH mem[,shift] X X
SACL mem[,shift] X X
SAR AR,mem X
SETC CNF/XF/INTM/OVM/SXM/TC/C X
SFL X X
SFR X X
SPAC X X
SPH mem X X
SPL mem X X
SPLK #lk,mem X X
SQRA mem X X
SQRS mem X X
SST #n,mem X
SUB mem[,shift1] X X
SUBB mem X
SUBC mem X X
SUBS mem X X
SUBT mem X X
TBLR mem X X
TBLW mem X X
XOR mem X X
ZALR mem X
This appendix highlights the architecture differences between the C27x and
the C28x and describes how to migrate your code from a C27x-based design
to a C28x-based design.
Topic Page
E-1
Architecture Changes
SP(16)
6/7bit
DP(16) offset
AR0H(16) AR0(16) XAR0(32)
AR1H(16) AR1(16) XAR1(32)
PC(22)
RPC(22)
Architecture Changes
XT(32), TL(16): The T register is increased to 32-bits and called the XT register. The existing C27x T register
portion represents the upper 16-bits of the new 32-bit register. The additional 16-bits, called
the TL portion, represents the lower 16-bits.
XAR0,..,XAR7(32): All of the AR registers are stretched to 32-bits. This enables a full 22-bit address. For
addressing operations, only the lower 22-bits of the registers are used, the upper 10-bits
are ignored. For operations between the ACC, all 32-bits are valid (register addressing
mode @XARx). For 16-bit operations to the low 16-bit of the registers (register addressing
mode @ARx), the upper 16-bits are ignored.
RPC(22): This is the return PC register. When a call operation is performed, the return address is
saved in the RPC register and the old value in the RPC is saved on the stack (in two 16-bit
operations). When a return operation is performed, the return address is read from the RPC
register and the value on the stack is written into the RPC register (in two 16-bit operations).
The net result is that return operations are faster (4 instead of 8 cycles)
ST0 (16): Shaded items indicate a change or addition from the C27x
PM: Functionality of the Product Shift Mode changes if the AMODE bit in ST1 is set to 1. C27x
users will not modify the AMODE bit and PM will function as they did on the C27x.
OVC/OVCU: The overflow counter is modified so that it behaves differently for signed or unsigned
operations. For signed operations (OVC), it behaves as it does on the C27x (increment
for positive overflow, decrement for negative underflow of a signed number). For
unsigned operations (OVCU), the overflow counter increments for an ADD operation
when there is a carry generated and decrements for a SUB operation when a borrow is
generated. Basically, in unsigned mode, the OVCU behaves like a carry (C) counter and
in signed mode the OVC behaves like an overflow (V) counter.
AMODE: This mode selects the appropriate addressing mode decodes for compatibility with the
C2xLP device. For all C27x/C28x based projects leave this bit as 0.
OBJMODE: This mode is used to select between C27x object mode (OBJMODE == 0) and C28x
object mode (OBJMODE == 1) compatibility. This bit is set by the ”C28OBJ” (or ”SETC
OBJMODE”) instructions. This bit is cleared by the ”C27OBJ” (or ”CLRC OBJMODE”)
instructions. The pipeline is flushed when setting or clearing this bit using the given
instructions. This bit can be saved and restored by interrupts and when restoring the ST1
register. This bit is set to 0 on reset.
M0M1MAP: This mode is used to remap block M0 and M1 in program memory space as discussed
in detail in section E.1.2. This bit is set by the ”C28MAP” (or ”SETC M0M1MAP”)
instructions. This bit is cleared by the ”C27MAP” (or ”CLRC M0M1MAP”) instructions.
The pipeline is flushed when setting or clearing this bit using the given instructions. This
bit cannot be restored by interrupts and when restoring the ST1 register (read only).
XF: This bit reflects the current state of the XFS output signal. This signal is for C2xLP
compatibility and is not used by C27x users.
Architecture Changes
Due to the register changes described in section E.1.1. C28x additional regis-
ters must be saved for a full-context store. Figure E−3 shows the difference
between a C27x and C28x full-context save/restore for an interrupt or trap.
Figure E−3. Code for a Full Context Save/Restore for C28x vs C27x
If you perform a task-switch operation (stack changes), the RPC register must
be manually saved. You are not to save the RPC register if the stack is not
changed.
00 0400
B0
00 07FF
On a C28x device at reset, these blocks are mapped uniformly in both program
and data space as shown in Figure E−5. This can cause issues when running
C27x object code that relies on the C27x mapping. If your code relies on this
mapping, you can flip-block M0 and M1 in program space only by clearing the
M0M1MAP bit in status register 1 (ST1) to a 0. Executing the ”C27MAP” (or
”CLRC M0M1MAP”) instruction is the only way to clear this bit. With
M0M1MAP == 0, the mapping is compatible with the C27x B0 and B1 blocks
as shown in Figure D-4. Remember that after a reset M0 and M1 revert to the
C28x mapping.
It is strongly recommended that you migrate your code to use the default C28x
mapping of these blocks and not rely on the compatible mapping.
00 0400 00 0400
M1 M1 M0 M1
00 07FF 00 07FF
C27x Source
CL2000-V27 C27x Object
Code
(.out)
(.asm .c .cpp)
−v27 Accepts C27x syntax only. Generates C27x object only (assumes OBJMODE = 0)
Once you have taken the mapping of blocks M0 and M1 into account as previously
described, you can simply load the C27x object (.out) code into the C28x and run it. When
using the C27x compatible mode, you are limited to the C27x instruction set. To take
advantage of advanced C28x operations, you should migrate to C28x object code.
When the device is operating in C27x object mode (OBJMODE == 0), the upper bits of the
stretched registers (XAR0(31:16) to XAR5(31:16), XAR6(31:22), XAR7(31:22)) are
protected from writes. Hence, if the registers are set to zero by a reset then the XARn
pointers behave like they do on the C27x and overflow problems are not of concern.
Moving to a C28x Object
Figure E−7. Building a C28x Object File From Mixed C27x/C28x Source
C27x/C28x
CL2000 C28x Object
Source Code
−V28 −m27 (.out)
(.asm .c .cpp)
−v28−m27 Accepts C28x & C27x syntax. Generates C28x object only (assumes OBJMODE == 1)
Prior to running C28x object you must set the mode of the device appropriately (OBJMODE
== 1). To do this, you set the OBJMODE bit in ST1 to 1 after reset. This can be done with
a ”C28OBJ” (or ”SETC OBJMODE”) instruction. Note that before the “C28OBJ” instruction
is executed, the disassembly window in the debugger may display incorrect information.
This is because the debugger will decode memory as C27x opcodes until after you execute
the “C28OBJ” instruction.
When running in this mode, the disassembly window in your debugger will show the C28x
instruction syntax for all instructions. For example, the C27x MOV AR0,@SP instruction
will look like MOVZ AR0,@SP, which is the C28x-equivalent instruction.
Now that you are using a C28x object file, you can add C28x operations to your source
code.
- If the user switches to C28x object mode (OBJMODE == 1), then the upper
bits of XARn registers may be modified. If you then switch back to C27x
mode (OBJMODE == 0), the upper bits of XARn registers may contain
nonzero values. You MUST zero out the upper bits of the XARn registers
when switching from OBJMODE == 1 to OBJMODE == 0.
RET LRET
LRET
RETE LRETE
LRETE
MOV ACC,P {MOVP T,@T decode} MOVL ACC,P << PM {MOVP T,@T decode}
ADD ACC,P {MOVA T,@T decode} ADDL ACC,P << PM {MOVA T,@T decode}
SUB ACC,P {MOVS T,@T decode} SUBL ACC,P << PM {MOVS T,@T decode}
For conditional branches on the C28x, the UNC code must always be specified
for unconditional tests. This will help to distinguish between unconditional
C2xLP branches (which have the same mnemonic ”B”).
ROR ACC
ROL ACC
NORM ACC,XARn++
NORM ACC,XARn−−
SUBCU ACC,loc16
MAC P,loc16,0:pma
MOV *(0:addr),loc16
MOV loc16,*(0:addr)
MOV loc16,#16bit
MOV loc16,#0
PREAD loc16,*XAR7
PWRITE *XAR7,loc16
NOP loc16
C27x Operations That Are Made Repeatable On C28x include the following:
MOV loc16,AX
ADDU ACC,loc16
SUBU ACC,loc16
ADDL ACC,loc32
SFR ACC,1..16
LSL ACC,1..16
MOVH loc16,P
MOV loc16,P
MOVA T,loc16
MOVS T,loc16
MPYA P,T,loc16
MPYS P,T,loc16
- The V flag and overflow counter (OVC) are not affected by the operation.
On the C27x the V and OVC flags are affected.
The V and OVC flags may be affected on the C27x and not on the C28x imple-
mentation. The values of these flags are not usable under prescribed usage
of such an operation.
C28x Source
CL2000 C28x Object
Code
−V28 (.out)
(.asm .c .cpp)
−v28: Accepts C28x syntax only. Generates C28x object only (assumes OBJMODE = 1)
Appendix
AppendixFA
Revision History
F.1 Changes
This revision history lists the technical changes made in the most recent
revision.
Preface page iii Changed About This Manual introduction and Chapter 1 description.
Table 2−6 Changed descriptions for MAX, MAXL, MIN, and MINL.
Page 2-32 Changed description of SXM bit values and added example code.
Example 3−1 Removed period in first line and changed semicolon to colon in 21st line.
Page 6-46 Changed 0xFFBE to 0xFFDE in example for AND IER, #16bit instruction.
Page 6-145 Changed RPT and CYC values for MAC P, loc16, 0:pma instruction.
Page 6-149 Changed then to than for MAX AX, loc16 instruction.
Page 6-150 Added closing square bracket in Description note and changed 2 to 0 in 7th line
of example for MAXCUL P, loc32 instruction.
Page 6-152, 6-153, 6-154 Changed then to than for multiple instructions.
F-1
Table F−1. Revision History
Location Additions, Deletions, Modifications
Page 6-168 Changed Repeat description for MOV loc16, ARn instruction.
Page 6-201 Changed operand from loc16 to loc32, modified Repeat description, and moved
notes in example for MOVDL instruction.
Page 6-224 Changed operand listed for Description from loc32 for MOVX TL, loc16 instruc-
tion.
Page 6-243 Changed PSA to SPA in Flags and Modes for NASP instruction.
Page 6-313 Modified alignment of code in Description for SAT ACC instruction.
Page 6-326 Changed RPT and CYC values for SFR ACC, T instruction.
Page 6-337 Added else to N flag description for SUB ACC, #16bit << 0..15 instruction.
Page 6-341 Changed to in Description to from for SUBB SP, #7bit instruction.
Page 6-360 Changed ADD to XOR in 6th line of example for TBIT loc16, T instruction.
Page 6-363 Corrected grammar in Description and added SP = SP + 2; line in example for
TRAP #VectorNumber instruction.
Appendix B−E Removed original Appendix B, Submitting Rom Codes to TI, and renumbered
remaining appendices.
Revision History F-3
Appendix
AppendixGA
Glossary
A
absolute branch: A branch to an address that is permanently assigned to
a memory ___location. See also offset branch.
access: A term used in this document to mean read from or write to. For ex-
ample, to access a register is to read from or write to that register.
address reach: The range of addresses beginning with 00 000016 that can
be used by a particular addressing mode.
address register arithmetic unit (ARAU): Hardware in the CPU that gen-
erates addresses for values that must be fetched from data memory. The
ARAU is also the hardware used to increment or decrement the stack
pointer (SP) and the auxiliary registers (AR0, AR1, AR2, AR3, AR4, AR5,
XAR6, and XAR7).
AH: High word of the accumulator. The name given to bits 31 through 16 of
the accumulator.
G-1
Glossary
AH.LSB: Least significant byte of AH. The name given to bits 23 through 16
of the accumulator.
AH.MSB: Most significant byte of AH. The name given to bits 31 through 24
of the accumulator.
AL: Low word of the accumulator. The name given to bits 15 through 0 of the
accumulator.
AL.LSB: Least significant byte of AL. The name given to bits 7 through 0 of
the accumulator.
AL.MSB: Most significant byte of AL. The name given to bits 15 through 8
of the accumulator.
analysis logic: A portion of the emulation logic in the core. The analysis log-
ic is responsible for managing the following debug activities: hardware
breakpoints, hardware watchpoints, data logging, and benchmark/event
counting.
arithmetic logic unit (ALU): A 32-bit hardware unit in the CPU that per-
forms 2s-complement arithmetic and Boolean logic operations. The ALU
accepts inputs from data from registers, from data memory, or from the
program control logic. The ALU sends results to a register or to data
memory.
arithmetic shift: A shift that treats the shifted value as signed. See also log-
ical shift.
ARP indirect addressing mode: The indirect addressing mode that uses
the current auxiliary register to point to a ___location in data space. The cur-
rent auxiliary register is the auxiliary register pointed to by the ARP. See
also auxiliary register pointer (ARP).
automatic context save: A save of system context (modes and key register
values) performed by the CPU just prior to executing an interrupt service
routine. See also context save.
Glossary
auxiliary register pointer (ARP): A 3-bit field in status register ST1 that se-
lects the current auxiliary register. When an instruction uses ARP indirect
addressing mode, that instruction uses the current auxiliary register to
point to data space. When an instruction specifies auxiliary register n by
using auxiliary-register indirect addressing mode, the ARP is updated,
so that it points to auxiliary register n. See also current auxiliary register.
B
background code: The body of code that can be halted during debugging
because it is not time-critical.
barrel shifter: Hardware in the CPU that performs all left and right shifts of
register or data-space values.
bit field: One or more register bits that are differentiated from other bits in
the same register by a specific name and function.
boundary scan: The use of scan registers on the border of a chip or section
of logic to capture the pin states. By scanning these registers, all pin
states can be transmitted through the JTAG port for analysis.
break event: A debug event that causes the CPU to enter the debug-halt
state.
Glossary G-3
Glossary
C
C bit: See carry (C) bit.
call: 1) The operation of saving a return address and then forcing program
control to a new address. 2) An instruction that performs such an opera-
tion. See also return.
carry (C) bit: A bit in status register ST0 that reflects whether an addition has
generated a carry or a subtraction has generated a borrow.
circular addressing mode: The indirect addressing mode that can be used
to implement a circular buffer.
circular buffer: A block of addresses referenced by a pointer using circular
addressing mode, so that each time the pointer reaches the bottom of the
block, the pointer is modified to point back to the top of the block.
clear : To clear a bit is to write a 0 to it. To clear a register or memory ___location
is to load all its bits with 0s. See also set.
COFF: Common object file format. A binary object file format that promotes
modular programming by supporting the concept of sections, where a
section is a relocatable block of code or data that ultimately occupies a
space adjacent to other blocks of code in the memory map.
conditional branch instruction: A branch instruction that may or may not
cause a branch, depending on a specified or predefined condition (for ex-
ample, the state of a bit).
context restore: A restoring of the previous state of a system (for example,
modes and key register values) prior to returning from a subroutine. See
also context save.
context save: A save of the current state of a system (for example, modes
and key register values) prior to executing the main body of a subroutine
that requires a different context. See also context restore.
core: The portion of the C28x that consists of a CPU, a block of emulation
circuitry, and a set of signals for interfacing with memory and peripheral
devices.
current auxiliary register: The register selected by the auxiliary register
pointer (ARP) in status register. For example, if ARP = 3, the current aux-
iliary register is AR3. See also auxiliary registers.
current data page: The data page selected by the data page pointer. For
example, if DP = 0, the current data page is 0. See also data page.
Glossary
D
D1 phase: See decode 1 (D1) phase.
data logging: Transferring one or more packets of data from CPU registers
or memory to an external host processor.
data page: A 64-word portion of the total 4M words of data space. Each data
page has a specific start address and end address. See also data page
pointer (DP) and current data page.
data page pointer (DP): A 16-bit pointer that identifies which 64-word data
page is accessed in DP direct addressing mode. For example, for as long
as DP = 500, instructions that use DP direct addressing mode will ac-
cess data page 500.
data-/program-write data bus (DWDB): The bus that carries data during
writes to data space or program space.
data-read address bus (DRAB): The bus that carries addresses for reads
from data space.
data-read data bus (DRDB): The bus that carries data during reads from
data space.
data-write address bus (DWAB): The bus that carries addresses for writes
to data space.
debug enable mask (DBGM) bit: A bit in status register ST1 used to enable
(DBGM = 0) or disable (DBGM = 1) debug events such as analysis
breakpoints or debug-and-test direct memory accesses (DT-DMAs).
Glossary G-5
Glossary
debug status register (DBGSTAT): A register that holds special debug sta-
tus information. This register, which need not be read from or written to,
is saved and restored during interrupt servicing, to preserve the debug
context during debugging.
direct addressing modes: The addressing modes that access data space
as if it were 65 536 separate blocks of 64 words each. DP direct address-
ing mode uses the data page pointer (DP) to select a data page from 0
to 65 535. PAGE0 direct addressing mode uses data page 0, regardless
of the value in the DP.
DP direct addressing mode: A direct addressing mode that uses the data
page pointer (DP) to select a data page from 0 to 65 535. See also
PAGE0 direct addressing mode.
E
E phase: See execute (E) phase.
EMU0 and EMU1 pins: Pins known as the TI extensions to the JTAG inter-
face. These pins can be used as either inputs or outputs and are avail-
able to help monitor and control an emulation target system that is using
a JTAG interface.
emulation access enable (EALLOW) bit: A bit in status register ST1 that
enables (EALLOW = 1) or disables (EALLOW = 0) access to the emula-
tion registers. The EALLOW instruction sets the EALLOW bit, and the
EDIS instruction clears the EALLOW bit.
emulation logic: The block of hardware in the core that is responsible con-
trolling emulation activities such as data logging and switching among
debug execution states.
Glossary G-7
Glossary
F
F1 phase: See fetch 1 (F1) phase.
fetch 1 (F1) phase: The first of eight pipeline phases an instruction passes
through. In this phase, the CPU places on the program-read bus the ad-
dress of the instruction(s) to be fetched. See also pipeline phases.
fetch counter (FC) : The register that contains the address of the instruction
that is being fetched from program memory.
H
hardware interrupt: An interrupt initiated by a physical signal (for example,
from a pin or from the emulation logic). See also software interrupt.
high word: The 16 MSBs of a 32-bit value. See also low word.
host processor: The processor running the user interface for a debugger.
I
IC: See instruction counter (IC).
IDLESTAT (IDLE status) bit: A bit in status register ST1 that indicates when
an IDLE instruction has the CPU in the idle state (IDLESTAT = 1).
idle state: The low-power state the CPU enters when it executes the IDLE
instruction.
IEEE 1149.1 standard: “IEEE Standard Test Access Port and Boundary-
Scan Architecture”, first released in 1990. See also JTAG.
IER: See interrupt enable register (IER).
IFR: See interrupt flag register (IFR).
illegal instruction: An unacceptable value read from program memory dur-
ing an instruction fetch. Unacceptable values are 000016, FFFF16, or any
value that does not match a defined opcode.
illegal-instruction trap: A trap that is serviced when an illegal instruction is
decoded.
immediate address: An address that is specified directly in an instruction
as a constant.
immediate addressing modes: Addressing modes that accept a constant
as an operand.
immediate constant/data: A constant specified directly as an operand of
an instruction.
immediate-constant addressing mode: An immediate addressing mode
that accepts a constant as an operand and interprets that constant as
data to be stored or processed.
immediate-pointer addressing mode: An immediate addressing mode
that accepts a constant as an operand and interprets that constant as the
16 LSBs of a 22-bit address. The six MSBs of the address are filled with
0s.
increment: To add 1 or 2 to a register or memory value. The value added
depends on the circumstance. For example, if you use the operand
*AR4++, the auxiliary register AR4 is incremented by 1 for a 16-bit opera-
tion and by 2 for a 32-bit operation.
Glossary G-9
Glossary
interrupt flag bit: A bit in the interrupt flag register (IFR). If the interrupt flag
bit is 1, the corresponding interrupt has been requested by hardware and
is awaiting approval by the CPU.
interrupt flag register (IFR): The register that contains the interrupt flag bits
for the maskable interrupts. If a bit in the IFR is 1, the corresponding inter-
rupt has been requested by hardware and is awaiting approval by the
CPU.
interrupt global mask (INTM) bit: A bit in status register ST1 that globally
enables or disables the maskable interrupts. If an interrupt is enabled in
the interrupt enable register (IER) but not by the INTM bit, it is not ser-
viced. The only time this bit is ignored is when the CPU is in real-time
mode and is in the debug-halt state; in this situation, the interrupt must
be enabled in the IER and in the DBGIER (debug interrupt enable regis-
ter).
interrupt vector: The start address of an interrupt service routine. After ap-
proving an interrupt request, the CPU fetches the interrupt vector from
your interrupt vector table and uses the vector to branch to the start of
the corresponding interrupt service routine.
interrupt vector table: The list of interrupt vectors you assign in program
memory.
Glossary G-11
Glossary
J
JTAG: Joint Test Action Group. The Joint Test Action Group was formed in
1985 to develop economical test methodologies for systems designed
around complex integrated circuits and assembled with surface-mount
technologies. The group drafted a standard that was subsequently
adopted by IEEE as IEEE Standard 1149.1-1990, “IEEE Standard Test
Access Port and Boundary-Scan Architecture”. See also boundary scan;
test access port (TAP).
L
latch: Hold a bit at the same value until a given event occurs. For example,
when an overflow occurs in the accumulator, the V bit is set and latched
at 1 until it is cleared by a conditional branch instruction or by a write to
status register ST0. An interrupt is latched when its flag bit has been
latched in the interrupt flag register (IFR).
least significant bit (LSB): The bit in the lowest position of a binary number.
For example, the LSB of a 16-bit register value is bit 0. See also MSB,
LSByte, and MSByte.
least significant byte (LSByte): The byte in the lowest position of a binary
value. The LSByte of a value consists of the eight LSBs. See also
MSByte, LSB, and MSB.
___location: A space where data can reside. A ___location may be a CPU register
or a space in memory.
logical shift: A shift that treats the shifted value as unsigned. See also arith-
metic shift.
LOOP (loop instruction status) bit: A bit in status register ST1 that indi-
cates when a LOOPNZ or LOOPZ instruction is being executed
(LOOP = 1).
low word: The 16 LSBs of a 32-bit value. See also high word.
Glossary
LSB: When used in a syntax of the MOVB instruction, LSB means least sig-
nificant byte. Otherwise, LSB means least significant bit. See least signif-
icant bit (LSB) and least significant byte (LSByte).
M
maskable interrupt: An interrupt that can be disabled by software so that
the CPU does not service it until it is enabled by software. See also non-
maskable interrupt.
memory interface: The buses and signals responsible for carrying commu-
nications between the core and on-chip memory/peripherals.
memory wrapper: The hardware around a memory block that identifies ac-
cess requests and controls accesses for that memory block.
mirror: A range of addresses that is the same size and is mapped to the
same physical memory block as another range of addresses.
most significant bit (MSB): The bit in the highest position of a binary num-
ber. For example, the MSB of a 16-bit register value is bit 15. See also
LSB, LSByte, and MSByte.
most significant byte (MSByte): The byte in the highest position of a binary
value. The MSByte of a value consists of the eight MSBs. See also
LSByte, LSB, and MSB.
MSB: When used in a syntax of the MOVB instruction, MSB means most sig-
nificant byte. Otherwise MSB means most significant bit. See most sig-
nificant bit (MSB) and most significant byte (MSByte).
multiplicand register (T): The primary function of this register, also called
the T register, is to hold one of the values to be multiplied during a multi-
plication. The following shift instructions use the four LSBs to hold the
shift count: ASR (arithmetic shift right), LSL (logical shift left), LSR (log-
ical shift right), and SFR (shift accumulator right). The T register can also
be used as a general-purpose 16-bit register.
Glossary G-13
Glossary
N
N (negative flag) bit: A bit in status register ST0 that indicates whether the
result of a calculation is a negative number (N = 1). N is set to match the
MSB of the result.
NMI: A hardware interrupt that is nonmaskable, like reset (RS), but does not
reset the CPU. NMI simply forces the CPU to execute its interrupt service
routine.
O
offset branch: A branch that uses a specified or generated offset value to
jump to an address relative to the current position of the program counter
(PC). See also absolute branch.
opcode: This document uses opcode to mean the complete code for an in-
struction. Thus, an opcode includes the binary sequence for the instruc-
tion type and the binary sequence and/or constant in which the operands
are encoded.
operand : This document uses operand to mean one of the values entered
after the instruction mnemonic and separated by commas (or for a shift
operand, separated by the symbol <<). For example, in the CLRC INTM
instruction, CLRC is the mnemonic and INTM is the operand.
operation: 1) A defined action; namely, the act of obtaining a result from one
or more operands in accordance with a rule that completely specifies the
result of any permitted combination of operands. 2) The set of such acts
specified by a rule, or the rule itself. 3) The act specified by a single com-
puter instruction. 4) A program step undertaken or executed by a com-
puter; for example, addition, multiplication, extraction, comparison, shift,
transfer, etc. 5) The specific action performed by a logic element.
overflow counter (OVC): A 6-bit counter in status register ST0 that can be
used to track overflows in the accumulator (ACC). The OVC is enabled
only when the overflow mode (OVM) bit in ST0 is 0. When OVM = 0, the
OVC is incremented by 1 for every overflow in the positive direction (too
large a positive number) and decremented by 1 for every overflow in the
negative direction (too large a negative number). The saturate (SAT) in-
struction modifies ACC to reflect the net overflow represented in the
OVC.
overflow flag (V): A bit in status register ST0 that indicates when the result
of an operation causes an overflow in the ___location holding the result
(V = 1). If no overflow occurs, V is not modified.
overflow mode (OVM) bit: A bit in the status register ST0 that enables or
disables overflow mode. When overflow mode is on (OVM = 1) and an
overflow occurs, the CPU fills the accumulator (ACC) with a saturation
value. When overflow mode is off (OVM = 0), the CPU lets ACC overflow
normally but keeps track of each overflow by incrementing or decrement-
ing by 1 the overflow counter (OVC) in ST0.
P
P register: See product register (P).
PAB: See program address bus (PAB).
PAGE0 bit: PAGE0 addressing mode configuration bit. This bit, in status
register ST1, selects between two addressing modes: PAGE0 stack ad-
dressing mode (PAGE = 0) and PAGE0 direct addressing mode
(PAGE0 = 1).
PAGE0 direct addressing mode: The direct addressing mode that uses
data page 0 regardless of the value in the data page pointer (DP). This
mode is available only when the PAGE0 bit in status register ST1 is 1.
See also DP direct addressing mode and PAGE0 stack addressing
mode.
PAGE0 stack addressing mode: The indirect addressing mode that refer-
ences a value on the stack by subtracting a 6-bit offset from the current
position of the stack pointer (SP). This mode is available only when the
PAGE0 bit in status register ST1 is 0. See also stack-pointer indirect ad-
dressing mode.
PC: See program counter (PC).
pending interrupt: An interrupt that has been requested but is waiting for
approval from the CPU. See also approve an interrupt request.
Glossary G-15
Glossary
pipeline: The hardware in the CPU that takes each instruction through eight
independent phases for fetching, decoding, and executing. During any
given CPU cycle, there can be up to eight instructions in the pipeline,
each at a different phase of completion. The phases, listed in the order
in which instructions pass through them, are fetch 1, fetch 2, decode 1,
decode 2, read 1, read 2, execute, and write.
pipeline freeze: A halt in pipeline activity in one of the two decoupled por-
tions of the pipeline. Freezes in the fetch 1 through decode 1 portion of
the pipeline are caused by a not-ready signal from program memory.
Freezes in the decode 2 through write portion are caused by lack of in-
structions in the instruction-fetch queue or by not-ready signals from
memory.
product register (P): This register, also called the P register, is given the re-
sults of most multiplications done by the CPU. The only other register that
can be given the result of a multiplication is the accumulator (ACC). See
also PH and PL.
Glossary
product shift mode (PM) bits: A 3-bit field in status register ST0 that en-
ables you to select one of eight product shift modes. The product shift
mode determines whether or how the P register value is shifted before
being used by an instruction. You have the choices of a left shift by 1 bit,
no shift, or a right shift by N, where N is a number from 1 to 6.
program address bus (PAB): The bus that carries addresses for reads and
writes from program space.
program control logic: This logic stores a queue of instructions that have
been fetched from program memory by way of the program-read bus
(PRDB). It also decodes these instructions and passes commands and
constant data to other parts of the CPU.
program counter (PC): When the pipeline is full, the 22-bit PC always
points to the instruction that is currently being processed—the instruction
that has just reached the decode 2 phase of the pipeline.
program-read data bus (PRDB): The bus that carries instructions or data
during reads from program space.
R
R1 phase: See read 1 (R1) phase.
read 1 (R1) phase: The fifth of eight pipeline phases an instruction passes
through. In this phase, if data is to be read from memory, the CPU drives
the address(es) on the appropriate address bus(es). See also pipeline
phases.
read 2 (R2) phase: The sixth of eight pipeline phases an instruction passes
through. In this phase, data addressed in the read 1 phase is fetched
from memory. See also pipeline phases.
Glossary G-17
Glossary
ready signals: When the core requests a read from or write to a memory
device or peripheral device, that device can take more time to finish the
data transfer than the core allots by default. Each device must use one
of the core’s ready signals to insert wait states into the data transfer when
it needs more time. Wait-state requests freeze a portion of the pipeline
if they are received during the fetch 1, read 1, or write pipeline phase of
an instruction.
real-time mode: An emulation mode that enables you execute certain inter-
rupts (time-critical interrupts), even when the CPU is halted. See also
stop mode.
register pair: One of the pairs of CPU register stored to the stack during an
automatic context save.
repeat counter (RPTC): The counter that is loaded by the RPT (repeat) in-
struction. The number in the counter is the number of times the instruc-
tion qualified by RPT is to be repeated after its initial execution.
reserved: A term used to describe memory locations or other items that you
cannot use or modify.
reset: To return the DSP to a known state; an action initiated by the reset
(RS) signal.
return address: The address at which the CPU resumes processing after
executing a subroutine or interrupt service routine.
Glossary
run state: A debug execution state. In this state, the CPU is executing code
and servicing interrupts freely. See also debug-halt state and single-in-
struction state.
S
select signal: An output signal from the C28x that can be used to select spe-
cific memory or peripheral devices for particular types of read and write
operations.
set: To set a bit is to write a 1 to it. If a bit is set, it contains 1. See also clear.
sign extend: To fill the unused most significant bits (MSBs) of a value with
copies of the value’s sign bit.
sign-extension mode (SXM) bit: A bit in status register ST0 that enables
or suppresses sign extension. When sign-extension is enabled
(SXM = 1), operands of certain instructions are treated as signed and
are sign extended during shifting.
Glossary G-19
Glossary
stack : The C28x stack is a software stack implemented by the use of a stack
pointer (SP). The SP, a 16-bit CPU register, can be used to reference a
value in the first 64K words of data memory (addresses
00 000016−00 FFFF16).
stack pointer (SP): A 16-bit CPU register that enables you to use any por-
tion of the first 64K words of data memory as a software stack. The SP
always points to the next empty ___location in the stack.
stack pointer alignment (SPA) bit: A bit in status register ST1 that indi-
cates whether an ASP instruction has forced the SP to align to the next
even address (SPA = 1).
status registers ST0 and ST1: These CPU registers contain control bits
that affect the operation of the C28x and contain flag bits that reflect the
results of operations.
T
T register: The primary function of this register, also called the multiplicand
register, is to hold one of the values to be multiplied during a multiplica-
tion. The following shift instructions use the four LSBs to hold the shift
count: ASR (arithmetic shift right), LSL (logical shift left), LSR (logical
shift right), and SFR (shift accumulator right). The T register can also be
used as a general-purpose 16-bit register.
target device/system: The device/system on which the code you have de-
veloped is executed.
test/control flag (TC): A bit in status register ST0 that shows the result of
a test performed by the TBIT (test bit) instruction or the NORM (normal-
ize) instruction.
test-logic-reset: A test and emulation logic condition that occurs when the
TRST signal is pulled low or when the TMS signal is used to advance the
JTAG state machine to the TLR state. This logic is a different type than
that used by the CPU, which resets functional logic.
U
USER1−USER12 interrupts: The interrupt vector table contains twelve
locations for user-defined software interrupts. These interrupts, called
USER1−USER12 in this document, can be initiated only by way of the
TRAP instruction.
Glossary G-21
Glossary
V
V bit (overflow flag): A bit in status register ST0 that indicates when the re-
sult of an operation causes an overflow in the ___location holding the result
(V = 1). If no overflow occurs, V is not modified.
vector map (VMAP) bit: A bit in status register ST1 that determines the ad-
dresses to which the interrupt vectors are mapped. When VMAP = 0, the
interrupt vectors are mapped to addresses 00 000016−00 003F16 in pro-
gram memory. When VMAP = 1, the vectors are mapped to addresses
3F FFC016−3F FFFF16 in program memory.
W
W phase: See write (W) phase.
wait state: A cycle during which the CPU waits for a memory or peripheral
device to be ready for a read or write operation.
write (W) phase: The last of eight pipeline phases an instruction passes
through. In this phase, if a value or result is to be written to memory, the
CPU sends to memory the destination address and the data to be written.
See also pipeline phases.
Z
zero fill: Fill the unused low- and/or high-order bits of a value with 0s.
zero flag (Z): A bit in status register ST0 that indicates when the result of an
operation is 0 (Z = 1).
Index
Index
Index-1
Index
Index-2
Index
Index-3
Index
Index-4
Index
Index-5
Index
Index-6
Index
Index-7
Index
loop instruction status bit (LOOP) 2-35 MIN AX, loc16 6-153
loop while not zero 6-125 MINCUL P, loc32 6-154
LOOPNZ loc16, #16bit 6-125 MINL ACC, loc32 6-155
LOOPZ loc16, #16bit 6-127 mixing of C2xLP code and C28x code seg-
LPADDR 6-129 ments C-6
LRET 6-130 modes
high-impedance 7-5
LRETE 6-131
nonpreemptive 7-16
LRETER 6-132 normal with emulation disabled 7-5
LSL ACC, #1..16 6-133 normal with emulation enabled 7-5
LSL ACC, T 6-134 preemptive 7-16
LSL AX, #1016 6-135 real-time 7-7, 7-9
LSL AX, T 6-136 slave 7-5
stop 7-7
LSL64 ACC:P, #1..16 6-137
MOV *(0:16bit), loc16 6-156
LSL64 ACC:P, T 6-138
MOV AX, loc16 6-161
LSLL ACC, T 6-139
MOV ACC, #16bit<#0..15 6-157
LSR AX, #1016 6-140
MOV ACC, loc16 < T 6-158
LSR AX, T 6-141
MOV ACC, loc16<#0..16 6-159
LSR64 ACC:P, #1..16 6-142
MOV AR6, loc16 6-160
LSR64 ACC:P, T 6-143
MOV DP, #10bit 6-162
LSRL ACC, T 6-144
MOV IER, loc16 6-163
MOV loc16, #0 6-166
M MOV loc16, #16bit 6-164
MOV loc16, *(0:16bit) 6-165
M0 M1 map bit B-9
MOV loc16, AX 6-169
M0M1MAP B-9, E-4
MOV loc16, AX COND 6-170
MAC P, loc16, 0:pma 6-145
MOV loc16, IER 6-172
MAC P, loc16, *XAR7 6-147
MOV loc16, OVC 6-173
Mapping of memory blocks B0 and B1 on C27 E-7
MOV loc16, P 6-174
maskable interrupts 3-6
MOV OVC, loc16 6-176
definition 3-2
flow chart of operation 3-12 MOV PH, loc16 6-177
MAX AX, loc16 6-149 MOV PL, loc16 6-178
MAXCUL P, loc32 6-150 MOV PM, AX 6-179
MAXL ACC, loc32 6-152 MOV T, loc16 6-180
MOV TL, #0 6-181
memory 1-9
address map 1-8 MOV loc16, ARn 6-168
interface 1-9 MOV XARn, PC 6-182
reserved addresses 1-8 MOV loc16, T 6-175
memory map B-12, B-13, E-2 MOVA T, loc16 6-183
Memory space B-12 MOVAD T, loc16 6-185
memory wrappers 1-11 MOVB ACC, #8bit 6-187
migration 1-2 MOVB AR6/7, #8bit 6-188
migration flow C-3 MOVB AX.LSB, loc16 6-190
migration guidelines C-1 MOVB AX.MSB, loc16 6-192
Index-8
Index
Index-9
Index
Index-10
Index
Index-11
Index
Index-12
Index
Index-13
Index
Index-14
IMPORTANT NOTICE
Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications, enhancements, improvements,
and other changes to its products and services at any time and to discontinue any product or service without notice. Customers should
obtain the latest relevant information before placing orders and should verify that such information is current and complete. All products are
sold subject to TI’s terms and conditions of sale supplied at the time of order acknowledgment.
TI warrants performance of its hardware products to the specifications applicable at the time of sale in accordance with TI’s standard
warranty. Testing and other quality control techniques are used to the extent TI deems necessary to support this warranty. Except where
mandated by government requirements, testing of all parameters of each product is not necessarily performed.
TI assumes no liability for applications assistance or customer product design. Customers are responsible for their products and
applications using TI components. To minimize the risks associated with customer products and applications, customers should provide
adequate design and operating safeguards.
TI does not warrant or represent that any license, either express or implied, is granted under any TI patent right, copyright, mask work right,
or other TI intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information
published by TI regarding third-party products or services does not constitute a license from TI to use such products or services or a
warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual
property of the third party, or a license from TI under the patents or other intellectual property of TI.
Reproduction of TI information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompanied
by all associated warranties, conditions, limitations, and notices. Reproduction of this information with alteration is an unfair and deceptive
business practice. TI is not responsible or liable for such altered documentation. Information of third parties may be subject to additional
restrictions.
Resale of TI products or services with statements different from or beyond the parameters stated by TI for that product or service voids all
express and any implied warranties for the associated TI product or service and is an unfair and deceptive business practice. TI is not
responsible or liable for any such statements.
TI products are not authorized for use in safety-critical applications (such as life support) where a failure of the TI product would reasonably
be expected to cause severe personal injury or death, unless officers of the parties have executed an agreement specifically governing
such use. Buyers represent that they have all necessary expertise in the safety and regulatory ramifications of their applications, and
acknowledge and agree that they are solely responsible for all legal, regulatory and safety-related requirements concerning their products
and any use of TI products in such safety-critical applications, notwithstanding any applications-related information or support that may be
provided by TI. Further, Buyers must fully indemnify TI and its representatives against any damages arising out of the use of TI products in
such safety-critical applications.
TI products are neither designed nor intended for use in military/aerospace applications or environments unless the TI products are
specifically designated by TI as military-grade or "enhanced plastic." Only products designated by TI as military-grade meet military
specifications. Buyers acknowledge and agree that any such use of TI products which TI has not designated as military-grade is solely at
the Buyer's risk, and that they are solely responsible for compliance with all legal and regulatory requirements in connection with such use.
TI products are neither designed nor intended for use in automotive applications or environments unless the specific TI products are
designated by TI as compliant with ISO/TS 16949 requirements. Buyers acknowledge and agree that, if they use any non-designated
products in automotive applications, TI will not be responsible for any failure to meet such requirements.
Following are URLs where you can obtain information on other Texas Instruments products and application solutions:
Products Applications
Amplifiers amplifier.ti.com Audio www.ti.com/audio
Data Converters dataconverter.ti.com Automotive www.ti.com/automotive
DLP® Products www.dlp.com Broadband www.ti.com/broadband
DSP dsp.ti.com Digital Control www.ti.com/digitalcontrol
Clocks and Timers www.ti.com/clocks Medical www.ti.com/medical
Interface interface.ti.com Military www.ti.com/military
Logic logic.ti.com Optical Networking www.ti.com/opticalnetwork
Power Mgmt power.ti.com Security www.ti.com/security
Microcontrollers microcontroller.ti.com Telephony www.ti.com/telephony
RFID www.ti-rfid.com Video & Imaging www.ti.com/video
RF/IF and ZigBee® Solutions www.ti.com/lprf Wireless www.ti.com/wireless
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2009, Texas Instruments Incorporated