Professional Documents
Culture Documents
Syllabus
Unit I
8086 Microprocessor
8086 Microprocessor Architecture
Segmented Memory
Addressing Modes
Instruction Set
8086 Assembly Language Programming
8087 Numerical Data Processor
(Math Coprocessor)
Architectural Details
Data types
Floating Point Operations
8087 Instructions
2
EE 574
3
EE 574
4
EE 574
8086 Register Organization
Ref [3]
7
EE 574
8086 Register Organization
1.1.3 Pointers and Index Registers: Ref [3]
Pointers contain offset within particular segments
IP - offset within the code segment
BP – offset within data segment
SP – offset within stack segment
8
EE 574
8086 Architecture
Ref [3]
9
EE 574
8086 Architecture
8086 Architecture: Ref [3]
8086 Architecture
(a) Bus Interface Unit
(b) Execution Unit
12
EE 574
8086 Architecture
(b) Execution Unit (EU): Ref [3]
EU contains
register sets except segment registers and IP.
16-bit ALU to perform arithmetic and logic operations
16-bit flag register – reflects results of execution by ALU
decoding unit – decodes the opcode bytes issued by the instruction
byte queue
Timing and Control Unit
- derives necessary control signals to execute the instruction opcode,
depending on the information made available by the decoding unit.
13
EE 574
8086 Memory Segmentation
1.2.1. Memory Segmentation: Ref [3]
14
EE 574
8086 Memory Segmentation
Ref [3]
Non-overlapping segments:
8086 can address 1Mbytes of physical memory
Divided into 16 segments of 64 Kbytes each
Segment address - 0000H to F000H
Offset address - 0000H to FFFFH
Physical address - 00000H to FFFFFH
In this case the segments are called non-overlapping. See Fig. 1.3(a) 15
EE 574
8086 Memory Segmentation
Overlapping segments: Ref [3]
Suppose a segment starts at a particular address
its max size can be 64 Kbytes.
If another segment starts before this 64 Kbytes of the first segment
the two segments are said to be overlapping.
Overlapped segment area
the area of the memory from the start of the second segment to the possible
end of the first segment. See Fig. 1.3(b)
- The location in the overlapped area can be addressed by same physical
address generated from two diff. segment addresses and offsets.
Advantages of segmented memory scheme:
1. Allows memory capacity to be 1 Mbytes although actual addresses are
of 16-bits size.
2. Allows placing of code, data, and stack portions the same programs in
diff. parts (segments) of memory for data and code protection.
3. Permits a program and/or its data to be put into diff. areas of memory
each time program is executed. i.e. provision for relocation may be done.
In Fig. 1.3(b), physical addresses for locations in overlapped area can be
generated as CS1+IP1 = CS2 + IP2 16
EE 574
8086 Flag Register Ref [3]
Flag Register:
16-bit flag register, divided into 2 parts
(a) condition code or status flags
= lower byte of flag register + overflow flag
= like 8085 flag register + overflow flag (not present in 8085)
Reflects the results of operations performed by ALU
(b) machine control flags
contains higher byte of flag register
- Direction flag (D)
- Interrupt flag (I)
- Trap flag (T)
17
EE 574
8086 Flag Register Ref [3]
20
EE 574
8086 Signal Descriptions
Signals common to Min and Max modes: Ref [3]
AD15-AD0 Multiplexed memory, I/O address and data lines
Address remains during T1 state, data is available during T2, T3, Tw, T4
states.
T1, T2, T3, T4, Tw are clock states of machine cycle, Tw is wait state
A19/S6, A18/S5, A17/S4 , A16/S3 Time multiplexed address and status lines
During T1 - MSB of address for memory operations
During I/O operations these lines are low
During I/O operations status information is available during T2, T3, Tw, T4
states.
S5 – displays interrupt enable flag bit, updated at the beginning of each
clock cycle
S4 , S3 – indicate which segment register is used for memory accesses,
floated to tristate off during local bus hold acknowledge
S6 – always low
Address bits are separated from status bits using latches controlled by ALE
signal
Table 1.1 Segment register status
21
EE 574
8086 Signal Descriptions
Signals common to Min and Max modes: Ref [3]
BHE/S7 Bus high enable is used to indicate transfer of data over higher order
(D15-D8) data bus shown in Table 1.2.
Goes low for data transfers over D15-D8
Also used to derive chip select signal of odd memory banks or peripherals
BHE is low during T1 for read, write, and interrupt acknowledge cycles
whenever a byte is to be transferred on higher byte of the data bus.
Status information is available during T2, T3, T4
Signal is active low and tristated during hold.
RD – Read Read signal when low indicates the peripherals that processor is
performing memory or I/O read operation.
Active low and shows the status for T2, T3, TW of any read cycle
Signal remains tristated during ‘hold acknowledge’.
READY –Acknowledgement from slow devices or memory that they have
completed data transfer. Signal is synchronized by 8284A clock generator
to provide ready input to 8086. – Active high.
22
EE 574
8086 Signal Descriptions
Signals common to Min and Max modes: Ref [3]
INTR – Interrupt Request Level triggered input, sampled during last clock
cycle of each instruction to determine the availability of the request.
If interrupt request is pending, the processor enters Interrupt Acknowledge
cycle,
can be internally masked by resetting the interrupt enable flag
Active high and internally synchronized.
TEST This input is examined by WAIT instruction
If TEST goes low, execution will continue, otherwise processor will remain
idle state.
Input is synchronized during each clock cycle on leading edge.
NMI-Nonmaskable interrupt Edge triggered input which causes Type2
interrupt.
Not maskable internally by software.
A transition from low to high initiates interrupt response at the end of the
current instruction.
Internally synchronized.
RESET This input causes the processor to terminate the current activity and
start execution from FFFF0H.
Active high, must remain active for at least 4 clock cycles.
It starts execution when the RESET returns to low.
Internally synchronized.
23
EE 574
8086 Signal Descriptions
Signals common to Min and Max modes: Ref [3]
CLK – Clock Input Provides basic timing for the processor operation and bus
control activity.
Asymmetric square wave with 33% duty cycle.
8086 range of frequency - 5 to 10 MHz.
Vcc +5 V power supply for the internal operation of the circuit.
GND Ground for the internal circuit.
MN/MX Logic level indicates whether the processor is to operate in minimum
(single processor) or maximum (multiprocessor) mode.
24
EE 574
8086 Signal Descriptions
Signals for Minimum modes: Ref [3]
M/I/O – Memory/IO Status line equivalent to S2 in Maximum mode.
When low – CPU in I/O operation
When high – CPU in memory operation
Becomes active in previous T4 and remains active till T4 in current cycle.
Tristated during local bus “hold acknowledge”.
INTA-Interrupt Acknowledge
To read strobe for interrupt acknowledge cycles.
When it goes low, it means CPU has accepted the interrupt
Active low during T2, T3 , and Tw of each interrupt acknowledge cycle
ALE- Address Latch Enable Output signal indicates the availability of valid
address on the address/data lines
Connected to latch enable input of latches
Active high, never tristated.
DT/R – Data Transmit/Receive Output used to decide direction of data flow
through the transreceivers (bidirectional buffers).
Processor sends out data, when this signal is high
Processor receives data, when this signal is low.
This is equivalent to S1 in maximum mode.
Timing is same as M/I/O.
Tristated during “hold acknowledge”.
25
EE 574
8086 Signal Descriptions
Signals for Minimum modes: Ref [3]
DEN – Data Enable Indicates the availability of valid data over address/data
lines. Used to enable the transreceivers (bidirectional buffers) to separate
the data from the multiplexed address/data signal.
Becomes active from previous T2 and remains active till the middle of T4
Tristated during local bus “hold acknowledge” cycle.
HOLD, HLDA- Hold/Hold Acknowledge
When HOLD line goes high, indicates to the processor that another
master is requesting bus access.
The processor issues hold acknowledge signal in HLDA pin, in the middle
of 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 line.
HOLD is asynchronous signal, should be externally synchronized.
DMA Operation – Direct Memory Access
If DMA request is made while CPU is performing a memory or I/O cycle,
it will release the local bus provided:
1. The request occurs on or before T2 state of the current cycle
2. The current cycle is not operating on the lower byte of a word (or
operating on an odd address)
3. The current cycle is not the first acknowledge of the interrupt
acknowledge sequence.
4. A lock instruction is not being executed.
26
EE 574
8086 Signal Descriptions
Signals for Maximum modes: Ref [3]
S2, S1, S0 – Status lines Status lines reflect the type of operation being carried
out by the processor
Become active during previous T4 and remains active till of T1, T2 of the
current bus cycle.
Return to passive state during T3 of the current bus cycle so that it may
become active for the next bus cycle during T4 .
Any change in these lines during T3 indicates the starting of the new cycle,
and return to passive state indicates end of the bus cycle.
27
EE 574
8086 Signal Descriptions
Signals for Maximum modes: Ref [3]
LOCK – Lock Output pin – when low other system bus masters will be
prevented from gaining the system bus.
Activated by LOCK prefix instruction, remains active until the completion
of next instruction.
Floats to Tristate off during “hold acknowledge” cycle.
When CPU is executing critical instruction which requires system bus, the
LOCK prefix instruction ensures that the other processors in the system will
not gain the control of the bus.
The 8086 while executing the prefixed instruction, asserts the bus lock
signal output, which may be connected to an external bus controller.
QS1, QS2- Queue Status
These lines give information about the status of the code prefetch queue.
Active during the CLK cycle after which the queue operation is performed.
Encoded as shown in Table 1.4.
28
EE 574
8086 Signal Descriptions
Pipelined processing of instructions: Ref [3]
29
EE 574
8086 Signal Descriptions
The Queue Operation: Ref [3]
- At the start, the CS:IP is loaded with the required address from which the
execution is to be started.
- Initially the queue is empty.
- The microprocessor starts the fetch operation to bring
one byte (first byte) of the instruction if the CS:IP address is odd
two bytes at a time if CS:IP address is even.
30
EE 574
8086 Signal
The Queue Operation: (continued)
Descriptions
Ref [3]
- One byte instruction - First byte is an opcode.
- Two byte instructions – second byte also contains part of opcode.
- The opcode along with data are fetched and arranged in the queue.
- When the first byte in the queue goes for decoding and interpretation, one
byte in the queue becomes empty and the queue is updated.
- The processor performs the fetch operation only after two bytes in the
queue are emptied. The instruction cycle is never broken for fetch
operation.
- After decoding the first byte, the decoding circuit decides whether the
instruction is single opcode byte or double opcode byte.
- If it is single opcode byte, the next bytes are treated as data bytes depending
on decoded instruction length.
- Otherwise the next byte in the queue is treated as second byte of opcode
- The second byte is decoded in continuation with the first byte to decide the
instruction length and the number of subsequent bytes to be treated as data.
- The queue is updated after every byte is read from the queue, but fetch
operation is initiated by BIU only after at least two bytes are emptied from
queue.
- The EU may be concurrently executing the fetched instructions 31
EE 574
8086 Signal
The Queue Operation: (continued)
Descriptions
Ref [3]
- The next byte after the instruction is completed is again the first byte of
opcode.
- This procedure is repeated till the program is completely executed.
Main point
- Fetch operation of the next instruction is overlapped with the execution of
the current instruction.
- There are two separate units in the architecture
– Bus Interface Unit (BIU) and Execution Unit (EU)
- While the EU is executing the instruction after it is decoded, the BIU may
be fetching the next instruction from memory depending on the queue status
32
EE 574
8086 Signal Descriptions
RQ/GT0, RQ/GT1 – Request/Grant Ref [3]
Request/Grant sequence
1. A pulse one clock wide from another bus master requests the bus access
to 8086
2. 8086 sends a pulse one clock wide to the requesting master during
current T4 or next T1, indicating that the 8086 has allowed the local bus to
float and it will enter the ‘hold acknowledge’ state at the next clock cycle.
The CPU’s BIU is likely to be disconnected from the local bus of the
system.
3. A pulse one clock wide from another bus 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.
33
EE 574
Physical Memory Organization
1.4. Physical Memory Organization Ref [3]
8086 based system
1 Mbytes memory is organized as odd bank and even bank, 512 Kbytes
each.
Addressed in parallel by the processor.
Byte data with even address transferred on D7-D0
Byte data with odd address transferred on D15-D8.
Processor provides BHE and A0 for selection even, odd or both banks
Processor fetches instruction stream as words from memory and addressed
internally as necessary.
Processor fetches a word (two consecutive bytes) from memory, there are
different possibilities:
1. Both the bytes may be data operands
2. Both the bytes may contain opcode bits
3. One of the bytes may be opcode and the other may be data.
Internal decoder circuit takes care of the above possibilities.
- identifies opcode and operands
- further derives signals that act as input to timing and control unit
Timing and control unit derives signals required for execution of the instruction.
34
EE 574
Physical Memory Organization
1.4. Physical Memory Organization Ref [3]
Reading from and Writing to Memory
BIU needs one or two memory cycles depending upon
whether the starting byte is located at even or odd address
When starting address is even, only one read or write cycle is required.
If word is located at odd address, two cycles are required
- First read or write cycle is needed for accessing the lower byte
- second cycle is required for accessing the higher byte.
Therefore it is always better to locate the word data at even address.
Stack structures should be initialized at an even address for efficient
operation.
36
EE 574
General Bus Operation
1.5. General Bus Operation Ref [3]
8086 has time multiplexed address/data bus, to limit the number of pins to 40.
The bus is demultiplexed using latches and transreceivers, whenever required.
38
EE 574
I/O Addressing Capability
1.6. I/O Addressing Capability Ref [3]
8086/8088 can address up to 64K I/O byte registers or 32K word registers.
- address of I/O devices should not be greater than 16 bits
- means max number of I/O devices that can be addressed by CPU
= 216 = 64 Kbytes
- I/O address appears on address lines A0 to A15 during T1, latched using
ALE signal
- Upper address lines (A16 – A19) are at logic 0 during I/O operations.
- DX register is used as 16-bit I/O address pointer
I/O ports are addressed in the same manner as memory locations in based
addressing mode using BX.
- In memory mapped I/O interfacing, I/O device addresses are treated as
memory locations in page 0, i.e. segment address 0000H
- Even addressed bytes are transferred on D7-D0
Odd addressed bytes are transferred on D15-D8
- While designing 8 bit I/O system around 8086, make sure that all the byte
registers in the system should be addresses even.
39
EE 574
Special Processor Activities
1.7. Special Processor Activities Ref [3]
1.7.1 Processor Reset and Initialization
When Logic 1 is applied to RESET pin, CPU is reset and remains in reset state
till Logic 0 is applied.
- 8086 terminates the ongoing operation on the positive edge of reset signal.
- At negative edge, reset sequence starts and continues for ~10 clock cycles.
- During reset operation, all internal registers are set to 0000H
except CS is set to F000H and IP to FFF0H. Thus execution starts again
at FFFF0H.
- Due to this EPROM in 8086 system has an address of FFFF0H to
FFFFFH, i.e. at the end of the map.
For reset signal to be accepted by 8086
- it must be high for at least 4 clock cycles.
- Reset pulse must be applied only after 50 ms after power on to allow for
proper initialization of 8086.
- In reset state all 3-state outputs are tristated.
- Status signals are active in idle state for first clock cycle after reset
becomes active, then floats to tristate.
- ALE and HLDA signals are driven low during the reset operation
- NMI that appears before 2nd clock after the end of reset operation will not
be served. For NMI to be served it must appear before 2nd clock cycle
during reset initialization or later 40
EE 574
Special Processor Activities
1.7 Special Processor Activities Ref [3]
1.7.1 Processor Reset and Initialization
- If HOLD request appears immediately after RESET, it will be
immediately served after initialization, before execution of any instruction.
1.7.2 HALT
When the processor executes HLT instruction, it enters the ‘halt’ state.
- Before entering ‘halt’ state, it indicates ‘halt’ state in two ways, depending
on whether it is in minimum or maximum mode
Minimum mode – issues ALE pulse, but does not issue any control signal.
Maximum mode – puts HALT status on S2, S1, S0 pins, then the bus
controller issues one ALE pulse, but no qualifying signal. i.e. no
appropriate address or control signals are issued onto the bus.
- Only an interrupt request or reset will force 8086 to come out of ‘halt’
state.
- Even ‘HOLD’ request can not force 8086 out of ‘halt’ state.
41
EE 574
Special Processor Activities
1.7 Special Processor Activities Ref [3]
1.7.3 TEST and Synchronization with External Signals
Besides interrupt, hold and general I/O capabilities
8086 has extra facility of TEST signal.
- When the CPU receives a WAIT instruction, it preserves the contents of
the registers before execution of WAIT instruction and waits for TEST
input to go low.
- If the TEST input goes low, it continues further execution.
- otherwise it keeps on waiting for TEST pin to go low.
- For TEST signal to be accepted, it must be low for at least 5 clock cycles.
- Activity of waiting does not consume any bus cycle. The processor
remains in idle state while waiting.
- While waiting, any HOLD request from an external device may be served.
- If an interrupt occurs during wait, it fetches the wait instruction once
more, executes it, and then serves the interrupt.
- After returning from interrupt, it fetches the wait instruction once more
and continues with the ‘wait’ state.
- Thus the execution of a program which appears after WAIT instruction
can be synchronized with an external signal connected with the TEST input.
42
EE 574
Minimum Mode 8086 System and Timings
1.8 Minimum Mode 8086 System and Timings Ref [3]
The 8086 system organization is shown in Fig. 1.8. Since it has 20 address lines and
16 data lines, 8086 CPU requires three address latches and two octal data buffers for the
complete address and data separation 43
EE 574
Minimum Mode 8086 System and Timings
1.8 Minimum Mode 8086 System and Timings Ref [3]
In Minimum mode 8086 system,
There is a single micro processor
MN/MX is connected to Logic 1 (VCC)
- All the control signals are given out by microprocessor itself.
- Latches, transreceivers, clock generator, memory and I/O devices are
remaining components.
- Chip selection logic may be required to select memory or I/O devices
The latches are buffered D-type flip-flops, like 74LS373 or 8282.
- Used for separating the valid address from multiplexed address/data
signals and are controlled by ALE signal.
Transreceivers are bidirectional buffers, also called data amplifiers.
- required to separate data from multiplexed address/data signal.
- controlled by two signals DEN and DT/R
- DEN signal indicates that valid data is available on the data bus
- DT/R indicates the direction of data, i.e. from or to the processor.
The system contains memory for monitor and user program.
- EPROMs are used for monitor storage
- RAMs are used for user program storage
System may contain I/O devices for communicating with the processor and
special I/O devices.
Clock generator generates clock from the crystal oscillator, and then shapes and
divides to make it more precise to be used as accurate timing reference for
the system. Also synchronizes some ext. signals with the system clock.44
EE 574
Minimum Mode 8086 System and Timings
1.8 Minimum Mode 8086 System and Timings Ref [3]
45
EE 574
Minimum Mode 8086 System and Timings
1.8 Minimum Mode 8086 System and Timings Ref [3]
Working of min mode configuration system can be described in terms of
timing diagram
- The opcode fetch and read cycles are similar.
- The timing diagram is categorized into two parts
– read cycle and write cycle
Read Cycle
- begins with the assertion of ALE signal and M/IO signal
- During negative edge of this signal, valid address is latched on the local
bus.
- The BHE and A0 signals address low, high, or both bytes.
- From T1 to T4, the M/IO signal indicates memory or I/O operation.
At T2 address is removed from the local bus and sent to the output. The bus
is then tristated.
- The read signal RD is also activated in T2. The RD signal causes the
addressed device to enable its data bus drivers.
- After RD goes low, the valid data is available on the bus.
- The addressed device will drive the READY line high.
- When the processor returns the RD signal to high level, the addressed
device will again tristate the bus drivers.
46
EE 574
Minimum Mode 8086 System and Timings
1.8 Minimum Mode 8086 System and Timings Ref [3]
47
EE 574
Minimum Mode 8086 System and Timings
1.8 Minimum Mode 8086 System and Timings Ref [3]
Write Cycle
- begins with the assertion of ALE signal and the emission of address
- the M/IO signal is asserted indicating memory or I/O operation
- After sending the address in T1, in T2 the processor sends the data to be
written to the addressed location.
- The data remains in the bus till the middle of T4.
- The WR becomes active at the beginning of T2 (unlike RD is delayed in
T2 to provide time for floating)
- BHE and A0 signals are used to select proper byte or bytes of memory or
I/O word as discussed in signal description.
- M/IO, RD, and WR signals indicate the type of data transfer as shown in
Table 1.5.
48
EE 574
Minimum Mode 8086 System and Timings
1.8 Minimum Mode 8086 System and Timings Ref [3]
1.8.1. Hold Response Sequence
- The hold pin is checked at the leading edge of each clock pulse.
If it is received active by the processor before T4 of the previous cycle
or during T1 of current cycle, the CPU activates HLDA in the next
clock cycle and for the succeeding bus cycles. The bus will be given
to another requesting master.
- The control of the bus regained by the processor when the
requesting master drops the HOLD pin low.
- then the HLDA is dropped by the processor at the trailing edge of
the next clock as shown in Fig. 1.9(c)
The other conditions for HOLD and HLDA are discussed in signal
description section.
49
EE 574
Maximum Mode 8086 System and Timings
1.9 Maximum Mode 8086 System and Timings Ref [3]
50
EE 574
Maximum Mode 8086 System and Timings
1.9 Maximum Mode 8086 System and Timings Ref [3]
In Maximum mode 8086 system,
There may be more than one micro processor in the system
MN/MX is connected to Logic 0 (GND)
- the processor drives the status signals S2, S1, S0.
- Another chip, known as bus controller, derives control signals from status
signals.
- The other components in the system are the same as in minimum mode
system
- The functions of all the pins having special functions in max mode have
been discussed in the section on pin description.
The basic function of the controller chip IC8288
is to derive control signals like RD, WR (for memory and I/O devices)
DEN, DT/R, ALE, etc. using the status signals.
- The bus controller chip has input lines S2, S1, S0, and CLK.
- These inputs to 8288 are driven by CPU
- It derives the outputs ALE, DEN, DT/R, MRDC, MWTC, AMWC, IORC,
IOWC, and AIOWC.
- AEN and IOB are generally grounded. CEN is tied to +5 V.
- Significance of MCE/PDEN output depends on status of IOB pin.
(master cascade enable/peripheral data enable)
- If IOB is grounded, it acts as a master cascade enable for cascaded 8259A
else it acts as peripheral data enable used in multiple bus configurations.
- INTA pin is used to issue two interrupt acknowledge pulses to the
interrupt controller or to an interrupting device. 51
EE 574
Maximum Mode 8086 System and Timings
1.9 Maximum Mode 8086 System and Timings Ref [3]
IORC = IO read command
IOWC = IO write command
These signals enable an IO interface to read or write data from or to the
addressed port.
MRDC = memory read command
MWTC = memory write command
These signals are used as memory read or write signals. These command
signals instruct the memory to accept or send data from or to the bus.
For both IO and memory write command signals, advanced commands are
available. AIOWC and AMWTC.
These also serve the same purpose, but are activated one clock cycle earlier
than IOWC and MWTC signals respectively.
52
EE 574
Maximum Mode 8086 System and Timings
1.9 Maximum Mode 8086 System and Timings Ref [3]
The timing diagrams are divided in two portions as read (input) and write
(output) timing diagrams.
The address/data and address/status timings are similar to minimum mode
The only difference lies in the status signals used and available control
and advanced command signals.
53
EE 574
Maximum Mode 8086 System and Timings
1.9 Maximum Mode 8086 System and Timings Ref [3]
54
EE 574
Maximum Mode 8086 System and Timings
1.9 Maximum Mode 8086 System and Timings Ref [3]
1.9.1 Timings for RQ/GT Signals
Suggested Reading
1. Barry B. Brey, “Intel Microprocessors: 8086/88, 80186/188, 80286,
80386, 80486, Pentium, Pentium II, Pentium III, Pentium IV –
Architecture, Programming and Interfacing”, Pearson Education,
2003.
2. Badri Ram, “Advanced Microprocessors and Interfacing”, Tata-
McGraw Hill, 2001.
3. A.K. Ray and K.M. Bhurchandi, “Advanced Microprocessors and
Peripherals – Architecture, Programming and Interfacing”, Tata-
McGraw Hill, 2000.
56