[comp.sys.ibm.pc] Why is DOS limited to 640K?

rock@cbnews.ATT.COM (Y. Rock Lee) (10/15/89)

Why is a plain DOS limited to 640K memory?
I heard of this claim many years ago,
but have never really understood why it has to be so.
Today, I just ran accross the same statement on the Byte magazine.
I am really puzzled (and bothered) by this OLD question.

Can some DOS guru out there kindly explain it to me?
(I am a UNIX person and know very little about DOS internal)
Thanks in advance.

Y. Rock Lee, att!cblph!rock
             rock@cblph.ATT.COM

ilan343@violet.berkeley.edu (10/15/89)

In article <10253@cbnews.ATT.COM> rock@cbnews.ATT.COM (Y. Rock Lee,55212,cb,1J312E,6148604774) writes:
>Why is a plain DOS limited to 640K memory?

I think a more direct question is why didn't Microsoft adopt an
official DOS extenter as soon as the ATs came out 5 years ago.
It would be compatible with the old DOS applications and would free
AT owners from DOS most serious limitation. After all this time the
286's are two (or three if you count RISC)  generations behind, and 
without an operating system.

campbell@redsox.bsw.com (Larry Campbell) (10/16/89)

Generic MS-DOS is actually limited to 1 megabyte.  This is because
the entire MS-DOS "architecture" assumes that you're on an 8088, which
has a 20-bit address space.

PC-DOS -- that is, MS-DOS as implemented by IBM on the PC -- is limited
to 640K because IBM reserved the addresses above 640K for device adapters
and the ROM BIOS.

