Data Hiding

You may use sections to "hide" data and symbols from other parts of your project. This is useful for preserving name space and improving the readability of your code.

Symbols within a section are generally distinct from other symbols used elsewhere in the source program, even if the symbol name is the same. This is true as long as the section name associated with each symbol is unique, the symbol is not declared public ( XDEF or GLOBAL), and the GLOBAL or LOCAL qualifiers are not used in the section declaration. Symbols that are defined outside of a section are considered global symbols and have no explicit section name associated with them. Global symbols may be referenced freely from inside or outside of any section, as long as the global symbol name does not conflict with another symbol by the same name in a given section. Consider the following listing.:

Listing: Data Hiding Example
SYM1     EQU        1
SYM2     EQU        2

         SECTION    EXAMPLE

SYM1     EQU        3

         MOVE       #SYM1,R0

         MOVE       #SYM2,R1

         ENDSEC

         MOVE       #SYM1,R2

SYM1 and SYM2 are global symbols, initially defined outside of any section. Then in section EXAMPLE another instance of SYM1 is defined with a different value. Because SYM1 was redefined inside the section, the value moved to R0 is 3. Since SYM2 is a global symbol the value moved to R1 is 2. The last move to R2 is outside of any section and thus the global instance of SYM1 is used; the value moved to R2 is 1.

Issues surrounding data hiding include: