Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Overlays
◄Programs and Modules► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Overlays Defined
In an overlaid version of a program, specified parts of the program (known
as "overlays") are loaded only if and when they are needed. These parts
share the same space in memory at different times during program execution.
Only code is overlaid; data is never overlaid.
Why Use Overlays?
If you create very large BASIC programs, or programs that dynamically
allocate very large arrays, you may occasionally run out of memory during
execution. When this occurs, you can reduce memory requirements by using
overlays.
Programs that use overlays usually require less memory than other programs,
but they run more slowly because of the time needed to load the code from
disk into memory.
Specifying Overlays
You specify overlays by enclosing overlay modules in parentheses in the
list of object files that you submit to the LINK utility. Each module in
parentheses represents one overlay. For example, the following LINK command
line produces three overlays from the seven object files A through I:
LINK A + (B+C) + (E+F) + G + (I)
The modules (B+C), (E+F), and (I) are overlays. The remaining modules, and
any drawn from the run-time libraries, constitute the memory-resident code
or root of your program.
If expanded memory is present in your computer, overlays are loaded from
expanded memory; otherwise, overlays are loaded from disk. You can specify
that overlays only be loaded from disk by linking your program with the
NOEMS.OBJ stub file.
Limits on Overlays
Overlays are loaded into the same region of memory, so only one overlay
module can be resident at a time. Duplicate names in different overlays
are not supported, so each module can appear only once in a program.
You must compile each module in the program with compatible options. This
means, for example, that all modules must be compiled with the same
floating-point options.