Open main menu

Wikibooks β

X86 Assembly/X86 Interrupts

< X86 Assembly

Interrupts are special routines that are defined on a per-system basis. This means that the interrupts on one system might be different from the interrupts on another system. Therefore, it is usually a bad idea to rely heavily on interrupts when you are writing code that needs to be portable.


What is an Interrupt?Edit

In modern operating systems, the programmer often doesn't need to use interrupts. In Windows, for example, the programmer conducts business with the Win32 API. However, these API calls interface with the kernel, and the kernel will often trigger interrupts to perform different tasks. In older operating systems (specifically DOS), the programmer didn't have an API to use, and so they had to do all their work through interrupts.

Interrupt InstructionEdit

int arg

This instruction issues the specified interrupt. For instance:

int 0x0A

Calls interrupt 10 (0x0A (hex) = 10 (decimal)).

Types of InterruptsEdit

There are 3 typeare devices. For instance, when you type on your keyboard, the keyboard triggers a hardware interrupt. The processor stops what it is doing, and executes the code that handles keyboard input (typically reading the key you pressed into a buffer in memory). Hardware Exceptions are caused by exceptional r There are also a series of conditions in the code which is executing, for example an attempt to divide by zero or access a protected memory area. The processor will detect this prs === Hasoftware interrupts that are usually used to transfer control to a function in the operating system kernel. Software interrupts are triggered by the instruction int. For example, the instruction "int 14h" triggers interrupt 0x14. The processor then stops the current program, and jumps to the code to handle interrupt 14. When interrupt handling is complete, the processor returns flow to the original program.

Exceptions ===dwdware InterruptsEdit

Hardware intred by harinterrupts are typically asyncherrupts are triggeronous - their occurrence iinstructions being executed at the time they are raised.

=== Software Interrupts ===oblro dividend), or if this cannot be done,s unrelated to the the program causing the exception may be terminated. em, and transfer control to a handler to service the exception. This handler may re-execute the offending code after changing some value (for example, the ze

Further ReadingEdit

A great list of interrupts for DOS and related systems is at Ralf Brown's Interrupt List.