The DEC Rainbow (don't laugh!) supports up to 896K RAM, since it reserves
only the top 128K of the address space.  (No expansion slots, no device
adapters to worry about.)
-- 
Larry Campbell                          The Boston Software Works, Inc.
campbell@bsw.com                        120 Fulton Street
wjh12!redsox!campbell                   Boston, MA 02146

nelson@sun.soe.clarkson.edu (Russ Nelson) (10/16/89)

In article <1464@redsox.bsw.com> campbell@redsox.bsw.com (Larry Campbell) writes:

   PC-DOS -- that is, MS-DOS as implemented by IBM on the PC -- is limited
   to 640K because IBM reserved the addresses above 640K for device adapters
   and the ROM BIOS.

Actually, Bill Gates has admitted to allocating "only" 640K to system ram.
Of course, if they realized that they had a winner, they would have designed
the thing rather than banging some Intel parts together.

This in itself is not so horrible as is the fact that people *had* to access
display memory in order to get any performance out of the machine.  If
Bill had started discouraging this with DOS 2.0, we could have eventually
wound up with a machine-independent OS.  The fact that he didn't tells me
more than a little about his technical expertise.

Apple got it right with the MacIntosh.  Give the developer a reasonable
software interface, leave the hardware interface undocumented, and keep
changing the hardware so that ill-behaved programs keep breaking.
--
--russ (nelson@clutx [.bitnet | .clarkson.edu])
Live up to the light thou hast, and more will be granted thee.
A recession now appears more than 2 years away -- John D. Mathon, 4 Oct 1989.

eichi@forty2.UUCP (Stefan Eichenberger) (10/16/89)

In article <10253@cbnews.ATT.COM> rock@cbnews.ATT.COM (Y. Rock Lee,55212,cb,1J312E,6148604774) writes:
>Why is a plain DOS limited to 640K memory?

It's sort of clear to me that DOS memory mamgement assumes a 8088 processor,
which can only address 1MByte. And IBM decided towards the end of last century,
that 384KBytes should be reserved for all imaginable 'system' requirements in
the next 100 MYears (such as Display Memory, ROM, EMS, ...)

The question that bothers me: If one doesn't have an EGA or VGA card, but
only CGA, memory between A000 and B800 is not used by anything. There is hard-
ware available to fill this hole with 96 K of additional RAM. But how to make
DOS avare of it? ... I know, there are programs, if you backfill the memory
with some of the LIM 4.0 memory cards or EEMS, or if you have a 80386.
My problem is, I've just conventional memory at that address, an 8086 processor
and no software yet to use it. Any ideas?


-- 
----------------------------------------------------------------------------
UUCP:      ...mcvax!cernvax!forty2!eichi         Stefan Eichenberger
BITNET:    K807817@CZHRZU1A                      University of Zurich
----------------------------------------------------------------------------

blitter@ele.tue.nl (Paul Derks) (10/16/89)

In article <10253@cbnews.ATT.COM> rock@cbnews.ATT.COM (Y. Rock Lee,55212,cb,1J312E,6148604774) writes:
>Why is a plain DOS limited to 640K memory?
>I heard of this claim many years ago,
>but have never really understood why it has to be so.
>Today, I just ran accross the same statement on the Byte magazine.
>I am really puzzled (and bothered) by this OLD question.

DOS is NOT limited to 640k. DOS IS limited to 1 Megabyte because it runs
on an 8088/8086 and these have an address space of 1 MB. 

DOS on an IBM PC (or compatible) IS limited to 640k simply because the 
memory map of the PC only has room for 640k RAM and the rest is reserved 
for ROM's and video ram.
I have seen MS-DOS machines (not PC compatibles) with as much as
896k under DOS. These machines have only 128k reserved for ROM's and 
video memory.

Hope this clarifies things a bit.

Paul Derks

mcdonald@uxe.cso.uiuc.edu (10/16/89)

>Why is a plain DOS limited to 640K memory?
It (MS-DOS itself) isn't. It is IBM's PC-DOS that is limited to
640 K. MS-DOS is limited to the amount of memory that appears below
the lower of the ROM-BIOS and video memory (if any). In a PC
ROM-BIOS starts at 640K+128K = 768K. So, if one had a hacked bios
and a video card somewhere above that, you use 768 K. Some  non-clone
MS-DOS computers really do run up to 704 K. A friend of mine has
an MS-DOS computer with a bios he write himelf that really uses
768K. The reason for the ultimate limit is that the ROM has to go
somewhere, and it better be below 1Meg, as that is all an 8086 can
address. 640K comes because that is where EGA video memory goes.


>I think a more direct question is why didn't Microsoft adopt an
>official DOS extenter as soon as the ATs came out 5 years ago.
>It would be compatible with the old DOS applications and would free
>AT owners from DOS most serious limitation. After all this time the
>286's are two (or three if you count RISC)  generations behind, and 
>without an operating system.

Because that is impossible. old DOS applications run on 8086's,
not in the 80286 extended mode. They DO sell OS/2, and does not
have a 640K limit - but they didn't have it then. They did have
a Xenix, which does not run DOS programs, but even the first version
worked fine as a Unix. 8086 programs cannot run in 286 mode because
Intel changed the way segment registers work. And, believe it or not,
somehow Intel forgot to add instructions to switch from 80286 mode
back to 8086 mode ( so hardware hacks get installed to do it
by a hardware reset). OS/2 cannot run most DOS programs.

Doug MCDonald

davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) (10/16/89)

In article <10253@cbnews.ATT.COM>, rock@cbnews.ATT.COM (Y. Rock Lee) writes:
|  Why is a plain DOS limited to 640K memory?

  It isn't. It's just that (a) IBM configures their DOS that way, and
(b) some video boards start after 640k. MS-DOS uses all of the memory in
other machines such as the Tandy 2000 (768k), but programs which write
directly to memory won't run. It's a problem with the applications.

  There is a patch for PC-DOS to use more memory, but you restrict the
