forked from Isuruni/MYOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterrupt_handler.s
49 lines (41 loc) · 1.16 KB
/
interrupt_handler.s
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
;Generic Interrupt Handler
;
extern interrupt_handler
%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 ebp
push esi
push edi
; call the C function
call interrupt_handler
; restore the registers
pop edi
pop esi
pop ebp
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 33 ; create handler for interrupt 1 (keyboard)
no_error_code_interrupt_handler 14 ; create handler for interrupt 2 (paging)