150 likes | 421 Views
THE SYSTEM OF INTERRUPTS Definitions Questions (??) Classification of interrupts The Interrupt Vector Table (IVT) The steps to execute a ISR The interrupt controller 8259 The sequence for “Interrupt Acknowledge” Applications of software interrupts. 1) Definitions.
E N D
THE SYSTEM OF INTERRUPTS • Definitions • Questions (??) • Classification of interrupts • The Interrupt Vector Table (IVT) • The steps to execute a ISR • The interrupt controller 8259 • The sequence for “Interrupt Acknowledge” • Applications of software interrupts
1) Definitions • Need of communication between the uP and the peripheral devices • Idea: to interrupt the execution of the current program • Def: Interrupts + Interrupt Service Routine uP Peripheral devices
2) Questions • Who can interrupt the uP? (possibilities) • Hardware • Software Classification of interrupts 2) What happens when an interrupt is accepted? 3) How the processor finds the address of ISR? 4) Then, which is the difference between a PROC and ISR? • Address (ISR), address (PROC) • End: ISR (iret), PROC (ret)
3) Classification of interrupts • Internal interrupts / exceptions • Hardware interrupts (from peripheral devices data transfer; signals are used) • INTR – maskable interrupts • I=1 (STI) • I=0 (CLI) • NMI – non-maskable interrupts • NMI • When accepted? - At the end of an instruction cycle ! • How are the peripheral devices recognised? By a type number which is used by the processor as a pointer in the IVT to obtain the address of the ISR
Classification (cont) c) Software interrupts INT k; k=0...255 (type of interrupt) Examples: INT 10h (video services) INT 14h (communication on serial interface)
4) The Interrupt Vector Table (IVT) • Implements a mechanism that associates for a specific interrupt request a service (handler or ISR). It stores the addresses of ISRs • 256 types of interrupt requests • What we need to obtain an address for ISR • CS & IP • Many ISRs : k=0 ... 255 (type of interrupts) • The structure of IVT • Location • Structuring (IP, CS), 256 entries • The input in the table is the “key k” (interrupt type) • Who delivers the key to the uP? (example of values)
5) The steps to execute a ISR • Peripheral device interrupt controller (it associate a key K to the device); K-progr • I=1?- uP accepts the interrupt INTA and asks for the key. The key is transmited to the uP. • The uP uses the key K to find out the address of the ISR (associates an ISR to the peripheral devices) • uP execute the ISR and then returns to the main program
Inputs on 8259 Explain: IRQi signals + connection of 2 controllers 8259 in the system
7) The sequence for “Interrupt Acknowledge” = a hardware mechanism to send the “key K” from the interrupt controller 8259 to the uP • The diagram of signals (if INTR and I=1) • Save on the stack: PSW, CS, IP, I=0, T=0 • It follows the sequence of INTA • 2 machine cycles • ALE • LOCK • INTA (1st activation, 2nd activation) Key K 3) Point into IVT at address k*4 to get the address of ISR 4) Jump to ISR and execute it 5) IRET – returns in the main program
8) Applications of software interrupts VIDEO SERVICES (INT 10h) – BIOS level AH =2 (setting the cursor to a specific location) In: DH = raw, DL=column Exercise: position in the centre of the screen AH=3 (get current cursor position) Returns in DH=raw, DL=column, CX=the shape of the cursor Exercise: Move Relative Nx, Ny AH=6 (scroll up) In: AL=no of lines for scroll (AL=0, CLS), BH=attribute of blank raws CH=upper raw, CL=left column, DH=lower raw, DL=right column Example: Clear Screen AH= 9 (display a character from AL) AL, BH=video page, BL=atrribute, CX-rep Example: Display a string defined in DS, starting in raw 3 column 5 AH=0Eh (display char with increment of cursor)
8) Applications of software interrupts KEYBOARD SERVICES (INT 16h) – BIOS level AH =1 (test if keypressed) Return Z=0 if Keypressed, Z=1 if not Keypressed AH=0 (read the character) Returns in AH the scane code and in AL the ASCII code of the Key. Exercise: Read a string and display it, until ESC is pressed
INT 21h (cont) Documentation: INT 1Ah, INT 14h, INT 17h, INT 13h