[comp.sys.ibm.pc] Why only 640K for programs?

gordon@osiris.cso.uiuc.edu (John Gordon) (06/28/90)

	Welcome to DOS. <grin>  That's just how DOS is.  Windows 3.0 does
get around this (if the program was written for windows, that is).


---
John Gordon
Internet: gordon@osiris.cso.uiuc.edu        #include <disclaimer.h>
          gordon@cerl.cecer.army.mil       #include <clever_saying.h>
GEnie:    j.gordon14                  

reyn@trsvax.UUCP (06/28/90)

Regarding the inability to use all of the memory in your machine for DOS
programs, the following is a grossly simplified synopsis of MS-DOS memory
limitations:

MS-DOS was originally written for the Intel 8086 and 8088.  These two
processors only had address lines for adressing 1 Meg of memory, and their
instruction sets can therefore only handle programs within the 1 Meg
address range.  The LIM memory expansion schemes are really nothing more
than bank switching schemes for swapping memory pages in the lower 1 Meg
with the "other" memory in your system.  On some machines this is done by
the hardware, on others it is done through software ( the 80386 has
hardware on chip that allows you to map your physical memory to logical
addresses ).

The 640K limit is due to MicroSoft reserving portions of the upper 256K for
the operating system and for the video memory.  Depending on your video
type ( CGA, EGA, VGA, Herc, etc. ) you may be able to use some of this
memory for your programs.  The original LIM standards also used these
memory addresses for swapping pages of extended memory.

The gist of the matter is that no plain vanilla DOS program can access more
than the lower 1 Meg unless it is designed to use LIM page swapping,
switches the processor to the "protected mode" ( available on 80286 and
80386 ), supports "overlays", or some similar trick.  All have drawbacks
since the BIOS ( operating system kernal in ROM ) was not written to work
in the "protected mode."

Under UNIX, you have the luxury of virtual memory, where your operating
system pretends you have oodles and gobs of memory.  Under DOS, you ( or
someone else ) have to take care of this yourself.

For a good ( I mean really good ) book on MS-DOS I recommend _The Waite
Group's MS-DOS Developer's Guide_.

				       John Reynolds
Standard Disclaimers Apply.