Vault 7: Projects
This publication series is about specific projects related to the Vault 7 main publication.
PIC24F Family Reference Manual
DS39703A-page 2-6 Advance Information © 2006 Microchip Technology Inc.
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
Some of the registers have a shadow register associated with them as shown in Table 2-5. The
shadow register is used as a temporary holding register and can transfer its contents to or from
its host register upon some occurring event. None of the shadow registers are accessible directly.
The PUSH.S and POP.S shadow rule is applied to register transfer into and out of shadows.
2.2.2.1 PUSH.S AND POP.S SHADOW REGISTERS
The PUSH.S and POP.S instructions are useful for fast context save/restore during a function call
or Interrupt Service Routine (ISR). The PUSH.S instruction will transfer the following register
values into their respective shadow registers:
• W0...W3
• SR (N, OV, Z , C, DC bits only)
The POP.S instruction will restore the values from the shadow registers into these register
locations. A code example using the PUSH.S and POP.S instructions is shown in Example 2-5.
Example 2-5: PUSH.S and POP.S Instructions
The PUSH.S instruction will overwrite the contents previously saved in the shadow registers. The
shadow registers are only one level in depth, so care must be taken if the shadow registers are
to be used for multiple software tasks.
The user must ensure that any task using the shadow registers will not be interrupted by a higher
priority task that also uses the shadow registers. If the higher priority task is allowed to interrupt
the lower priority task, the contents of the shadow registers saved in the lower priority task will
be overwritten by the higher priority task.
2.2.3 Uninitialized W Register Reset
The W register array (with the exception of W15) is cleared during all Resets and is considered
uninitialized until written to. An attempt to use an uninitialized register as an Address Pointer will
reset the device. Refer to Section 7. “Reset” for more details (check Microchip web site for
availability: www.microchip.com).
A word write must be performed to initialize a W register. A byte write will not affect the initialization
detection logic.
MyFunction:
PUSH.S ; Save W registers, MCU status
MOV #0x03, W0 ; load a literal value into W0
ADD RAM100 ; add W0 to contents of RAM100
BTSC SR, #Z ; is the result 0?
BSET Flags, #IsZero ; Yes, set a flag
POP.S ; Restore W regs, MCU status
RETURN
Protego_Release_01_05-Related-OEM-Documentation-PIC24FJ32MC10X-Reference_Manual-Section2-CPU.pdf