Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

General rules for segmentation

  1. If the sections that belong to a given segment, i.e. sections which have the same segment-number, are scattered through the compilation unit, they must be reordered by the compiler. However, the compiler will maintain the logic flow of the compilation unit. The compiler will also insert statements necessary to load and/or initialize a segment as necessary. Control may be transferred within a compilation unit to any paragraph in a section; that is, it is not mandatory to transfer control to the beginning of a section.

  2. Only the fixed segments remain in internal storage throughout program execution. Both the overlayable fixed segments and the independent segments may overlay one another.

  3. The following criteria should be noted when classifying segments:

    Logical requirements:

    Sections that must be available for reference at all times or which are referred to frequently should be classified as one of the permanent segments; sections that are less frequently used should be classified as one of the overlayable fixed segments or one of the independent segments, in accordance with the logic requirements of the program flow.

    Relationship to other sections:

    Sections that frequently communicate with one another should be given equal segment-numbers. All sections with the same segment-number each constitute a program segment.

  4. When segmentation is used, the following rules apply to the ALTER, PERFORM, MERGE and SORT statements as well as the called programs:

    ALTER statement:

    1. A GO TO statement in a section whose segment-number is greater than or equal to 50 must not be referenced by an ALTER statement in a section with a different segment-number.

    2. A GO TO statement in a section whose segment-number is less than 50 may be referenced by an ALTER statement in any section, even if the GO TO statement referenced by the ALTER statement belongs to a program segment which has not yet been called for execution.

    PERFORM statement: 

    1. A PERFORM statement that appears in a section whose segment-number is less than the segment-number supplied in the SEGMENT-LIMIT clause can have within its range only the following:

      • Sections each having a segment-number less than 50.

      • Sections wholly contained in a single segment whose segment number is greater than 49.

      However, the compiler permits the PERFORM statement to reference, within its range, sections having any section number.

    2. A PERFORM statement appearing in a section whose segment-number is equal to or greater than the segment number specified in the SEGMENT-LIMIT clause can have within its range only one of the following:

      • Sections each having the same segment-number as that of the section containing the PERFORM statement.

      • Sections each having a segment-number less than that specified in the SEGMENT-LIMIT clause.

    However, the compiler permits the PERFORM statement to reference, within its range, sections having any section number. 

    SORT/MERGE statement:

    1. When using a SORT or MERGE statement within a section which is not an independent segment, the input procedures or output procedures referenced by that SORT or MERGE statement:

      • must be contained wholly within independent segments,

      • or must be contained wholly within a single independent segment.

    2. When using a SORT or MERGE statement within an independent segment, the input procedures or output procedures referenced by that SORT or MERGE statement:

      • must be wholly contained within independent segments, or

      • must be wholly contained within the same independent segment as the SORT or MERGE statement.

    These restrictions do not apply to the compiler discussed in this manual.

    Called programs

    A program that was called by a CALL statement may have its entry points only in the permanent segment.