# BIOS Interrupt Vector Table (IVT) ## Overview The BIOS Interrupt Vector Table (IVT) is a crucial data structure in real mode that maps interrupt numbers to their handler routines. It is located at the very beginning of memory, starting at physical address 0x0000:0x0000. ## Structure - The IVT contains 256 entries (0x00 to 0xFF) - Each entry is 4 bytes long: - 2 bytes for the offset - 2 bytes for the segment - Total size: 256 * 4 = 1024 bytes (0x400) ``` Memory Layout: 0x0000:0x0000 - Int 0x00 vector (Divide by zero) 0x0000:0x0004 - Int 0x01 vector (Single step) 0x0000:0x0008 - Int 0x02 vector (NMI) ... 0x0000:0x0040 - Int 0x10 vector (Video services) ... 0x0000:0x03FC - Int 0xFF vector (Last vector) ``` ## Common BIOS Interrupts - **Int 0x10**: Video Services - AH=0x00: Set video mode - AH=0x0E: Write character in TTY mode - AH=0x13: Write string - **Int 0x13**: Disk Services - AH=0x00: Reset disk system - AH=0x02: Read sectors - AH=0x03: Write sectors - AH=0x41: Check extensions present - AH=0x42: Extended read sectors - AH=0x43: Extended write sectors - **Int 0x16**: Keyboard Services - AH=0x00: Read keystroke - AH=0x01: Check for keystroke ## How It Works 1. When an interrupt occurs (via hardware or `int` instruction): - CPU pushes FLAGS, CS, and IP onto stack - CPU disables further interrupts - CPU looks up handler address in IVT - CPU jumps to handler address 2. Example of int 0x10 call: ```nasm mov ah, 0x0E ; TTY output function mov al, 'A' ; Character to print int 0x10 ; Call BIOS video interrupt ``` 3. The BIOS handler: - Receives control - Reads parameters from registers - Performs requested operation - Returns via IRET instruction ## Important Notes 1. BIOS interrupts are only available in real mode 2. When transitioning to protected mode: - BIOS interrupts become unavailable - Must set up new Interrupt Descriptor Table (IDT) - Must provide own interrupt handlers 3. Some BIOS operations require interrupts to be enabled: - Disk I/O (int 0x13) - Keyboard input (int 0x16) - Some video operations (int 0x10) 4. Memory Map Considerations: - IVT: 0x0000 - 0x03FF - BIOS Data Area: 0x0400 - 0x04FF - Your code should not overwrite these areas