Microsoft KB Archive/63161

= Overlaid Modules Loaded into EM Only When 1st Overlay Called =

Article ID: 63161

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1

-



This article was previously published under Q63161



SUMMARY
When using expanded memory with an overlaid program, the overlaid modules are not loaded when the EXE file is invoked. They remain on disk until the first overlay is called. When this occurs, all the overlaid modules are loaded from disk into expanded memory. From then on, the overlays are swapped to and from expanded memory and the disk is no longer needed for that purpose.

This information applies to Microsoft Basic Professional Development System (PDS) versions 7.00 and 7.10.

For more information about using linker overlays in Basic PDS 7.00 and 7.10, search for a separate article in this Knowledge Base with the following words:

LINK and overlays and expanded and memory and Basic



MORE INFORMATION
To demonstrate this characteristic of Basic overlays, boot up with an Lotus/Intel/Microsoft (LIM) version 4.0 Expanded Memory Specification (EMS) device driver and compile and link the three modules below as follows: bc main; bc overlay1; bc overlay2; link main+(overlay1)+(overlay2);

MAIN.BAS
'* NOTE: The disk activity will be most obvious if this test '       is run on a floppy drive. PRINT &quot;MAIN&quot; PRINT &quot;HIT ANY KEY TO LOAD OVERLAYS INTO EMS&quot; SLEEP CALL ovl1 PRINT &quot;OVERLAYS LOADED&quot; PRINT &quot;HIT ANY KEY TO CALL SECOND OVERLAY&quot; PRINT &quot;THERE SHOULD BE NO DISK ACTIVITY IF YOU HAVE EMS&quot; SLEEP CALL ovl2 PRINT &quot;HIT ANY KEY TO END THE PROGRAM&quot; SLEEP END

OVERLAY1.BAS
SUB ovl1 PRINT &quot;OVERLAY1&quot; END SUB

OVERLAY2.BAS
SUB ovl2 PRINT &quot;OVERLAY2&quot; END SUB When run, the resulting EXE file (MAIN.EXE) produces the following output:

MAIN

OVERLAY1

OVERLAY2

However, before &quot;OVERLAY1&quot; is displayed, there will be disk activity while the code for overlay1 is loaded into the overlay area of conventional memory (for execution) and overlay2 is loaded into expanded memory. To see this clearly, run MAIN.EXE from a floppy drive. When overlay2 is called, there will be no disk activity because it will be swapped in from expanded memory.

Note that this is not a problem with Basic PDS 7.00 or 7.10, but a feature of the overlay manager. However, it can present a speed problem for applications that rely on the quickness of swapping from expanded memory for the first-called overlay. To work around this, make the first executable statement in your program a CALL to an additional overlay with no code in it. When it is called, all the other overlays will be loaded into expanded memory. The functionality and speed of the application will remain intact while the difference in EXE size and load time will be minimal.

For example, the module MAIN.BAS above would be modified as follows: CALL loadovls PRINT &quot;MAIN&quot; CALL ovl1 CALL ovl2 END The subprogram &quot;loadovls&quot; (meaning &quot;load overlays&quot;) would be coded as the following: SUB loadovls END SUB When loadovls is called, the code for overlay1 and overlay2 will be loaded into expanded memory. This eliminates the disk activity between the display of &quot;MAIN&quot; and &quot;OVERLAY1&quot;.

Additional query words: BasicCom

Keywords: KB63161

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.