Home > Articles

  • Print
  • + Share This

16- and 32-Bit Code

At the core of every computer lies a chip called the central processing unit (CPU). The CPU does most of the important computational work of a computer—adding, dividing, determining which part of a program to run next, and so on. The CPU is nothing, however, without memory—random-access memory (RAM) especially, but also other types of memory, such as read-only memory (ROM). When a CPU accesses its memory, it specifies the memory address in the form of a number, which is similar to a street address, as in Figure 3.1. Unlike street addresses, though, computer memory addresses are fixed in length, as if there were a law that said no street address could have more than some number of digits. The number of digits in a memory address varies from one CPU to another and is expressed in terms of binary digits (bits), meaning the number of digits in the address when it's expressed in binary (base 2) form. Each memory address can store a number that's a fixed number of bits in size—eight bits (one byte) on most desktop computers, meaning it can store a value ranging from 0 to 255.

The original IBM personal computer (PC), based on the Intel 8088 CPU, used a peculiar memory-addressing scheme. Fundamentally, it was a 16-bit design, meaning that the CPU could address only 216, or 65536, memory locations. This is the origin of the so-called 64KB limit on DOS memory structures, with which you're probably familiar if you've ever used DOS.

Figure 3.1 Each memory address can store precisely one number between 0 and 255.

The IBM PC, though, could have up to 640KB of RAM, plus more memory for ROM (in which the BIOS resides) and other features. How was this accomplished? By using a special 4-byte segment address in addition to the basic 16-byte address. The combination of these two addresses resulted in an effective memory address range of 220 bytes, or 1MB. Because of this strange arrangement, programs required extra code to use the segment address. Even 1MB was rather limiting, however, so future CPUs raised the limit. The Intel 80286 (or 286 for short) used a more complex scheme that allowed for access to more memory, but it still used separate main and segment addresses. The 386 CPU introduced a true 32-bit address scheme to the Intel line, meaning that a program could directly and easily address 232 bytes, or 4GB, of RAM, which is more than enough even for most needs today. (Both Intel and other manufacturers have designed or are planning 64-bit CPUs, though, for future needs.) The trouble with the 386's 32-bit mode is that it required new programs and new operating systems—or at least special extensions to DOS. CPUs from the 386 through to modern x86 CPUs such as the Intel Pentium III and AMD Athlon can therefore continue to use the old 16-bit memory address modes. Without this capability, modern computers wouldn't be able to run DOS or even Windows 9x.

The BIOS works into this picture in that it was originally designed around the old 16-bit memory address schemes, and changing the BIOS to use 32-bit addressing has proved to be an extremely challenging task. In fact, rather than even try, most Intel-based PCs include a 16-bit BIOS and let the OS use 32-bit code after it's booted. This means that even the most advanced OSs for Intel PCs must include at least a minimal amount of 16-bit code to handle the switch from the 16-bit BIOS to the 32-bit OS. This fact has little consequence to you as an end user, but it's of vital importance to those who design OS boot loader code and OS-selection utilities.


  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.