programs you can run. Some programs can also take advantage of memory
about 640k but not contiguous, and the 63k about 1MB which can be
addresses by the 286.
-- 
bill davidsen	(davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon

rob@prism.TMC.COM (10/17/89)

    There are basically two reasons for the 640K limitation. First, DOS
was designed to run on the Intel 8088, which is limited to addressing
1Mb of memory. When running on newer Intel CPUs (80286, 386, etc.), DOS
runs them in 8088 emulation (or 'real') mode, so that they are bound by
the same 1Mb constraint.

   Due to the design of most PC's, only the first 640K of that 1Mb can
be used by DOS. The remaining area is reserved for such things as BIOS
code, video buffers, and so on. 

   It's possible to make a larger memory available to DOS by remapping
the memory used by the BIOS or the video adapter. But there are serious 
difficulties with this approach (for example, most PC programs make 
assumptions about the address of the video buffer), and relatively few
PC vendors do this.

jwbirdsa@phoenix.Princeton.EDU (James Webster Birdsall) (10/17/89)

In article <913@forty2.UUCP> eichi@forty2.UUCP (Stefan Eichenberger) writes:
>The question that bothers me: If one doesn't have an EGA or VGA card, but
>only CGA, memory between A000 and B800 is not used by anything. There is hard-
>ware available to fill this hole with 96 K of additional RAM. But how to make
>DOS avare of it? 

>UUCP:      ...mcvax!cernvax!forty2!eichi         Stefan Eichenberger
>BITNET:    K807817@CZHRZU1A                      University of Zurich


   There is a program known as MORERAM that makes DOS recognize as much
additional RAM as it can find. I have heard of people reaching 768K
using this program.

   I believe it is available from SIMTEL20 in the SYSUTL directory. If
you have the RAM and no advanced graphics card, you should check it out.


-- 
James W. Birdsall  jwbirdsa@phoenix.Princeton.EDU  jwbirdsa@pucc.BITNET
   ...allegra!princeton!phoenix!jwbirdsa   Compu$erve: 71261,1731
"For it is the doom of men that they forget." -- Merlin

werner@aecom.yu.edu (Craig Werner) (10/17/89)

In article <NELSON.89Oct15233456@image.clarkson.edu>, nelson@sun.soe.clarkson.edu (Russ Nelson) writes:
> Apple got it right with the MacIntosh.  Give the developer a reasonable
> software interface, leave the hardware interface undocumented, and keep
> changing the hardware so that ill-behaved programs keep breaking.
> --
	You call getting this right?!!
	True there is a software interface.  However, you're stuck with
it.  I happen to loath and despise the Macintosh interface, and several
programs that would have made it bearable (I can see the screen flicker
of reverse video. I would like nothing better than to have white text on
black screens) like reverse screen programs, seem to fail on the Mac II,
or else have designed in side-effects that are worse than the flicker
(this last applies to the Apple-supplied CloseView).  This is just one
example of about a dozen gripes, which is why I use Macs under protest
(although I'm using one now to type this) and use PCs willingly.
	Because you can't bypass the software, you can't realize the
speed increases by bypassing it, so nobody really notices how slow the
machine actually is because there's no basis of comparison. Or something
like that.
	
-- 
	        Craig Werner   (future MD/PhD, 4.5 years down, 2.5 to go)
	     werner@aecom.YU.EDU -- Albert Einstein College of Medicine
              (1935-14E Eastchester Rd., Bronx NY 10461, 212-931-2517)
 "..pursuing Dharma, Artha, and Kama (although not nearly enough of the last)."

jeh@simpact.com (10/18/89)

I have a somewhat-related question.  

I have an AT clone with the Award BIOS.  It came with 640K ram.  

I acquired some 256K DRAMs and replaced the 64Ks, providing 1 Mbyte on
the motherboard, assuming that this would let me use 640K for DOS and
384K for whatever (VDISK ?).  I changed the SETUP EEPROM options to 
tell the system that this was available.  

I did this a while back and I can't remember all the permutations -- but
there seemed to be no combination that would let me set it up as 640/384.  
At least, Norton Utilities' SI would not report that 384K extended (expanded?
I can never remember -- I'm not really a PC person) was available.  The
best I could do was 640/128, which hardly seemed worth the trouble.  
Oh, by telling the EEPROM that I had 512K on board I got SI to report 512 K
main and 512K ex., but that's not what I want either.  

What gives?

mcdonald@uxe.cso.uiuc.edu (10/18/89)

	>Because you can't bypass the software, you can't realize the
>speed increases by bypassing it, so nobody really notices how slow the
>machine actually is because there's no basis of comparison. Or something
>like that.

This refers to MAC's - not PC's.  You CAN bypass it, on a given
machine. And when you do, you find that for most (but not all)
purposes the supplied software is quite good. It is NOT by any
stretch of tha imagination a botch. It is better than anything
IBM has given us. Apparently IBM actually LIKES slow graphics,
in order to sell fast computers.

AS to reverse video - for a mono screen, reverse it with HARDWARE - 
i.e. an inverting amplifier in line between the computer and
the monitor - oops, a good argument for separate monitors!

Doug MCDonald.	

gillies@p.cs.uiuc.edu (10/20/89)

Re: Limitations of DOS and Bill Gates's mind.

Was Microsoft responsible for the PC's original BIOS?  If so, perhaps
this is why people began writing to display memory in the early days
of the PC....

An undergrad in the MIT PC/IP project was trying to implement telnet
on a PC (in 1982..).  The screen update was terribly slow, until he
looked at the BIOS and found that IBM PC's were doing 2K byte copies
to scroll the monochrome screen 1 line.

The solution was simple.  Write 5-10 lines of assembly code to use the
HARDWARE SCROLL CIRCUITRY built into the display chip on the IBM PC.

stevel@eleazar.dartmouth.edu (Steve Ligett) (10/24/89)

In article <126@euteal.ele.tue.nl> blitter@ele.tue.nl (Paul Derks) writes:
>In article <10253@cbnews.ATT.COM> rock@cbnews.ATT.COM (Y. Rock Lee,55212,cb,1J312E,6148604774) writes:
>>Why is a plain DOS limited to 640K memory?
...
>DOS on an IBM PC (or compatible) IS limited to 640k simply because the
>memory map of the PC only has room for 640k RAM and the rest is reserved 
>for ROM's and video ram.

PC-DOS is not limited to 640K.  At least version 2.1 wasn't, I'm not
sure about the newer ones.  That's because I sold my IBM PC.  On the
old PC, you set switches to tell it how much ram it had.  It wasn't
"smart" enough to look.  I had 704K (and MDA) in mine, and it believed
me when I told it so.  Alas, my "new" XT figures out how memory it has
by itself, and so only looks for 640K.
--
Steve Ligett       steve.ligett@dartmouth.edu or
(decvax harvard linus true)!dartvax!steve.ligett

bedra@bgsuvax.UUCP (craig bedra) (10/25/89)

From article <16320@dartvax.Dartmouth.EDU>, by stevel@eleazar.dartmouth.edu (Steve Ligett):
> In article <126@euteal.ele.tue.nl> blitter@ele.tue.nl (Paul Derks) writes:
>>In article <10253@cbnews.ATT.COM> rock@cbnews.ATT.COM (Y. Rock Lee,55212,cb,1J312E,6148604774) writes:
>>>Why is a plain DOS limited to 640K memory?
> ...
>>DOS on an IBM PC (or compatible) IS limited to 640k simply because the
>>memory map of the PC only has room for 640k RAM and the rest is reserved 
>>for ROM's and video ram.

I amlooking for a memory manager for a 286 with an EGA card to extend base 
memory 64K.  I have checked Simtel and all they have is stuff for use with
CGA(sorry that's not an option). I have 1Meg with ems 4.0 compatable and need
to run a program that uses 640k and a res driver that needs 64k o top of that.
I really don't want to by an All Charge Card.

Help
Craig Bedra
Chem Dept
Bowling Green State Univ
bedra@andy.bgsuvax.edu
419-372-8824
 

perry@ccssrv.UUCP (Perry Hutchison) (10/25/89)

In article <5049@bgsuvax.UUCP> bedra@bgsuvax.UUCP (craig bedra) writes:

> ... for a 286 with an EGA card to extend base memory 64K.  I have checked
> Simtel and all they have is stuff for use with CGA ...

The reason there is no program to do this with an EGA is that, in some
display modes, the EGA's buffer space starts at the 640K boundary.  If you
can guarantee that none of your programs will try to set EGA graphic modes,
the CGA stuff might work.  (You can still use the higher-resolution but
otherwise CGA-compatible text modes.)  If you actually need EGA graphics,
you're stuck with 640K max.

garye@hp-ptp.HP.COM (Gary_Ericson) (10/28/89)

Now that I finally understand the 640K/1M arrangement of DOS, here's the 
logical follow-on question:

	Can you please explain Extended Memory and Expanded Memory?

	- what each is, what's the difference between them, who uses
	  them

Gary Ericson - Hewlett-Packard, Workstation Systems Division
               phone: (408)746-5098  mailstop: 101N  email: gary@hpdsla9.hp.com

jwbirdsa@phoenix.Princeton.EDU (James Webster Birdsall) (10/29/89)

In article <757@ccssrv.UUCP> perry@ccssrv.UUCP (Perry Hutchison) writes:
>The reason there is no program to do this with an EGA is that, in some
>display modes, the EGA's buffer space starts at the 640K boundary.  If you
>can guarantee that none of your programs will try to set EGA graphic modes,
>the CGA stuff might work.  (You can still use the higher-resolution but
>otherwise CGA-compatible text modes.)  If you actually need EGA graphics,
>you're stuck with 640K max.

   Not necessarily. A few months ago, PC Magazine had a mini-review of 
some utilities which actually use EGA video RAM to expand your DOS
conventional RAM. Of course, they would work only as long as you didn't
switch into a graphics mode -- the manufacturer was, of course, quite
emphatic about this :-) -- but since most software is text-only, they
sounded medium useful.

   No matter how weird any given idea sounds, somebody somewhere has
probably at least tried it...

-- 
James W. Birdsall  jwbirdsa@phoenix.Princeton.EDU  jwbirdsa@pucc.BITNET
   ...allegra!princeton!phoenix!jwbirdsa   Compu$erve: 71261,1731
"For it is the doom of men that they forget." -- Merlin

jeffa@hpmwtd.HP.COM (Jeff Aguilera) (10/31/89)

> Why is a plain DOS limited to 640K memory?

Planned obsolescence.  Microsoft wants to sell OS/2.

cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) (11/02/89)

$PC-DOS is not limited to 640K.  At least version 2.1 wasn't, I'm not
$sure about the newer ones.  That's because I sold my IBM PC.  On the
$old PC, you set switches to tell it how much ram it had.  It wasn't
$"smart" enough to look.  I had 704K (and MDA) in mine, and it believed
$me when I told it so.  Alas, my "new" XT figures out how memory it has
$by itself, and so only looks for 640K.

   That's no big problem ... if you do have nore than the 640K your machine
looks for, there are programs that will change the PC's internal count
of ho much memory it has.  These programs do the following:

1.  Find out how much RAM _really_ is there
2.  Change the low-memory variable that says how much memory you have
3.  Reboot the machine

   Bingo, you have more than 640K.  Anyone who wants a copy of such a
program (I've never tried it, but I imagine it works; it was printed in
BYTE a few years back), just e-mail me a note saying "I want that memory
expander" or something similar and I'll mail you the program (if you
want source, too, let me know).

