Professional Documents
Culture Documents
Scan 11 Feb 2022
Scan 11 Feb 2022
All memory locations and 1/O registers are. of course, conprised of bits, but
because single bits contain very little information they are grouped together
form bytes and words. Because characters are normally 7 or 8 bits long and becausa
computers work more naturally with powers of 2. bytes almost always consist of s
on the
bits.
Words may consist of 2. 3, or 4 bytes, depending
computer
have
and its
systembus structure. Since the 16-bit single-chip microprocessors 16 data
lines in their system buses, they use the term "*word" to mean 2 bytes (16 bits).
Each byte has an identifying address associated with it and when a byte is to
be accessed its address is transmitted to the appropriate interface via the addres
lines. Addresses are composed of bit combinations and the set of all possible
combinations for a given situation is called an address space. Some computers have
two address spaces while others use a single address space to access all memory
locations and I/O registers. If there are separate memory and 1/O address spaces,
then of the control lines must be used in conjunction with the address lines
some
I/O address and the register within the interface is selected by the 2 or 3 low-order
bits. The overall organization of memory and I/O registers and how they are
addressed is summarized in Fig. 1-7.
The number of possiblebits in an address determines the size of an
space. If an address is n bits wide, then there are 2" possible addresses (0 through
address
2"-1). The number of address lines in the system bus dictates the size of the
emory (or possibly the combined memory and I/0) space. A total of address
nes would imply a maximum memory (or overall memory and 1/O) capaciy oi
n
220=(210)2=(103)2 =
1 million bytes
nere are 2
uaress is to be used tobytes in a
identifv
word there is some
question
the word. Also. it is
as to
wnic
te
t about a specific bit in a sometimes necessa to
C manuals) the address of byte or word. the
a word is the address Throughout this book (ai
of its low-order, or Ss,
loW-adu
Sec. 1-3 Addresses 15
Addresses
Memory module
Bytes in memory
|
Interface10
Bus control
CPU logic
High-order bits
determine module
1/0 registers
(or ports)
conventions.
Address and bit numbering
Figure 1-8
Word address
AddressN
Address N+1 Low-order byte
High-order byto
Bit 7 1465 4 21 08 7 6 5
3 10
13 12 11 9
nos. 15
Introduction
16
Chap. 1
words may require more than
one memory acce
however, accessing *nonaligned" cess
word that begins with an odd address require.
res
(e.g.. c n the 8086, referencing
a
6. Subroutines.
7. 1/O.
processorstatus word The PSW contains bits which indicate such things
(PSW).
whether the previous arithmetic operations produced a positive, negative, or zei
CPU
Address registers
Program counter (PC)
ALU
A
branch instruction
Branch F
condition met
T
Set PC to address
of next sequential
Set PC to
instruction
branch address
Subroutine
Entry point:
Return Call
address
Return
was last accessed (or, on some computers, that will be accessed next) is kept in
the stack pointer (SP) register. Stacks and subroutines are discussed in detail in
Chap. 4.
The working registers are for temporarily holding information that aids the
addressing and computational process. They tend to be divided into two groups.
an address group and an arithmetic group, although some registers may be such
that they can be used for both purposes.
The address group is used for making the addressing of data more flexible.
A datum being operated on by an instruction may be part
of the instruction, its
address may be part of the instruction, it may be in a register,
its address may be
of the instruction and the
in a register, or its address may be the sum of part
contents of one or more registers.
Sometimes when a register is used the instruction
contains the address, but other times the address
simply indicates the register that when accessing elements of an
determination is more complicated. For example,
an element is comprised of
two parts, a base address, which
array the address of
in the array, and an offset. Because one often
is the address of the first element
if the offset can be easily incremented.
needs to index through an array, it is helpful
element is frequently computed by adding two
Therefore, the address of an array
contains the base address and is called a base register
registers together, one which
and is called an index register. A two-dimensional
and one which contains the offset
more complex situation which requires
the addition of a base.
array offers a slightly
This normally involves the sum of part of the
a column offset, and a displacement.
instruction (the displacement), a base register, and an index register. Base registers
and blocks of data within memory, a topic that
are also used to relocate programs
and 4.
is explored further in Chaps. 2
Arithmetic registers are for temporarily holding the operands and results of
the arithmetic operations. Because transfers over the system bus are the primary
limiting factor with regard to speed, accessing a register is muchfaster than accessing
memory. Therefore, il several operations must be perlormed on a set of data, it
is better to input the data to the arithmetic registers, do the necessary calculations,
and return the result to memory than it is to work directly from memory. The
2 8086 Architecture
LIBRARY
up to 10 MHz.) Rounding out the 40-pin contiguration are
and 20.
25
8086 Arcniet
Chap.2
Supply voltage, +5 v
a0Vcc Address/data
26 3 9 A D 1 5 -
GND
3 8 A 1 6 / $ 3
Ground
c14
Address/control
37A17/s4
AD13 3
36 A 18/S5
AD124
35 A 19/S6
AD11 5
AD10 6 34BHES7
AD97 33MN/MK
AD8 8 32RD
Address/data AD79 31ROGTO
(HOLD)
AD610 8086 3 0 R O / G T Í (HLDA)
CPU
AD511 29 LOCK (WR)
AD4 12
(M/O) Control
2852
AD3 13
27T (DT/A)
A02 14
(DEN)
26 S0
AD115 (ALE)
25 as0
ADO16
24 aS1 INTA)
NMI 17
Control INTR 18 23 TEST
Instruction
Data registers
queue
AX AH AL
BX 8H BL
Address/data
Control
CX CH CL logic (20 pins)
DX DH DL
PSW IP -Ground
Clock
gram counter and stack pointer; and the segment group, which is a set of special
purpose base registers. All of the registers are 16 bits wide.
The data group consists of the AX, BX, CX, and DX registers. These registers
can be used to store both operands and results and each of them can be accessed
as a whole, or the upper and lower bytes can be accessed separately. For example,
either the 2 bytes in AX can be used together, or the upper byte AH or the lower
byte AL can be used by itself by specifying AH or AL, respectively. For purposes
of converting 8080 software into 8086 software the following correspondences can
be drawn:
8086 8080
AL
BH H
L
H B
L C
DH
DL
D
In addition to serving as arithmetic registers, the BX, CX, and DX registers
play special addressing, counting, and I/O roles:
BX may be used as a base register in address calculations.
CX is used as an implied counter by certain instructions.
DX is used to hold the I/O address during certain 1/0 operations.
28 8086 Architecture
Chap
The pointer and index IP, SP, BP, SI,
consists of the
group and DI
rogram.registe
he instruction pointer (IP) and SP registers are essentially the pro
and stack pointer registers, but the complete instruction and stack add Oun
formed by iding the contents of these
registers to the contents of the codeesa
(CS) and stack segment (SS) registers discussed below. BP is a base r"gme
ecessing the stack and may be used with other registers and/ora giste
a t is part of the instruction. The SI and DI registers are for indexing. A e displace
they may be used by themselves, they are often used with the BX or Bpou
andor a displacement. Except for the IP. a pointer can be used to hold
old an.
an
giste=
but must be accessed
as a
whole. operan
o provide flexible base addressing and indexing, a data address
may
tormed by adding together a combination of the BX or BP register contay
Or
DI register contents, displacement. The result of such an addrese
and a ents,
putation is called an effective address (EA) or offset. |lhe Intel CoE
use the term
manuals tend
"effective address" when discussing the machine
term "offset" when
language and
discussing the assembler language. The word
IS used to
indicate a quantity that is added to the contents of a "*displacema
an
EA.] The final data address, however, is determined by the EAregister(s) to f
or
propriate data segment (DS), extra segment (ES), or stack segment and the-
The segment group consists of the (SS) regist
CS, SS, DS, and ES registers. As indicata
above, the registers that can be used for
DI registers, are addressing, the BX, IP, SP, BP, SL
only 16 bits wide and, therefore, an effective address has
bits.On the other hand, the address only 1
put on the address bus, called the physic
address, must contain 20 bits. The extra 4 bits are obtained
address to the contents of one of the by adding the etfectiv
addition is carried out by
segment registers shown in Fig. 2-3. Th
as
The utilization of the segment registers essentially divides the memory space
into overlapping segments, with each segment being 64K bytes long and beginning
at a 16-byte, or paragraph, boundary, i.e., beginning at an address that is divisible
by 16. We will hereafter refer to the contents of a segment register as the segment
address, and the segment address multiplied by 160 as the beginning physical
segment address, or simply, the beginning segment address. An illustration ot the
example above is given in Fig. 2-4(a) and the overall segmentation of memory iIs
shown in Fig. 2-4(b).
The advantages of using segment registers are that they:
Figure 2-5 shows how a program's code and its associated data and stack can
be separated in memory. The simpler and conventional approach is to let both the
code and the data reside in one contiguous area in memory and put the stack in
some fixed area which always begins at, say, address 08000. This is satisfactory if
there is only one program in memory at a time, but in a multiprogramming en-
vironment there may be several programs in memory simultaneously. For multi-
Memory
Memory
00000
00000
-(CS) 00010
123A0 (
-First segment
Effective address
(341B) 00020
Second segment
157BB Range of
code segment
Third segment
Next instruction 10000
10010
2239F
223A0
10020
beginning with an even address, and Fig. 2-9(b) shows the same sequence but
assumes an odd beginning address. Note that in the latter case the last byte of the
third instruction will not be brought into the queue until an empty word in the
queue becomes available.
An instruction is divided into groups of bits, or fields, with one field, called the
carrying out its task. An operand may contain a datum, at least part of the address
of a datum, an indirect pointer to a datum, or other information pertaining to the
data to be acted on by the instruction. A general instruction format is shown in
Fig. 2-10.
Instructions may contain several operands, but the more operands and the
these operands are, the more memory space they will occupy and
the more
longer
order to minimize
time it will take to transfer each instruction into the CPU. In
those for
the total number of bits in an instruction, most instructions, particularly
16-bit computers, are limited to one or two operands
with at least one operand in
a register. Because the memory
and/or I/O
a two-operand instruction involving
instruction.
Instruction Memory
EA Datur
(b) Direct
Instruction Register
Register Datum
(c) Register
Instruction
Register D1splacement
EA Memory
Register Datum
Address
(e) Register relative
Instruction Register
Base reg.index reg Index
Memory
Register Datum
Base addr.
(f) Based indexed
Instruction
Base reg. Index
reg.|Displacement
Register
Index Memory
Regisler Datum
Base addr.
(g) Relatve based
EA is
added to
1610 times indexed
the
contents ot the
aopropriate segrment Figure 2-11
reg ster.
modes.
Data-related a
Sec 2-3 Machine Language Instructions 37
(BX)
EA = (DI)
(SI)
Register Relative-The effective address is the sum of an 8- or l6-bit dis-
placement and the contents of a base register or an index register, i...
EA (BX)
1BP) J(D»}
(SI) |
Relative Based Indexed-The effective address is the sum of an 8- or 16-bit
displacement and a based indexed address, i.e.,
Direct: EA = IB57
Register
Instruction
EA' computed Effective branch address
Addressing mode according to or
addressing mode Memory
Effective branch address
(b) Intrasegment indirect
Instruction CS
Ofset Segynent
IP
Segrnent address
d) inter segnent
ndurect
EAIS odded to 101, tmes t e
contents of the
appropriate sug1nent
register
Sec. 2-3 Machine Language Instructions 39
placement is computed "relative" to the IP. It may be used with either con-
ditional or unconditional branching, but a conditional branch instruction can
have only an 8-bit displacement.
Intrasegment Indírect-The effective branch address is the contents of a reg-
ister or memory location that is accessed using any of the above data-related
addressing modes except the immediate mode. The contents of IP are replaced
by the effective branch address. This addressing mode may be used only in
unconditional branch instructions.
Intersegment Direct-Replaces the contents of IP with part of the instruction
and the contents of CS with another part of the instruction. The purpose of
this addressing mode is to provide a means of branching from one code
segment to another.
Intersegment Indirect-Replaces the contents of IP and CS with the contents
of two consecutive words in memory that are referenced using any of the
above data-related addressing modes except the immediate and register modes.
Note that the physical branch address is the new contents of IP plus the contents
of CS multiplied by 1610. An intersegment branch must be unconditional.
To demonstrate how indirect branching works with some of the data-related
addressing modes, suppose that
(BX) = 1256 (SI) = 528F Displacement = 20A1
Then:
With direct addressing, the effective branch address is the contents of:
Several representative 8086 instruction formats are shown in Fig. 2-13. The in-
structions vary from 1 to 6 bytes in length and a complete summary of them is
given in Scc. 3-12. Displaceinents and immediate data may be either 8 bits or 16
bits long depending on the instruction. The op code and addressing mode desig-
nations are in the first 1 or 2 bytes of an instruction. The op code/addressing mode