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-7
Section 2. CPU
CPU
2
2.3 SOFTWARE STACK POINTER
W15 serves as a dedicated Software Stack Pointer and is automatically modified by exception
processing, subroutine calls and returns. However, W15 can be referenced by any instruction in
the same manner as all other W registers. This simplifies reading, writing and manipulating the
Stack Pointer (e.g., creating stack frames).
W15 is initialized to 0x0800 during all Resets. This address ensures that the Stack Pointer (SP)
will point to valid RAM in all PIC24F devices and permits stack availability for non-maskable trap
exceptions, which may occur before the SP is initialized by the user software. The user may
reprogram the SP during initialization to any location within data space.
The Stack Pointer always points to the first available free word and fills the software stack,
working from lower towards higher addresses. It pre-decrements for a stack pop (read) and
post-increments for a stack push (writes), as shown in Figure 2-3.
When the PC is pushed onto the stack, the PC<15:0> bits are pushed onto the first available
stack word; then, the PC<22:16> bits are pushed onto the second available stack location. For
a PC push during any CALL instruction, the MSB of the PC is zero-extended before the push, as
shown in Figure 2-3. During exception processing, the MSB of the PC is concatenated with the
lower 8 bits of the CPU STATUS register, SR. This allows the contents of SRL to be preserved
automatically during interrupt processing.
Figure 2-3: Stack Operation for a CALL Instruction
Note: In order to protect against misaligned stack accesses, W15<0> is fixed to ‘0’ by the
hardware.
<Free Word>
PC<15:0>
PC<22:16>
015
W15 (before CALL)
W15 (after CALL)
Stack Grows Towards
Higher Address
B‘000000000’
CALL SUBR
Protego_Release_01_05-Related-OEM-Documentation-PIC24FJ32MC10X-Reference_Manual-Section2-CPU.pdf