-Steve

-- 
Stephen M. Dunn                               cs4g6ag@maccs.dcss.mcmaster.ca
          <std_disclaimer.h> = "\nI'm only an undergraduate!!!\n";
****************************************************************************
They say the best in life is free // but if you don't pay then you don't eat

eichi@forty2.UUCP (Stefan Eichenberger) (11/08/89)

In article <254F201F.22212@maccs.dcss.mcmaster.ca> cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) writes:

>1.  Find out how much RAM _really_ is there
>2.  Change the low-memory variable that says how much memory you have
>3.  Reboot the machine

This is done, for example by a program called MORERAM1.ARC on SIMTEL20
in <msdos.sysutl> (if I remember correct...).  

I asked the same question here about two weeks ago (how to make DOS aware
of more than 640 kBytes conventional memory) and got mail response to the
effect that it would be sufficient to modify the last MCB (memory control
block) such that the length is enlarged by the additional RAM. So, can any-
body tell me, why I should then go through the process of rebooting the 
machine? Modifying the last MCB is a program of about 20 Pascal lines and 
seems to work. Only INT 12 reads the above mentioned BIOS variable to
determine installed memory. So, what's wrong with

  1. Find out about how much RAM there is
  2. Patch BIOS data area at 0040:0013 to let BIOS know it (just in case...)
  3. Modify th last MCB
  4. Enjoy the memory

Are there any inconsistencies in this procedure? Any crashes to be expected?

Btw, rebooting the machine doesn't help with some BIOS clones such as the
AT&T6300 BIOS, which *always* (even at a warm reboot) rechecks the amount
of awailable memory (up to 640k only, of course) and resets 0040:0013! To 
overcome this problem I saw suggestgions such as patching the boot sector
of the hard disk...that's where the real dirty business starts!
 

-- 
----------------------------------------------------------------------------
UUCP:      ...mcvax!cernvax!forty2!eichi         Stefan Eichenberger
BITNET:    K807817@CZHRZU1A                      University of Zurich
----------------------------------------------------------------------------