Nesting and Fragmentation

Sections can be n ested to any level. When the Assembler encounters a nested section, the current section is stacked and the new section is used. When the ENDSEC directive of the nested section is encountered, the Assembler restores the old section and uses it. The ENDSEC directive always applies to the most recent SECTION directive. Nesting sections provides a measure of scoping for symbol names, in that symbols defined within a given section are visible to other sections nested within it. For example, if section B is nested inside section A, then a symbol defined in section A can be used in section B without XDEFing in section A or XREFing in section B. This scoping behavior can be turned off and on with the NONS and NS options, respectively.

Sections may also be split into separate parts. That is, sectionname can be used multiple times with SECTION and ENDSEC directive pairs. If this occurs, then these separate (but identically named) sections can access each other's symbols freely without the use of the XREF and XDEF directives. If the XDEF and XREF directives are used within one section, they apply to all sections with the same section name. The reuse of the section name is allowed to permit the program source to be arranged in an arbitrary manner (for example, all statements that reserve X space storage locations grouped together), but retain the privacy of the symbols for each section.