Assigning Code Segments to Overlays Using MOVE

ID: Q87926

5.30 5.31 5.50 5.60 MS-DOS kbtool

The information in this article applies to:

SUMMARY

Version 5.3 of the Microsoft Segmented Executable Linker (LINK) introduces the ability to build executable files that contain dynamic overlays and use the Microsoft Overlaid Virtual Environment (MOVE). MOVE uses a module-definition (.DEF) file to define the organization of the overlays. The text below describes the syntax of a module- definition file for an application that uses MOVE.

MORE INFORMATION

This information describes only the process of using the SEGMENTS statement to allocate entire code segments to overlays; it does not describe the process of using the FUNCTIONS statement to allocate individual functions to specific overlays. For information on the latter process, query in the Microsoft Knowledge Base on the following words:

   functions and statement and overlays and pwb and move and def

The article is titled "Assigning Functions to Overlays Using MOVE."

An overlaid program contains a root portion, code that remains resident throughout program execution, and one or more overlays, that the overlay manager can swap into and out of conventional memory as needed. MOVE allows more than one overlay to be resident in conventional memory simultaneously (if space permits) and it can swap an overlay to extended or expanded memory (if available).

When compiling an overlaid program, use the medium or large memory model, both of which support multiple code segments. Because the small and compact memory models support only one code segment, they do not support overlays.

The compiler assigns names to code segments. In the medium and large memory model, the default name of each segment has the form <modulename>_TEXT. The compiler uses the default naming convention unless the code contains the alloc_text pragma or the __based keyword or the compiler command line includes the /NT option.

LINK version 5.3 uses the SEGMENTS statement in the .DEF file to assign segments to overlays.

The following example demonstrates creating overlays. Consider an application that contains four source files, which are compiled as follows:

   cl /c /AM file1.c file2.c file3.c file4.c

Linking the application with the following creates an overlaid program:

   SEGMENTS
      FILE2_TEXT OVL:1
      FILE3_TEXT OVL:2
      FILE4_TEXT OVL:2

Note that LINK assigns data segments and code segments that are not listed in the SEGMENTS statement to the resident portion of the program (overlay 0).

The LINK command line to build this application might resemble the following:

   LINK file1 file2 file3 file4, myapp.exe,,,myapp.def;

In this example, LINK creates an example called MYAPP.EXE with a resident portion (that contains code from FILE1.OBJ and from the C run- time library), and two overlays. The first overlay contains code from FILE2.OBJ and the second overlay contains code from FILE3.OBJ and from FILE4.OBJ.

LINK also supports another syntax to create overlays. On the LINK command line, place parentheses around the names of object files to assign object files to overlays. While the current versions of LINK support this alternate syntax, it may not be supported in the future. Using the old syntax, the LINK command line that corresponds to the example above is as follows:

   LINK file1 (file2) (file3 file4), myapp.exe;

The main advantage of the .DEF file syntax to build an overlaid program is its ease of use with Programmer's WorkBench (PWB). After listing the segments, include the .DEF file in the project list to build the overlaid program.

REFERENCE

Additional reference words: kbinf kbinf 5.30 5.31.009 5.50 moveoverlay PwbIss visualc KBCategory: kbtool KBSubcategory: MoveOverlay
Keywords          : kb16bitonly MoveOverlay 
Version           : 5.30 5.31 5.50 5.60
Platform          : MS-DOS

Last Reviewed: July 19, 1997