Vault 7: Projects
This publication series is about specific projects related to the Vault 7 main publication.
© 2006 Microchip Technology Inc. Advance Information DS39703A-page 2-5
Section 2. CPU
CPU
2
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 PIC24F 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:
Example 2-1: Register Instructions
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:
Example 2-2: File Register Instructions
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:
Example 2-3: Access W Register in File Register Instruction
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:
Example 2-4: W Register Used as Address Pointer and Operand Destination
In Example 2-4, 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 PIC24F ensures that the data
write will dominate, resulting in W2 = 0x1234 in the example above.
Note: For a complete description of addressing modes and instruction syntax, please refer
to the
“dsPIC30F Programmer’s Reference Manual”
(DS70030).
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.
MOV WREG, 0x0100 ; move contents of W0 to address 0x0100
ADD 0x0100, WREG ; add W0 to address 0x0100, store in W0
MOV 0x0004, W10 ; equivalent to MOV W2, W10
where:
0x0004 is the address in memory of W2
MOV W1, [W2++]
where:
W1 = 0x1234
W2 = 0x0004 ;[W2] addresses W2
Protego_Release_01_05-Related-OEM-Documentation-PIC24FJ32MC10X-Reference_Manual-Section2-CPU.pdf