Microsoft KB Archive/38067

From BetaArchive Wiki

How to Use Segmentation in COBOL Version 3.0

PSS ID Number: Q38067 Article last modified on 04-20-1993

3.00 | 3.00 MS-DOS | OS/2

The information in this article applies to:
- Microsoft COBOL for MS-DOS and OS/2, version 3.0

Summary: The segmentation facility of Microsoft COBOL allows programs larger than physical memory to be compiled and executed. When you use segmentation, the entire PROCEDURE DIVISION must be written in sections. Section numbers less than 50 are fixed segments while those greater than 49 are independent segments. A PERFORM statement in a fixed segment may have its target in either a fixed or independent segment. However, a PERFORM statement in an independent segment may only target a fixed segment or a paragraph within its own segment. See Chapter 7 of the “Microsoft COBOL Compiler Version 3.0: Language Reference Manual” for more information on this subject.

More Information: Segmentation is not allowed under MS OS/2 protected mode. The code shown below is an example of the correct syntax to enable segmentation. Note: the code below includes the MS(2) compiler directive and is required. When this code is compiled, the following five files with a .OBJ filename extension will be generated: SEGMEN.OBJ SEGMEN01.OBJ SEGMEN02.OBJ SEGMEN03.OBJ SEGMEN04.OBJ Intermediate code for each of the independent segments will also be generated and will have the filename extensions .I50 to .I53. The compiler will also generate a response file with the name SEGMEN.LNK. To create the executable program, do the following: 1. Compile in a normal manner, as in the following example: COBOL SEGMEN; 2. Link with a command such as the following: LINK @SEGMEN.LNK + @ADIS.LNK The following is a code example:

  $SET MS"2"
   identification division.
   program-id. SEGMEN.
  *
  * Example:  DEMONSTRATE USING SEGMENTATION IN
  *           COBOL  3.0
  *
   environment division.
   data division.
   working-storage section.
   01   mov-value  pic 9 value 1.
   01   tble.
         05  tbl-ent occurs 5 times pic 9.
  * INCLUDES THE INKEY TO PROVIDE A BREAK TO ALLOW A
  * PERSON TO NOTICE THAT THE DISK IS ACCESSED
   01 INKEY PIC X.
   procedure division.
   A SECTION 01.
   para1.
         perform loop-it until mov-value = 6.
         perform SEE5.
         ACCEPT INKEY.
         perform SEE1.
         ACCEPT INKEY.
         PERFORM SEE2.
         ACCEPT  INKEY.
         PERFORM SEE3.
         ACCEPT INKEY.
         PERFORM SEE4.
         ACCEPT INKEY.
         PERFORM SEE5.
         stop run.
   B SECTION 02.
   loop-it.
         move mov-value to tbl-ent (mov-value).
         add 1 to mov-value.
   C SECTION 49.
   SEE1.
         exhibit tbl-ent (1).
  * ALL SECTION GREATER THAN 49 ARE SEPARATELY
  * GENERATED OVERLAYS -- AND WILL BE SEPARATE
  * DISK FILES.
   G SECTION 50.
   SEE2.
         exhibit tbl-ent (2).
   D SECTION 51.
   SEE3.
         exhibit tbl-ent (3).
   E SECTION 52.
   SEE4.
         exhibit tbl-ent (4).
   F SECTION 53.
   SEE5.
         exhibit tbl-ent (5).

Additional reference words: 3.00 Copyright Microsoft Corporation 1993.