-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterrupt_handler.s
More file actions
56 lines (47 loc) · 1.67 KB
/
interrupt_handler.s
File metadata and controls
56 lines (47 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
; Generic Interrupt Handler
extern interrupt_handler ; The C function
%macro no_error_code_interrupt_handler 1
global interrupt_handler_%1
interrupt_handler_%1:
push dword 0 ; push 0 as error code
push dword %1 ; push the interrupt number
jmp common_interrupt_handler ; jump to the common handler
%endmacro
%macro error_code_interrupt_handler 1
global interrupt_handler_%1
interrupt_handler_%1:
push dword %1 ; push the interrupt number
jmp common_interrupt_handler ; jump to the common handler
%endmacro
common_interrupt_handler: ; the common parts of the generic interrupt handler
; save the registers
push eax
push ebx
push ecx
push edx
push esp
push ebp
push esi
push edi
; call the C function
call interrupt_handler
; restore the registers
pop edi
pop esi
pop ebp
pop esp
pop edx
pop ecx
pop ebx
pop eax
; restore the esp
add esp, 8
; return to the code that got interrupted
iret
no_error_code_interrupt_handler 0 ; DIVISION BY 0
no_error_code_interrupt_handler 1 ; DEBUGGER SINGLE STEP
; etc
error_code_interrupt_handler 7 ; PROCESSOR EXTENSION NOT AVAILABLE
no_error_code_interrupt_handler 9 ; PROCESSOR EXTENSION PROTECTION ERROR
no_error_code_interrupt_handler 16 ; GET KEYSTROKE
no_error_code_interrupt_handler 1Ch ; SYSTEM TIMER TICK