ARCHITECTURE AND INSTRUCTIONS
been prefetched and that it
is
waiting in the
instruction queue,
an
assumption that
is
valid
under most, but not all operating conditions.
A series of fast executing (fewer than two
clocks per opcode byte) instructions can
drain the queue and increase execution time.
Execution time also
is
slightly impacted by
the interaction of the
CPU's internal instruc-
tion execution unit
(EU) and BU's interface
unit
(BIU) when memory operands must be
read
or
written.
If
the EU needs access to
memory, it may have to wait for up to one
clock if the
BIU has already started an
instruction fetch bus cycle. The
EU can
detect the need for a memory operand and
post a bus request far enough in advance of
its need for this operand to
avoid waiting a
fu1l4-clock bus cycle.
Of course, the EU does
not have to wait if the instruction queue be-
tween the
BIU and EU
is
full, because the BIU
is
idle. (Note:
8088
queue contains 4 bytes.)
With typical instruction mixes, the time actu-
ally required to execute a sequence
of
instructions
will
typically be within
5-10%
of
the sum
of
the individual timings given in the
instruction set sequence. Cases can be con-
structed, however, in which execution time
may be much higher than the sum of the
figures provided. The execution time for a
given sequence of instructions, however,
is
always repeatable, assuming comparable ex-
ternal conditions (interrupts, coprocessor
activity, etc.)
If
the execution time for a given
series of instructions must be determined
exactly, the instructions should be run on
an
actual system hardware implementation.
ASSEMBLY LANGUAGE PROGRAMMING[1]
This section, while not meant to be a com-
pendium
of
all features and rules
of
ASM-86
(the Intel assembler for
8088
instructions)
covered in detail by the Intel
iAPX
86,88
Assembly Language Reference Manual, pre-
sents most of the ASM-86 features in a form
[1] Edited and reprinted with permission of Hayden Book Co. from
The 8086 Primer. by Stephen P. Morse. Copyright
1980.
2-18
to enable you to write meaningful programs.
Not covered are many advanced ASM-86
features; attention
is
focused on underlying
concepts of the language.
Object Code
Let's first consider a simple program that
reads in word values from input port
5,
increments each value read, and writes the
results to output port
2.
The program
is
as
follows:
Memory Address
(Hexadecimal)
00000
00001
00002
00003
00004
00005
00006
00007
Memory Contents
(Binary)
11100101
00000101
01000000
11100111
00000010
11101011
11111001
Comments
read word into
AX
...
...
from input port 5
increment
AX
write word from AX
...
...
to output port 2
repeat by jumping
...
...
back
seven
bytes
The first two columns specify the address and
contents of each relevant memory location
and, as such, constitute the only form of the
program comprehensible to the processor.
This
is
called object code, and the language
of
l's and
O's
in which the object code
is
writ-
ten
is
called machine language. Once
we
have
the program in object code form,
we
can
store it in memory and then have the
8088
execute it.
Source Code
Writing a program in l's and
O's
is
tedious
and repetitive, a task that computers do
well.
So, instead
of
writing the program in
machine language,
we
write the program in a
language more familiar to us and then use a
computer to translate it into the
8088's lan-
guage. A program written in this more
familiar language
is
called source code, and
the computer program that translates source
code into object
code)s
called a translator.
(Fig.
2-11)
There are two kinds
of
translator languages
for writing source code:
assembly languages
and high-level languages described below and
illustrated in Fig.
2-12