3.3 Include Files

Just as with C source code, assembly code can include the content of other files.

The best way to include files into your source code is with the #include directive. As this is a preprocessor directive, the preprocessor must be run over the source file for it to be executed. To do this, use a (capital) .S extension with the source file name or use the -xassembler-with-cpp option.

The preprocessor will search for included files specified in angle brackets, < >, from standard directories in the assembler distribution. Searches for file names that are quoted, " ", will begin in the current working directory, then in the standard directories. You can specify additional search paths by using the -I option.

All but the most trivial of assembly programs will need to include the <xc.inc> include file, as shown in this chapter's example by the line:
#include <xc.inc>
This include file is provided by the PIC Assembler and allows your source code to access special function registers, predefined psects and macros, and other device features. Do not include device-specific include files (for example, do not include files like pic18lf8720.inc) or maintain your own version of these files, as their content might change in future versions of the assembler.