dsPIC30F
DS70043A-page 14 Advance Information 2002 Microchip Technology Inc.
3.1.1 COMPILER DRIVEN
ENHANCEMENTS
In addit ion to D SP perf ormanc e requ iremen ts, the co re
architecture was strongly influenced by recommenda-
tions which would lead to a more efficient (code size
and speed) C compiler.
1. For most instructions, th e core is capabl e of exe-
cuting a data (or program data) memory read, a
working register (data) read, a data memory
write and a program (instruction) memory read
per instruction cycle. As a result, 3 operand
instructions can be supported, allowing C= A+B
operations to be executed in a single cycle.
2. Instruction addressing modes are extremely
flexible to meet compiler needs.
3. The working register array is comprised of 16 x
16-bit registers, each of which can act as data,
address or offset reg isters. One work ing register
(W15) operate s as the software sta ck pointer for
interrupts and calls.
4. Linear indirect access of all data space is
possible, plus the memory direct address range
has been extended to 8 Kbytes. This, together
with the addition of 16-bit direct address MOV
based instructions, has provided a contiguous
linear addressing space.
5. Linear indirect access of 32K word (64 Kbyte)
pages within program space is possible, using
any working register via new table read and
write instructions.
6. Part of data sp ace c an be ma ppe d i nto program
spa ce, allowi ng const ant dat a to be acc essed as
if it were in data space.
3.1.2 INSTRUCTION FETCH MECHANISM
A one-stage pre-fetching mechanism accesses each
instruction a cycle ahead to maximize available
execution time. Most instructions execute in a single
cycl e. Exceptions are:
1. Flow control instructions (such as program
Branches, Calls, Returns) take 2 cycles, since
the IR (instruction register) and pre-fetc h buffer
must be flushed and refilled.
2. Instr uct ion s w her e one opera nd is t o be fet che d
from prog ram space (using a ny me tho d). T hes e
operations consume 2 cycles (with the notable
exception of instructions executed within a
REPEAT loop, which executes in 1 cycle).
3. Double-word move based instructions.
Most instructions access data as required during
instruc tion executi on. Instructio ns which u tilize the mu l-
tiplier array must have data available at the beginning
of the instruction cycle. Consequently, this data must
be pre-fetched, usually by the preceding instruction,
resulting in a simple out of order data processing
model.
3.2 Pro grammer’s Model
The programmer’s model is shown in Figure 3-1 and
consists of 16 x 16-bit working registers (W0 through
W15), 2 x 40-bit accumulators (ACCA and ACCB),
Status register (SR), Data Table Page register
(TBLPAG), Program Space Visibility Page register
(PSVPAG), DO and REPEAT registers (DOSTART,
DOEND, DCOUNT and RCOUNT), and Program
Counter (PC). The working registers can act as data,
address or offset registers. All registers are memory
mapped. W0 is the W register for all instructions that
perform file regi ster addressing.
Most of these registers have a shadow register
associated with them, as shown in Figure 3-1. The
shadow register is used as a temporary ho lding register
and can t r ans fer i t s con ten t s t o or from its host register
upon some event occurring. None of the shadow
registers are accessible directly. The following rules
apply for transfer of registers into and out of shadows.
•PUSH.s and POP.s
W0...W14, TBLP AG, PSVPAG, SR (DC, N, OV, SZ
and C bits only) transferred
•DO instr ucti on
DA bit, DOSTART, DOEND, DCOUNT shadows
pushed on loop start, popped on loop end
When a byte operation is performed on a working
register, only the Least Significant Byte of the target
register is affected. However, a benefit of memory
mapped working registers is that both the Least and
Most Significant Bytes can be manipulated through
byte wide data memory space accesses.
3.2.1 SOFTWARE STACK P OINTER/
FRAM E POIN TE R
W15 is the dedicated software stack pointer (SP), and
will be automatically modified by exception processing
and sub routine calls and r eturns. However , W15 can be
referenced by any instruction in the same manner as all
other W registers. This simplifies the reading, writing
and manipulation of the stack pointer (e.g., creating
stac k fram es ).
In order to protect against misaligned stack accesses,
W15<0> is always clear.
W15 is initialized to 0x0800 during a RESET. The user
may reprogram the SP during initialization to any
location withi n data space greater than 0x0800.
W14 has been dedicated as a stack frame pointer, as
defined by the LNK and ULNK instructions. However,
W14 can be referenced by any instruction in the same
manner as all other W registers.
The stack pointer always points to the first available
free word and grows from lower addresses towards
higher addresses. It pre-decrements for stack pops
(reads) and post increments for stack pushes (writes).