Intel 80386 DJ Equipment User Manual


 
CHAPTER 2
APPLICATION ARCHITECTURE
The 80386 provides the assembly language appli-
cation programmer
or
compiler writer with an
extensive set
of
32-bit resources. The chapter
describes these resources in three sections:
I) registers,
2)
memory and logical addressing,
and
3)
data types and instructions.
2.1
Registers
Computers, including the 80386, provide registers
that programmers can use for very fast local
storage. Register-resident data can
be
accessed
without running bus cycles, thereby improving
instruction execution time and leaving more bus
bandwidth for other processors, such as direct
memory access controllers. The
80386 provides
programmers and compilers with eight general
registers; another eight registers can be supplied
by an optional
80287
or
80387
Numeric Coproces-
sor.
Two
other 80386 registers, which are oriented
toward processor control and status, rather than
data storage, are also important to programmers;
these are the Flags register and the Instruction
Pointer.
2.1.1
General Registers
As
Figure
2-1
shows, the 80386 general registers
are
32
bits wide; the processor's internal data
paths, data bus, and address bus are also 32 bits
wide.
By
any usual definition, the 80386
is
a
32-bit word machine. However, following the
practice of a number of processors whose ances-
tors are 16-bit machines, an
80386 word
is
16
bits,
while a 32-bit quantity
is
called a doubleword,
or
dword.
As Figure
2-1
shows, all
of
the general registers
can be used as
16-
or
32-bit registers and four of
them can also be used as eight 8-bit registers. In
nearly all instructions, any general register can
be
specified as
an
operand.
For
example, any two
registers can be multiplied together. Similarly,
any register can be used as a base
or
index
2-1
register in
an
address computation (discussed
later in the chapter). Because every useful pro-
gram needs a stack, the
ESP
general register
is
implicitly defined as the top of stack pointer.
31
15
AX
AH
I
AL
EAX
BX
BH
I
BL
EBX
CX
CH
I
CL
ECX
OX
OH
I
OL
EOX
SI
ESI
01
EOI
BP
EBP
SP
ESP
Figure
2-1.
General Registers
2.1.2
Flags and Instruction Pointer
Figure
2-2
shows the format
of
the 80386 Flags
register. The flags can
be
considered in three
classes: status, control, and system. The processor
sets the status flags after many instructions to
reflect the outcome
of
the operation.
For
exam-
ple, when two operands compare equal, the
processor sets the Zero
flag.
Other instructions,
notably the conditional
Jump
instructions,
testa
status flag and behave differently depending on
the flag's value. Programmers can set control
flags to modify the semantics of some instruc-
tions.
For
example, the Scan string instruction
looks toward higher or lower addresses depending
on the value
of
the Direction Flag. The system
flags are provided for operating system use, and
can be ignored by application programmers.
(The system flags are discussed in Chapter 3.) In
fact, the
80386 protection system can be used to