Professional Documents
Culture Documents
Chap37 Intel CS2
Chap37 Intel CS2
microprocessors, the 4004 for a calculator and the 8008 for a CRT
A. The Prophecy terminal. The 4004, in particular,
replaced what would otherwise
have been six customized chips, usable by
Intel introduced the microprocessor in November 1971 with the only one customer.
advertisement, "Announcing a New Era in Integrated Electron- Because the first microcomputer applications were known,
tangi-
"
ics. The fulfillment of this prophecy has already occurred with ble,and easy to understand, instruction sets and architectures
the delivery of the 8008 in 1972, the 8080 in were defined in a matter of weeks. Since
they were programmable
1974, the 8085 in
1976, and the 8086 in 1978. During this time, throughput has computers, their uses could be extended indefinitely.
Both of these first microprocessors were
improved 100-fold, the price of a CPU chip has declined from complete CPUs-on-a-
$300 to $3, and microcomputers have revolutionized chip and had similar characteristics. But because the 4004 was
design
concepts in countless applications. They are now entering our designed for serial BCD arithmetic while the 8008 was made for
homes and cars. 8-bit character handling, their instruction sets were quite differ-
Each successive product implementation depended on semi- ent.
conductor process innovation, improved architecture, The succeeding years saw the evolutionary process
that eventu-
better
circuit design, and more ally led to the 8086. Table 1 summarizes the
sophisticated software, yet upward progression of
features that took place during these years.
compatibility not envisioned by the first designers was main-
tained. This paper provides an
insight into the evolutionary
process that transformed the 8008 into the 8086, and gives
descriptions of the various processors, with on the 8086.
II. 8008 Objectives and Constraints
emphasis
615
616 Part 3 I
Computer Classes Section 2 I Microcomputers
B. Register Structure result. The presence of this flag creates the illusion that the 8008 is
stack.
more, comparing signed numbers by subtracting them and then
testing the SIGN flag will not give the correct result if the
1. The scratchpad file contains an 8-bit accumulator subtraction resulted in signed overflow. This oversight was not
Scratchpad.
A and corrected until the 8086.
called six additional 8-bit registers called B,C,D,E,H, and
L. All arithmetic operations use the accumulator as one of the The PARITY flag indicates if the result is even or odd parity.
This permits testing for transmission errors, an obviously usefiil
operands and store the result back in the accumulator. All seven
fimction for a CRT terminal.
registers can be used interchangeably for on-chip temporary
storage. C. Instruction Set
There is one pseudo-register, M, which can be used inter-
M The 8008 instructions are designed for moving or modifying 8-bit
changeably with the scratchpad registers. is, in effect, that
particular byte in memory whose address is currently contained in operands. Operands are either contained in the instruction itself
H and L (L contains the eight low-order bits of the address and H (immediate operand), contained in a scratchpad register (register
contains the six high-order bits). Thus M
is a byte in memory and operand), or contained in the M
register (memory operand). Since
not a register; although instructions address as if it were aM the M register can be used interchangeably with the scratchpad
register, accesses to M actually involve memory references. The registers, there are only two distinct operand-addressing modes —
M register the only mechanism by which data in immediate and register. Typical instruction formats for these
is memory can be
accessed. modes are shown in Fig. 1. A summary of the 8008 instructions
appears in Fig. 2.
2.Address Stack. The address stack contains a 3-bit stack pointer The instruction set consists of scratchpad-register instructions,
and eight 14-bit address registers providing storage for eight accumulator-specific instructions, transfer-of-control instructions,
addresses. These
registers are not directly accessible by the input/output instructions, and processor-control instructions.
programmer; rather they are manipulated with control-transfer The scratchpad-register instructions modify the contents of the
instructions. M register or any scratchpad register. This can consist of moving
Any one of the eight address registers in the address stack can data between any two registers, moving immediate data into a
serve as the program counter; the current program counter is register, or incrementing or decrementing the contents of a
specified by the stack pointer. The other seven address registers register. The incrementing and decrementing instructions were
permit storage for nesting of subroutines up to seven levels deep. not in Computer Terminal's specified instruction set; they were
The execution of a call instruction causes the next address register added by Intel to provide for loop control, thereby making the
in turn to become
the current program counter, and the return processor more general-purpose,
instruction causes the address register that last served as the Most of the accumulator specific instructions perform opera-
program counter to again become the program counter. The stack tions between the accumulator and a specified operand. The
wrap around
will if subroutines are nested more than seven levels operand can be any one of the scratchpad registers, including M,
deep. or it can be immediate data. The operations are add, add-with-
carry, subtract, subtract-with-borrow, logical AND, logical OR,
3. Flags. The
four flags in the 8008 are CARRY, ZERO, SIGN, logical exclusive-OR, and compare. Furthermore, there are four
and PARITY. They are used to reflect the status of the latest unit-rotate instructions that operate on the accumulator. These
arithmetic or logical operation. Any of the flags can be used to instructions perform either an 8- or 9-bit rotate (the CARRY flag
alter program flow through the use of the conditional jump, call, acts as a ninth bit) in either the left or right direction.
or return instructions. There no direct mechanism for saving or
is Transfer-of-control instructions consist of jumps, calls, and
restoring flags, which places a severe burden on interrupt returns. of the transfers can be unconditional, or can be
Any
processing (see Appendix 1 for details). conditional based on the setting of any one of the four flags.
The CARRY flag indicates if a carry-out or borrow-in was Making calls and returns conditional was done to preserve the
generated, thereby providing the ability to perform multiple- symmetry with jumps and for no other reason. A short one-byte
precision binary arithmetic. form of call is also provided, which will be discussed later under
The ZERO flag indicates whether or not the result is zero. This interrupts.
provides the ability to compare the two values for equality. Each of the jump and call instructions (with the exception of the
The SIGN flag reflects the setting of the leftmost bit of the one-byte call) specifies an absolute code address in the second and
618 Part 3 Computer Classes Section 2 Microcomputers
I
no operands
m
i
.i
>.
g S
620 Part 3 Computer Classes Section 2 | Microcomputers
I
instructions but not necessarily with the same encodings. This facilitiesof the 8080 are primarily byte-oriented (the 8008 was
meant would be portable but the actual ROM
that user's software exclusively byte-oriented), certain operations permit two consecu-
chips containing the programs would have to be replaced. The tive bytes of memory to be treated as a single data item. The two
main objective of the 8080 was to obtain a 10:1 improvement in bytes are called a word. The data bus of the 8080 is only eight
throughput, eliminate many of the 8008 shortcomings that had by bits wide, and hence word accesses require an extra memory
then become apparent, and provide new processing capabilities cycle.
not found in the 8008. These included a commitment to 16-bit The most significant eight bits of a word are located at the
data types mainly for address computations, BCD arithmetic, higher memory address. This results in the same kind of inverted
enhanced operand-addressing modes, and improved interrupt storage already noted in transfer instructions of the 8008.
capabilities. Now that memory costs had come down and process-
The 8080 extends the 32-port capacity of the 8008 to 256 input
ing speed was approaching TTL, larger memory spaces were ports and 256 output ports. In this instance, the 8080 is actually
appearing more practical. Hence another goal was to be able to more symmetrical than the 8008. Like the 8008, all of the ports
address directly more than 16K bytes. Symmetry was not a goal, are directly addressable by the instruction set.
opcode space. The 8080 processor contains a file of seven 8-bit general registers,
a 16-bit program counter (PC) and stack pointer (SP), and five
1-bit flags. A comparison between the 8008 and 8080 register sets
V. The 8080 Instruction-Set Processor is shown in Fig. 3.
taken.
C. Instruction Set
General Registers. The 8080 registers are the same seven
1.
8-bit registers that were in the 8008 scratchpad namely A,B,C, — The 8080 includes the entire 8008 instruction set as a subset. The
D,E,H, and L. In order to incorporate 16-bit data facilities in the added instructions provide some new operand-addressing modes
8080, certain instructions operate on the register pairs BC, DE, and some facilities for manipulating 16-bit data. These extensions
and HL. have introduced a good deal of asymmetry. Typical instruction
The seven be used interchangeably for on-chip
registers can formats are shown in Fig. 1. A summary of the 8080 instructions
temporary storage. three register pairs are used for address
The appears in Fig. 4.
not interchangeable; there is an 8008 had in
manipulations, but their roles are The only means that the for accessing operands
operations on DE and not BC,
and
8080 instruction that allows
memory was via the M register. The 8080 has certain instructions
there are address modes that access memory indirectly through that access memory by specifying the memory address (direct
BC or DE but not HL. addressing) and also certain instructions that
access memory by
As in the 8008, the A register has a unique role
in arithmetic
a
specifying pair of general registers in which the memory address
and logical operations: it serves as one of the operands and is the iscontained (indirect addressing). In addition, the 8080 includes
receptacle for the result, The HL register again has its special role the register and immediate operand-addressing modes of the
of pointing to the pseudo-register M. 8008. A 16-bit immediate mode is also included.
The added be classified as load/store
instructions can instruc-
2. Stack Pointer and Program Counter. The 8080 has a single tions, register-pair instructions, HL-specific instructions,
counter of the I/O
program counter instead of the floating program accumulator-adjust instructions, carry instructions, expanded
8008. The program counter is 16 bits (two bits more than the instructions, and interrupt instructions.
80O8's counter), thereby permitting an address space of
program The load/store instructions load and store the accumulator
64K. register and the HL
register pair using the direct and
indirect
removes the restriction of only seven levels of nested subroutines. but due to chip size constraints, only the direct mode was
The entries on the stack are 16 bits wide. The 16-bit stack pointer implemented for HL.
is used to locate the stack in memory. The execution
of a call The for the manipulation of
register-pair instructions provide
instruction causes the contents of the program counter to be 16-bit data items. Specifically, register pairs can be loaded with
causes the last immediate data, incremented, decremented, added to HL,
pushed onto the stack, and the return instruction 16-bit
be the counter. The stack the
pushed on the stack, or popped off the stack. Furthermore,
stack entry to popped into program
was chosen to run "downhill" (with the stack advancing themselves can be and popped, thereby
pointer flag settings pushed
toward lower memory) to simplify indexing into the stack from the simplifying saving the environment when interrupts
occur (this
the
user's (positive indexing) and to simplify displaying
program was not possible in the 8008).
contents of the stack from a front panel. The HL-specific instructions include facilities for transferring
Unlike the 8008, the stack pointer is directly accessible to the HL to the to the stack pointer, and exchang-
program counter or
programmer. Furthermore, the stack itself is directly accessible, ing HL with
or DE
with the top entry on the stack. The last of
and instructions are provided that permit the programmer to push these instructions was included to provide a mechanism for (1)
and pop his own 16-bit items onto the stack. removing a subroutine return address from the stack so that
a result-to-be-
passed parameters can be discarded or (2) burying
3. Flags. A fifth flag, AUXILIARY CARRY, augments the 8008 returned under the return address. This became the longest
flag set to form the flag set of the 8080. The AUXILIARY
CARRY instruction in the 8080 (5 memory cycles); its implementation
a carry was generated out of the four low-order instructions that were
flag indicates precluded the inclusion of several other
if
bits. This flag, in conjunction with a decimal-adjust instruction, already proposed for the processor.
provides the ability to perform packed
BCD addition (see Two accumulator-adjust instructions are provided. One comple-
Appendix 2 for details). This facility can be traced back to the 4004 ments each bit in the accumulator and the other modifies the
processor. The AUXILIARY CARRY flag has no purpose other accumulator so that it contains the correct decimal result after a
than for BCD
arithmetic, and hence the conditional transfer packed BCD addition is performed.
instructions were not expanded to include tests on the AUXILIA- carry instructions provide for setting or complementing
The the
RY CARRY flag. CARRY flag. No instruction provided
is for clearing the CARRY
It was proposed too late in the design that the PARITY flag Because of the way the CARRY flag semantics are defined,
flag.
should double as an OVERFLOW flag. Although this feature the CARRY flag can be cleared simply by ORing or ANDing the
didn't make it into the 8080, it did show up two years later in accumulator with itself
Zilog's Z-80.
Section 2 Microcomputers
622 Part 3 I
Computer Classes I
Chapter 37 {
Intel Microprocessors: 8008 to 8086 623
required a separate oscillator chip and system controller chip to megabyte of memory space and up to 64K input/output ports. The
make it usable). The new processor, called the 8085, was register structure includes three files of registers. Four 16-bit
constrained to be compatible with the 8080 at the machine-code general registers can participate interchangeably in arithmetic and
level.This meant that the only extension to the instruction set logic operations, two and two 16-bit index registers
16-bit pointer
could be in the twelve unused opcodes of the 8080. are used for address and four 16-bit segment
calculations,
The 8085 turned out to be architecturally not much more than a registers allow extended addressing capabilities. Nine flags record
repackaging of the 8080. The major diflFerences were in such areas the processor state and control its operation.
as an on-chip oscillator, power-on reset, vectored interrupts, The instruction set supports a wide range of addressing modes
decoded control lines, a serial I/O port, and a single power supply. and provides operations for data transfer, signed and unsigned 8-
Two new instructions were added to handle the serial port and and 16-bit arithmetic, logicals, string manipulations, control
interrupt mask. These instructions (RIM and SIM) appear in Fig. transfer, and processor control. The external interface includes a
4. Several other instructions that had been contemplated were not reset sequence, interrupts, and a multiprocessor-synchronization
made available because of the software ramifications and the and resource-sharing facility.
compatibility constraints they would place on the forthcoming
8086. A. Memory and I/O Structure
compatible with the 8080 so that existing 8080 software could be million 8-bit bytes, a considerable increase over the 64K bytes in
reassembled and correctly executed on the 8086. To allow for this, the 8080. Any two consecutive bytes may be paired together to
the 8080 register set and instruction set appear as logical subsets form a 16-bit word. Such words may be located at odd or even
of the 8086 registers and instructions. By utilizing a general- byte addresses. The data bus of the 8086 is 16 bits wide, so, unlike
register structure
architecture, could capitalize on its
Intel the 8080, a word can be accessed in one memory cycle (however,
experience with the 8080 to obtain a processor with a higher words located at odd byte addresses still require two memory
degree of sophistication. Strict 8080 compatibility, however, was cycles).As in the 8080, the most significant 8 bits of a word are
not attempted, especially in areas where it would compromise the located in the byte with the higher memory address.
final design. Since the 8086 processor performs 16-bit arithmetic, the
Thegoals of the 8086 architectural design were to provide address objects it manipulates are 16 bits in length. Since a 16-bit
symmetric extensions of existing 8080 features, and to add quantity can address only 64K bytes, additional mechanisms are
processing capabilities not foimd in the 8080. These features required to build addresses in a megabyte memory space. The
included 16-bit arithmetic, signed 8- and 16-bit arithmetic 8086 memory may be conceived of as an arbitrary number of
(including multiply and divide), efficient interruptible byte-string segments, each at most 64K bytes in size. Each segment begins at
operations, improved bit-manipulation facilities, and mechanisms an address which is evenly divisible by 16 (i.e., the low-order 4
to provide for re-entrant code, position-independent code, and bits of a segment's address are zero). At any given monient the
dynamically relocatable programs. contents of four of these segments are immediately addressable.
By now memory had become very inexpensive and micro- These four segments, called the current code segment, the
processors were being used in applications that required large current data segment, the current stack segment, and the current
amounts of code and/or data. Thus another design goal was to be extra segment, need not be unique and may overlap. The
able to address directly more than 64K bytes and support high-order 16 bits of the address of each current segment are held
multiprocessor configurations. in a dedicated 16-bit segment register. In the degenerate case
where all four segments start at the same address, namely address
0, we have an 8080 memory structure.
VIII. The 8086 Instruction-Set Processor Bytes or words within a segment are addressed by using 16-bit
offset addresses within the 64K byte segment. A 20-bit physical
The 8086 processor architecture is described in terms of its address is constructed by adding the 16-bit ofiset address to the
memory structure, register structure, instruction set, and external contents of a 16-bit segment register with 4 low-order zero bits
interface. The 8086 memory structure includes up to one appended, as illustrated in Fig. 5.
624 Part 3 I
Computer Classes Section 2 I
Microcomputers
The 8086 processor contains three files of four 16-bit registers and
a file of nine 1-bit flags. The three files of registers are the
Segment
Segment register the pointer- and index-register and the
address general-register file, file,
1///////////////
HL:
Fig. 5. To address 1 requires a 20-bit memory
million bytes
address. Tliis 20-blt constructed by offsetting the
address is BC:
effective address 4 bits to the right of the segment address, filling
in the 4 low-order bits of the segment address with zeros, and
general registers
7
AX : ; AH
626 Part 3 I
Computer Classes Section 2 I
Microcomputers
Such a scheme would have resulted in virtually no thrashing of 1. Operand Addressing. The 8086 instruction set provides many
segment register contents; start addresses of all needed segments more ways to address operands than were provided by the 8080.
would be loaded initially into one of the eight segment registers, Two-operand operations generally allow either a register or
and the roles of the various segment registers would vary memory to serve as one operand (called the firs{ operand), and
dynamically during program execution. Concern over the size of either a register or a constant within the instruction to serve as the
the resulting processor chip forced the number of segment other (called the second operand). Typical formats for two-
registers to be reduced to the minimum number necessary, operand operations are shown in Fig. 9 (second operand is a
namely four. With this minimum number, each segment register register) and Fig. 10 (second operand is a constant). The result of a
could be dedicated to a particular type of segment (code, data, two-operand operation may be directed to either of the source
stack, extra), and the specifying field- in the program status word operands, with the exception, of course, of in-line immediate
was no longer needed. constants.Single-operand operations generally allow either a
register or amemory to serve as the operand. A typical one-
4. Flag-Register File. The AF-CF-DF-IF-OF-PF-SF-TF-ZF operand format is shown in Fig. 11. Virtually all 8086 operators
register set is called the flag-register file or F group. The flags in may specify 8- or 16-bit operands.
this group are all one bit in size and are used to record proces-
sor status information and to control processor operation. The An address an operand
Memory operands. instruction may
flag registers' names have the following associated mnemonic one of four ways determined by the mod
residing in memory in as
phrases: and r/m fields in the instruction (see Table 2).
The AF, CF, PF, SF, and ZF flags retain their familiar 8080 The general register, BX, and the pointer register, BP, may serve
semantics, generally reflecting the status of the latest arithmetic as base registers. When
the base register BX is used without an
or logical operation. The OF flag joins this group, reflecting the index register, the operand by default resides in the current data
signed arithmetic overflow condition. The DF, IF, and TF flags segment. When the base register BP is used without an index
are used to control certain aspects of the processor. The DF flag register, the operand by default resides in the current stack
controls the direction of the string manipulations (auto- segment. When both base and index registers are used, the
incrementing or auto-decrementing). The IF flag enables or operand by default resides in the segment determined by the base
disables external interrupts. The TF flag puts the processor into a register. When an index register alone is used, the operand by
mode default resides in the current data segment.
single-step for prograrti debugging. More detail is given on
each of these three flags later in the chapter.
Auto-incrementing and auto-decrementing address modes were
not included in general, since it was felt that their use is mainly'
C. Instruction Set
oriented towards string processing. These modes were included
The 8086 instruction set — most of the 8080 set as a
^while including on the string primitive instructions.
subset —has more ways to address operands and more power in
ever>' area. It isdesigned to implement block-structured languag- Register operands. The four 16-bit general registers and the four
es efficiently. Nearly all instructions operate on either 8- or 16-bit 16-bit pointer and index registers may serve interchangeably as
operands. There are four classes of data transfer. All four operands in 16-bit operations. Three exceptions to note are
arithmetic operations are available. An additional logic instruc- multiply, divide, and the string operations, all of which use the
tion, test, is included. Also new are byte- and word-string AX register implicitly. The eight 8-bit registers of the group HL
manipulations and intersegment transfers. A summary of the 8086 may serve interchangeably in 8-bit operations. Again, multiply,
instructions appears in Fig. 8. divide, and the string operations use AL implicitly. Table 3 shows
lis
111
ii J J -ii I I I
jii slflUll I
111
Hi|iiii|lli|
§5? I IB S 8 o o
5
s = ;? :
iiii =8if liii
;"s=i
Lf I
L < < U O Ul <
1
1
o
o
628 Part 3 I
Computer Classes Section 2 I
Microcomputers
+.+.+.+.+.+.+.+.+ +-+-+-+-+-+--+-+ +--+-+-+--+-+- . + .*, + . + . + . + . + ,+ «- + . + ..t..4.- + -4.- + -4, 4.-4.- + -4.- + .4._ + _4._ +
optional( ) (optional )
first operand la register or meziory specified by seg, mod, r/m operand is register or memory specified by seg, mod, r/m,
disp-lo, disp-hi disp-lo disp-hi ,
mod : 00,01,10: first operand is memory (see Table 2) mod = 00,01,10: operand is memory (see Table 2)
11: first operand is register (see Table 3) 11; operand is register (see Table 3)
w s 0: operand is B bits
1: operand is 16 bits
:seg:
Chapter 37 |
Intel Microprocessors: 8008 to 8086 629
Table 2 Determining 8086 Offset Address of a IMemory Operand ;CALL MYPROC (ALPHA, BETA)
(Use This Table When mod 1 1 Otherwise Use Table 3.)
=!* ;
PUSH ALPHA ;pass parameters by
This table applies to the first operand only; the second operand
PUSH BETA
can never be a memory operand.
mod specifies how disp-lo and disp-hi are used to define a dis-
placement as follows:
performs a table-lookup byte translation. We will see the useful- A quotient overflow (e.g., that caused by dividing by zero) will
ness of this operation below, when it is combined with string automatically interrupt the processor.
operations.
—
The address-object transfers load efiFective address and load Decimal Packed
instructions. BCD
operations are provided in
—
pointer are an 8086 facility not present in the 8080. A pointer is a the form of accumulator-adjustment instructions. Two such
pair of 16-bit values specifying a segment start address and an instructions are provided —
one for an adjustment following an
offset address; it is used megabyte of
to gain access to the full addition and one following a subtraction. The addition adjustment
memory. The load pointer operations provide a means of loading a is identical to the 8080 DAA instruction; the subtraction adjust-
segment start address into a segment register and an offset address ment is defined similarly. Packed multiply and divide adjustments
into a general or pointer register in a single operation. The load are not provided, because the cross terms generated make it
effective address operation provides access to the offset address of impossible to recover the decimal result without additional
an operand, as opposed to the value of the operand itself processor facilities (see Appendix 2 for details).
The flag transfers provide access to the collection of flags for Unpacked BCD operations are also provided in the form of
such operations as push, pop, load, and store. A similar facility for accumulator adjust instructions (ASCII is a special case of
pushing and popping flags was provided in the 8080; the load and unpacked BCD). Four such instructions are provided, one each
store flags facility is new in the 8086. for adjustments involving addition, subtraction, multiplication,
should be noted that the load and store operations involve
It and division. The addition and subtraction adjustments are similar
only those flags that existed in the 8080. This is part of the to the corresponding packed BCD adjustments except that the
concessions made for 8080 compatibility (without these operations AH register is updated if an adjustment on AL is required. Unlike
would take nine 8086 bytes
it to perform exactly an 8080 PUSH packed BCD, unpacked BCD byte multiplication does not
PSW or POP PSW). generate cross terms, so multiplication adjustment consists of
converting the binary value in the AL register into BCD digits in
3. Arithmetics. Whereas the 8080 provided for only 8-bit AH and AL; the divide adjustment does the reverse. Note that
addition and subtraction of unsigned numbers, the 8086 provides adjustments for addition, subtraction, and multiplication are
all four basic mathematical functions on 8- and 16-bit signed and performed following the arithmetic operation; division adjustment
unsigned numbers. Standard 2's complement representation of is performed prior to a division operation. See Appendix 2 for
signed values is used. Sufficient conditional transfers are provided more details on unpacked BCD adjustments.
to allow both signed and unsigned comparisons. The OF flag
allows detection of the signed overflow condition. 4. Logicals. The standard logical operations AND, OR, XOR,
Consideration was given to providing separate operations for and NOT are carry-overs from the 8080. Additionally, the 8086
signed addition and subtraction which would automatically trap on provides a logical TEST for specific bits. This consists of a logical
signed overflow (signed overflow is an exception condition, AND instruction which sets the flags but does not store the result,
whereas unsigned overflow is not). However, lack of room in the thereby not destroying either operand.
opcode space prohibited this. As a compromise, a one-byte The four unit-rotate instructions in the 8080 are augmented
trap-on-overflow instruction was included to make testing for with four unit-shift instructions in the 8086. Furthermore, the
signed overflow less painful. 8086 provides multi-bit shifts and rotates including an arithmetic
The 8080 provided a correction operation to allow addition to be right shift.
performed directly on packed binary-coded representations of
decimal digits. In the 8086, correction operations are provided to 5. String Manipulation. The 8086 provides a group of 1-byte
allow arithmetic to be performed directly on unpacked represen- instructions which perform various primitive operations for the
tations of decimal digits (e.g., ASCII) or on packed decimal manipulation of byte or word strings (sequences of bytes or
representations. words). These primitive operations can be performed repeatedly
in hardware by preceding the instruction with a special prefix.
Multiply and divide. Both signed and unsigned multiply and The single-operation forms may be combined to form complex
divide operations are provided. Multiply produces a double- string operations in tight software loops with repetition provided
length product (16 bits for 8-bit multiply, 32 bits for 16-bit by special iteration operations. The 8080 did not provide any
multiply), while divide returns a single-length quotient and a string-manipulation facilities.
to be in the current data segment. The DI register is used to strings) into the destination operand. As a repeated opera-
address the destination operands, which reside in the current tion this provides for filling a string with a given value.
operand pointer registers (SI and DI) and the operation count • LOOPE decrements the CX register by 1 and transfers if
register (CX) are updated after each repetition, whereas the CX is not and the ZF flag is set (loop while equal).
instruction pointer will retain the offset address of the repeat
Primitive string operations. Five primitive string operations are By combining the primitive string operitions and iteration-
provided: control operations with other operations, it is possible to build
flags but does not return the result. As a repeated operation EBCDIC DI
initialized to point to the beginning of the buffer, is
this provides for scanning for the occurrence of or depar-
initialized to point to the beginning of the buffer to receive the
ture from, a given value in the string.
ASCII characters, BX is made to point to an EBCDIC-to-ASCII
• LODS loads a string element from the source operand into translation table, and CX is initialized to contain the length of the
AL (or AX for word strings). This operation ordinarily would EBCDIC The translation table contains
buffer (possibly empty).
not be repeated. theASCII equivalent for each EBCDIC character, perhaps with
• STOS stores a string element from AL (or AX for word ASCII nulls for illegal characters. The EOT code is placed into
632 Part 3 Computer Classes Section 2 I
Microcomputers
I
JCXZ
Chapter 37 ;
Intel Microprocessors: 8008 to 8086 633
The 8086 processor recognizes two varieties of external information would be contained in an in-line data byte (or bytes)
interrupt
—the non-maskable interrupt and the maskable inter- following the interrupt-generating instruction.
rupt. A pin is provided for each variety. The same number of bytes are required to issue a specialized
Program execution control may be transferred by means of operation instruction to the external processor or to invoke the
operations similar in effect to that of external interrupts. A software subroutines, as illustrated in Fig. 12. Thus the compiler
generalized 2-byte instruction is provided that generates an could generate object code that could be used either way. The
interrupt of any type; the type is specified in the second byte. A actual determination of which way the specialized operations were
special 1-byte instruction to generate an interrupt of one particu- carried out could be made at load time and the object code
lar type is also provided. Such an instruction would be required modified by the loader accordingly.
by a software debugger so that breakpoints can be "planted"
on 1-byte instructions without overwriting, even temporarily, Sharing resources with parallel processors. In multiple-
the next instruction. And finally, an interrupt return instruction processor systems with shared resources it is necessary to provide
is provided which pops and restores the saved flag settings mechanisms to enforce controlled access to those resources. Such
in addition to performing the normal subroutine return func- mechanisms, while generally provided through software operat-
tion. ing systems, require hardware assistance. A sufficient mechanism
for accomplishing this is a locked exchange (also known as
Single step. When the TF flag register is set, the processor test-and-set-lock) .
generates an interrupt after the execution of each instruction. The 8086 provides a special 1-byte prefix which may precede
During interrupt transfer sequences caused by any type of any instruction. This prefix causes the processor to assert its
interrupt, the TF flag is cleared after the push-flags step of the bus-lock signal for the duration of the operation caused by the
interrupt sequence. No instructions are provided for setting or instruction. It is assumed that external hardware, upon receipt of
clearing TF directly. Rather, the flag-register file image saved on
the stack by a previous interrupt operation must be modified so
-- code monitored by external procesaor
that the subsequent interrupt return operation restores TF set.
This allows a diagnostic task to single-step through a task under
WAIT opcode I WAIT Instruction
test while still executing normally itself.
ESCAPE
that permit the 8086 to utilize an external processor to perform (opt ional ) instruction
that signal, will prohibit bus access for other bus masters during IX. Summary and Conclusions
the period of its assertion.
The instruction most useful in this context is an exchange "The 8008 begat the 8080, and the 8080 begat the 8085, and the
register with memory. A simple software lock may be implement- 8085 begat the 8086."
ed with the following code sequences:
Check: During the six years in which the 8008 evolved into the 8086, the
MOV AL.l set AL to 1 (implies processor underwent changes in many areas, as depicted by the
locked) conceptual diagram of Fig. 13. Figure 14 compares the functional
LOCK XCHG Sema,AL test and set lock block diagrams of the various processors. Comparisons in per-
TEST AL,AL set flags based on AL formance and technology are shown in Tables 5 and 6.
JNZ Check retry if lock already set The era of the 8008 through the 8086 is architecturally notable
for its role in exploiting technology and
capabilities, thereby
;critical region lowering computing costs by over three orders of magnitude. By
removing a dominant hurdle that has inhibited the computer
MOV Sema.O ;clear the lock when done industry
—the necessity to conserve expensive processors
—the
<
9 S
Q
m
.<=>
<
a:
?-, <
ao
o
UJ CC
a <
o c
UJ uj
X 3 z
ec K
E2 o < <?;
=0 -I
~ <
CO
z
(J=> ^ (r
^ S
•" =^ Q
z9
UJ Q <
S <
*l C
3
O
i33n3SU31SI03H
LLC ix
z
'
o
r IN
oz yd m a
o o h- I- X H UJ z UJ Z c o
< H Q U UJ O O Q = -1 Q Z Q C
D 1-
CC «
=5 cu
p
<y
<u:> Q
< (1 y
5 2 >-
-<^O
§ si 5 UJ
(A Q
I-
z
is a
<
< UJ
o X
Q
.
^
O
5g I
<
.Q
-J
X
£5. ju o I-
3 s Q
E2 I- t^ 5z -J
l3 '
35
u. i
ES03< Q
•O
00 < (A
z (A iii lA
X &
tn to r^'
= 2 '
KK<
CX t-
X
iA (A t/>
UJ Z X X X H
O
I-
zo
Hi
1g
mJ •«—* h-Mi
^1 =5?
di
3 Q tt o
X >
ul -i
TT 8
SI
r" 1 n
E2 uj 3
£ in CO a
OS
•-•
rt 8«
toO
cc
<
z
o
n t^
/^ 2Jz
<
c <
o
z
<^ «
^^c=
63$ Part 3 |
Computer Classes Section 2 I
Microcomputers
Table 5 Performance Comparison new era has permitted system designers to concentrate on solving
the fundamental problems of the applications themselves.
8008 8080 (2 MHz) 8086 (8 MHz)
register-register 12.5 2 0.25
transfer X. References
jump 25 5 0.875
register-immediate 20 3.5 0.5
Bylinsky [1975]; Faggin et al. [1972]; HofiF [1972]; Intel 8080
operation Manual [1975]; Intel MCS-8 Manual [1975]; Intel MCS-40 Manual
subroutine call 28 9 2.5
[1976]; Intel MCS-85 Manual [1977]; Intel MCS-86 Manual
increment (16-bit) 50 2.5 0.25
[1978]; Morse [1980]; Morse, Pohlman, and Ravenel [1978];
addition (16-bit) 75 5 0.375
Shima, Faggin, and Mazor [1974]; Vadasz et al. [1969].
transfer (16-bit) 25 2 0.25
Silicon
Chapter 37 {
Intel Microprocessors: 8008 to 8086 639
• The original value of the SIGN flag, being in bit 6, will wind APPENDIX 2 DECIMAL ARITHMETIC
up in bit 7 and will become the sign of the result. The new
value of the SIGN flag will reflect this sign. A. Packed BCD
• The complement of the original value of the PARITY flag
1. Addition. Numbers can be represented as a sequence of
will wind up in bit 1, and it alone will determine the
parity decimal digits by using a 4-bit binary encoding of the digits and
of the result (all other bits in the result are paired up and
have no net effect on parity). The new setting of the PARITY packing these encodings two to a byte. Such a representation is
flag will be the complement of this bit (the flag denotes
calledpacked BCD (unpacked fiCD would contain only one digit
even parity) and therefore will take on the original value of per byte). In order to preserve this decimal interpretation in
the PARITY flag. performing binary addition on packed BCD numbers, the value 6
must be added to each digit of the sum whenever (1) the resulting
• Whenever ZERO flag is 1, the SIGN flag must be
the
(zero is a positive two's-complement number) and the digit is greater than 9 or (2) a carry occurs out of this digit as a
PARITY result of the addition. This is because the 4-bit encoding contains
flag must be 1 (zero has even parity). Thus an
original ZERO flag value of 1 will cause all bits of FLAGS, six more combinations than there are decimal digits. Consider the
with the possible exception of bit 7, to be 0. After the ADD following examples (numbers are written in hexadecimal instead
instruction is executed, all bits of the result will be and the of binary for convenience).
new value of the ZERO flag will therefore be L
• An original ZERO value of will cause two bits in Example 1: 81+52
flag
FLAGS to be 1 and will wind up in the result as well. The d2 dl do names of digit positions
new value of the ZERO flag will therefore be 0.
8 BCD augend
packed
packed BCD addend
The above algorithm relies on the fact that flag values are always
consistent, i.e. ,
that the SIGN flag cannot be a 1 when the ZERO
adjustment because dl > 9
flag is a 1. This always true in the 8008, since the flags
is come up
in a consistent state whenever the processor is reset and
flags can packed BCD sum
Section 2 Microcomputers
640 Part 3 I
Computer Classes |
2
Chapter 37 |
Intel Microprocessors: 8008 to 8086 641
supported.) Once it was decided not to support packed BCD 5 unpacked BCD product (low-order byte)
multiplication in the processors, no attempt was made to even
analyze packed BCD division. 3. Division. Primitive unpacked division involves dividing a
two-digit (two-byte) unpacked dividend by a one-digit (one-byte)
B. Unpacked BCD unpacked divisor to yield a one-digit (one-byte) unpacked quo-
tient and a one-digit (one-byte) unpacked remainder. If the
Unpacked BCD representation of numbers consists of storing the
encoded digits in the low-order four bits of consecutive bytes. An high-order four bits in each byte of the dividend are zeros (instead
of don't-cares), the dividend can be adjusted to a one-byte binary
ASCII string of digits is a special case of unpacked BCD with the
number as follows:
high-order four bits of each byte containing 0110.
Arithmetic operations on numbers represented as unpacked = 10 * high-order byte +
Binary dividend low-order byte
BCD digit strings can be formulated in terms of more primitive
BCD operations on single-digit (two digits for dividends and two If the high-order four bits of the divisor are zero, the divisor will
digits for products) unpacked BCD numbers. represent the same value interpreted as a binary number or as a
BCD number. A binary division of the adjusted (binary) dividend
1. Addition and Subtraction. Primitive unpacked additions and and BCD divisor will yield a one-byte quotient and a one-byte
subtractions follow the same adjustment procedures as packed remainder, each representing the same value interpreted as a
additions and subtractions. binary number or as a BCD number. This is illustrated in the
following example (numbers are written in hexadecimal instead of
2. Multiplication. Primitive unpacked multiplication involves binary for convenience).
multiplying a one-digit (one-byte) unpacked multiplicand by a
one-digit (one-byte) unpacked multiplier to yield a two-digit Example 6: 45/6
(two-byte) unpacked product. If the high-order four bits of the dido names of digit positions
multiplicand and multiplier are zeros (instead of don't-cares), each BCD dividend (high-order byte)
unpacked
will represent the same value interpreted as a binary number or as
unpacked BCD dividend (low-order byte)
a BCD number. A binary multiplication will yield a two-byte
product in which the high-order byte is zero. The low-order byte adjusted dividend (4 * 10 + 5)
of this product will have the correct value when interpreted as a unpacked BCD divisor
binary number and can be adjusted to a two-byte BCD number as unpacked BCD quotient
follows:
unpacked BCD remainder
High-order byte = (binary product)/10 4. Adjustment Instructions. The 8086 processor provides four
Low-order byte = binary product modulo 10 adjustment instructions for use in performing primitive unpacked
—
BCD arithmetic one for addition, one for subtraction, one for
This is illustrated in the following example (numbers are written
multiplication, and one for division.
in hexadecimal instead of binary for convenience). The addition and subtraction adjustments are performed on a
642 Part 3 I
Computer Classes Section 2 I
Microcomputers
Addition
I080:«
begin
cycle.
••MP.State»*
m[0:ll'177777]<7:0> 1
Primary memory
••PC.State*"
PC<15:0>, I
Program counter
dr[0:3]<15:0>. ! Double registers
r[0:7]<7:0>:=dr[0:3]<15:0>. I
Registers
B<7:0>
C<7:0>
APPENDIX 3 (cont'd^
t :
Section 2 Microcomputers
646 Part 3 Computer Classes
APPENDIX 3 (confd.)
RET := (cond.ret(l)).
= 8 L).
PCHl. :-- (PC II
= H 8 L).
SPHL := (SP
JNZ := (cond. jump(not Z)) ,
JZ := (cond. jump(Z)),
JNC ;= (cond. juiiip{not CY)).
JC :» (cond.jump{CY)).
JPO :» (cond. jump(not P)) .
JPE := (cond.jump(P)).
:= (cond. jump{not S)).
JH := {cond. jump(S)) ,
JMP ;
=
begin
source. i2( )
next
PC > dbuf
end.
OUT
begin
source. il() next
= A
output .device[buf]
end.
beg in
source. il( ) next
A = input. device[buf]
end.
begin
tempd = m[SP] 8 L next
L = tempd<l5:8>:
m[SP]
=
tefnpd<7:0> next
tempd = m[SP + 1] 8 II ne
H = tempd< 15:8>;
'
m[SP I] tempd<7:0>
end.