Remembering Memory: EMS, and TSRs

You often hear that Bill Gates once proclaimed, “640 kB is enough for anyone,” but, apparently, that’s a myth — he never said it. On the other hand, early PCs …read more

May 13, 2025 - 19:52
 0
Remembering Memory: EMS, and TSRs

You often hear that Bill Gates once proclaimed, “640 kB is enough for anyone,” but, apparently, that’s a myth — he never said it. On the other hand, early PCs did have that limit, and, at first, that limit was mostly theoretical.

After all, earlier computers often topped out at 64 kB or less, or — if you had some fancy bank switching — maybe 128 kB. It was hard to justify the cost, though. Before long, though, 640 kB became a limit, and the industry found workarounds. Mercifully, the need for these eventually evaporated, but for a number of years, they were a part of configuring and using a PC.

Why 640 kB?

The original IBM PC sported an Intel 8088 processor. This was essentially an 8086 16-bit processor with an 8-bit external data bus. This allowed for cheaper computers, but both chips had a strange memory addressing scheme and could access up to 1 MB of memory.

In fact, the 8088 instructions could only address 64 kB, very much like the old 8080 and Z80 computers. What made things different is that they included a number of 16-bit segment registers. This was almost like bank switching. The 1 MB space could be used 64 kB at a time on 16-byte boundaries.

So a full address was a 16-bit segment and a 16-bit offset. Segment 0x600D, offset 0xF00D would be written as 600D:F00D. Because each segment started 16-bytes after the previous one, 0000:0020, 0001:0010, and 0002:0000 were all the same memory location. Confused? Yeah, you aren’t the only one.

What happened to the other 360 kB? Well, even if Gates didn’t say that 640 kB was enough, someone at IBM must have. The PC used addresses above 640 kB for things like the video adapter, the BIOS ROM, and even just empty areas for future hardware. MSDOS was set up with this in mind, too.

The 640K user area, 384K system area, and almost 64K of HMA in a PC (80286 or above)

For example, your video adapter used memory above 640 kB (exactly where depended on the video card type, which was a pain). A network card might have some ROM up there — the BIOS would scan the upper memory looking for ROMs on system boot up. So while the user couldn’t get at that memory, there was a lot going on there.

What Were People Doing?

Speaking of MSDOS, you can only run one program at a time in MSDOS, right? So what were people doing that required more than 640 kB? You weren’t playing video. Or high-quality audio.

There were a few specialized systems that could run multiple DOS programs in text-based windows, DesqView and TopView, to name two. But those were relatively rare. GEM was an early Windows-like GUI, too, but again, not that common on early PCs.

Sidekick activated

However, remember that MSDOS didn’t do a lot right out of the box. Suppose you had a new-fangled network card and a laser printer. (You must have been rich back then.) Those devices probably had little programs to load that would act like device drivers — there weren’t any in MSDOS by default.

The “driver” would be a regular program that would move part of itself to the top of memory, patch MSDOS to tell it the top of memory was now less than it was before, and exit. So a 40 kB network driver would eat up from 600 kB to 640 kB, and MSDOS would suddenly think it was on a machine with 600 kB of RAM instead of 640. If you had a few of these things, it quickly added up.

TSRs

Then came Sidekick and similar programs. The drivers were really a special case of a “terminate and stay resident” or TSR program. People figured out that you could load little utility programs the same way. You simply had to hook something like a timer interrupt or keyboard interrupt so that your program could run periodically or when the user hit some keys.

Sidekick might not have been the first example of this, but it was certainly the first one to become massively successful and helped put Borland on the map, the people who were mostly famous or would be famous for Turbo Pascal and Turbo C.

Of course, these programs were like interrupt handlers. They had to save everything, do their work, and then put everything back or else they’d crash the computer. Sidekick would watch for an odd key stroke, like Ctrl+Alt or both shift keys, and then pop up a menu offering a calculator, a notepad, a calendar, an ASCII table, and a phone dialer for your modem.

Sidekick caught on and spawned many similar programs. You might want a half dozen or more resident programs in your daily MSDOS session. But if you loaded up a few TSRs and a few drivers, you were quickly running out of memory. Something had to be done!

EMS

EMS board were “expanded memory.” There actually were a few flavors, not all of which caught on. However, a standard developed by Intel, Microsoft, and Lotus did become popular.

The Captain286 EMS board used SIMs, unlike most of its contemporaries

In a nutshell, EMS reserved — at least at first — a 64 kB block of memory above the 640 kB line and then contained a lot of memory that you could switch in and out of that 64 kB block. In fact, you generally switched 16 kB at a time, so you could access four different EMS 16 kB pages at any one time.

This was complex and slow. The boards usually had some way to move the block address, so you had to take that into account. Later boards would offer even more than 64 kB available in upper memory or even allow for dynamic mapping. Some later boards even had sets of banking registers so you could context switch if your software was smart enough to do so.

EMS was important because even an 8088-based PC could use it with the right board. But, of course, newer computers like the IBM AT used 80286 processors and, later, even newer processors were common. While they could use EMS, they also had more capabilities.

Next Time

If you had a newer computer with an 80286 or better, you could directly access more memory. Did you notice the high memory area (HMA) in the memory map? That’s only for newer computers. But, either way, it was not fully supported by MSDOS.

Many boards for the newer computers could provide both EMS and just regular memory. The real issue was how could you use the “regular memory” above the 1MB line?  I’ll tell you more about that next time, including a trick independently discovered by a number of hackers at about the same time.