User's Manual

CHAPTER
2
80286
BASE
ARCHITECTURE
This chapter describes the 80286 application programming environment as seen
by
assembly language
programmers.
It
is
intended to introduce the programmer to those features of the 80286 architecture
that directly affect the design and implementation of
80286 application programs.
2.1 MEMORY ORGANIZATION AND SEGMENTATION
The main memory of an 80286 system makes up its physical address space. This address space
is
organized
as
a sequence of 8-bit quantities, called bytes. Each byte
is
assigned a unique address ranging
from
0 up to a maximum of 2
20
(1
megabyte) in Real Address Mode, and up to
224
(16 megabytes)
in
Protected Mode. .
A virtual address space
is
the organization of memory
as
viewed by a program. Virtual address space
is
also organized in units of bytes. (Other addressable units such as words, strings, and BCD digits are
described below
in
section 2.2, "Data Types.") In Real Address Mode,
as
with the 8086 itself, programs
view physical memory directly, inasmuch as they manipulate pure physical addresses. Thus, the virtual
address space
is
identical to the physical address space
(1
megabyte).
In Protected Mode, however, programs have
no
direct access to physical addresses. Instead, memory
is
viewed
as
a much larger virtual address space of 2
30
bytes
(1
gigabyte). This 1 gigabyte virtual
address
is
mapped onto the Protected Mode's 16-megabyte physical address space by the address trans-
lation mechanisms described
in
Chapter
6.
The programmer
views
the virtual address space
on
the 80286
as
a collection of up to sixteen thousand
linear subspaces, each with a specified size or length. Each of these linear address spaces
is
called a
segment. A segment
is
a logical unit of contiguous memory. Segment sizes may range from one byte
up to 64K (65,536) bytes.
80286 memory segmentation supports the logical structure of programs and data
iq
memory. Programs
are not written
as
single linear sequences of instructions and data, but rather
as
modules of code and
data. For example, program code may include a main routine and several separate procedures. Data
may also be organized into various data structures, some private and some shared with other programs
in
the system. Run-time stacks constitute yet another data requirement. Each of these several modules
of code and data, moreover, may be very different
in
size
or
vary dynamically with program execution.
Segmentation supports this logical structure (see figure 2-1). Each meaningful module of a program
may be separately contained in individual segments. The degree of modularization, of course, depends
on
the requirements of a particular application. Use of segmentation benefits almost all applications.
Programs execute faster and require less space. Segmentation also simplifies the design
of
structured
software.
2.2
DATA TYPES
Bytes and words are the fundamental units in which the 80286 manipulates data, i.e., the fundamental
data types.
2-1