10
Set 20 Interrupts

Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks

Embed Size (px)

Citation preview

Page 1: Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks

Set 20Interrupts

Page 2: Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks

INTERRUPTS

The Pentium has a mechanism whereby external devices can interrupt it.

Devices such as the keyboard, the monitor, hard disks etc. can cause such interrupts, when they require service of some kind, such as to get or receive a byte.

For example, when you press a key on the keyboard this causes an interrupt.

  

2

Page 3: Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks

WHAT HAPPENS WHEN AN INTERRUPT OCCURS

When the pentium is interrupted, it completes the current instruction, then pushes onto the stack the flags register plus the address of the next instruction (the return address).

It then carries out the procedure that services the interrupt involved.

Then it uses a special return instruction iret which pops the flags register from the stack, and pops and uses the return address to resume doing whatever it was doing before the interrupt occurred.

  

3

Page 4: Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks

EXAMPLES OF INTERRUPT ROUTINES

When you press a key on the keyboard, the interrupt routine that the Pentium carries out is to input the key and store it in a buffer in memory.

Another example is provided by a separate timer chip which interrupts the Pentium typically every 10 milliseconds. This interrupt is called a timer tick. Here the Pentium’s interrupt routine updates it’s time of day (it actually stores the number of timer ticks since midnight).

  

4

Page 5: Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks

HOW DOES THE PENTIUM KNOW WHAT CAUSED THE INTERRUPT?

 

 

5

PENTIUM INTERRUPT CONTROLLER

from the timer chip

from the keyboard

from the monitordata bus

interrupt requested

interrupt acknowledged

identification of the interrupt

1

2

3

4

Page 6: Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks

1. The device signals its request, for an interrupt service, to the interrupt controller.

2. The interrupt controller sends a signal to the Pentium requesting an interrupt.

3. The Pentium is hard-wired to respond by finishing its current instruction, pushing the flags register, and the address of the next instruction (the return address) onto the stack, and then sending an acknowledgment signal back to the interrupt controller.

4. The interrupt controller then puts onto the data bus a code that identifies which which of its input lines (and hence which device) is requesting this interrupt.

  

6

Page 7: Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks

HOW THE PENTIUM FINDS THE CORRECT INTERRUPT ROUTINE

• All Pentiums maintain an area of memory at the same fixed location called a jump table.

• This consists of a sequence of 4 byte entries, where each entry consists of an (offset value, segment register value).

• These entries (called interrupt vectors) specify the locations of the various interrupt routines.

• The code that the interrupt routine sends the Pentium, to identify the kind of interrupt, is used to index this jump table and so locate the appropriate interrupt routine.

  

7

Page 8: Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks

NOTES

• From the instant the device signals its request for an interrupt routine, up to when the Pentium starts executing the routine required, everything described on the proceeding slides takes place automatically entirely by wired-in hardware.

• The jump table makes it simple for new versions of the interrupt routines to be written and placed at different locations in memory when new versions of the operating system are produced. All that needs to be changed is the corresponding entries in the jump table.

  

8

Page 9: Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks

INTERRUPT VECTOR NUMBERS

• The 4 byte entries (interrupt vectors) in the jump table are numbered.

• For example interrupt vector 9 is for the keyboard, and interrupt vector 3Ch is for the timer tick.

  

9

Page 10: Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks

RETRIEVING & CHANGING INTERRUPT VECTORS

The code to retrieve an interrupt vector (so you can store & later restore it) is of the form:

MOV AL,… ; the interrupt vector no., e.g. 9 for the keyboard MOV AH, 35h INT 21h

This puts the offset value part of the interrupt vector into BX, and thesegment register part into ES

The code to change an interrupt vector is of the form: MOV AL,… ; the interrupt vector no.

LEA DX,… ; the offset of the new interrupt routine ; DS should contain the segment value concerned

MOV AH, 25H INT 21H

  

10