5.12.3.6 Undefined Symbols
If an object is defined in C source code, but is only accessed in assembly code, the compiler might ordinarily remove the object believing it is unused, resulting in an undefined symbol error.
To work around this issue, MPLAB XC8 searches for symbols in
assembly code that have no assembly definition (which would typically be a label). If these
symbols are encountered in C source they are automatically treated as being
volatile
(see 5.3.8.2 Volatile Type Qualifier), which will prevent them from being
removed.
For example, if a C program defines a variable as follows:
int input;
but this variable is never used in C code. The assembly module(s) can
simply declare this symbol, with the leading underscore character (see 5.12.3 Interaction between Assembly and C Code), using the
GLOBAL
assembler directive and then use it as follows.
GLOBAL _input, _raster
PSECT text,local,class=CODE,reloc=2
_raster:
movf _input,w