
Software Project Management
Sections And Data Hiding
MOTOROLA
DSP ASSEMBLER REFERENCE MANUAL
For More Information On This Product,
Go to: www.freescale.com
4-3
XDEF
ed symbols by default are recognized only in other sections which
XREF
them.
They can be made fully global (recognizable by sections which do not
XREF
them) by use
of the
XR
option (see the
OPT
directive, Chapter 6). Alternatively the
GLOBAL
directive
(see Chapter 6) may be used within a section to make the named symbols visible outside
of the section. Both the
XDEF
and
XREF
directives must be used before the symbols to
which they refer are defined or used in the section. Here is another example:
SYM1
EQU
SECTION
XDEF
EQU
EQU
ENDSEC
SECTION
XREF
MOVE
MOVE
ENDSEC
MOVE
1
SECT1
SYM2
2
3
SYM1
SYM2
SECT2
SYM2
#SYM1,R0
#SYM2,R1
#SYM2,R2
SYM1 is first defined outside of any section. Then in section SECT1 SYM2 is declared
public with an
XDEF
directive. SYM1 is also defined locally to section SECT1. In section
SECT2 SYM2 is declared external via the
XREF
directive, followed by a move of SYM1
to R0. Since SYM1 was defined locally to section SECT1, the Assembler uses the global
value and moves a 1 to R0. Because SYM2 was declared external in section SECT1 the
value moved to R1 is 3. If SYM2 had not been
XREF
ed in section SECT2 the value
moved to R1 would have been unknown at this point. In the last instruction it is not known
what value will be moved to R2 since SYM2 was not defined outside of any section or was
not declared
GLOBAL
within a section.
If the
GLOBAL
qualifier follows the <section name> in the
SECTION
directive, then all
symbols defined in the section until the next
ENDSEC
directive are considered global.
The effect is as if every symbol in the section were declared with the
GLOBAL
directive.
This is useful when a section needs to be independently relocatable, but data hiding is not
required.
If the
LOCAL
qualifier follows the <section name> in the
SECTION
directive, then all sym-
bols defined in the section until the next
ENDSEC
directive are visible to the immediately
enclosing section. The effect is as if every symbol in the section were defined within the
parent section. This is useful when a section needs to be independently relocatable, but
data hiding within an enclosing section is not required.
Symbols that are defined with the
SET
directive can be made visible with
XDEF
only in
absolute mode, and the section name associated with the symbol will be the section name
of the section where the symbol was first defined. This will be true even if the symbol value
is changed in another section.
F
Freescale Semiconductor, Inc.
n
.