dsPIC30F Family Reference Manual
DS70049C-page 2-6 © 2004 Microchip Technology Inc.
2.2.1 Working Register Array
The 16 working (W) registers can function as data, address or address offset registers. The
function of a W register is determined by the Addressing mode of the instruction that accesses it.
The dsPIC30F instruction set can be divided into two instruction types: register and file register
instructions. Register instructions can use each W register as a data value or an address offset
value. For example:
MOV W0,W1 ; move contents of W0 to W1
MOV W0,[W1] ; move W0 to address contained in W1
ADD W0,[W4],W5 ; add contents of W0 to contents pointed
; to by W4. Place result in W5.
2.2.1.1 W0 and File Register Instructions
W0 is a special working register because it is the only working register that can be used in file
register instructions. File register instructions operate on a specific memory address contained
in the instruction opcode and W0. W1-W15 cannot be specified as a target register in file register
instructions.
The file register instructions provide backward compatibility with existing PICmicro
®
devices
which have only one W register. The label ‘WREG’ is used in the assembler syntax to denote W0
in a file register instruction. For example:
MOV WREG,0x0100 ; move contents of W0 to address 0x0100
ADD 0x0100,WREG ; add W0 to address 0x0100, store in W0
2.2.1.2 W Register Memory Mapping
Since the W registers are memory mapped, it is possible to access a W register in a file register
instruction as shown below:
MOV 0x0004, W10 ; equivalent to MOV W2, W10
where 0x0004 is the address in memory of W2.
Further, it is also possible to execute an instruction that will attempt to use a W register as both
an address pointer and operand destination. For example:
MOV W1,[W2++]
where:
W1 = 0x1234
W2 = 0x0004 ;[W2] addresses W2
In the example above, the contents of W2 are 0x0004. Since W2 is used as an address pointer,
it points to location 0x0004 in memory. W2 is also mapped to this address in memory. Even
though this is an unlikely event, it is impossible to detect until run-time. The dsPIC30F ensures
that the data write will dominate, resulting in W2 = 0x1234 in the example above.
2.2.1.3 W Registers and Byte Mode Instructions
Byte instructions which target the W register array only affect the Least Significant Byte of the
target register. Since the working registers are memory mapped, the Least and Most Significant
Bytes can be manipulated through byte wide data memory space accesses.
2.2.2 Shadow Registers
Many of the registers in the programmer’s model have an associated shadow register as shown
in Figure 2-2. None of the shadow registers are accessible directly. There are two types of
shadow registers: those utilized by the PUSH.S and POP.S instructions and those utilized by the
DO instruction.
Note: For a complete description of Addressing modes and instruction syntax, please
refer to the dsPIC30F Programmer’s Reference Manual (DS70032).