38.2 Extended Instruction Set
In addition to the standard 75 instructions of the PIC18 instruction set, PIC18F27/47Q10 devices also provide an optional extension to the core CPU functionality. The added features include eight additional instructions that augment Indirect and Indexed Addressing operations and the implementation of Indexed Literal Offset Addressing mode for many of the standard PIC18 instructions.
The additional features of the extended instruction set are disabled by default. To enable them, users must set the XINST Configuration bit.
The instructions in the extended set can all be classified as literal operations, which either manipulate the File Select Registers, or use them for Indexed Addressing. Two of the instructions, ADDFSR and SUBFSR, each have an additional special instantiation for using FSR2. These versions (ADDULNK and SUBULNK) allow for automatic return after execution.
The extended instructions are specifically implemented to optimize re-entrant program code (that is, code that is recursive or that uses a software stack) written in high-level languages, particularly C. Among other things, they allow users working in high-level languages to perform certain operations on data structures more efficiently. These include:
- dynamic allocation and deallocation of software stack space when entering and leaving subroutines
- function pointer invocation
- software Stack Pointer manipulation
- manipulation of variables located in a software stack
A summary of the instructions in the extended instruction set is provided in 38.2.1 Extended Instruction Syntax. Detailed descriptions are provided in 38.2.2 Extended Instruction Set. The opcode field descriptions in 38.1 Standard Instruction Set apply to both the standard and extended PIC18 instruction sets.