global isr0 ; division by zero global isr1 ; debug exception global isr2 ; Non-maskable interrupt global isr3 ; Breakpoint exception global isr4 ; Into detected overflow exception global isr5 ; Out of bounds exception global isr6 ; Invalid opcode exception global isr7 ; No co-processor exception global isr8 ; Double fault exception global isr9 ; Co-processor segment overrun exception global isr10 ; Bad TSS exception global isr11 ; Segment not present global isr12 ; Stack fault exception global isr13 ; General protection fault global isr14 ; Page fault exception global isr15 ; Unkown interrupt exception global isr16 ; Co-processor fault exception global isr17 ; Alignment check exception global isr18 ; Machine check exception global isr19 ; Reserved global isr20 global isr21 global isr22 global isr23 global isr24 global isr25 global isr26 global isr27 global isr28 global isr29 global isr30 global isr31 ; reserved isr0: ; division by zero cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 0 ; Push the interrupt number to the stack jmp isr_common_stub isr1: ; debug exception cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 1 ; Push the interrupt number to the stack jmp isr_common_stub isr2: ; Non-maskable interrupt cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 2 ; Push the interrupt number to the stack jmp isr_common_stub isr3: ; Breakpoint exception cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 3 ; Push the interrupt number to the stack jmp isr_common_stub isr4: ; Into detected overflow exception cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 4 ; Push the interrupt number to the stack jmp isr_common_stub isr5: ; Out of bounds exception cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 5 ; Push the interrupt number to the stack jmp isr_common_stub isr6: ; Invalid opcode exception cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 6 ; Push the interrupt number to the stack jmp isr_common_stub isr7: ; No co-processor exception cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 7 ; Push the interrupt number to the stack jmp isr_common_stub isr8: ; Double fault exception cli ; This interrupt pushes an error code, so we only need to push its number. push byte 8 ; Push the interrupt number to the stack jmp isr_common_stub isr9: ; Co-processor segment overrun exception cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 9 ; Push the interrupt number to the stack jmp isr_common_stub isr10: ; Bad TSS exception cli ; This interrupt pushes an error code, so we only need to push its number. push byte 10 ; Push the interrupt number to the stack jmp isr_common_stub isr11: ; Segment not present cli ; This interrupt pushes an error code, so we only need to push its number. push byte 11 ; Push the interrupt number to the stack jmp isr_common_stub isr12: ; Stack fault exception cli ; This interrupt pushes an error code, so we only need to push its number. push byte 12 ; Push the interrupt number to the stack jmp isr_common_stub isr13: ; General protection fault cli ; This interrupt pushes an error code, so we only need to push its number. push byte 13 ; Push the interrupt number to the stack jmp isr_common_stub isr14: ; Page fault exception cli ; This interrupt pushes an error code, so we only need to push its number. push byte 14 ; Push the interrupt number to the stack jmp isr_common_stub isr15: ; Unkown interrupt exception cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 15 ; Push the interrupt number to the stack jmp isr_common_stub isr16: ; Co-processor fault exception cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 16 ; Push the interrupt number to the stack jmp isr_common_stub isr17: ; Alignment check exception cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 17 ; Push the interrupt number to the stack jmp isr_common_stub isr18: ; Machine check exception cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 18 ; Push the interrupt number to the stack jmp isr_common_stub isr19: ; Reserved cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 19 ; Push the interrupt number to the stack jmp isr_common_stub isr20: cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 20 ; Push the interrupt number to the stack jmp isr_common_stub isr21: cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 21 ; Push the interrupt number to the stack jmp isr_common_stub isr22: cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 22 ; Push the interrupt number to the stack jmp isr_common_stub isr23: cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 23 ; Push the interrupt number to the stack jmp isr_common_stub isr24: cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 24 ; Push the interrupt number to the stack jmp isr_common_stub isr25: cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 25 ; Push the interrupt number to the stack jmp isr_common_stub isr26: cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 26 ; Push the interrupt number to the stack jmp isr_common_stub isr27: cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 27 ; Push the interrupt number to the stack jmp isr_common_stub isr28: cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 28 ; Push the interrupt number to the stack jmp isr_common_stub isr29: cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 29 ; Push the interrupt number to the stack jmp isr_common_stub isr30: cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 30 ; Push the interrupt number to the stack jmp isr_common_stub isr31: ; reserved cli push byte 0 ; This doesn't produce an error code, so push a dummy code ; to the stack. This keeps the stack uniform when calling the common interrupt stub. push byte 31 ; Push the interrupt number to the stack jmp isr_common_stub extern interrupt_handler isr_common_stub: pusha ; Registers are pushed in this order: AX, CX, DX, BX, SP, BP, SI, DI push ds push es push fs push gs mov ax, 0x10 ; Load the Kernel Data Segment descriptor mov ds, ax mov es, ax mov fs, ax mov gs, ax mov eax, esp ; Push the stack pointer push eax mov eax, interrupt_handler call eax ; A special call, preserves the 'eip' register pop eax pop gs pop fs pop es pop ds popa add esp, 8 ; Cleans up the pushed error code and pushed ISR number iret ; pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP!