0% found this document useful (0 votes)
16 views3 pages

8 Interrupts

The document provides an overview of interrupts, including definitions of interrupts, Interrupt Service Routines (ISRs), and the interrupt vector table. It details common x86 software interrupts, their functions, and the operations of interrupt flags, as well as the interrupt handling process. Additionally, it includes examples of using INT 21h for DOS services and common assembly instructions related to interrupts.

Uploaded by

Sarah Sheikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

8 Interrupts

The document provides an overview of interrupts, including definitions of interrupts, Interrupt Service Routines (ISRs), and the interrupt vector table. It details common x86 software interrupts, their functions, and the operations of interrupt flags, as well as the interrupt handling process. Additionally, it includes examples of using INT 21h for DOS services and common assembly instructions related to interrupts.

Uploaded by

Sarah Sheikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

8.

Interrupts
●​ Interrupt: A mechanism to handle events (e.g., hardware signals or software
requests).
●​ Interrupt Service Routine (ISR): A special function or block of code executed when
an interrupt occurs.
●​ Interrupt Vector: A table holding addresses of ISRs, where each interrupt has a
unique index.

Common x86 Software Interrupts (INT Instructions)


Interrupt Function Purpose

INT 21h DOS Interrupt System services (file operations, input/output, etc.)

INT 10h Video Services For video control (e.g., changing modes, writing text)

INT 13h Disk Services For accessing disk drives (e.g., read/write sectors)

INT 16h Keyboard For handling keyboard input


Services

INT 1Ah Time/Date For accessing system time and date

Interrupt Flag Operations


Instruction Effect Description

STI Set Interrupt Flag Enables interrupts globally.

CLI Clear Interrupt Disables interrupts globally.


Flag

HLT Halt the CPU Stops the CPU until reset or power off.

IRET Interrupt Return Returns from an interrupt by restoring the previous


state.

Common Interrupt Numbers for DOS Services (INT 21h)

Function AH Register Service Description

Print String 09h Display string at DX. Ends with $


Read Character 01h Reads a single character from standard input

Read String 0Ah Reads a string from input (buffer starts at DX)

Print Character 02h Prints a single character in DL

Exit Program 4Ch Exit to operating system (return code in AL)

Move/Copy File 3Ch Open a file for read/write

Set Video Mode 00h Set video mode (requires AL for mode
number)

Hardware Interrupts (IRQ)

Hardware interrupts are often associated with devices and are mapped into the interrupt
vector table at specific locations.

IRQ Interrupt Description

IRQ 0 Timer Interrupt Generated by the system timer (every 18.2 ms)

IRQ 1 Keyboard Generated when a key is pressed on the


keyboard

IRQ 2 Cascade (used by IRQ Cascade signal for IRQs 8-15


8-15)

IRQ 3 COM2/COM4 Used by serial ports (COM2 and COM4)

IRQ 4 COM1/COM3 Used by serial ports (COM1 and COM3)

IRQ 8 Real-Time Clock (RTC) Generated by the system clock

IRQ Math Coprocessor (FPU) Used by the floating-point unit (FPU)


13

Interrupt Handling Process

1.​ Interrupt Occurs: Hardware or software triggers an interrupt.


2.​ Save State: CPU saves current program state (e.g., registers, flags).
3.​ Jump to ISR: CPU jumps to the interrupt vector (ISR address).
4.​ Execute ISR: The ISR handles the interrupt (e.g., reading from a device).
5.​ Restore State: The CPU restores the saved state using IRET (or equivalent).
6.​ Resume Execution: CPU continues execution of the program.
Common x86 Assembly Instructions for Interrupts

●​ INT n: Trigger a software interrupt where n is the interrupt number.


●​ IN AL, port: Read byte from I/O port to AL register.
●​ OUT port, AL: Write byte from AL register to I/O port.
●​ IRET: Return from interrupt by restoring flags and registers.

Example Usage of INT 21h


asm
CopyEdit
MOV AH, 09h ; DOS Function to print string
MOV DX, OFFSET msg ; Address of the string in DX
INT 21h ; Call DOS Interrupt (prints string)

MOV AH, 4Ch ; DOS Function to exit


INT 21h ; Exit the program

In this example:

●​ INT 21h is called to display a string and exit the program.

You might also like