Intel 80386 DJ Equipment User Manual


 
CHAPTER 4
ARCHITECTURAL COMPATIBILITY
The
80386
is
compatible at the object code level
with both the 80286 and the 8086. While it
is
possible to use the 80386 simply as a fast 80286
or
a very fast 8086, its compatibility facilities are
substantially more versatile. The 80386 can
execute 80286 and 80386 programs concurrently,
and, using the 80386's Virtual
86
Mode, existing
8086 programs can also be run concurrently.
With the 80386, then,
it
is
possible to build
systems that can concurrently execute software
written for three generations of Intel
86
family
microprocessors.
4.1
80286 Compatibility
The 80286 architecture
is
a proper subset
of
the
80386 architecture. Because the
80386 recognizes
all 80286 instructions, registers, descriptors, and
so on,
an
80286 operating system and application
programs can be ported to comparable 80386-
based hardware without changing a bit.
Direct porting, as described above,
is
the quickest
way to get existing 80286 software running on
an
80386-based system. Alternatively,
an
80386
operating system can be designed to support
existing 80286 applications, while at the same
time allowing new applications to use the full
facilities
of
the 80386 architecture (for example,
32-bit parameters and large segments).
In
such a
hybrid design, new applications call the operating
system directly, passing 32-bit parameters. The
calls
of
old applications, which are in the 80286's
16-bit format, are intercepted and converted to
32-bit format and then passed to the operating
system.
4.2 Real and Virtual 86 Modes
The 80386 can execute 8086 object code in either
of
two modes, Real Mode or Virtual 86 Mode.
The 80386 enters Real
Mode
when it
is
reset. In
Real Mode, the processor provides fast execution
in
an
unprotected environment like that
of
an
4-1
8086. Most operating systems will switch from
Real Mode to
Protected Mode after initiali-
zation, but it
is
also possible to run 8086 software
in
Real Mode. The principal difference between
80386 Real
Mode
and
an
actual 8086
is
speed:
8086 programs that are speed-dependent (for
example, those that use timing loops) may need
minor modifications to run properly on the
much faster
Real
Mode
80386.
The great majority
of
8086 programs, however,
will
run without
difficulty, just as they do on a Real Mode
80286.
Virtual
86
Mode establishes
an
8086 execution
environment within the protected multi task envi-
ronment of the
80386.
Where
Real
Mode governs
everything the processor does, Virtual
86
Mode
can
be
applied to selected 80386 tasks. When
executing a Virtual
86
Mode task, the processor
behaves like an
8086, but upon a switch to a
normal task, the processor operates as an
80386
(which, of course, can interpret both 80286 and
80386 programs). Thus, Virtual
86
Mode enables
an operating system to support the execution
of
8086, 80286, and 80386 programs concurrently.
Chapter 3 described how a task's Task State
Segment represents the state
of
its virtual pro-
cessor. The
VM86 flag
in
the Flags register,
which
is
loaded from the TSS, defines the
running task's virtual processor as an
8086
or
an
80386. When the 80386 loads its registers from a
TSS whose VM86 flag
is
set, the processor enters
Virtual
86
Mode. When, on a subsequent task
switch, the processor loads register values from a
TSS whose VM86 flag
is
clear,
it
leaves Virtual
86
Mode. Thus, on a task
by
task basis, the
processor emulates an
80386
or
an
8086 according
to the value
of
the VM86 flag. The 80386 also
leaves Virtual
86
Mode
when
it
raises
an
excep-
tion
or
is
interrupted, making the full resources
of
the architecture available to interrupt and
exception handlers.
On
return from a handler
invoked in Virtual
86
Mode, the 80386 auto-
matically re-enters Virtual 86 Mode.