Você está na página 1de 5

Previously in this tutorial, we discussed memory in terms of the chips themselves.

In this
section, we look at how that memory is allocated for use by the CPU. This is called
memory mapping and uses hexadecimal addresses to define ranges of memory.

Run the memory video located in the demos folder on the CD accompanying this book
to view a presentation of memory allocation.
The original processors developed by Intel were unable to use more than 1 MB of RAM,
and the original IBM PC allowed only the first 640 KB of memory for direct use. MS-DOS
applications were written to conform to this limitation. As application requirements grew,
programmers needed to optimize the use of memory to make the most of the available
space. This 1 MB of memory was divided into two sections. The first 640 KB was reserved
for the operating system and applications (designated as conventional memory). The
remaining 384 KB of RAM (designated as upper memory) was earmarked for running the
computer's own housekeeping needs (BIOS, video RAM, ROM, and so on). Although some
early PC clones had firmware that could make direct use of the upper memory block
available to programmers, actually doing so would result in hardware and software
incompatibility issues (see Figure 7.9)

Figure 7.9 IBM PC/MS-DOS Memory map


Under MS-DOS and Windows 3.x, the 640-KB area must be kept as free as possible for
program use. MS-DOS memory optimization ensures that MS-DOS applications have as
much of this memory as possible. The MS-DOS limitations no longer apply to Windows 95
in 32-bit mode and newer operating systems. However, they are still an important part of
running MS-DOS, Windows 3.x-based programs on older machines or in MS-DOS
compatibility mode with the more advanced operating systems.
Types of Memory Access
When we speak of memory in a computer, we are generally speaking of its RAM, because
ROM cannot be written to by either the system or applications. Although we have only
one source of RAM, under MS-DOS-based operating systems, it is divided into smaller
groups depending on how it is used.
Extended Memory Specification (XMS)
RAM above the 1-MB address is called extended memory. With the introduction of the
80286 processor, memory was addressable up to 16 MB. Starting with the 80386DX
processor, memory was addressable up to 4 GB. Extended memory is accessed through
an extended memory manager (HIMEM.SYS for MS-DOS or a third-party utility such as
386MAX).
Conventional Memory
Conventional memory is the amount of RAM, typically 640 KB, that is addressable by an
IBM PC or compatible machine operating in real mode. (Real mode is the only operating
mode supported by MS-DOS.) Conventional memory is located in the area between 0 and
640 KB. Without the use of special techniques, conventional memory is the only kind of
RAM accessible to MS-DOS programs.
MS-DOS Protected Mode Interface (DPMI)
MS-DOS Protected Mode Interface (DPMI) is a specification that allows multiple
applications to access extended memory at the same time and has been endorsed by
most memory-manager producers and applications developers. Windows uses the DPMI
specification.
Expanded Memory Specification (EMS)
This technique, developed by Lotus/Intel/Microsoft (LIM), uses a 64-KB section of
memory (usually in upper memory) to provide a "window" in which data can be written.
Once in this area, the data can be transferred to the expanded memory. The memory
chips are located on an expansion card installed inside the computer. The data is paged
or swapped to and from the CPU through this window (see Figure 7.10).
Figure 7.10 Expanded memory
Expanded memory can provide up to 32 MB of additional memory, and because it is
loaded from a 64-KB section, it is below the 1-MB limit and therefore MS-DOS can
recognize it.
MS-DOS applications must be specifically written to take advantage of expanded
memory. Windows applications do not use expanded memory; 80386 and newer
processors can emulate expanded memory by using memory managers such as
EMM386.EXE and HIMEM.SYS.
High Memory Area (HMA)
An irregularity was found in the Intel chip architecture that allowed MS-DOS to address
the first 64 KB of extended memory on machines with 80286 or higher processors. This
special area is called the high memory area. A software driver called an "A20 handler"
must be run to allow the processor to access the HMA. MS-DOS uses HIMEM.SYS for this
purpose. The only limitation is that HIMEM.SYS can load only a single program into this
area. Typically, MS-DOS is loaded into HMA to free conventional memory (see Figure
7.11).
Figure 7.11 High memory area
Protected Mode
Beginning with 80286 processors using an operating system such as OS/2 or Windows, a
computer can create "virtual machines," providing all the functionality of a standard
computer in real mode but allowing multiple tasks to take place at the same time. This is
called protected mode because the processor, memory, and other hardware are
"protected" from the software application taking direct control of the system by the
operating system, which allocates memory and processor time.
Real Mode
In real mode (MS-DOS), a computer can perform only one operation at a time and an
application expects full control of the system. Real mode operates within the MS-DOS 1-
MB limitation.
Shadow RAM
Many high-speed expansion boards use shadow RAM to improve the performance of a
computer. Shadow RAM rewrites (or shadows) the contents of the ROM BIOS and/or
video BIOS into extended RAM (between the 640-KB boundary and 1 MB). This allows
systems to operate faster when application software calls any BIOS routines. In some
cases, system speed can be increased up to 400 percent (see Figure 7.12).
Figure 7.12 Shadow RAM
Upper Memory Area (UMA)
The upper memory area (UMA), the memory block from 640 KB to 1024 KB, is
designated for hardware use, like video RAM, BIOS, and memory-mapped hardware
drivers that are loaded into high memory. Refer to Tutorial 15, "Software: MS-DOS and
Windows 3.x," for details.
Upper Memory Blocks (UMB)
The unused addresses in upper memory, known as upper memory blocks (UMB), can be
divided into blocks. These empty blocks have no RAM associated with them and are
simply reserved space. This unused space is valuable because, unlike expanded and
extended memory, MS-DOS can run programs in UMB.
Virtual Control Program Interface (VCPI)
The memory-management specification, known as Virtual Control Program Interface
(VCPI), accesses extended memory for MS-DOS-based applications. It allows only one
application to control extended memory and does not support multitasking. Windows is
not compatible with the VCPI specification.

Você também pode gostar