6.1.9.22 Global Directive
The GLOBAL identifier_list
directive
declares a list of comma-separated symbols. If the symbols are defined within the current
module, they are made public. If the symbols are not defined in the current module, they
are made references to public symbols with the same name that are defined in other modules.
Thus, to use the same symbol in more than one module, the GLOBAL
directive
must be used multiple times: once in the module that defines the symbol to make that symbol
public, and again in each module that uses the symbol, to allow that symbol to link in with
the external definition.
lab1
and lab2
are both defined in file1.S and made globally accessible. In
file2.S, they are accessed.;file1.S
#include <xc.inc>
GLOBAL lab1,lab2
PSECT udata_bank2
lab1:
DS 1
lab2:
DS 2
;file2.S
#include <xc.inc>
GLOBAL lab1,lab2
PSECT code
movlw 0xfe
BANKSEL 2
movwf BANKMASK(lab1)
movwf BANKMASK(lab2)
Only symbols that are marked as being globally accessible will be visible in debuggers,
since there can be more than one local symbol in separate assembly modules with the same
name. Thus, you might need to use the GLOBAL
directive in order to watch
symbols associated with variables.