8 8086 Interrupts
8 8086 Interrupts
Applications
• The interrupt vector table contains the IP and CS of all the interrupt
types stored sequentially from address 0000: 0000 to 0000: 03FF H.
• The interrupt type N is multiplied by 4 and the hexadecimal
multiplication obtained gives the offset address in the 0th code
segment at which the IP and CS addresses of the interrupt service
routine (ISR) are stored.
8
Interrupt Cycle Of 8086/8088
9
8086 Interrupt Response
1. Push FLAGS Interrupt Service
main
2. Clear IF Routine (ISR)
Program
3. Clear TF
4. Push CS PUSH registers
5. Push IP ...
6. Fetch ISR
...
address
...
....
POP IP
...
POP CS
....
POP FLAGS
POP registers
IRET
How does 8086 get to Interrupt
Service Routine?
– Simple. It loads its CS and IP registers with the
address of ISR.
– So, the next instruction to be executed is the
first instruction of ISR
How does 8086 get the address of
Interrupt Service Routine (ISR)?
–It goes to specified memory location to
fetch four consecutive bytes
• higher two bytes to be used as CS
• lower two bytes to be used as IP
How does 8086 get the address of
that specified memory location?
• In an 8086 system, the first 1Kbytes of memory, from
00000 to 003FF, is set aside as a Table for storing the
starting addresses of interrupt service routines.
– Since 4 bytes are required to store CS and IP
values for each ISR, the Table can hold the starting
addresses for up to 256 ISRs.
8086 Interrupt Pointer Table
• The starting address of an ISR is often called
– the interrupt vector or
– the interrupt pointer.
• So the Table is referred to as
– interrupt-vector table or
– interrupt-pointer table.
8086 Interrupt Pointer Table
• Next slide shows how the 256 interrupt vectors
are arranged in the table in memory
• Note that
– the IP value is put in as the low word of the vector
– CS as high word of the vector
• Each double word interrupt vector is identified
by a number from 0 to 255
• INTEL calls this number the TYPE of the
interrupt
AVAILABLE 3FFH TYPE 255
FOR USER
...
(224) 080H TYPE 32
TYPE 31
RESERVED (27)
...
014H TYPE 5
TYPE 4
010H INTO OVERFLOW
TYPE 3
Predefined/ 00CH INT
Dedicated/Internal TYPE 2
Interrupts Pointers 008H NON-MASKABLE
(5) TYPE 1
004H SINGLE STEP
CS Base Address TYPE 0
IP Offset 000H DIVIDE ERROR
How does 8086 get the address of a
particular ISR?
• In an 8086 system, each “interrupter” has an id#
• 8086 treat this id# as interruption type#
• after receiving INTR signal, 8086 sends an INTA signal
• after receiving INTA signal, interrupter releases it’s id#,
i.e., type# of the interruption.
• 8086 multiplies this id# or type# by 4 to produced the
desired address in the vector table
• 8086 reads 4 bytes of memory starting from this address to
get the starting address of ISR
• lower 2 byte is loaded in to IP
• higher 2 bytes to CS
Non-Maskable Interrupt
• The processor 8086/88 has a non-maskable interrupt pin
(NMI), that has the highest priority among the external
interrupts.
• TRAP is an internal interrupt having the highest priority
among the interrupts except the Divide by zero (Type-0)
exception.
• The NMI pin should remain high for at least two clock
cycles and need not synchronized with the clock for being
sensed.
• When the NMI is activated, the current instruction being
executed is completed and then the NMI is served.
• In case of string type instructions, this interrupt will be
served only after the complete string has been
manipulated. 18
Maskable Interrupt
• The processor 8086/88 also provides a pin INTR that has lower
priority as compared to NMI.
• Further the priorities within the INTR types are decided by the type
of the INTR signal that is to be passed to the processor via data bus
by some external device like the programmable interrupt controller.
• The INTR signal is level triggered and can be masked by resetting
the interrupt flag.
• It is internally synchronized with the transition of the clock. For the
INTR signal, to be responded to in the next instruction cycle, it
must go high in the last clock cycle of the current instruction or
before that.
• The INTR requests appearing after the last clock cycle of the
current instruction will be responded to after the execution of the
next instruction.
• The status of the pending interrupts is checked at the end of each
instruction cycle.
19
Maskable Interrupt
• If the IF is set, the processor is ready to respond to any
INTR interrupt if the IF is reset, the processor will not
serve any interrupt appearing at this pin.
• However, once the processor responds to an INTR signal,
the IF is automatically reset.
• If one wants the processor to further respond to any type
of INTR signal, the IF should again be set.
• The interrupt acknowledge sequence is as shown in
figure.
• Suppose the external signal interrupts the processor and
the pin LOCK bar goes low at the trailing edge of the first
ALE pulse that appears after the interrupt signal
preventing the use of bus for any other purpose.
20
Maskable Interrupt
• The pin LOCK bar remains low till the start of next
machine cycle.
• When trailing the trailing edge of the LOCK bar, the
INTA goes low and remains low for two clock states
before returning back to the high state.
• It remains high till the start of the next machine cycle
i.e. next trailing edge of ALE.
• Then INTA again goes low, remains low for the two
states before returning to the high state.
• The first trailing edge of ALE floats the bus AD0 - to -
AD7, while second trailing edge prepares the bus to
accept the type of interrupt.
• The type of interrupt remains on the bus for a period of
two cycles.
21
Maskable Interrupt
Interrupt acknowledge sequence of 8086
22
Interrupt Programming
23
Interrupt Programming
• While programming for any type of interrupt, the programmer
must, either externally or through the program, set interrupt vector
table for that type preferably with the CS and IP addresses of the
interrupt service routine.
• The method of defining the interrupt service routine for software as
well as hardware is the same.
• To execute the above program,
– first assemble it using MASM.EXE, link it using LINK.EXE.
– Then execute the above program at a DOS prompt.
– After execution, you will find a new file RESULT in the
directory.
– Then apply an external pulse to IRQ2 pin of the IBM PC IO
channel.
– This will again cause the execution of ISR that writes 500 H
bytes into the file.
24
Interrupt Programming
Transfer of control during execution
of an interrupt service routine
25
Interrupt Programming
26