MP LMT Notes
MP LMT Notes
MP LMT Notes
1. 8086 CPU
Internal Architecture
As 8086 does 2-stage pipelining (overlapping fetching and execution), its architecture is divided
into two units:
● Bus Interfacing Unit (BIU)
● Execution Unit (EU)
Bus Interfacing Unit (BIU)
● It provides the interface of 8086 to external memory and I/O devices.
● It operates with respect to bus cycles (machine cycles). This means it performs various
machine cycles such as memory read, I/O read etc. to transfer data with memory and
I/O devices.
● BIU performs the following functions-
● It generates the 20 bit physical address for memory access.
● It fetches instruction from memory.
● It transfers data to and from the memory and I/O.
● It supports pipelining using the 6 byte instruction queue.
● The main components of the BIU are as follows:
○ Segment registers
○ CS register: CS holds the base address for the Code Segment. All
programs are stored in the Code Segment. CS is multiplied by 10H to
give the 20 bit physical address of the Code Segment. E.g. If CS = 4321H
then CS x 10H = 43210H→ Starting address of Code Segment.
● It fetches instructions from the Queue in BIU, decodes and executes them.
● It performs arithmetic, logic and internal data transfer operations within the
microprocessor.
● It sends request signals to the BIU to access the external module.
● It operates with respect to T-stats (clock cycles) and does not depend upon which
machine cycle is being performed by the BIU.
● The main components of the EU are as follows:
○ AX register (16 bits): It holds operands and results during multiplication and
division operations. All I/O data transfers using IN and OUT instructions use A
register (AL/AH or AX). It functions as accumulator during string operations.
○ BX register (16 bits): It holds the memory address (offset address) in indirect
addressing modes.
○ CX register (16 bits): It holds count for instructions like loop, rotate, shift and
string operations.
○ DX register (16 bits): It is used with AX to hold 32 bit values during multiplication
and division. It is used to hold the address of the I/O port in indirect I/O
addressing mode.
● Special purpose registers-
● Stack Pointer (SP 16 bits): It holds offset address of the top of the Stack. Stack is a set
of memory locations operating in LIFO manner. Stack is present in the memory in Stack
Segment. It is used during instructions like PUSH, POP, CALL, RET etc.
● Base Pointer (BP 16 bits): BP can hold offset address of any location in the stack
segment. It is used to access random locations of the stack.
● Source Index (SI 16 bits): It is normally used to hold the offset address for Data Segment
but can also be used for other segments using Segment Overriding. It holds offset
address of source data in Data Segment during string operations.
● Destination Index (DI 16 bits): It is normally used to hold the offset address for Extra
Segment but can also be used for other segments using Segment Overriding. It holds
offset address of destination in Extra Segment during string operations.
Operand register
It is a 16 bit register used by the control register to hold the operands temporarily. It is not
available to the programmer.
Pin Diagram
1. 8086 microprocessors works on voltage level 5 V DC power supply.
2. It comes in a 40-Lead Cerdip and Plastic Package, with 20 on each side.
● PIN 1 & 20 are GND Pins which should be connected to low potential of the power
supply or to the ground of the whole system.
● PIN 2-16 & 39 : AD15-AD0,
○ These are ADDRESS DATA BUS. These lines are used for I/O function with time
multiplexed memory. These are active high and 3-state during interrupt
acknowledge.
● PIN 17 : NMI, NON-MASKABLE INTERRUPT.
○ This pin is for creating a type 2 interrupts, which occurs due to a triggered input.
This cannot be done internally with software as you have to make it happen
physically from LOW to HIGH, but the interrupt is internally synchronized.
● PIN 18 : INTR, INTERRUPT REQUEST.
○ This is a level triggered input (active HIGH) which usually occurs at the last clock
cycle of each instruction to check whether or not the processor into interrupt
acknowledge operation mode.
○ This can be set internally with the help of software by resetting the interrupt
enable bit, also the interrupt is synchronized internally.
● PIN 19 : CLK, CLOCK.
○ This pin provides the clock signal for the processor and bus control.
○ It is asymmetric with 33% duty cycle to provide optimized internal timing.
● PIN 21 : RESET.
○ This pin is used to reset the processor from whatever state it is in. The signal
should be active high for at least 4 clock cycles.
○ When the pin is pulled low, it restarts execution from the beginning as in the code
or program, all this is internally synchronized.
● PIN 22 : READY.
○ This pin reads the ready signal that indicated that the addressed memory or I/O
has completed the data transfer. the signal is synchronized by the 8284A Clock
Generator along with the address bus to from READY.
○ The signal is active HIGH, but it is not synchronized also it may malfunction if
signal timings are not correctly matched.
● PIN 23 : TEST.
○ This input is detected by a “WAIT” instruction in 8086 microprocessor. If the input
is LOW execution of the program continues, else the processor will wait or delay
the task until the signal is LOW.
○ The input is synchronized internally during each clock cycle at the leading edge
(start or LOW to HIGH) of CLK signal.
● PIN 24, 25 : QS1, QS0; QUEUE STATUS.
○ These two pins are used to determine the queue status.
○ This signal is valid during the CLK cycle after which the queue operation is
performed.
○ These are usually used for external visualization of tasks performed by the
processor. These pin functions only in maximum mode.
● PIN 26-28 : S2—S0.
○ These pins give output which floats to 3-state OFF in hold acknowledge.
○ These have a truth table for all type of combinations, which you van refer to
datasheet attached below on pg4.
○ These pin also functions only in maximum mode.
● PIN 29 : LOCK.
○ This pin output indicated the supremacy of bus control over other system bus
masters.
○ The signal is active low and remains low until completion of the next instruction.
● PIN 30,31 : RQ/GT, REQUEST/GRANT.
○ These pins are bidirectional and used by other bus master to request the control
over bus at the end of the current bus cycle also they have internal pull-up
resistor.
● PIN 32 : RD, READ.
○ This output pin indicated that the processor is performing a memory size of 8086
microprocessor or I/O cycle, which totally depends on the state of S2 pin.
○ This pin is used to read devices, which resides on the 8086 local bus.
● PIN 33 : MN/MX, MINIMUM/MAXIMUM.
○ This is used to set the processor in either MINIMUM or MAXIMUM mode. And
pins function accordingly.
● PIN 34 : BHE/S7, BUS HIGH ENABLE/STATUS.
○ This pin provides a signal to enable the data on the most significant half of the
data bus (D15-D8).
● PIN 35-38 : A19/S6-A16/S3, ADDRESS/STATUS.
○ These pins are the most significant line for memory operations during t1. During
I/O operation, these pins are LOW.
● PIN 40 : VCC.
○ This is the power pin which should be connected to high potential of the system.
The working voltage level of the IC s 5V, and it should not exceed that.
Control signals provided by 8086 for memory operations and i/o interfacing :
● They are used to identifying whether the bus is carrying a valid address or not , in which
direction data is needed to be transferred over the bus, when there is valid write data on
the data bus and when to put read data on the system bus.
● Therefore, their sequence pattern makes all the operations successful in a particular
machine cycle.
● At T1 state ALE =1 ,this indicates that a valid address is latched on the address bus and
also M / IO’= 1, which indicates the memory operation is in progress.
● In T2, the address is removed from the local bus and is sent to the addressed device.
Then the bus is tristated.
● When RD’ = 0 , the valid data is present on the data bus.
● During T2 DEN’ =0, which enables transceivers and DT/R’ = 0 ,which indicates that the
data is received.
● During T3, data is put on the data bus and the processor reads it.
● The output device makes the READY line high. This means the output device has
performed the data transfer process. When the processor makes the read signal to 1,
then the output device will again tristate its bus drivers.
Write memory cycle
● At T1 state ALE =1 ,this indicates that a valid address is latched on the address bus and
also M / IO’= 1, which indicates the memory operation is in progress.
● In T2, the processor sends the data to be written to the addressed location.
● The data is buffered on the bus until the middle of T4 state.
● The WR’=0 becomes at the beginning of T2.
● The BHE’ and A0 signals are used to select the byte or bytes of memory or I/O word.
● During T2 DEN’ =0, which enables, transceivers and DT/R’ = 1 ,which indicates that the
data is transferred by the processor to the addressed device.
● All kinds of memory and i/o operations are performed using the decoding of M/IO’and
RD’ WR’ as shown in the table above.
Maximum Mode of 8086
● In this we can connect more processors to 8086 (8087/8089).
● 8086 max mode is basically for implementation of allocation of global resources and
passing bus control to other coprocessor(i.e. second processor in the system), because
two processors can not access system bus at same instant.
● All processors execute their own program.
● The resources which are common to all processors are known as global resources.
● The resources which are allocated to a particular processor are known as local or private
resources.
Circuit explanation:
● When MN/ MX’ = 0 , 8086 works in max mode.
● Clock is provided by 8284 clock generator.
● 8288 bus controller- Address form the address bus is latched into 8282 8-bit latch.
Three such latches are required because address bus is 20 bit. The ALE(Address latch
enable) is connected to STB(Strobe) of the latch. The ALE for latch is given by 8288
bus controller.
● The data bus is operated through 8286 8-bit transceiver. Two such transceivers are
required, because data bus is 16-bit. The transceivers are enabled the DEN signal,
while the direction of data is controlled by the DT/R signal. DEN is connected to OE’ and
DT/ R’ is connected to T. Both DEN and DT/ R’ are given by 8288 bus controller.
● Control signals for all operations are generated by decoding S’2, S’1 and S’0 using 8288
bus controller.
● Bus request is done using RQ’ / GT’ lines interfaced with 8086. RQ0/GT0 has more
priority than RQ1/GT1.
● INTA’ is given by 8288, in response to an interrupt on INTR line of 8086.
● In max mode, the advanced write signals get enabled one T-state in advance as
compared to normal write signals.
● This gives slower devices more time to get ready to accept the data, therefore it reduces
the number of cycles.
Timing Diagram (Separate Question):
Read Operation
Write Operation
These are explained in steps.
1. S0,S1,S2 are set at the beginning of bus cycle. On detecting the change on
2. passive state S0 = S1 = S2 = 1, the 8288 bus controller will output a pulse on its ALE
and apply a required signal to its DT/R pin during T1.
3. In T2, 8288 will set DEN = 1 thus enabling transceiver. For an input, 8288 it will activates
MRDC or IORC. These signals are activated until T4. For an output, the AMWC or
AIOWC is activated from T2 to T4 and MWTC or IOWC is activated from T3 to T4.
4. The status bits S0 to S2 remain active until T3, and become passive during T3 and T4.
5. If ready input is not activated before T3, wait state will be inserted between T3 and T4.
Design 8086 microprocessor based system using minimum mode with
following specifications:
Memory Calculations:
EPROM:
● Required Memory = 128 KB,
● Available Memory = 32 KB
● Number of chip required = 4
● Number of Address Lines = 15 lines (A15 – A1)
RAM:
● Required Memory = 64 KB,
● Available Memory = 16 KB
● Number of chip required = 4
● Number of Address Lines = 14 lines (A14 – A1)
Memory Map:
Final Configuration:
3. Programmer’s Model
The 8086 programmer's model is a picture of the processor as available to the grammer. These
are the registers used to hold numbers and addresses, as well as indicate status and act as
controls.
Data Registers
1. For 16-bit data registers can be accessed by names AX, BX, CX and DX,
2. Individual bytes of these registers can be accessed by name, AH, AL, BH, BL, CH, CL,
DH and DL
Address Registers:
1. The segment register are CS, DS, ES and SS and offset is stored in instruction pointer
IP or stack pointer SP or base registers BX or BP, or one of the index registers SI or DI
2. The CS:IP pair gives the address of the next instruction to be executed in the program
sequence.
3. The SS.SP pair gives the address of the top of the stack, a temporary storage area often
automatically used by the computer. SP is used for sequential access of the stack.
4. The SS:BP pair is used as a pointer into the stack. BP is used for random access of the
stack
5. The DS:SI pair is used as a source pointer and ES: DI pair is used as destination pointer
for string instructions. For all other instructions DI register is used with DS segment
register.
6. The DS:SI and ES:DI registers are used as general purpose pointers for copying and
data processing.
7. The dotted lines below show common default couplings. These defaults can be
overridden by a notation such as DS:[BP], where DS will be used in place of the default
SS.
8. The BX data register not shown is also used as a pointer in the data segment (by
default).
Flag Registers:
1. CF = Carry Out
2. PF = Parity Of Last Operation
3. ZF = Zero result
4. TF = Trap Flag
5. DF = Direction Flag
6. U = It can be 0 or 1. It is undefined
7. AF = Auxiliary Carry (used in BCD arithmetic)
SF = Sign bit from last operation
8. IF = Interrupt enable flag
9. OF = Overflow (error for signed numbers)
Hardware Interrupts
1. Hardware interrupts are those interrupts that are caused by any peripheral device by
sending a signal through a specified pin to the microprocessor. There are two hardware
interrupts in the 8086 microprocessor. They are:
a. NMI (Non-Maskable Interrupt): It is a single pin non-maskable hardware interrupt
that cannot be disabled. It is the highest priority interrupt in the 8086
microprocessor. After its execution, this interrupt generates a TYPE 2 interrupt.
IP is loaded from word location 00008 H, and CS is loaded from the word
location 0000A H.
b. INTR (Interrupt Request): It provides a single interrupt request and is activated
by the I/O port. This interrupt can be masked or delayed. It is a level-triggered
interrupt. It can receive any interrupt type, so the value of IP and CS will change
on the interrupt type received.
Software Interrupts
1. These are instructions inserted within the program to generate interrupts. There are 256
software interrupts in the 8086 microprocessor.
2. The instructions are of the format INT type, where the type ranges from 00 to FF. The
starting address ranges from 00000 H to 003FF H.
3. These are 2-byte instructions. IP is loaded from type * 04 H, and CS is loaded from the
following address given by (type * 04) + 02 H. Some important software interrupts are:
a. TYPE 0 corresponds to division by zero(0).
b. TYPE 1 is used for single-step execution for debugging the program.
c. TYPE 2 represents NMI and is used in power failure conditions.
d. TYPE 3 represents a break-point interrupt.
e. TYPE 4 is the overflow interrupt.
1. The interrupt vector (or interrupt pointer) table is the link between an interrupt type code
and the procedure that has been designated to service interrupts associated with that
code.
2. 8086 supports total 256 types i.e. 00H to FFH.
3. For each type it has to reserve four bytes i.e. double word. This double word pointer
contains the address of the procedure that is to service interrupts of that type.
4. The higher addressed word of the pointer contains the base address of the segment
containing the procedure. This base address of the segment is normally referred as
NEW CS.
5. The lower addressed word contains the procedure’s offset from the beginning of the
segment. This offset is normally referred as NEW IP.
6. Thus NEW CS: NEW IP provides NEW physical address from where user ISR routine
will start.
7. As for each type, four bytes (2 for NEW CS and 2 for NEW IP) are required; therefore
interrupt pointer table occupies up to the first 1k bytes (i.e. 256 x 4 = 1024 bytes) of low
memory.
8. The total interrupt vector table is divided into three groups namely,
a. Dedicated interrupts (INT 0…..INT 4)
b. Reserved interrupts (INT 5…..INT 31)
c. Available interrupts (INT 32…..INT 225)
6. Segmentation in 8086
● Segmentation is the process in which the main memory of the computer is logically
divided into different segments and each segment has its own base address.
● It is basically used to enhance the speed of execution of the computer system, so that
the processor is able to fetch and execute the data from the memory easily and fast.
Types Of Segmentation
1. Overlapping Segment – A segment starts at a particular address and its maximum size
can go up to 64kilobytes. But if another segment starts along with this 64kilobytes
location of the first segment, then the two are said to be Overlapping Segment.
2. Non-Overlapped Segment – A segment starts at a particular address and its maximum
size can go up to 64kilobytes. But if another segment starts before this 64kilobytes
location of the first segment, then the two segments are said to be Non-Overlapped
Segment.
Rules of Segmentation:
The starting address of a segment should be such that it can be evenly divided by 16.
Minimum size of a segment can be 16 bytes and the maximum can be 64 kB.
1. Addressing Modes
The different ways in which a source operand is denoted in an instruction is known as
addressing modes.
There are 8 different addressing modes in 8086 programming −
Instructions are classified on the basis of functions they perform. They are categorized into the
following main types:
MOV Moves data from register to register, register to memory, memory to register,
memory to accumulator, accumulator to memory, etc.
LDS Loads a word from the specified memory locations into specified register. It also
loads a word from the next two memory locations into DS register.
LES Loads a word from the specified memory locations into the specified register. It
also loads a word from next two memory locations into ES register.
LAHF Loads low order 8-bits of the flag register into AH register.
SAHF Stores the content of AH register into low order bits of the flags register.
XCHG Exchanges the contents of the 16-bit or 8-bit specified register with the contents
of AX register, specified register or memory locations.
PUSH Pushes (sends, writes or moves) the content of a specified register or memory
location(s) onto the top of the stack.
POP Pops (reads) two bytes from the top of the stack and keeps them in a specified
register, or memory location(s).
POPF Pops (reads) two bytes from the top of the stack and keeps them in the flag
register.
Arithmetic Instructions
Instructions of this group perform addition, subtraction, multiplication, division, increment,
decrement, comparison, ASCII and decimal adjustment etc.
ADC Adds specified operands and the carry status (i.e. carry of the previous stage).
SBB Subtract immediate data with borrow from accumulator, memory or register.
DAA Decimal Adjust after BCD Addition: When two BCD numbers are added, the DAA
is used after ADD or ADC instruction to get correct answer in BCD.
DAS Decimal Adjust after BCD Subtraction: When two BCD numbers are added, the
DAS is used after SUB or SBB instruction to get correct answer in BCD.
AAA ASCII Adjust for Addition: When ASCII codes of two decimal digits are added, the
AAA is used after addition to get correct answer in unpacked BCD.
AAD Adjust AX Register for Division: It converts two unpacked BCD digits in AX to the
equivalent binary number. This adjustment is done before dividing two unpacked
BCD digits in AX by an unpacked BCD byte.
AAM Adjust result of BCD Multiplication: This instruction is used after the multiplication
of two unpacked BCD.
AAS ASCII Adjust for Subtraction: This instruction is used to get the correct result in
unpacked BCD after the subtraction of the ASCII code of a number from ASCII
code another number.
NEG Obtains 2's complement (i.e. negative) of the content of an 8-bit or 16-bit specified
register or memory location(s).
Logical Instructions
Instruction of this group perform logical AND, OR, XOR, NOT and TEST operations.
AND Performs bit by bit logical AND operation of two operands and places the result in
the specified destination.
OR Performs bit by bit logical OR operation of two operands and places the result in
the specified destination.
XOR Performs bit by bit logical XOR operation of two operands and places the result in
the specified destination.
TEST Perform logical AND operation of a specified operand with another specified
operand.
Rotate Instructions
RCL Rotate all bits of the operand left by specified number of bits through carry flag.
RCR Rotate all bits of the operand right by specified number of bits through carry
flag.
ROL Rotate all bits of the operand left by specified number of bits.
ROR Rotate all bits of the operand right by specified number of bits.
Shift Instructions:
SAL or Shifts each bit of operand left by specified number of bits and put zero in LSB
SHL position.
SAR Shift each bit of any operand right by specified number of bits. Copy old MSB into
new MSB.
SHR Shift each bit of operand right by specified number of bits and put zero in MSB
position.
Branch Instructions:
It is also called program execution transfer instruction. Instructions of this group transfer
program execution from the normal sequence of instructions to the specified destination or
target.
CALL Calls a procedure whose address is given in the instruction and saves
their return address to the stack.
Here, CF = Carry Flag, ZF = Zero Flag, OF = Overflow Flag, SF = Sign Flag, CX = Register
String Instructions:
String is series of bytes or series of words stored in sequential memory locations.
The 8086 provides some instructions which handle string operations such as string movement,
comparison, scan, load and store.
MOVS/MOVSB/MOVSW Moves 8-bit or 16-bit data from the memory location(s) addressed by SI register
to the memory location addressed by DI register.
CMPS/CMPSB/CMPSW Compares the content of memory location addressed by DI register with the
content of memory location addressed by SI register.
SCAS/SCASB/SCASW Compares the content of accumulator with the content of memory location
addressed by DI register in the extra segment ES.
LODS/LODSB/LODSW Loads 8-bit or 16-bit data from memory location addressed by SI register into
AL or AX register.
STOS/STOSB/STOSW Stores 8-bit or 16-bit data from AL or AX register in the memory location
addressed by DI register.
Status Flags
In 8086 there are 6 different flags which are set or reset after 8-bit or 16-bit operations. These
flags and their functions are listed below.
Control Flags
In 8086 there are 3 different flags which are used to enable or disable some basic operations of
the microprocessor. These flags and their functions are listed below.
4. It consists of 40 pins and operates in +5V regulated power supply. Port C is further
divided into two 4-bit ports i.e. port C lower and port C upper and port C can work in
either BSR (bit set rest) mode or in mode 0 of input-output mode of 8255.
5. Port B can work in either mode 0 or in mode 1 of input-output mode. Port A can work
either in mode 0, mode 1 or mode 2 of input-output mode. It has two control groups,
control group A and control group B.
6. Control group A consist of port A and port C upper. Control group B consists of port C
lower and port B. Depending upon the value if CS’, A1 and A0 we can select different
ports in different modes as input-output function or BSR. This is done by writing a
suitable word in control register (control word D0-D7).
CS’ A1 A0 Selection Address
0 0 0 PORT A 80 H
0 0 1 PORT B 81 H
0 1 0 PORT C 82 H
0 1 1 Control Register 83 H
1 X X No Selection X
Pin Diagram:
Mode 0 –In this mode all the three ports (port A, B, C) can work as simple input function or
simple output function. In this mode there is no interrupt handling capacity.
Mode 1 – Handshake I/O mode or strobed I/O mode. In this mode either port A or port B can
work as simple input port or simple output port, and port C bits are used for handshake signals
before actual data transmission. It has interrupt handling capacity and input and output are
latched. Example: A CPU wants to transfer data to a printer. In this case since speed of
processor is very fast as compared to relatively slow printer, so before actual data transfer it will
send handshake signals to the printer for synchronization of the speed of the CPU and the
peripherals.
Mode 2 – Bi-directional data bus mode. In this mode only port A works, and port B can work
either in mode 0 or mode 1. 6 bits port C are used as handshake signals. It also has interrupt
handling capacity.
Advantages:
1. Versatility: The PPI 8255 can be programmed to operate in a variety of modes, which
makes it a versatile component in many different systems. It provides three 8-bit ports
that can be configured as input or output ports, and supports multiple modes of
operation for each port.
2. Ease of use: The PPI 8255 is relatively easy to use and program, even for novice
programmers. The control register of the PPI can be programmed using simple
commands, which makes it easy to interface with other devices.
3. Compatibility: The PPI 8255 is widely used and has been around for many years, which
means that it is compatible with a wide range of devices and software.
4. Low cost: The PPI 8255 is a relatively low-cost component, which makes it an affordable
option for many different applications.
Disadvantages:
1. Limited functionality: While the PPI 8255 is versatile, it has limited functionality
compared to newer I/O interface components. It is not capable of high-speed data
transfer and has limited memory capacity.
2. Limited number of ports: The PPI 8255 provides only three 8-bit ports, which may not be
sufficient for some applications that require more I/O ports.
3. Limited resolution: The PPI 8255 provides only 8 bits of resolution for each port, which
may not be sufficient for some applications that require higher resolution.
4. Obsolete technology: While the PPI 8255 is still used in some applications, it is
considered an older technology and is being replaced by newer, more advanced I/O
interface components.
Features of 8257
1. Here is a list of some of the prominent features of 8257 −
2. It has four channels which can be used over four I/O devices.
3. Each channel has 16-bit address and 14-bit counter.
4. Each channel can transfer data up to 64kb.
5. Each channel can be programmed independently.
6. Each channel can perform read transfer, write transfer and verify transfer operations.
7. It generates MARK signal to the peripheral device that 128 bytes have been transferred.
8. It requires a single phase clock.
9. Its frequency ranges from 250Hz to 3MHz.
10. It operates in 2 modes, i.e., Master mode and Slave mode.
8257 Architecture
The following image shows the architecture of 8257 −
8257 Pin Description
The following image shows the pin diagram of a 8257 DMA controller −
DRQ0−DRQ3
These are the four individual channel DMA request inputs, which are used by the peripheral
devices for using DMA services. When the fixed priority mode is selected, then DRQ0 has the
highest priority and DRQ3 has the lowest priority among them.
DACKo − DACK3
These are the active-low DMA acknowledge lines, which updates the requesting peripheral
about the status of their request by the CPU. These lines can also act as strobe lines for the
requesting devices.
Do − D7
These are bidirectional, data lines which are used to interface the system bus with the internal
data bus of DMA controller. In the Slave mode, it carries command words to 8257 and status
word from 8257. In the master mode, these lines are used to send higher byte of the generated
address to the latch. This address is further latched using ADSTB signal.
IOR
It is an active-low bidirectional tri-state input line, which is used by the CPU to read internal
registers of 8257 in the Slave mode. In the master mode, it is used to read data from the
peripheral devices during a memory write cycle.
IOW
It is an active low bi-direction tri-state line, which is used to load the contents of the data bus to
the 8-bit mode register or upper/lower byte of a 16-bit DMA address register or terminal count
register. In the master mode, it is used to load the data to the peripheral devices during DMA
memory read cycle.
CLK
It is a clock frequency signal which is required for the internal operation of 8257.
RESET
This signal is used to RESET the DMA controller by disabling all the DMA channels.
Ao - A3
These are the four least significant address lines. In the slave mode, they act as an input, which
selects one of the registers to be read or written. In the master mode, they are the four least
significant memory address output lines generated by 8257.
CS
It is an active-low chip select line. In the Slave mode, it enables the read/write operations
to/from 8257. In the master mode, it disables the read/write operations to/from 8257.
A4 - A7
These are the higher nibble of the lower byte address generated by DMA in the master mode.
READY
It is an active-high asynchronous input signal, which makes DMA ready by inserting wait states.
HRQ
This signal is used to receive the hold request signal from the output device. In the slave mode,
it is connected with a DRQ input line 8257. In Master mode, it is connected with HOLD input of
the CPU.
HLDA
It is the hold acknowledgement signal which indicates the DMA controller that the bus has been
granted to the requesting peripheral by the CPU when it is set to 1.
MEMR
It is the low memory read signal, which is used to read the data from the addressed memory
locations during DMA read cycles.
MEMW
It is the active-low three state signal which is used to write the data to the addressed memory
location during DMA write operation.
ADST
This signal is used to convert the higher byte of the memory address generated by the DMA
controller into the latches.
AEN
This signal is used to disable the address bus/data bus.
TC
It stands for ‘Terminal Count’, which indicates the present DMA cycle to the present peripheral
devices.
MARK
The mark will be activated after each 128 cycles or integral multiples of it from the beginning. It
indicates the current DMA cycle is the 128th cycle since the previous MARK output to the
selected peripheral device.
Vcc
It is the power signal which is required for the operation of the circuit.
Advantages
1. DMA accelerates memory operations by avoiding the participation of the CPU.
2. The workload on the CPU is reduced.
3. Only a few clock cycles are required for each transmission.
Disadvantages
1. When DMA is utilized for data transport, a cache coherence problem might occur.
2. Increases the system's cost.
1. The Block Diagram consists of 8 blocks which are – Data Bus Buffer, Read/Write Logic,
Cascade Buffer Comparator, Control Logic, Priority Resolver and 3 registers- ISR, IRR,
IMR.
2. Data bus buffer – This Block is used as a mediator between 8259 and 8085/8086
microprocessor by acting as a buffer. It takes the control word from the 8085 (let say)
microprocessor and transfer it to the control logic of 8259 microprocessor. After selection
of Interrupt by 8259 microprocessor (based on priority of the interrupt), it transfer the
opcode of the selected Interrupt and address of the Interrupt service sub routine to the
other connected microprocessor. The data bus buffer consists of 8 bits represented as
D0-D7 in the block diagram. Thus, shows that a maximum of 8 bits data can be
transferred at a time.
3. Read/Write logic – This block works only when the value of pin CS is low (as this pin is
active low). This block is responsible for the flow of data depending upon the inputs of
RD and WR. These two pins are active low pins used for read and write operations.
4. Control logic – It is the center of the PIC and controls the functioning of every block. It
has pin INTR which is connected with other microprocessor for taking interrupt request
and pin INT for giving the output. If 8259 is enabled, and the other microprocessor
Interrupt flag is high then this causes the value of the output INT pin high and in this way
8259 responds to the request made by other microprocessor.
5. Interrupt request register (IRR) – It stores all the interrupt level which are requesting for
Interrupt services.
6. Interrupt service register (ISR) – It stores the interrupt level which are currently being
executed.
7. Interrupt mask register (IMR) – It stores the interrupt level which have to be masked by
storing the masking bits of the interrupt level.
8. Priority resolver – It examines all the three registers and set the priority of interrupts and
according to the priority of the interrupts, interrupt with highest priority is set in ISR
register. Also, it reset the interrupt level which is already been serviced in IRR.
9. Cascade buffer – To increase the Interrupt handling capability, we can further cascade
more number of pins by using cascade buffer. So, during increment of interrupt
capability, CSA lines are used to control multiple interrupt structure.
10. SP/EN (Slave program/Enable buffer) pin is when set to high, works in master mode else
in slave mode. In Non Buffered mode, SP/EN pin is used to specify whether 8259 work
as master or slave and in Buffered mode, SP/EN pin is used as an output to enable data
bus.
Advantages:
1. Interrupt Management: The 8259 PIC is designed to handle interrupts efficiently and
effectively, allowing for faster and more reliable processing of interrupts in a system.
2. Flexibility: The 8259 PIC is programmable, meaning that it can be customized to suit the
specific needs of a given system, including the number and type of interrupts that need
to be managed.
3. Compatibility: The 8259 PIC is compatible with a wide range of microprocessors, making
it a popular choice for managing interrupts in many different systems.
4. Multiple Interrupt Inputs: The 8259 PIC can manage up to 8 interrupt inputs, allowing for
the management of complex systems with multiple devices.
5. Ease of Use: The 8259 PIC includes simple interface pins and registers, making it
relatively easy to use and program.
Disadvantages:
1. Cost: While the 8259 PIC is relatively affordable, it does add cost to a system,
particularly if multiple PICs are required.
2. Limited Number of Interrupts: The 8259 PIC can manage up to 8 interrupt inputs, which
may be insufficient for some applications.
3. Complex Programming: Although the interface pins and registers of the 8259 PIC are
relatively simple, programming the 8259 can be complex, requiring careful attention to
interrupt prioritization and other parameters.
4. Limited Functionality: While the 8259 PIC is a useful peripheral for interrupt
management, it does not include more advanced features, such as DMA (direct memory
access) or advanced error correction.
Command word of 8259 is divided into two parts :
1. Initialization command words(ICW)
2. Operating command words(OCW)
ICW1 command :
1. The control word is recognized as ICW1 when A0 = 0 and D4 = 1.
2. It has the control bits for Edge and level triggering mode, single/cascaded mode, call
address interval and whether ICW4 is required or not.
3. Address lines A7 to A5 are used for interrupt vector addresses.
4. When the ICW1 is loaded, then the initializations performed are:
a. The edge sense circuit is reset because, by default, 8259 interrupt is edge
triggered.
b. The interrupt mask register is cleared.
c. IR7 is assigned to priority 7.
d. Slave mode address is assigned as 7.
e. When D0 = 0, this means IC4 command is not required. Therefore, functions
used in IC4 are reset.
f. Special mask mode is reset and status read is assigned to IRR.
ICW2 command :
1. The control word is recognized as ICW2 when A0= 1.
2. It stores the information regarding the interrupt vector address.
3. In the 8085 based system, the A15 to A8 bits of control word is used for interrupt vector
addresses.
4. In the 8086 based system, T6 to T3 bits are inserted instead of A15 to A8 and A10 to
A8 are used for selecting interrupt level, i.e. 000 for IR0 and 111 for IR7.
5. Initialization of 8259 by ICW1 and ICW2 command words
ICW3 :
1. ICW3 command word is used when there is more than one 8259 present in the system
i.e. when SNGL bit in ICW1 is 0, then it will load 8-bit slave register.
ICW4 :
1. When AEOI = 1, then Automatic end of interrupt mode is selected.
2. When SFMN = 1, then a special fully nested mode is selected.
3. when BUF = 0 , then Non buffered mode is used (i.e. M/S is don’t care) and when M/S =
1, then 8259 is master, otherwise it is a slave.
4. when µPM = 1, then 8086 operations are performed, otherwise 8085 operations are
performed.
OCW1 –
1. It is used to set and reset the mask bits in IMR(interrupt mask register). M7 – M0
describes 8 mask bits
OCW2 –
1. It is used for selecting the mode of operation of 8259. Here L2 to L0 are used to describe
interrupt level on which action need to be performed.
2. Detailed operations are described in the diagram below.
OCW3 –
When the ESMM (Enable special mask mode ) bit is set, then the SMM bit is don’t care. If SMM
= 1 and ESMM = 1, then 8259 will enter in Special mask mode.
If ESMM = 1 and SMM = 0, then 8259 will return into normal mask mode.
RR and RIS are used to give the read register command.
P = 1 is used for poll command.
4. Partial & Absolute decoding
Absolute decoding:
● In absolute decoding technique, all the higher address lines are decoded to select the
memory chip, and the memory chip is selected only for the specified logic levels on
these high-order address lines; no other logic levels can select the chip.
Partial decoding:
● In small systems, hardware for the decoding logic can be eliminated by using individual
high-order address lines to select memory chips.
● This is referred to as linear decoding. Figure shows the addressing of RAM with linear
decoding technique. This technique is also called partial decoding.
● It reduces the cost of decoding circuit, but it has a drawback of multiple addresses
(shadow addresses).
● Figure shows the addressing of RAM with linear decoding technique.
● A15 address line, is directly connected to the chip select signal of EPROM and after
inversion it is connected to the chip select signal of the RAM.
● Therefore, when the status of A15 line is ‘zero’, EPROM gets selected and when the
status of A15 line is ‘one’ RAM gets selected.
● The status of the other address lines is not considered, since those address lines are not
used for generation of chip select signals.
Module 4 - Intel 80386DX Processor
● During real addressing mode, the 80386 can address up to 1 MB of physical memory
using address lines A19-A0.
● In this address mode, the paging unit is disabled so that the real addresses are the
same as the physical addresses.
● To compute a physical memory address, the contents of the segment register are shifted
left by four bit positions and then added to the 16-bit offset address formed using one of
the addressing modes just like the 8086 real address mode.
● Figure shows the physical address computation in real mode of 80386. In real-mode
operation of 80386, the segments can be read, written or executed.
● The segments in 80386 real modes can be overlapped or non-overlapped.
Protected Mode
1. A 32-bit address space is available in protected mode, a sophisticated operating mode
that gives users access to up to 4GB of memory.
2. Additionally, it offers sophisticated memory management and security features including
segmentation and paging.
3. Pages are fixed-size units of memory that can be moved in and out of physical memory
as needed. Paging enables this.
4. Memory can be separated into logical units called segments through segmentation,
which can be used to restrict access to particular memory locations.
5. The 80386 also has access to a number of privileged instructions and registers in a
protected mode that are not present in regular mode.
6. The protected mode also supports virtual memory which allows the system to use more
memory than the physical memory available by swapping memory pages to and from the
disk.
Virtual 8086
● In real mode, 80386 is able to execute the 8086 programs along with all capabilities of
80386.
● But once the 80386 processor enters into the protected mode from real mode, it cannot
revert back to the real mode without a reset operation.
● During the protected mode of operation, 80386 processors confer a virtual 8086
operating environment to execute the application programs of 8086.
● Therefore, the virtual mode operation of 80386 provides an advantage of executing 8086
programs although the 80386 processor is in protected mode.
● The address computation mechanism in virtual 80386 modes is same as 8086 real
mode. In this Operating Modes of 80386, 80386 can address 1 Mbytes of physical
memory, which will be within the 4 Gbytes memory address of the protected mode of
80386.
● The paging mechanism and protection capabilities are also available in this mode of
operation. In the virtual mode, the paging unit provides 256 pages, each of 4 Kbytes
size. Each of the pages will be anywhere within the maximum 4 Gbytes physical
memory.
● The 80386 can support multiprogramming; hence the multiple 8086 real-mode software
applications can be executed at a time.
● Figure shows the memory management in virtual 386 modes in a multitasking virtual
8086 environment.
2. Explain memory management in protected mode of 80386
● In protected mode, the 80386 can able to address 4 gigabytes of physical memory and
64 terrabytes of virtual memory.
● In this Operating Modes of 80386, the 80386 has capability to support all programs
written for 80286 and 8086 and to be executed.
● The controls of memory management and protection abilities of 80386 are possible in
this Operating Modes of 80386.
● All additional instructions and addressing modes of 80386 feasible in protected mode.
● In protected mode addressing, the contents of segment registers are used as selectors
which can address the segment descriptors.
● The segment descriptors consist of the segment limit, base address and access rights
byte of the segment.
● The effective or offset address is added with segment base address to determine linear
address.
● When the paging unit is disabled, the linear address is used as physical address. If the
paging unit becomes enabled, the paging unit converts the linear address into physical
address.
● Figures show the protected mode addressing without paging and with paging unit
respectively. In general, the paging unit is a memory management unit which is enabled
only in the protected mode.
● The paging mechanism is able to handle memory segments in terms of pages of 4 KB
size. Usually, a paging unit operates under the control of segmentation unit.
● The 80386 starts with real mode and then changes the operation from real mode to the
protected mode operation. To change the operation from real mode to the protected
mode, the following steps must be followed:
○ Step 1 Initialize the IDT so that it contains valid interrupt gates for at least the
first 32 interrupt type numbers. Usually, IDT contains up to 256 8-byte interrupt
gates to define all 256 interrupt type.
○ Step 2 Initialize the GDT so that it contains a null descriptor at Descriptor 0. The
valid descriptors are used for at least one code, one stack and one data
segment.
○ Step 3 Switch to protected mode after setting the PE bit in CR0.
○ Step 4 Perform an intrasegment near JMP operation to flush the internal
instruction queue and load the TR with the base TSS descriptor.
○ Step 5 After that, load all the segment registers with their initial selector values.
○ Step 6 80386 operates in the protected mode using segment descriptors that are
defined in GDT and IDT.
Module 5 - Pentium Processor
● Each integer unit has the basic five-stage pipeline as given below:
○ Prefetch (PF)
○ Decode-1 (D1)
○ Decode-2 (D2)
○ Execute (E)
○ Write Back (WB)
Prefetch (PF)
In the prefetch stage of integer pipeline of the Pentium processor, instructions are fetched from
the instruction cache as instructions are stored initially in the instruction cache.
Decode-1 (D1)
In the decode-1 (D1) pipeline stage, the CPU decodes the instruction and generates a control
word. The D1 pipeline stage has two parallel instruction decoders. These implement the pairing
rules.
Decode-2 (D2)
The decode-2(D2) pipeline stage is required whenever the control word from D1 stage is
decoded to complete the instruction decoding. In this stage, the CPU generates addresses for
data memory.
Execute (E)
The execution stage is used for both ALU operations and data cache access. The data cache is
used for data operands and ALU performs arithmetic logic computations or floating-point
operations.
Decode-1 (D1)
The decode-1 (D1) pipeline stage is also same as the integer pipeline of Pentium processor.
Decode-2 (D2)
The decode-2 (D2) pipeline stage is worked as required whenever the control word from D1
stage is decoded to complete the instruction decoding. In this stage, it is the integer pipeline of
Pentium processor.
Operand Fetch
During the execution stage (E), the floating-point unit accesses the data cache and the
floating-point register to fetch operands. Before writing the floating-point data to the data cache,
the floating-point unit converts internal data format into appropriate memory representation
format.
● The gain produced by Pipelining can be reduced by the presence of program transfer
instructions eg JMP, CALL, RET etc
● They change the sequence causing all the instructions that entered the pipeline after
program transfer instructions invalid
● Thus no work is done as the pipeline stages are reloaded.
● To avoid this problem, Pentium uses a scheme called Dynamic Branch Prediction. In this
scheme, a prediction is made for the branch instruction currently in the pipeline.
● The prediction will either be taken or not taken. If the prediction is true then the pipeline
will not be flushed and no clock cycles will be lost.
● If the prediction is false then the pipeline is flushed and starts over with the current
instruction. It is implemented using 4 way set associated cache with 256 entries.
● This is called Branch Target Buffer (BTB).
● The directory entry for each line consists of:
○ Valid bit: Indicates whether the entry is valid or not.
○ History bit: Track how often bit has been taken.
● Source memory address is from where the branch instruction was fetched. If the
directory entry is valid then the target address of the branch is stored in corresponding
data entry in BTB.
Working:
● BTB is a lookaside cache that sits to the side of Decode Instruction(DI) stage of 2
pipelines and monitors for branch instructions.
● The first time that a branch instruction enters the pipeline, the BTB uses its source
memory to perform a lookup in the cache.
● Since the instruction was never seen before, it is BTB miss. It predicts that the branch
will not be taken even though it is unconditional jump instruction.
● When the instruction reaches the EU(execution unit), the branch will either be taken or
not taken. If taken, the next instruction to be executed will be fetched from the branch
target address. If not taken, there will be a sequential fetch of instructions.
● When a branch is taken for the first time, the execution unit provides feedback to the
branch prediction. The branch target address is sent back which is recorded in BTB.
● A directory entry is made containing the source memory address and history bit is set as
strongly taken.
● The diagram is explained by the following table:
Remains in Downgraded to
11 Strongly Taken Branch Taken
same state weakly taken
Upgraded to Downgraded to
10 Weakly Taken Branch Taken
strongly taken weakly not taken
Upgraded to
Strongly Not Branch Not Remains in same
00 weakly not
Taken Taken state
taken
Advantages:
1. Improved performance
2. Increased instruction throughput
3. Reduced branch misprediction penalty
4. More efficient use of processor resources
5. Better handling of large code bases
6. More accurate predictions over time
7. Improved pipelining
Disadvantages:
1. Increased complexity
2. Increased power consumption
3. Limited accuracy
4. Increased memory usage
5. Difficulty predicting indirect branches
6. Increased vulnerability to side-channel attacks
7. Increased software complexity
3. MESI Protocol
MESI (Modified, Exclusive, Shared, Invalid) Protocol
1. The abbreviation of MESI is Modified, Exclusive, Shared, and Invalid, which are the four
possible states of a cache line.
2. The MESI protocol is a general mechanism to control cache consistency, using snooping
techniques.
3. The Pentium processors can change the state of a cache line through read or write
cycles or internal snooping and other devices such as L2-cache controller can change
the state through external snooping.
4. The MESI protocol provides each cache line that can be one of the four states, and the
MESI protocol is managed by the two MESI bits. Figure shows the state transition
diagram of MESI protocol.
Modified (M)
When the data of a cache line is marked as modified (M), it is available in a single cache of the
complete system only. This cache line can be read or written to without an external cycle.
Exclusive (E)
The exclusive (E) cache line is always stored in only one of the caches in a computer system,
though it has not been modified. Hence its values are the same as in the rest of the system. The
cache line can be read or written to without an external cycle. Once it is written, to the cache
line should be set to modify.
Shared (S)
The shared (S) line can be stored in other caches of the system. The shared line always has the
current value so that read accesses can be obtained from the cache. Write accesses to a
shared cache line are switched through the external data bus, whenever any cache write
strategy is used. Therefore, the shared cache lines in the other caches are invalidated.
Invalid (I)
The cache line which is marked as invalid is not available in the cache. The catch lines marked
as invalid (I) lines might be empty or could have invalid data in the cache. Each access to an
invalid cache line generates a cache miss. During read access, the cache controller starts a
catch line fill and the cache controller switches the write through to the external bus, rather than
a write-allocate.
4. Cache Organization
A Cache Memory in Pentium Processor is used to store both the data and the address where
the data is stored in the main memory.
There are methods of cache organization such as direct mapped cache and two-way
set-associative cache.
Data bus 16-bit data 32-bit data 64-bit data 64-bit data 64-bit data
bus. bus. bus. bus. bus.
Arithmetic The 8086 The 80386 The Pentium Improved the The Pentium
Operations processor processor 1 processor MMX 3 processor
did not have featured a introduced technology of continued to
native built-in the MMX the Pentium enhance
support for floating-point (MultiMedia 1 and multimedia
floating-point unit (FPU) for eXtensions) introduced performance
arithmetic. improved and instruction the Katmai with the
Floating-poin faster set, which New introduction
t operations floating-point improved Instructions of the SSE
had to be arithmetic multimedia (KNI) set, (Streaming
emulated operations. and vector which SIMD
using arithmetic enhanced Extensions)
software operations. multimedia instruction
routines. and 3D set.
graphics
operations.
Instruction Decoder
The instruction decoder is used to decode all instructions of the Pentium 4 processor
concurrently and translate them into micro-operations (μ-ops). One instruction decoder decodes
one instruction per clock cycle.
Execution Unit
A superscalar processor has multiple parallel execution units, which can process the
instructions simultaneously. Actually, the executions of instructions are sequentially dependent
on each other.
Allocator
The allocator accepts micro-operations (µ-ops) from the μ-ops queue and allocates the key
machine buffers to execute micro-operations.
Register Rename
The register rename logic is used to rename the registers of Intel Architecture 32-bit Pentium
processors onto the machine’s physical registers.
Instruction Schedulers
The instruction scheduler is used to schedule micro-operations (μ-ops) to an appropriate
execution unit. There are five instruction schedulers to schedule micro-operations in different
execution units.
Memory Subsystem
The virtual memory and paging technique are used in memory-subsystem representation. The
linear address space can be mapped into the processor’s physical address space, either directly
or using a paging technique. In direct mapping, paging is disabled and each linear address
represents a physical address
Replicated Resources
Each processor has general-purpose registers, control registers, flags, time stamp counters,
and APIC registers. The content of these registers are used as replicated resources.
Shared Resources
Memory and range registers can be independently read/write. Therefore, memory, range
registers and data buses are used as shared resources.
Shared/Replicated Resources
The caches and queues in the hyper-threading pipeline can he shared or not shared according
to the situation.