# Vault 7: Projects

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

### Protego

# PIC24FJ64GA004 - Programmers Reference Manual

- 1
- 2
…
- 77
- 78
- 79
- 80
- 81
…
- 501
- 502

© 2005-2011 Microchip Technology Inc. DS70157F-page 79
Section 4. Instruction Set Details
Instruction Set
Details
4
4.10.2 Implied Frame and Stack Pointer
To accommodate software stack usage, W14 is the implied Frame Pointer (used by the LNK and
ULNK instructions) and W15 is the implied Stack Pointer (used by the CALL, LNK, POP, PUSH,
RCALL, RETFIE, RETLW, RETURN, TRAP and ULNK instructions). Even though W14 and
W15 have this implied usage, they may still be used as generic operands in any instruction, with
the exceptions outlined in
Section 4.10.1 “Implied DSP Operands (dsPIC30F, dsPIC33F and
dsPIC33E Devices)”. If W14 and W15 must be used for other purposes (it is strongly advised
that they remain reserved for the Frame and Stack Pointer), extreme care must be taken such
that the run-time environment is not corrupted.
4.10.3 PIC
®
Microcontroller Compatibility
4.10.3.1 DEFAULT WORKING REGISTER WREG
To ease the migration path for users of the Microchip 8-bit PIC MCU families, the 16-bit MCU and
DSC devices have matched the functionality of the PIC MCU instruction sets as closely as
possible. One major difference between the 16-bit MCU and DSC and the 8-bit PIC MCU
processors is the number of working registers provided. The 8-bit PIC MCU families only provide
one 8-bit working register, while the 16-bit MCU and DSC families provide sixteen, 16-bit working
registers. To accommodate for the one working register of the 8-bit PIC MCU, the 16-bit MCU
and DSC device instruction set has designated one working register to be the default working
register for all legacy file register instructions. The default working register is set to W0, and it is
used by all instructions which use file register addressing.
Additionally, the syntax used by the 16-bit MCU and DSC device assembler to specify the default
working register is similar to that used by the 8-bit PIC MCU assembler. As shown in the detailed
instruction descriptions in
Section 5. “Instruction Descriptions”, “WREG” must be used to
specify the default working register. Example 4-16 shows several instructions that use WREG.
Example 4-16: Using the Default Working Register WREG
4.10.3.2 PRODH:PRODL REGISTER PAIR
Another significant difference between the Microchip 8-bit PIC MCU and 16-bit MCU and DSC
architectures is the multiplier. Some PIC MCU families support an 8-bit x 8-bit multiplier, which
places the multiply product in the PRODH:PRODL register pair. The 16-bit MCU and DSC
devices have a 17-bit x 17-bit multiplier, which may place the result into any two successive
working registers (starting with an even register), or an accumulator.
Despite this architectural difference, the 16-bit MCU and DSC devices still support the legacy file
register multiply instruction (MULWF) with the “MUL{.B} f” instruction (described on page 303).
Supporting the legacy MULWF instruction has been accomplished by mapping the
PRODH:PRODL registers to the working register pair W3:W2. This means that when “MUL{.B}
f” is executed in Word mode, the multiply generates a 32-bit product which is stored in W3:W2,
where W3 has the most significant word of the product and W2 has the least significant word of
the product. When “MUL{.B} f” is executed in Byte mode, the 16-bit product is stored in W2,
and W3 is unaffected. Examples of this instruction are shown in
Example 4-17.
ADD RAM100 ; add RAM100 and WREG, store in RAM100
ASR RAM100, WREG ; shift RAM100 right, store in WREG
CLR.B WREG ; clear the WREG LS Byte
DEC RAM100, WREG ; decrement RAM100, store in WREG
MOV WREG, RAM100 ; move WREG to RAM100
SETM WREG ; set all bits in the WREG
XOR RAM100 ; XOR RAM100 and WREG, store in RAM100

- 1
- 2
…
- 77
- 78
- 79
- 80
- 81
…
- 501
- 502