Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 17

BIOS and DOS Interrupts

Basic Input /Outpu System Disk Operating System

Computer Interrupt 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
- x86 internals: int, into, divide error, and single step - trap generally means any processor generated interrupt; in x86, usually means the single step interrupt

x86 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 AD14 AD13 AD12 AD11 AD10 AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 AD1 AD0 NMI INTR CLK GND 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 VCC AD15 A16/S3 A17/S4 A18/S5 A19/S6 BHE/S7 MN/MX RD HOLD HLDA WR M/IO DT/R DEN ALE INTA TEST READY RESET GND A14 A13 A12 A11 A10 A9 A8 AD7 AD6 AD5 AD4 AD3 AD2 AD1 AD0 NMI INTR CLK GND 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 VCC A15 A16/S3 A17/S4 A18/S5 A19/S6 SS0 MN/MX RD HOLD HLDA WR IO/M DT/R DEN ALE INTA TEST READY RESET

8086

8088

8086 Pin 31 30 29 28 27 26 25 24 Minimum HOLD HLDA WR M/IO DT/R DEN ALE INTA Mode Maximum RQ/GT0 RQ/GT1 LOCK S2 S1 S0 QS0 QS1 Pin 31 30 29 28 27 26 25 24 34

8088 Mode Minimum HOLD HLDA WR IO/M DT/R DEN ALE INTA SS0 Maximum RQ/GT0 RQ/GT1 LOCK S2 S1 S0 QS0 QS1 High State

8086 External Interrupt Connections


NMI - Non-Maskable Interrupt INTR - Interrupt Request

NMI Requesting Device

Programmable Interrupt Controller (part of chipset)

NMI

8086 CPU
INTR

Intel 8259A PIC

Interrupt Logic

int

into

Divide Error

Single Step

Software

Traps

Interrupt Vector Table IVT (in memory)


x86 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:03ffh

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:0000 0000:0001 0000:0002 0000:0003 0000:0004 0000:0005 0000:0006 0000:0007

Offset Interrupt 0 Segment Offset Segment Given a Vector, where is the ISR address stored in memory ?
IP LSB IP MSB CS LSB

Interrupt 1

CS MSB

Offset = Type 4
0000:03fc 0000:03fd 0000:03fe 0000:03ff

Offset Interrupt 255 Segment

Example:

int 36h

Offset = (54 4) = 216 = 00d8h

What Happens During an Interrupt ?


Complete Current Instruction
YES

push Flags

Internal Interrupt
NO

Set TEMP=TF

TF=TEMP

YES

NMI
NO

IF=0 TF=0

pop IP and CS

INTR
NO

YES

IF
0

push CS and IP

popf

TF
0

acknowled ge interrupt Read Type Code #

call ISR

Resume Interrupted Procedure

Fetch Next Instruction

NMI
NO

YES

Similarity to Subroutine Procedure


call int ret iret
subroutine 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

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 one of the following events occurs: nor executed until

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 0000h 0000h ffffh 0000h 0000h 0000h Empty

Interrupt Vector Assignments


Type 0 1 2 3 4 5 6 7 8 9 A-F 10 11 12 13 14 15 16 Function Divide Error Single Step (DEBUG) Nonmaskable Interrupt Pin Breakpoint Arithmetic Overflow Print Screen Key Invalid Opcode Coprocessor Not Present Time Signal Keyboard Service Originally Bus Ops (IBM PC) Video Service Request Equipment Check Memory Size Disk Service Request Serial Port Service Request Miscellaneous Keyboard Service Request Comment Processor - zero or overflow Processor - TF=1 Processor - NMI Signal Processor - Similar to Sing Step Processor - into BIOS - Key Depressed Processor - Invalid Opcode Processor - no FPU BIOS - From RT Chip (AT - IRQ0) BIOS - Gen Service (AT - IRQ1) BIOS - (AT - IRQ2-7) BIOS - Accesses Video Driver BIOS - Diagnostic BIOS - DOS Memory BIOS - Accesses Disk Driver BIOS - Accesses Serial Port Drvr BIOS - Cassette, etc. BIOS - Accesses KB Driver

Interrupt Vector Assignments (cont.)


Type 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 2F 70-77 Function Parallel Port LPT Service ROM BASIC Reboot Clock Service Control-Break Handler User Timer Service Pointer to Video Parm Table Pointer to Disk Parm Table Pointer to Graphics Fonts Program Terminate Function Call Terminate Address Control-C Handler Fatal Error Handler Absolute Disk Read Absolute Disk Write Terminate Idle Signal Print Spool Hardware Interrupts in AT Bios Comment BIOS - Printer Driver BIOS - BASIC Interpreter in ROM BIOS - Bootstrap BIOS - Time of Day from BIOS BIOS - Keyboard Break BIOS - Timer Tick BIOS - Video Initialization BIOS - Disk Subsystem Init. BIOS - CGA Graphics Fonts DOS - Clear Memory, etc. DOS - Transfer Control DOS - program Terminate handler DOS - For OS Use DOS - Critical Error DOS - Disk Read DOS - Disk Write DOS - TSR Usage DOS - Idle DOS - Cassette, etc. DOS - (AT - IRQs 8-15)

AT IRQ Definitions
IBM-AT (Advanced Technology) - Intel 80286
Name NMI IRQ0 IRQ1 IRQ2 IRQ3 IRQ4 IRQ5 IRQ6 IRQ7 IRQ8 IRQ9 IRQ10 IRQ11 IRQ12 IRQ13 IRQ14 IRQ15 Interrupt Vector 02 08 09 0A 0B 0C 0D 0E 0F 70 71 72 73 74 75 76 77 Priority 1 2 3 4 13 14 15 16 17 5 6 7 8 9 10 11 12 Description Memory Parity Error Timer (Intel 8253 Chip 55 ms intervals) Keyboard 8259 PIC Slave or EGA/VGA Vert. Retrace Serial Port (COM2 or COM4) Serial Port (COM1 or COM3) Fixed Disk or LPT2 Request Floppy Disk Driver LPT1 Request CMOS Real-Time Clock (RT Chip) Re-directed to IRQ2 RESERVED RESERVED Mouse or other Math Coprocessor (NPX) Hard Disk RESERVED

Interrupt Service Routines


ALL Interrupts Interrupts for Inpu Interrupts for Output

Interrupts for Inpu


INT 16h / AH = 00h - get keystroke from keyboard (no echo) INT 16h / AH = 01h - check for keystroke in the keyboard buffer INT 21h / AH=1 - read character from standard input, with echo INT 21h / AH=6 - direct console input or output INT 21h / AH=7 - character input without echo to AL INT 21h / AH=0Ah - input of a string INT 21h / AH=0Bh - get input status

Interrupts for Output


INT 21h / AH=2 - write character to standard output INT 21h / 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 23rd Mail to: Mr Kazari and me (vahdat@sharif.edu or vosoughivahdat@yahoo.com) Subject: HW1 UPI2010 IDxxxxxxxx

You might also like