# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Protego

# PIC24FJ64GA004 - Programmers Reference Manual

- 1
- 2
…
- 70
- 71
- 72
- 73
- 74
…
- 501
- 502

16-bit MCU and DSC Programmer’s Reference Manual
DS70157F-page 72 © 2005-2011 Microchip Technology Inc.
Figure 4-7: Stack Pointer After “PUSH W1” Instruction
Figure 4-8: Stack Pointer After “POP W3” Instruction
4.7.2 Software Stack Frame Pointer
A Stack Frame is a user-defined section of memory residing in the software stack. It is used to
allocate memory for temporary variables which a function uses, and one Stack Frame may be
created for each function. W14 is the default Stack Frame Pointer (FP) and it is initialized to
0x0000 on any Reset. If the Stack Frame Pointer is not used, W14 may be used like any other
working register.
The link (LNK) and unlink (ULNK) instructions provide Stack Frame functionality. The LNK
instruction is used to create a Stack Frame. It is used during a call sequence to adjust the SP,
such that the stack may be used to store temporary variables utilized by the called function. After
the function completes execution, the ULNK instruction is used to remove the Stack Frame
created by the LNK instruction. The LNK and ULNK instructions must always be used together to
avoid stack overflow.
0x0000
0xFFFE
0x0800
W15 (SP)
W15 = 0x0804
W0 = 0x5A5A
W1 = 0x3636
5A5A
<TOS>
0x0802
3636
0x0804
0x0000
0xFFFE
0x0800
W15 (SP)
W15 = 0x0802
W0 = 0x5A5A
W1 = 0x3636
5A5A
0x0802
<TOS>
0x0804
W3 = 0x3636
Note: The contents of 0x802, the new TOS, remain unchanged (0x3636).

- 1
- 2
…
- 70
- 71
- 72
- 73
- 74
…
- 501
- 502