Module 3
Module 3
101003/CS500D
Microprocessors and Microcontrollers
Syllabus
● SP gets decremented by two as a data word is stored into the stack → Push
● SP gets incremented by two as a data word is retrieved from the stack back to the
● The Stack Segment register (SS) and Stack pointer register (SP) together address
the stack-top.
● Stack Segment register (SS) contains the base address of the stack segment in the
memory.
● The stack pointer is a 16-bit register that contains the offset address of the
● The stack segment, like any other segment, may have a memory block of a
● The Stack Segment register (SS) and Stack pointer register (SP) together address
the stack-top.
● Stack top → 52050H, ie the location 52050H is already occupied with the
● Next 16 bit push operation will decrement the stack pointer by two.
● For a selected value of SS, the maximum value of SP=FFFFH and the segment can
● After successive push operations, when the stack pointer contains 0000H, any
attempt to further push the data to the stack will result in stack overflow.
8086 Stack - Uses
● After a procedure is called using the CALL instruction, the IP is incremented to the
next instruction.
● Then the contents of IP, CS and flag register are pushed automatically to the
stack.
● The control is then transferred to the specified address in the CALL instruction
Interrupts
● After executing ISR control
gets transferred back to the
program that got interrupted.
● Execution is resumed from the
point at which it was
interrupted
● Interrupt is the method of creating a temporary halt during program execution
and allows peripheral devices to access the microprocessor.
● Interrupts are useful when interfacing I/O devices with low data-transfer rates, like
a keyboard or a mouse, in which case polling the device wastes valuable processing
time
● The peripheral interrupts the normal application execution, requesting to send or
receive data.
● After the processor services the peripheral, the execution of the interrupted
program continues.
Hardware interrupt is caused by any
peripheral device by sending a signal
through a specified pin to the
microprocessor.
The 8086 gets the new values of CS and IP register from four memory
addresses.
In the Interrupt Structure of 8086 system the first 1 Kbyte of memory from
00000H to 003FFH is reserved for storing the starting addresses of interrupt
service routines.
This block of memory is often called the Interrupt Vector Table in 8086 or the
interrupt pointer table.
The size for each interrupt vector is 4 bytes (2 word in 16 bit), where 2 bytes (1
word) for segment and 2 bytes for offset of interrupt service routine address.
Every external and internal interrupt is assigned with a type that is either
implicit (NMI, TRAP, Divide by Zero etc. ) or specified in instruction INT N
Interrupt Vector Table
Interrupt Vector Table Cont’d
The starting address for Type 0 interrupt is 000000H, for Type 1 interrupt is
00004H similarly for Type2 is 00008H and ……so on.
● Get the offset address of the ISR using the Offset directive
● Get the segment address of the ISR using the Segment directive
Interrupt Controller
interrupt.
The PIC, after issuing an Interrupt to the CPU, must somehow input
information into the CPU that can ‘‘point’’ the Program Counter to the service
routine associated with the requesting device.
This ‘‘pointer’’ is an address in a vectoring table and will often be referred to,
as Interrupt Vector Table.
8259 - Internal Block Diagram
DATA BUS BUFFER : This 3-state, bidirectional 8-bit buffer is used to interface
the 8259A to the system Data Bus.
Control words and status information are transferred through the Data Bus
Buffer.
This function block also allows the status of the 8259A to be transferred onto
the Data Bus.
INTERRUPT REQUEST REGISTER (IRR) AND IN-SERVICE REGISTER (ISR) : The
interrupts at the IR input lines are handled by two registers in cascade, the
Interrupt Request Register (IRR) and the In-Service Register (ISR).
The IRR is used to store all the interrupt levels which are requesting service;
and the ISR is used to store all the interrupt levels which are being serviced.
PRIORITY RESOLVER : This logic block determines the priorities of the bits set
in the IRR.
The highest priority is selected and stored into the corresponding bit of the
ISR during INTA pulse.
The IR0 has the highest priority while the IR7 has the lowest priority in fixed
priority mode.
INTERRUPT MASK REGISTER (IMR) : The IMR stores the bits which mask the
interrupt lines to be masked.
The IMR operates on the IRR. Masking of a higher priority input will not affect
the interrupt request lines of lower quality.
INT (INTERRUPT) : This output goes directly to the CPU interrupt input.
The VOH level on this line is designed to be fully compatible with the 8080A,
8085A and 8086 input levels
IR0-IR7: These pins act as inputs to accept interrupt requests to the CPU.
WR: This pin is active-low write enable input to 8259A. This enable it to
accept command words from CPU.
RD: This pin is active-low read enable input to 8259A. A low on this line
enables 8259A to release status onto the data bus of the CPU.
CS: This is an active-low chip select signal for enabling RD and WR operations
of 8259A.
CASCADE BUFFER/COMPARATOR : This block stores and compares the ID’s of
all the 8259As used in the system. The 3 I/O pins CAS0-2 are outputs when the
8259A is used as a master. The same pins act as inputs when the 8259A is in
slave mode. The 8259A in master mode sends the ID of the interrupting slave
device on these lines. The slave thus selected, will send its preprogrammed
vector address on the data bus during the next INTA pulse
SP/EN: This pin is used as an input to designate whether the chip is used as a
master (SP = 1) or a slave (EN = 0)
4 Read/ Write word at an odd address 0 1 D15 – D0 in first operation byte from
odd bank is transferred
Semiconductor
Memory
RAM ROM
SRAM DRAM
Memory Map of 8086
EPROM’s are mapped at FFFFFH
● Data bus → used for accessing all bits in a location at the same time
● n = Log2 N
● If the processor has n address lines, then it can address N locations where
2n = N
● If only P out of N locations has to be interfaced, then only p address lines
are needed for directly connecting from microprocessor to chip
● Remaining n-p higher order address lines may be used for address
decoding (as inputs to chip selection logic)
● Memory address depends upon the hardware circuit used for decoding
chip select (CS)
● The output of the decoding circuit is connected with the CS pin of the
memory chip
● The general procedure of static memory interfacing with 8086 is as
follows:
1. Arrange the available memory chips so as to obtain 16 bit data bus width.
Upper 8-bit bank →Odd address memory bank
Lower 8-bit bank → Even address memory bank
2. Connect address lines of memory chips with the 8086 address lines
Connect memory RD and WR inputs to the corresponding 8086 signal
Connect the 16 bit data bus of the memory bank with that of 8086.
3. BHE and A0 are used for decoding the chip select signals for odd and even
memory banks. CS of memory → derived from o/p of decoding circuit
● Problem 1: Interface two 4K x 8 EPROMS and two 4K x 8 RAM chips with
8086. Select suitable maps.
● Solution: After reset , the processor starts from FFFF0H. This address
must lie in the EPROM.
● Memory map
● 8K bytes of EPROM → 13 address lines form A0 to A12
● Solution: After reset , the processor starts from FFFF0H. This address
must lie in the EPROM.
● Memory map