24-12-2024
24-12-2024
Multiprocessor Configuration.
Coprocessor configuration.
Closely coupled configuration.
Loosely coupled configuration.
Coprocessor Configuration:
118
The 8086 can perform most of the operations but their instruction
set is not able to perform complex and/or floating point
mathematical operations, so in this case the microprocessor
requires the math coprocessor like Intel 8087 math coprocessor,
which can perform these operations easily and quickly.
The next figure shows the cooperation between the 8086 and the
math coprocessor 8087.
Clock Generator
Processor
8086
Bus control System bus
logic
Coprocessor Memory IO
8087 devices
The coprocessor and the host processor are connected via TEST,
RQ/GT and QS0 & QS1 signals.
119
TEST signal takes care of the coprocessor’s activity, i.e. the
coprocessor is busy or idle.
The coprocessor uses QS0 & QS1 to track the status of the queue of
the host processor.
Processor
8086
Bus control System bus
logic
Independent Memory IO
processor devices
121
The connection of the independent processor & the host processor:
121
Clock Generator
Processor
8086
Local bus System bus
control logic control logic
Local Local IO
memory devices
I/O System
System bus
Clock Generator
Processor
8086
Local bus System bus
control logic control logic
Local Local IO
memory devices
System bus
Memory System
Clock Generator
Processor
8086
Local bus System bus
control logic control logic
Local Local IO
memory devices
Advantages
122
Each processor has its own local bus to access the local memory or
I/O devices. This makes it easy to achieve parallel processing.
The system structure is flexible, i.e. the failure of one module doesn’t
affect the whole system failure; faulty module can be replaced
later.
123
Numeric data coprocessor 8087
124
The data types supported by 8087 are:
Binary Integers.
Packed decimal numbers.
Real numbers.
Temporary real format.
0.10101101*21011
mantissa exponent
The exponent is represented on 8 bits from which the most
significant is the sign bit and it’s treated differently. The physical
length of the mantissa is 23 bits. The sign of the real number is
given by the most significant bit as shown in the following
figure.
125
always 1, and thus this bit is never written being considered by
default. Thus the mantissa’s real size is 24 bits.
It is important for us to know the actual precision. The mantissa
represents 6-7 digits, while the exponent with its 8 bits raises
their number to the order of ~1038 (the exact number cannot be
determined because it depends on the mantissa). The highest
number is approximately of 1.7 *1038 and the lowest positive
real number in around 10-38.
Long Real: A 64 bit number represented in floating point. The number
is decomposed in mantissa and characteristic. The exponent is
represented on 11 bits from which the most significant is the
sign bit and it’s treated differently. The physical length of the
mantissa is 52 bits. The sign of the real number is given by the
most significant bit Mantissa, 1 bit considered as default, thus
the actual length of the mantissa is 53 bits and these 53 bits
represent approximately 16-17 decimal digits, which means; the
representation of the smallest number in very precise.
Temporary real numbers: An 80 bit number represented in floating
point format. The number is decomposed in mantissa and
for exponant
exponent. The exponent is represented on 15 bits from which
the most significant bit is the sign bit. The physical length of the
mantissa is 64 bits. for mantissa
126
The most important features of 8087 numeric data processor are as
follows:
support all types of data
It supports data of type integer, float, and real types ranging from
2-10 bytes.
127
Interfacing of coprocessor 8087 with 8086:
8284
Clock gen.
Ready
Reset
Clock
Crystal Oscillator.
128
The signals S0, S1 and S2 are the status signals of microprocessor 8086
that provide the status of the operation which is used by the Bus
Controller 8087 to generate memory and I/O control signals as
shown in table (1).
S2 S1 S0 Ch Remarks
0 0 0 INTA cycle Unused by 8087
0 0 1 I/O read Unused by 8087
0 1 0 I/O write Unused by 8087
0 1 1 Halt Unused by 8087
1 0 0 Operation code fetch Unused by 8087
1 0 1 Memory read used by 8087
1 1 0 Memory write used by 8087
1 1 1 No bus cycle used by 8087
Table (1)
The signals RQ/GT1 & RQ/GT0 are the Request/Grant signals used by
the 8087 processors to gain control of the bus from the host
processor 8086 for operand transfers.
The busy pin of 8087 is connected to the test pin of 8086 to indicate
that the processor is busy or not to perform its internal
operations, the queue status lines QS0 and the QS1 are connected
to the corresponding pins of 8086 as shown in table 2.
129
QS1 QS0 Instruction queue status
0 0 All six instruction queue registers are full (no operation)
0 1 The first instruction operation code in instruction queue is
being executed.
1 0 The instruction queue registers are empty (clear due to
branching operation).
1 1 An instruction operation code in instruction queue other
than the first one is being executed.
Table 2. The instruction queue status QS0 and QS1 output pins of
8086.
If the coprocessor 8087 is used with the 8086, then the program can
be written using the instruction set of the processor 8086 along
with the instruction set of the 8087. But the opcode fetch
operation is performed only by 8086 and the instruction code
fetched from memory is stored in the queue registers of 8086 as
well as 8087.
131
1 – The coprocessor 8087 will decode all instruction codes, but the
instruction given with "escape" is executed by the coprocessor
8087. Other instructions are decoded and executed by 8086 and
in this case the 8087 performs no operation. (The opcode of
escape is 11011).
2 – The processor 8086 will decode also all instruction codes, but it
executes the instruction given without "escape", when the
processor 8086 decodes any instruction of 8087 it performs two
operations:
Data transfer between 8087 and 8086 cannot be done directly, but it
is performed through memory. The 8087 keeps track the queue
status and the machine cycle of 8086 by reading QS0 and QS1
also the reading status signals S0, S1 and S2.
131
Data transfer between 8087 and memory:
When the host processor 8086 decodes any instruction of 8087 that
requires data transfer between the 8087 and the memory, the
8086 generates the following:
iii) BHE.
132
without 8086 intervention. During this time the host processor
8086 remains in a hold state.
In this case the coprocessor 8087 can communicate with memory but
not with IO ports.
There are two states in which the wait operation in the processor
8086 takes place:
133
8087 Architecture
8087 Architecture is divided into two groups, i.e, Control Unit (CU) and
Numeric Extension Unit (NEU).
134
The numeric data processor is a coprocessor which has been
designed to work under the control of the 8086 processor. It
offers additional numeric processing capabilities. It is available
in 5 MHz, 8 MHz and 10 MHz versions 8086 will perform the
opcode fetch cycles and identify the instructions for 8087.
135
task of 8086 to identify the 8087 instructions from the program,
send it to the 8087 for execution and get back the results.
The binary encodings for all 8087 instructions begin with the bit
pattern 11011, decimal 27, sometimes referred to as "escape
codes".
136
6. Processor control instructions.
At first, we use; ST(0) to indicate the top element of the floating point
stack and ST(i) stands for the element number i of the floating
point stack and 1 ≤ i ≤ 7.
1 – Load instructions:
This set of instructions pushes the specified operand onto the stack.
The menumonics of the instructions is as follows:
menumonic Explanation
FLD Load floating point number to stack top
FILD Load integer to stack top
FBLD Load BCD code to stack top
Example:
137
FLD ST(2) [ST (2)] Top of stack ST(0)
2 – Store instructions:
menumonic Explanation
FST Store the stack top to the destination operand
FIST Store the integer stack top to the destination
operand
Example:
FST ST(2) Store the content of stack top ST (0) to the stack pointer
register ST(2).
FIST ST(6) Convert the contents of ST(0) to integer and store it into
the stack pointer register ST (6).
138
menumonic Explanation
FLDZ Load zero into the the stack top ST (0).
FLD1 Load constant one into the the stack top.
FLDPI Load π = 3.14 into the the stack top.
FLDL2T Load Log2 of the stack top into the the stack top.
FSQRT Calculate the square root of stack top and load it
Exchange the specified register (destination) and the stack top. the
menumonic of the instruction is as follows:
menumonic Explanation
FXCH Exchange the stack top with the destination
operand
139
Example:
Arithmetic instructions:
1 – Addition instructions:
Add the source to the destination and the sum in the destination. If
two register operands are specified, one must be ST (top of
stack).
menumonic Explanation
FADD Add the source to the destination and the sum
in the destination.
Example:
141
FADD ST, ST(3) ST (0) = ST(3) + ST (0)
2 – Subtraction instructions:
Subtract the source from the destination and the difference in the
destination, which means; destination – source = destination.
menumonic Explanation
FSUB Subtract the source from the destination and the
difference in the destination.
FSUBR (subtract Subtract the destination from the source and the
reversed) difference in the destination.
Example:
141
FSUB ST, ST(3) ST (0) = ST(0) - ST (3)
3 – Multiplication instruction:
menumonic Explanation
FMUL Multiply the source from the destination and the
product in the destination.
Example:
142
FMUL ST, ST(3) ST (0) = ST(0) * ST (3)
4 – Division instruction:
menumonic Explanation
FDIV Divide the destination by the source and the
quotient in the destination.
Example:
143
FDIV ST, ST(3) ST (0) =
FDIV ST (0) =
The remaining set of instructions are not studied here, for more
information about the complete instruction set one can read
any of the microprocessor books used as a reference in this
lecture notes.
144
Solution:
Instruction Explanation
MOV SI, 2800H Initialize the source index
MOV DI, 2900H Initialize the destination index
MOV CX, 0014H The number of circles = 20
Repeat FLD [SI] Load the value of the first radius
in ST (0)
FST ST(1) Store copy of ST(0) in ST (1)
FMUL ST(0)*ST(1) = ST(0) (radius)2
FST ST(1) Store (radius)2 in ST (1)
FLDPI Load π = 3.14 in ST (0)
FMUL ST(0)*ST(1) = ST(0) π*(radius)2
FST [DI] Store the area in the memory
INC SI The next circle
INC DI The next storing location of area
LOOP Repeat
Program 2:
Write an assembly language program to calculate the following
expression √ the values 'a' and 'b' are stored in
memory in effective addresses EA = 3800H and 38005H, then;
store the result in the memory in effective address EA = 2900H.
Solution:
145
Instruction Explanation
MOV SI, 3800H Location of the first number
MOV DI, 3805H Location of the second number
MOV AX, 2900H Location of the result
FLD [SI] Load the value of the first number 'a' in ST (0)
FMUL ST(0), ST(0) ST(0) = a2
FST ST(1) Store copy of ST(0) in ST (1) a2
FLD [DI] Load the value of the second number 'b' in ST (0)
FMUL ST(0), ST(0) ST(0) = b2
FADD ST(1) + ST(0) = ST(0) a2 + b2
FSQRT ST (0) = √
FST [AX] Store the result ST (0) in memory at a location
determined by AX.
146
Chapter Five
Interfacing keyboard and memory with 8086
Address bus
Control bus
147
Memory Interfacing:
When we are executing any instruction, we need the microprocessor
to access the memory for reading instruction codes and the data
stored in the memory. For this, both the memory and the
microprocessor require some signals to read from and write to
registers.
The interfacing process includes some key factors to match with the
memory requirements and microprocessor signals. The
interfacing circuit should be designed in such a way that it
matches the memory signal requirements with the signals of the
microprocessor.
The connection of the microprocessor and the outside world:
There are two ways of connecting the microprocessor with the
outside world:
1 – Serial connection interface: In this type of connection, the
interface gets a single byte of data from the microprocessor and
sends it bit by bit to the other system serially and vice-a-versa.
2 – Parallel connection interface: In this type of connection, the
interface gets a byte of data from the microprocessor and sends
all bits of the data byte to the other systems simultaneously and
vice-a-versa.
148
In the next section; the communication and interfacing of keyboard
with the microprocessor 8086 using programmable
keyboard/display controller 8279 (PKDC) is studied.
Programmable Keyboard/display 8279
programmable keyboard/display controller 8279 (PKDC) is designed
to simultaneously drives the display of a system and interfaces a
keyboard with the microprocessor.
The PKDC 8279 first scans the keyboard and identifies if any key has
been pressed, and sends the code of the pressed key to the
microprocessor, it also performs the transmission of the data to
the display device. Both of these functions are performed by the
programmable keyboard/display controller 8279 (PKDC) in
repetitive fashion without involving the microprocessor.
OR 8279
Methods of interfacing the keyboard with the microprocessor:
The Keyboard can be interfaced either in the interrupt or the polled
mode.
In the Interrupt mode; the microprocessor is requested service only if
any key is pressed, otherwise the the microprocessor will
continue with its main task.
149
Operation of PKDC 8279:
The keyboard consists of maximum 64 keys, which are interfaced
with the the microprocessor by using the key-codes. These key-
codes are de-bounced and stored in an 8-byte first in first out
RAM (FIFO RAM) which can be accessed by the microprocessor.
If a FIFO contains a valid key entry, then the microprocessor is
interrupted in an interrupt mode else the microprocessor checks
the status in polling to read the entry.
Once the microprocessor reads a key entry, then FIFO RAM is
updated, and the key entry is pushed out of the FIFO RAM to
generate space for new entries.
The PKDC 8279 consists of the following function units:
1 – I/O Control and Data Buffer:
This unit controls the flow of data through the microprocessor. Its
data buffer interfaces the external bus of the system with the
internal bus of the microprocessor.
2 – Control and Timing Register and Timing Control:
This unit contains registers to store the the key-codes, display modes,
and other operations as programmed by the the
microprocessor.
The timing and control unit handles the timings for the operation of
the circuit.
3 – Scan counter:
151
It has two modes: encoded mode and decoded mode.
In the encoded mode: the counter provides the binary count that is
to be externally decoded to provide the scan lines for the
keyboard and display.
In the decoded scan mode: the counter internally decodes the least
significant 2 bits and provides a decoded 1 out of 4 scan.
4 – Return Buffers, Keyboard Debounce, and Control:
This unit first scans the key closure row-wise, if found then the
keyboard debounce unit debounces the key entry. In case, the
same key is detected, then the code of that key is directly
transferred to the sensor RAM along with SHIFT & CONTROL key
status.
5 – FIFO/Sensor RAM and Status Logic:
This unit acts as 8-byte first-in-first-out (FIFO) RAM where the key
code of every pressed key is entered into the RAM in sequence.
The status logic generates an interrupt request after each FIFO
read operation untill the FIFO gets empty.
6 – Display Address Registers and Display RAM:
This unit consists of display address registers which holds the
addresses of the word currently read/written by the
microprocessor to/from the display RAM.
The internal structure of the programmable keyboard/display
controller 8279 (PKDC) is shown in the following figure.
151
Operational modes of 8279:
There are two modes of operation on 8279: input mode and output
mode.
Input mode:
This mode deals with the input from the keyboard. This mode is
further classified into 3 modes:
a. Scanned keyboard mode: In this mode, the key matrix can be
interfaced using either encoded or decoded scans. In the
encoded scan, an 8x8 keyboard or in the decoded scan, a 4x8
152
keyboard can be interfaced. The code of key pressed with
SHIFT and CONTROL status is stored into the FIFO RAM.
b. Scanned sensor matrix: In this mode, a sensor array can be
interfaced with the microprocessor using either encoder or
decoder scans. In the encoder scan, 8x8 sensor matrix or with
decoder scan 4x8 sensor matrix can be interfaced.
c. Strobed input: In this mode, when the control line is set to 0,
the data on the return lines is stored in the FIFO byte by byte.
Output Mode:
This mode deals with display-related operations. It is classified into
two output modes:
Display Scan: This mode allows 8/16 character multiplexed displays
to be organized as dual 4-bit/single 8-bit display units.
Display Entry: This mode allows the data to be entered for display
either from the right side or left side.
In the next section; the transferring of data between IO devices and
the memory using Direct Memory Access 8257 is studied.
OR function of 8257
Direct Memory Access 8257
When the application is designed to transfer a large amount of data,
from input and output device to memory
it may be a waste of time of the microprocessor to transfer the
data from the source to the destination under its control,
153
because the speed of the peripheral devices is less than the
speed of the microprocessor.
The alternative way to transfer a large amount of data is to use a
separate unit to transfer the data and the microprocessor does
other useful work. This unit is called DMA which stands for
Direct Memory Access. It is a device to transfer the data directly
between IO device and memory without microprocessor
intervention. So it performs a high-speed data transfer between
memory and I/O device.
The DMA controller requests the microprocessor to hold its data bus,
address bus and control bus, so the device is free to transfer
data directly to/from the memory. The DMA data transfer is
initiated only after receiving HLDA signal from the
microprocessor.
DMA Operation.
Following is the sequence of operations performed by a DMA:
1- CPU issues the following to DMA:
a. device identification.
a.b. read/write.
Initially, when any device has to send data between the device
c. memory location for read or write.
and the
d. number of memory,
words. the device sends request (DRQ) to DMA
2- CPU executes programs normally.
controller.
3- when the transfar is done DMA interrupts CPU to informe that the transfer is done
154
c. The microprocessor tri-states all the data bus, address bus, and
control bus. The microprocessor leaves the control over bus and
acknowledges the HOLD request through HLDA signal.
d. Now the microprocessor is in HOLD state and the DMA
controller has to manage the operations over buses between
the microprocessor, memory, and I/O devices.
The features of 8257:
The DMA 8257 has the following features
1. The 8257 has four channels and so it can be used to provide
services to four I/O devices.
2. Each channel has 16-bit address and 14-bit counter so; it can
be independently programmed to transfer up to 64kb of data.
3. Each channel can be independently perform read transfer,
write transfer and verify transfer.
4. It generates MARK signal to the peripheral device that 128
bytes have been transferred.
The block diagram of the DMA 8257 is shown in the following figure
155
156