summaryrefslogtreecommitdiff
path: root/asm/int_clock_handler.asm
blob: c6c91fc88daaeb29af5335073af31d68cda9ba10 (plain)
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
global int_clock_handler
[extern task_switch_next]

;CLOCK_COUNTER:
;    db 0x00

[bits 32]
int_clock_handler:

 cli
 
 ;Notice there is no IRQ number or error code - we don't need them

; inc byte [CLOCK_COUNTER]
 
; cmp byte  [CLOCK_COUNTER], 0x2

; jne skip_clock

; mov byte [CLOCK_COUNTER], 0x00

pusha          ;Push all standard registers
 push esp       ;Push pointer to all the stuff we just pushed

 call task_switch_next ;Call C code

 ;pop ebx

 ;compare:
 ;cmp eax,ebx
 ;jne compare 

 
 mov esp, eax   ;Replace the stack with what the C code gave us

 
; skip_clock:
 mov al, 0x20   ;Port number AND command number to Acknowledge IRQ
 out 0x20, al   ;Acknowledge IRQ, so we keep getting interrupts

 popa           ;Put the standard registers back

 ;We didn't push an error code or IRQ number, so we don't have to edit esp now
 sti
 
 iretd           ;Interrupt-Return