-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinter.asm
62 lines (47 loc) · 1.05 KB
/
inter.asm
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
57
58
59
60
61
62
org 0x7C00
BITS 16
start:
; Set up GDT
lgdt [gdt_descriptor]
; Set up IDT
lidt [idt_descriptor]
; Configure the PIT
mov al, 0x36 ; Set timer channel 0, mode 3, binary counter
out 0x43, al
mov al, 0x4C ; Set the desired frequency (e.g., 100 Hz)
out 0x40, al
mov al, ah
out 0x40, al
; Enable interrupts
sti
; Infinite loop
cli
hlt
gdt_descriptor:
dw $ - gdt - 1
dd gdt
gdt:
; GDT entry for code segment
dw 0xFFFF ; Limit
dw 0x0000 ; Base
db 0x00 ; Base
db 0x9A ; Access byte
db 0xCF ; Granularity byte
db 0x00 ; Base
idt_descriptor:
dw $ - idt - 1
dd idt
idt:
times 256 dw interrupt_handler ; IDT entries, each pointing to interrupt_handler
interrupt_handler: ; Timer interrupt handler
; Save CPU state
pusha
; Perform operations
; End of interrupt
mov al, 0x20
out 0x20, al
; Restore CPU state
popa
iret
times 510-($-$$) db 0
dw 0xAA55 ; Boot signature