Mpi Chapter1
Mpi Chapter1
Mpi Chapter1
Interfacing
CHAPTER
in
less
than
decade's
time.
complete CPU
8085 was introduced in 1977.
Interfacing
Microcomputers and
Microcomputers and
Interfacing
memory
management
and
protection
capabilities,
which
were
Microcomputers and
the
early
days
of
microprocessor
development
the
Interfacing
Microcomputers and
Microcomputers and
Interfacing
considerable
difference
between
the
memory
addressing
The bus interface unit contains the circuit for physical address
calculations and a pre-decoding instruction byte queue (6 bytes long).
The bus interface unit makes the system bus signals available for
external interfacing of the devices. In other
words,
this
unit
is
Microcomputers and
Interfacing
may
Interfacing
Microcomputers and
Microcomputers and
Interfacing
S-Sign Flag: This flag is set, when the result of any computation is
negative. For signed computations, the sign flag equals the MSB of the
result.
Z-Zero Flag: This flag is set, if the result of the computation or
comparison performed by the previous instruction/instructions is zero.
P-Parity Flag: This flag is set to 1, if the lower byte of the result contains
even number of 1s.
C-Carry Flag: This flag is set, when there is a carry out of MSB in case
of addition or a borrow in case of subtraction.
T-Trap Flag: If this flag is set, the processor enters the single step
execution
mode. In other words, a trap interrupt is generated after execution of
each instruction. The processor executes the current instruction and
the control is transferred to the Trap interrupt service routine.
I-interrupt Flag: If this flag is set, the maskable interrupts are
recognized by the
CPU, otherwise,
ignored.
they
are
to
the
highest
address,
i.e.
auto-incrementing
mode.
numbers,
if
the
Microcomputers and
Interfacing
Microcomputers and
The three remaining flags in the flag register are used to control
certain operations of the processor. These flags are different from
the six conditional flags described above in the way they are set or
reset. The six conditional flags are set or reset by the EU on the basis
of the results of some arithmetic or logic operation. The control flags
are deliberately set or reset with special instructions you put in your
program. The three control flags are the trap flag (TF), which is used for
single stepping through a program; the interrupt flag (IF), which is used
to allow or prohibit the interruption of a program; and the direction flag
(DF), which is used with string instructions.
1.2.1.2. General-Purpose Registers
The EU has eight general-purpose registers, labeled AH, AL, BH,
BL, CH, DH, and DL. These registers can be used individually for
temporary storage of 8- bit data. Te AL register is also called the
Accumulator. It has some features that the other general-purpose
registers do not have.
Certain pairs of these general-purpose registers can be used
together to store 16-bit data words. The acceptable register pairs are
AH and AL, BH and BL, CH and CL, and DH and DL. The AH-AL pair is
referred to as the AX register, the BH-BL pair is referred to as the BX
register, the CH-CL pair is referred to as the CX register, and the DH-DL
pair is referred to as the DX register.
The 8086 general-purpose register set is very similar to those of
the earlier- generation 8080 and 8085 microprocessors. It was designed
this way so that the many programs written for the 8080 and 8085
could easily be translated to run on the 8086 or the 8088. The
advantage of using internal registers for the temporary storage of data
is that, since the data is already in the EU, it can be accessed much
more quickly than it could be accessed in external memory. Now let's
look at the features of the BIU.
Interfacing
1.2.2
The
Interface Unit
1.2.2.1.
QUEUE
THE
Microcomputers and
Bus
INSTRUCTION
SEGMENT
The 8086 BIU sends out 20-bit addresses, so it can address any of
220 or
1,048,576 bytes in memory. However, at any given time the 8086
works with only four 65,536-byte (64-Kbyte) segments within this
1,048,576- byte (I -Mbyte) range. Four segment registers in the BIU
are used to hold the upper 16 bits of the starting addresses of four
memory segments that the 8086 is working with at a particular time.
The four segment registers are the code segment (CS) register,
the stack segment (SS) register, the extra segment (ES) register, and
the data segment (DS) register. Figure above shows how these four
segments might be positioned in memory at a given time. The four
segments can be separated as shown, or, for small programs, which do
not need all 64 Kbytes in each segment they can overlap.
To repeat, then, a segment register is used to hold the upper 16 bits
of the
Interfacing
Microcomputers and
Interfacing
Microcomputers and
segment.
Fig: One way four 64-Kbyte segments might positioned within 1-Mbyte
address space of an 8086.
Microcomputers and
Interfacing
bits of the starting address for the program stack. The extra segment
register and the data segment are used to hold the upper 16 bits of
the starting addresses of
two memory segments that are used for data.
of
the starting
address
of
the
address. Notice
Interfacing
directly in line,
that
the
two
16-bit
Microcomputers and
numbers
are
not
added
because the CS register contains only the upper 16 bits of the base
address for the code segment. The BIU automatically inserts zeros for
the lowest 4 bits of the segment base address.
If the CS register, for example, contains 348AH, you know that the
starting
address for the code segment is 348A0H. When the BIU adds the
offset of 4214H
in the IP to this segment base address, the result is a 20-bit physical
address of
38AB4H. An alternative way of representing a 20-bit physical address is
the segment base : offset form. For the address of a code byte, the
format for this alternative form will be CS:IP. As an example of this, the
address 38AB4H, can also be represented as 348A:4214.
To summarize, then, the CS register contains the upper 16 bits of
the starting address of the code segment in the 1 -Mbyte address range
of the 8086. The instruction pointer register contains a 16-bit offset,
which tells where in that
64-Kbyte code segment the next instruction byte is to be fetched from.
The actual
physical address sent to memory is produced by adding the offset
contained in the IP register to the segment base represented by the
upper 16 bits in the CS register.
Any time the 8086 accesses memory, the BIU produces the
required 20-bit physical address by adding an offset to a segment base
value represented by the contents of one of the segment registers.
STACK SEGMENT
REGISTER
REGISTER
AND
STACK
POINTER
register in the execution unit holds the 16-bit offset from the start of
the segment to the memory location where a word was most recently
stored on the stack. The memory location where a word was most
recently stored is called the top of stack. Figure above, shows this in
diagram form.
destination
Index
(DI)
register.
These
three registers can be used for temporary storage of data just as the
general-purpose registers described above. However, their main use is
to hold the 16-bit offset of a data word in one of the segments. SI, for
example, can be used to hold the offset of a data word in the data
segment. The physical address of the data in memory will be generated
In this case by adding the contents of SI to the segment base address
represented by
the 16-bit number in the DS register.
Fig: Addition of data segment (DS) register and effective address (BX) to produce
the physical address of the data byte.
operations. During I/0 operations, these lines are low. During memory
or I/0 operations, status information is available on those lines for T2,
T3, Tw, and T4. The status of the interrupt enable flag bit (displayed
on S5) is updated at the
beginning of each clock
cycle.
S4
S3
Indications
Alternate Data
Stack
Code or None
Data
and S3
write
and
interrupt
the
first
pulse
of
the
interrupt
BHE
A0
Indicatio
ns
Whole Word
None
RD-Read Read signal, when low, indicates the peripherals that the
processor is
performing a memory or I/0 read operation. RD is active low and
shows the
state for T2, T3, Tw of any read cycle. The signal remains tristated
during the 'hold acknowledge'.
READY This is the acknowledgement from the slow devices or
memory that they have completed the data transfer. The signal made
available by the devices is synchronized by the 8284A clock generator
to provide ready input to the 8086. The signal is active high.
INTR-interrupt Request This is a level triggered input. This is
sampled during the last clock cycle of each instruction to determine
the availability of the request. If any interrupt request is pending, the
processor enters the interrupt acknowledge cycle. This can be
internally masked by resetting the interrupt enable flag. This signal is
active high and internally synchronized.
TEST This input is examined by a 'WAIT' instruction. If the TEST input
goes low, execution will continue, else, the processor remains in an idle
state. The input is synchronized internally during each clock cycle on
leading edge of clock.
NMI Non-maskable Interrupt This is an edge-triggered input which
causes a Type2 interrupt. The NMI is not maskable internally by
software. A transition from low to high initiates the interrupt response
at the end of the current instruction. This input is internally
synchronized.
RESET This input causes the processor to terminate the current
activity and start
execution from FFFF0H. The signal is active high and must be active for
at least four clock cycles. It restarts execution when the RESET
returns low. RESET is also internally synchronized.
CLK
Clock Input The clock input provides the basic timing for
Vcc
+5V power supply for the operation of the internal circuit. GND
MN/MX The logic level at this pin decides whether the processor is to
operate
in
either
minimum
(single
processor)
or
maximum
(multiprocessor) mode. The following pin functions are for the minimum
mode operation of 8086.
M/ I/O -Memory/IO This is a status line logically equivalent to 92 in
maximum
mode. When it is low, it indicates the CPU is having an 1/0 operation,
and when it is high, it indicates that the CPU is having a memory
operation. This line becomes active in the previous T4 and remains
active till final T4 of the current cycle. It is tristated during local bus
"hold acknowledge".
INTA - Interrupt Acknowledge This signal is used as a read strobe
for interrupt
acknowledge cycles. In other words, when it goes low, it means
that the processor has accepted the interrupt. It is active low during
T2, T3 and Tw of each interrupt acknowledge cycle.
ALE-Address
Latch
Enable
This
output
signal
indicates
the
output
is
Data
used
to
decide
the
direction
of
data
flow
on HLDA pin, in the middle of the next clock cycle after completing the
current bus (instruction) cycle. At the same time, the processor floats
the local bus and control lines. When the processor detects the HOLD
line low, it lowers the HLDA signal.
input,
and
it
should
be
HOLD
is
an
asynchronous
S1
S0
Indications
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
Interrupt
Acknowledge
Read I/O Port
Write I/O Port
Halt
Code
Access
Read
Memory
LOCK This output pin indicates that other system bus masters will be
prevented
from gaining the system bus, while the LOCK signal is low. The LOCK
signal is
QS0
Indication
No operation
Empty queue
byte (the first byte) of instruction code, if the CS:IP address is odd or
two bytes at a time, if the CS:IP address is even. The first byte is a
complete opcode in case of some instructions (one
byte
opcode
queue
are
decoding
whether
the
first
byte,
the
decoding
circuit
opcode byte. If it is single opcode byte, the next bytes are treated as
data bytes depending upon the decoded instruction length, otherwise
the next byte in the queue is treated as the second byte of the
instruction opcode. The second byte is then decoded in continuation
with the first byte to decide the instruction length and the number of
subsequent bytes to be treated as instruction data. The queue is
updated after every byte is read from the queue but the fetch cycle is
initiated by BIU only if at least two
repeated till the complete execution of the program. The main point to
be noted here is, that the fetch operation of the next instruction is
overlapped with the execution of the current instruction. As shown in
the architecture, there are two separate units, namely, execution unit
and bus interface unit, while the execution unit is busy in executing an
instruction, after it is completely decoded, the bus interface unit
may be fetching the bytes of the next instruction from memory,
depending upon the queue status.
RQ/GT0, RQ/GT1-Request/Grant
Other local bus masters, in maximum mode, to force the
processor to release the local bus at the end of the processors
current bus cycle, use these pins. Each of the pins is bi-directional
with RQ/GT0 having higher priority than RQ/GT1. RQ/GT pins have
internal pull-up resistors and may be left unconnected. The request/
grant sequence is as follows:
1. A pulse one clock wide from another bus master requests the bus
access to
808
6.
2. During T4 (current) or T, (next) clock cycle, a pulse one clock wide
from
8086 to the requesting master, indicates that the 8086 has
allowed the local bus to float and that it will enter the "hold
acknowledge" state at next clock cycle. The CPU's bus interface
unit is likely to be disconnected from the local bus of the system.
3. A one clock wide pulse from another master indicates to 8086
that the
'hold' request is about to end and the 8086 may regain control of
the local bus at the next clock cycle.
request and grant pulses are active low. For the bus requests those are
received while
8086
is
performing
memory
or
1/0
cycle,
the
MEMORY
3. One of the bytes may be opcode while the other may be data.
All the above possibilities are taken care of by the internal decoder
circuit of the microprocessor. The opcodes and operands are identified
by the internal decoder circuit, which further derives the signals those
act as input to the timing and control unit. The timing and control unit
then derives all the signals required for execution of the instruction.
In referring word data, the BIU requires one or two memory cycles,
depending upon whether the starting byte is located at an even or odd
address. It is always better to locate the word data at an even address.
To read or write a complete word from/to memory, if it is located at an
even address, only one read or write cycle is required. If the word is
located at an odd address, the first read or write cycle is required for
accessing the lower byte while the second one is required for accessing
the upper byte. Thus two bus cycles are required, if a word is located at
an odd address. It should be kept in mind that while initializing the
structures like stack they should be initialized at an even address for
efficient operation.
Certain locations in memory are reserved for specific CPU
operations. The locations from FFFF0H to FFFFFH are reserved for
operations
BUS
reason
time
multiplexed
address
and
data
bus.
The
1.6
I/O
CAPABILITY
ADDRESSING
after
RESET,
it
will
be
immediately
served
after
cycle. The
processor remains in idle state while waiting. While waiting, any 'HOLD'
request
8086
imparted
of
8086,
like
1-Mbyte
memory
some hardware
addressing capability,
capabilities.
The
is
homogeneously
memory
locations
using
the
addressed
as
segmented
bank
memory
complete
of
1-Mbyte
scheme.
This
interface.
1.
systems
such
as
the
SDK-86/EV-Z2
where
it
is
the
only