summaryrefslogtreecommitdiff
path: root/asm/pit.s
blob: 8e16d0b3fafbbc375545bf1fd0e15ffd4eb61a88 (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
.global asm_pit_init
.global asm_pit_tick
.global asm_pit_get_ticks

ticks:
.int 0

asm_pit_get_ticks:
    
    mov (ticks),%eax
    ret

asm_pit_tick:

    push %eax // persist

    // INC TICK COUNTER
    mov $ticks, %eax    
    incl (%eax)

    pop %eax // load original
    
    ret

asm_pit_init:

    // configure ticking 25 times a second
    // 1193180 / 25 = 47727.2
    mov $47727, %dx

    mov $0b00110100, %al
    outb %al,$0x43

    mov %dx,%ax

    out %al, $0x40
    xchg %ah,%al
    out %al, $0x40

    ret