Window's soul. (Microsoft Windows' development) (Windows Workshop) (Column)
by Clifton Karnes
Let's part under a shade tree, roll up our sleeves, and pop open Window's hood.
Have you ever wondered what Windows really is? It's such a strange beast, after all. Is it a DOS program, for example? It seems to be a COM file (which is the old-fashioned DOS executable format), it runs from DOS, and after you exit Windows, the program returns to DOS. In many ways it seems like a DOS program. But it's graphical, and more important than that, it multitasks. And you can use all of your PC's extended memory with Windows, which DOS by itself certainly won't let you do.
To answer some of these questions and really understand Windows' essence, we need to talk a little about the Intel 8088, 80286, and 80386 processors, collectively known as the 80x86 family. The 8088, as you probably know, is the brain of the original IBM PC. It has a 16-bit register width, an 8-bit data bus, and a 20-bit address bus, all of which means it can operate on 16 bits of data at a time, can access data from memory and peripherals 8 bits at a time, and can address 1MB ([2.sup.20]) of memory.
The 8088's 1MB address space is divided between 640K of user memory and 384K of adapter memory. This 640K seemed endless in 1981, when the machine debuted, but faster than you could sort a big database or recalculate a huge spreadsheet, it was too small.
Intel tried to solve the 8088's memory problems (as well as several other problems) with the 80286, which appeared in the IBM AT in 1983. The 80286 is completely compatible with the 8088, but it's faster (6 MHz originally, compared with the 8088's 4.77 MHz), and it can address more memory. In fact, the AT's 24-bit address bus can address a whopping 16MB of RAM. The 80286 also features an additional mode, called protected mode, which allows the processor to address this full 16Mb address space. The 8088's native operating mode was dubbed real mode because of the way it addresses its 1MB of memory, using the memory's real address. The 80286's protected mode uses aliases to address memory instead of real addresses.
Unfortunately, to use protected mode and get at all the memory above the 1MB boundary, you have to abandon DOS, because DOS only works in real mode. Intel seemed to think that new operating systems would soon be developed to take advantage of protected mode and the vast RAM it offered, but these new operating systems didn't appear. There were so many mission-criticalf applications running under DOS that nobody wanted to switch.
So almost everyone used 80286-powered PCs simply as faster 8088s. And those giant databases and spreadsheets got bigger and bigger and bigger.
After the 80286 had been crunching numbers and sorting data for a while, some people realized that you can run the processor in real (DOS) mode and switch to protected mode to address the extended memory in the system. The trouble is that you have to restart the system to get back to real mode. For compatibility, Intel designed the 80286 to start life in real mode (the 80386 and 80486 do the same thing) and made the switch to protected mode an option. Intel obviously couldn't imagine why anyone would want to go back to real mode after having switched to protected mode, so it didn't make the gate between the two modes two-way.
The trick IBM discovered was to put a special byte in the system that the ROM BIOS would read when it was reset. If the byte was a value that said, in effect, "I'm switching from protected mode to real mode, so don't restart this computer," the CPU would go back to real mode, and everything would be cool.
VDISK, the RAM disk that comes with DOS, was the first application to use this technique. The technique is a little ugly, but it works, and it spawned a whole new category of programs called DOS extenders. DOS extenders are applications that can run part of the time in real mode and part of the time in protected mode. They, in effect, add memory management to DOS. If you've followed me so far, you may already know where I'm going: Windows is a DOS extender, and in standard mode, it works much like the early DOS extenders. However, Windowes wouldn't be nearly the operating system it is (or is it an operating environment?) without the magical new features of the 80386.
With the 80386, Intel really got everything right. The processor is completely compatible with the 8088 and 80286, and it adds more powerful new features. First, it's faster than the 80286, with speeds ranging from 25 to 33 MHz. Second, it's a full 32-bit processor with 32-bit registers, a 32-bit address bus, and a 32-bit data bus. And it adds two new features that really turned Windows into a success story: a new form of memory management, called paging, and a new mode, called virtual 8086 mode.
Next month, I'll talk a little more about these new Intel 80386 modes and how Windows exploits them to create virtual memory and multitask DOS applications.