More Memory for DOS Exec
Kim Kokkonen
As many have lamented, the 640K of memory available to DOS programs is looking
smaller every year. With TSR's gobbling up memory on one end, and our
applications growing larger on the other, it is easy to use up all the space
and then some. Of course, necessity is the mother of invention, so desperate
DOS programmers have devised a number of ad hoc methods to cram more functions
into the same space -- by using expanded and extended memory, overlays, and so
on.
This article describes another such method. We've enhanced the DOS Exec
function by swapping most of the calling program into expanded memory or to
disk, and giving all that free memory to the child process. When the
subprocess is complete, the calling program is swapped back into place and
continues normally. This technique is especially valuable for menuing
environments which must execute other large programs, or modern programming
editors which are expected to spawn huge compilations at the touch of a key.
In fact, it's useful for any program that must invoke another.
The swapping Exec function is implemented in a Turbo Pascal 5.0 unit called
ExecSwap. The real meat of the code is written in assembly language, however,
and with some changes could be linked into other languages such as C or
Fortran.
How It's Done
-------------
ExecSwap's Pascal source file, EXECSWAP.PAS, is given in Listing 2. It's
little more than a shell for the assembly language routines in EXECSWAP.ASM,
Listing 3.
In Summary
----------
ExecSwap seems quite reliable. It doesn't depend on any newly discovered
undocumented features of DOS, and has been tested by thousands of
|