Docsity

Microprocessor Programming - 8086 Interrupts and Interrupt Applications, Study notes of Microprocessors

Partial preview of the text

Download Microprocessor Programming - 8086 Interrupts and Interrupt Applications and more Study notes Microprocessors in PDF only on Docsity!

8086 Interrupts and Interrupt

Applications

Interrupts

• An interrupt is a break in the flow of execution of

program and the CPU is said to be “interrupted”

– Interrupt request : a signal that ask for

immediate attention

  • (^) Interrupt processing : what CPU does in response to

request

  • (^) Interrupt service : what is done in software as a result

• When an interrupt occurs, the CPU deals with

the interruption, then carries on where it left off

Interrupt Handling

  • (^) When an interrupt occurs the CPU finishes executing current instruction and respond to interrupt by stepping following series of major action 1. decrement SP by 2 and pushes flag register onto stack 2. disables the INTR input by clearing the (IF) interrupt flag in the flag register 3. clears the (TF) trap flag in the flag register 4. decrement SP by 2 and pushes the current CS contents onto the stack 5. decrement SP by 2 pushes the current IP contents onto the stack 6. does an indirect far jump to the start of the (ISR) Interrupt Service Routine.

Flow chart of Interrupt Handling Complete Current Instruction Internal Interrupt NMI INTR TF Fetch Next Instruction IF Read Type Code # push Flags Set TEMP=TF IF= TF= push CS and IP call ISR NMI TF=TEMP pop IP and CS popf Resume Interrupted Procedure YES YES YES YES NO NO NO NO 0 1 1 0 acknowledge interrupt

8086 External Interrupt Connections NMI - Non-Maskable Interrupt INTR - Interrupt Request Interrupt Logic int into^ Divide Error Single Step NMI Requesting Device 8086 CPU Intel 8259A PIC NMI INTR Software Traps Programmable Interrupt Controller (part of chipset)

IVT Format Offset Offset Offset Segment Segment Segment Interrupt 0 Interrupt 1 Interrupt 255 0000: 0000: 0000: 0000: 0000: 0000: 0000: 0000: 0000:03fc 0000:03fd 0000:03fe 0000:03ff IP LSB IP MSB CS LSB CS MSB Given a Vector, where is the ISR address stored in memory? OffsetType  4 Example: int 36h Offset = (544) = 216 = 00d8h

Interrupt Vector Assignments Type Function Comment 0 Divide Error^ Processor - zero or overflow 1 Single Step (DEBUG)^ Processor - TF= 2 Non-maskable Interrupt Pin^ Processor - NMI Signal 3 Breakpoint^ Processor - Similar to Sing Step 4 Arithmetic Overflow^ Processor - into 5 Print Screen Key^ BIOS - Key Depressed 6 Invalid Opcode^ Processor - Invalid Opcode 7 Coprocessor Not Present^ Processor - no FPU 8 Time Signal^ BIOS - From RT Chip (AT - IRQ0) 9 Keyboard Service^ BIOS - Gen Service (AT - IRQ1) A - F Originally Bus OPS(IBM PC)^ BIOS - (AT - IRQ2-7)

Interrupt Vector Assignments Type Function Comment 10 Video Service Request BIOS - Accesses Video Driver 11 Equipment Check BIOS - Diagnostic 12 Memory Size BIOS - DOS Memory 13 Disk Service Request BIOS - Accesses Disk Driver 14 Serial Port Service Request BIOS - Accesses Serial Port Drvr 15 Miscellaneous BIOS - Cassette, etc. 16 Keyboard Service Request BIOS - Accesses KB Driver 17 Parallel Port LPT Service BIOS - Printer Driver 18 ROM BASIC BIOS - BASIC Interpreter in ROM

Initialization List

• Initialize the interrupt-vector table

  • (^) use the ES register
  • (^) the starting address of our type 0 ISR needs to be in locations 00000H and 00002H

• Set up the data segment

  • (^) include a declaration for the BAD_DIV_FLAG
  • (^) Initialize DS

• Set up a stack

  • (^) Initialize SS and SP

Single-Step Interrupt - Type 1

• If the TF (trap flag) is set, a type 1 interrupt

will automatically occur

• To implement single-stepping, such as in a

debugger:

  • (^) set the trap flag
  • (^) write an ISR that saves all registers on the stack, so they can be examined
  • (^) load the address of the ISR into the addresses 00004H and 00006H

Breakpoint Interrupt -Type 3

  • (^) This type of interrupt is produced by executing an INT 3 instruction - (^) no automatic triggers
  • (^) Useful for debugging
    • (^) many debuggers implement breakpoints by inserting an INT 3 instruction before the specified instruction
    • (^) the Type 3 ISR may then store all the registers so that they can be examined by the user

Overflow Interrupt - Type 4

• This type of interrupt may be produced if the

OF (Overflow flag) is set… but not

automatically triggered

• OF will be set if the signed result of an

arithmetic operation on 2 signed numbers is

too large to be represented in the destination

  • (^) 01101100 (108 decimal) + 01010001 (81 decimal), remember that these are signed!