BIOS and DOS Interrupts Basic Input Outpu System
BIOS and DOS Interrupts Basic Input /Outpu System Disk Operating System
Computer Interrupt request: a signal that immediate attention is needed Interrupt processing: what CPU does in response to request Interrupt service: what is done in software as a result
Computer Interrupt 2 General Types of Interrupts: External - generated outside CPU by other hardware Internal - generated within CPU as a result of instruction or operation - x 86 internals: int, into, divide error, and single step - “trap” generally means any processor generated interrupt; in x 86, usually means the single step interrupt • • x 86 Terminology for Interrupts: 1) Hardware Interrupt – External, uses INTR and NMI control bus lines 2) Software Interrupt – Internal, from int or into 3) Processor Interrupt – traps, exceptions
8086/8088 Pinout Diagrams GND AD 14 AD 13 AD 12 AD 11 AD 10 AD 9 AD 8 AD 7 AD 6 AD 5 AD 4 AD 3 AD 2 AD 1 AD 0 NMI INTR CLK GND 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 8086 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 VCC AD 15 A 16/S 3 A 17/S 4 A 18/S 5 A 19/S 6 BHE/S 7 MN/MX RD HOLD HLDA WR M/IO DT/R DEN ALE INTA TEST READY RESET GND A 14 A 13 A 12 A 11 A 10 A 9 A 8 AD 7 AD 6 AD 5 AD 4 AD 3 AD 2 AD 1 AD 0 NMI INTR CLK GND 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 8088 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 VCC A 15 A 16/S 3 A 17/S 4 A 18/S 5 A 19/S 6 SS 0 MN/MX RD HOLD HLDA WR IO/M DT/R DEN ALE INTA TEST READY RESET
8086 External Interrupt Connections NMI - Non-Maskable Interrupt INTR - Interrupt Request Programmable Interrupt Controller (part of chipset) NMI Requesting Device NMI 8086 CPU INTR Interrupt Logic Intel 8259 A PIC into Software Divide Error Single Step Traps
Interrupt Vector Table – IVT (in memory) • x 86 has 256 interrupts, specified by Type Number or Vector • 1 byte of data must accompany each interrupt; specifies Type • Vector is a pointer (address) into Interrupt Vector Table, IVT – IVT is stored in memory from 0000: 0000 to 0000: 03 ffh • IVT contains 256 far pointer values (addresses) – Far pointer is CS: IP values • Each far pointer is address of Interrupt Service Routine, ISR – Also referred to as Interrupt Handler When interrupt is requested, which IVT entry? Type!
IVT Format 0000: 0001 0000: 0002 0000: 0003 0000: 0004 0000: 0005 0000: 0006 0000: 0007 Offset Interrupt 0 IP LSB Segment IP MSB CS LSB Offset CS MSB Interrupt 1 Segment Given a Vector, where is the ISR address stored in memory ? 0000: 03 fc 0000: 03 fd 0000: 03 fe 0000: 03 ff Offset Example: int 36 h Interrupt 255 Segment Offset = (54 4) = 216 = 00 d 8 h
What Happens During an Interrupt ? push Flags Complete Current Instruction Set TEMP=TF TF=TEMP IF=0 TF=0 pop IP and CS push CS and IP popf acknowledge interrupt call ISR Resume Interrupted Procedure Read Type Code # NMI YES Internal Interrupt NO YES NMI NO INTR YES 1 0 NO TF IF 1 0 Fetch Next Instruction NO YES
Similarity to Subroutine Procedure call int ret iret • call pushes CS, IP and loads CS: IP with address of • int does what call does and more • ret pops IP, CS • iret pops FLAGS, IP, and CS subroutine This is why ALL programs MUST have a stack segment, so that interrupts can be handled
halt Instruction • This instruction causes processor to enter a HALT state • HALT state is one where no further instructions are fetched nor executed until one of the following events occurs: 1) System is reset - rising edge on RESET pin 2) External interrupt occurs CPU Asset FLAGS Register IP CS DS SS ES Instruction Queue Content 0000 h ffffh 0000 h Empty
Interrupt Vector Assignments
Interrupt Vector Assignments (cont. )
AT – IRQ Definitions IBM-AT (Advanced Technology) - Intel 80286
Interrupt Service Routines • ALL Interrupts • Interrupts for Inpu • Interrupts for Output
Interrupts for Inpu • INT 16 h / AH = 00 h - get keystroke from keyboard (no echo) • INT 16 h / AH = 01 h - check for keystroke in the keyboard buffer • INT 21 h / AH=1 - read character from standard input, with echo • INT 21 h / AH=6 - direct console input or output • INT 21 h / AH=7 - character input without echo to AL • INT 21 h / AH=0 Ah - input of a string • INT 21 h / AH=0 Bh - get input status
Interrupts for Output • INT 21 h / AH=2 - write character to standard output • INT 21 h / AH=9 - output of a string
HW#1 • Develop an assembly program that receives a decimal number (up to max 100 digits) from user and displays its hexadecimal equivallent. • Due Date: Sunday Esfand 23 rd • Mail to: Mr Kazari and me (vahdat@sharif. edu or vosoughivahdat@yahoo. com) • Subject: HW 1 UPI 2010 IDxxxx
- Slides: 17