The incredible expanding RAM. (Column)
by Mark Minasi
Last month, I discussed using the DOS 5.0 memory manager to create extra memory for DOS programs, in particular TSRs and device drivers. This month, I want to continue that discussion by talking about another kind of memory: expanded memory.
Most PC users eventually come to feel that 640K of memory--the most DOS will allow--is insufficient for most needs. Most 286- and 386-based computers have memory beyond 640K, called extended memory. Unfortunately, expanded memory is generally useless under most DOS programs--unless that DOS program was written with a kind of program development tool, called a DOS extender. One well-known example of a program that uses a DOS extender is Lotus 1-2-3 version 3.1; it can use extended memory directly. That's good, but there aren't too many programs blessed with DOS extenders. So what to do?
Lotus Development faced exactly the same problem back in 1985. Lotus had captured the spreadsheet market with the run-away bestseller, 1-2-3 version 1A. Eager to improve its flagship product, Lotus feverishly worked to create version 2.0. Lotus 1-2-3 version 2.0 had some really nifty features when compared to version 1A. But it also had a real problem--it took up more memory than 1A did.
This was a problem because there were loads of 1-2-3 spreadhseets out there designed by pioneering spreadsheet users. Many of those spreadsheets had been built under version 1A for machines with 640K, and they used every single byte of memory. So the 1985 introduction of 2.0, with less free RAM, was viewed as something of a bad thing.
Lotus needed some extra memory from somewhere. It could have built a spreadsheet with a DOS extender, giving 1-2-3 access to extended memory, but remember that only 286 and better machines have extended memory. In 1985, very few people had 286 machines, and no one had a 386 machine.
So Lotus turned to Intel, the folks who build the chips. Intel used an old trick to get more memory for 1-2-3, a trick called paging.
Recall from last month that the memory area from 768K to 959K is allocated for ROMs (Read Only Memories) on add-in adapter cards. Most cards don't use those addresses, leaving much of that space, called the Upper Memory Area (UMA), unused. So Intel and Lotus designed a board that placed a 64K memory window up at address D0000 hex, or 832K.
Now, adding another 64K doesn't sound like much help; that's why I said it was a 64K window, or, more correctly, a page frame. The idea is that Intel designed a memory system that could accept up to 8MB (it later became 32MB) of RAM--that is, RAM not addressed in the normal way, but in pages 16K in size. It works this way: A piece of software, such as 1-2-3 version 2.1, can direct this paged memory board to move any four pages--say, pages 20, 200, 215, and 470--from the paged memory into the four 16K slots in the 64K page frame located at 832K. Then 1-2-3 can put data into those pages, and the pages can be copied from the page frames to their original memory locations in the paged memory board.
Gang of Three
For some reason, this isn't usually called a paged memory board; it's called an expanded memory board. And Lotus and Intel weren't the only players here; Microsoft got involved a bit later on. This led to another name for these boards: LIM, for Lotus-Intel-Microsoft.
As of version 4.0, up to 32MB of paged or expanded memory (whichever you want to call it) can be installed in a PC. It's also sometimes known as the Expanded Memory Standard (EMS).
Basically, the LIM memory isn't viewed by the system as memory. All the PC knows is that there are pages of storage available--16K-sized pages. LIM can support up to 2000 of these pages, hence the 32MB maximum size. LIM boards allocate 64K of memory--enough space for four pages--somewhere in the reserved area between 640K and 1023K, so a program can manipulate up to four pages at a time.
LIM is manipulated, then, by pulling in a page from LIM memory to your computer memory's reserved area (this memory is called a page frame, and moving data to and from LIM and page frames is called paging), reading and/or modifying the page frame, and possibly writing the page frame back to the LIM memory.
So 1-2-3 version 2.1 supported LIM, and that was reason enough for people all over the PC world to go out and buy add-in LIM memory boards for their 8088- and 286-based machines.
Perhaps you're wondering if all this paging takes time. It does--LIM memory is slower than conventional memory. LIM gets around DOS's 640K limitation, but at a cost in speed. And these days we're seeing more and more new applications use extended rather than expanded LIM memory.
I know all of this is confusing, so let's review. Extended memory can be used with (1) 286 or later machines, (2) DOS when used with a DOS extender, and (3) both Windows and OS/2. Expanded or LIM memory (1) can be used with any machine, XT and up, and (2) is only useful with applications designed to use it.
Doing the Limulation
Last month, I inbtroduced the DOS 5.0 386 memory manager, EMM386.EXE. You saw that it was pretty neat in that it allows you to create new memory areas in the UMA. It also lets you put programs into those UMA areas, freeing up space in DOS's lower 640K. But a memory manager does another neat trick--it can take your extended memory and make it behave like expanded memory.
Recall that expanded memory is also called EMS or LIM memory, so this process--emulating LIM--has gotten the name limulation. It's useful because there are still a number of applications out there that can use LIM if it's present, so it's nice to be able to make some of your extended memory work like expanded.
I must stress that you need a 386-class machine to do this. It's possible to do limulation with a 286 machine, but only with a small subset of the 286 machines out there. This makes for a difficult buying decision for 286 owners--when buying a memory board for your 286, should you buy extended or expanded? (Remember that for 386 owners, it's easy--just buy extended, and limulate if necessary.) Many 286 memory boards are reversible for extended or expanded. These are good buys, as you may need expanded today and want to be able to use extended later.
In general, limulators for 286s aren't a good idea, as full LIM 4.0 powers can't be emulated and the 286 isn't built to limulate.
So how do you make a memory manager like EMM386 do limulation as well as create and manage UMBs--Upper Memory Blocks, recall? You've already learned the hard parts. In last month's column, we invoked the memory manager, telling it to include and exclude certain memory areas with the following CONFIG.SYS:
BUFFERS=30 FILES=30 DEVICE=HIMEM.SYS DEVICE=EMM386.EXE NOEMS I=CE00-EFF DEVICEHIGH=SMARTDRV.SYS 512 512
The DEVICEHIGH= just loads SMARTHDRV.SYS above 640K. The I=CE00-EFF says, "Use the memory areas from 844K through 959K." If you missed last month, don't worry too much about it--it doesn't affect this discussion. I just carried it over for continuity's sake.
There's a separate keyword to activate limulation. In the case of EMM386, you replace NOEMS with RAM.
Remember the page frame? EMS needs a 64K window between 640K and 1023K for a page frame. That's 64K that gets taken out of your UMBs. As before, DOS's default locations for the page frame may not be the best, so you may have to step in and help EMM386 out. I change NOEMS to RAM in the EMM386 line and reboot.
You'll get different results on different machines, but most machines just issue a message such as EMM386 not loaded--page frame could not be set. What it's saying is "I'm confused" or, put another way, "I'm DOS--and I'm lost." For some reason, EMM386 throws up its hands if you insist on employing the E0000-EFFFF area. (I'm going to shift to hex for this last bit. If you're uncomfortable with hex, use the Calculator that comes with Windows 3.0 to do the decimal/hex conversions.) Now, you could just give in and remove the I=CE00-EFF parameter--in fact, I find that's what most users do. but it's a terrible shame, but then you end up with a wasted 64K. Left to itself, EMM386 will waste the area from E0000 to EFFF.
We forced DOS to use the full address space before. This time, we'll force it to place the page frame at E0000-EFFFF; that way, we'll have a 64K-EMS page frame from E0000 to EFFFF and 72K of UMB space from CE000 to DFFF.
The option we want is FRAME=. You specify the starting address of the page frame with, as before, the rightmost hex number dropped off. To specify a page frame starting at E0000, we just use the following.
DEVICE=EMM386.EXE RAM I-CE00-EFFF FRAME=E000
That's all there is to it. Now you've got 256K of LIM memory available to your DOS programs. What if you want more LIM memory? Just put a number after EMM386.EXE, as in the following.
DEVICE=EMM386.EXE 512 RAM I=CE00-EFF FRAME=E000
That would set aside 512K of RAM for LIM emulation.