PreviousDebug Module Double-Byte Character Set SupportNext

Chapter 4: Segmentation

The segmentation module provides a capability to specify object program overlay requirements.

Segmentation provides a facility for specifying permanent and independent segments. Segmentation also allows the intermixing of sections with different segment-numbers and allows the fixed portion of the source program to contain segments that can be overlaid.

The Segmentation module is classed as an obsolete element in the ANSI'85 standard and is scheduled to be deleted from the next full revision of the ANSI Standard.

All dialects in this COBOL implementation fully support this syntax. The FLAGSTD directive can be used to detect all occurrences of this syntax.

Although it is a part of the standard COBOL definition, this module is explicity excluded from the X/Open COBOL language definitions and should not be used in a conforming X/Open COBOL source program.

4.1 General Description of Segmentation

COBOL segmentation is a facility that provides a means by which the user can communicate with your COBOL system to specify object program overlay requirements.

COBOL segmentation deals only with segmentation of procedures. As such, only the Procedure Division is considered in determining segmentation requirements for an object program.

4.1.1 Organization

4.1.1.1 Program Segments

Although it is not mandatory, the Procedure Division for a source program is often written as a consecutive group of sections, each of which is composed of a series of closely related operations that are designed to collectively perform a particular function. However, when segmentation is used, the entire Procedure Division must be in sections. In addition, each section must be classified as belonging either to the fixed portion or to one of the independent segments of the object program. Segmentation in no way affects the need for qualification of procedure-names to ensure uniqueness.

4.1.1.2 Fixed Portion

The fixed portion is defined as that part of the object program which is logically treated as if it were always in memory. This portion of the program is composed of fixed permanent segments, and fixed overlayable segments.

A fixed permanent segment is a segment in the fixed portion which cannot be overlaid by any other part of the program.

A fixed overlayable segment is a segment in the fixed portion which, although logically treated as if it were always in memory, can be overlaid by another segment to optimize memory utilization.

4.1.1.3 Independent Segments

An independent segment is defined as part of the object program which can overlay, and can be overlaid by either a fixed overlayable segment or another independent segment. An independent segment is in its initial state whenever control is transferred (either implicitly or explicitly) to that segment for the first time during the execution of a program. On subsequent transfers of control to the segment, an independent segment is also in its initial state when:

On subsequent transfer of control to the segment, an independent segment is in its last-used state when:

4.1.2 Segmentation Classification

Sections which are to be segmented are classified, using a system of segment-numbers and the following criteria:

4.1.3 Segmentation Control

The logical sequence of the program is the same as the physical sequence except for specific transfers of control. Control can be transferred in a source program to any paragraph in a section; that is, it is not mandatory to transfer control to the beginning of a section.

4.2 Structure of Program Segments

4.2.1 Segment-Numbers

Section classification is accomplished by means of a system of segment-numbers. The segment-number is included in the section header.

General Format

Syntax Rules

  1. The segment-number must be an integer ranging in value from 0 through 99.

  2. If the segment-number is omitted from the section header, the segment-number is assumed to be 0.

  3. Sections in the declaratives must contain segment-numbers less than 50.

  4. The segment-number must be a signed integer, but must not be a floating-point literal.

General Rules

  1. All sections which have the same segment-number constitute a program segment. All sections which have the same segment-number need not be physically contiguous in the source program.

  2. Segments with segment-number 0 through 49 belong to the fixed portion of the object program.

  3. Segments with segment-number 50 through 99 are independent segments.

4.2.2 Segment-Limit

General Format

The SEGMENT-LIMIT clause appears in the OBJECT-COMPUTER paragraph and has the following format:

Syntax Rules

  1. Segment-number must be an integer ranging in value from 1 thru 49.

General Rules

  1. The SEGMENT-LIMIT clause is treated as documentary.

4.3 Restrictions on Program Flow

When segmentation is used, the following restrictions are placed on the ALTER, PERFORM, MERGE and SORT statements.

4.3.1 The ALTER Statement

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

All other uses of the ALTER statement are valid and performed even if the GO TO to which the ALTER refers is in a fixed overlayable segment.

4.3.2 The PERFORM Statement

A PERFORM statement that appears in a section that is not in an independent segment can have within its range, in addition to any declarative sections whose execution is caused within that range, only one of the following:

A PERFORM statement that appears in an independent segment can have within its range, in addition to any declarative sections whose execution is caused within that range, only one of the following:

4.3.3 The MERGE Statement

If the MERGE statement appears in a section that is not in an independent segment, then any output procedure referenced by that MERGE statement must appear:

If a MERGE statement appears in an independent segment, then any output procedure referenced by that MERGE statement must be contained:

4.3.4 The SORT Statement

If a SORT statement appears in a section that is not an independent segment, then any input procedures or output procedures referenced by that SORT statement must appear:

If a SORT statement appears in an independent segment, then any input procedures or output procedures referenced by that SORT statement must be contained:


Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.
PreviousDebug Module Double-Byte Character Set SupportNext