LumaOS  v0.1.116
An experimental x86-64 OS
Loading...
Searching...
No Matches
isr.asm
1;;
2; @file isr.asm
3; @brief Handler for the idt (the isr). Gets data ready for and calls the C exception handler
4;
5; @author Matheus Boscariol
6; @since 18/11/2026
7; @copyright (c) 2026 Matheus Boscariol. Licensed under GNU AGPL-3.0.
8;;
9
10bits 64
12
13%macro ISR_NOERR 1
14global isr%1
15isr%1:
16 push qword 0 ; dummy error code, so every frame looks the same
17 push qword %1 ; vector number
18 jmp isr_common
19%endmacro
20
21%macro ISR_ERR 1
22global isr%1
23isr%1:
24 push qword %1 ; the CPU already pushed the error code
25 jmp isr_common
26%endmacro
27
28section .text
29
30ISR_NOERR 0
31ISR_NOERR 1
32ISR_NOERR 2
33ISR_NOERR 3
34ISR_NOERR 4
35ISR_NOERR 5
36ISR_NOERR 6
37ISR_NOERR 7
38ISR_ERR 8
39ISR_NOERR 9
40ISR_ERR 10
41ISR_ERR 11
42ISR_ERR 12
43ISR_ERR 13
44ISR_ERR 14
45ISR_NOERR 15
46ISR_NOERR 16
47ISR_ERR 17
48ISR_NOERR 18
49ISR_NOERR 19
50ISR_NOERR 20
51ISR_ERR 21
52ISR_NOERR 22
53ISR_NOERR 23
54ISR_NOERR 24
55ISR_NOERR 25
56ISR_NOERR 26
57ISR_NOERR 27
58ISR_NOERR 28
59ISR_ERR 29
60ISR_ERR 30
61ISR_NOERR 31
62ISR_NOERR 32
63ISR_NOERR 33
64ISR_NOERR 34
65ISR_NOERR 35
66ISR_NOERR 36
67ISR_NOERR 37
68ISR_NOERR 38
69ISR_NOERR 39
70ISR_NOERR 40
71ISR_NOERR 41
72ISR_NOERR 42
73ISR_NOERR 43
74ISR_NOERR 44
75ISR_NOERR 45
76ISR_NOERR 46
77ISR_NOERR 47
78
79
80;;
81; Saves the current frame and calls the exception handler
82;;
83isr_common:
84 push rax
85 push rbx
86 push rcx
87 push rdx
88 push rsi
89 push rdi
90 push rbp
91 push r8
92 push r9
93 push r10
94 push r11
95 push r12
96 push r13
97 push r14
98 push r15
99
100 mov rdi, rsp ; first argument: pointer to the saved frame
102
103 pop r15
104 pop r14
105 pop r13
106 pop r12
107 pop r11
108 pop r10
109 pop r9
110 pop r8
111 pop rbp
112 pop rdi
113 pop rsi
114 pop rdx
115 pop rcx
116 pop rbx
117 pop rax
118
119 add rsp, 16 ; drop the vector number and error code
120 iretq
121
122section .rodata
123global isr_stub_table
124isr_stub_table:
125%assign i 0
126%rep 48
127 dq isr %+ i
128%assign i i+1
129%endrep
130
131section .note.GNU-stack noalloc noexec nowrite progbits
void exception_handler(struct interrupt_frame *frame)
Prints information about an exception.
Definition idt.c:63