-
Notifications
You must be signed in to change notification settings - Fork 3
/
TIMERASM.ASM
63 lines (53 loc) · 1.7 KB
/
TIMERASM.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
63
; Timer interrupt handler
; Modified by BSpider for NASM on 5th Sep 2006
%include "segments.inc"
%ifdef djgpp
section .text
%else
segment _TEXT
%endif
global _timer_code_lock_start
global _timer_code_lock_end
global _timer_oldvect
global _timer_count
global _timer_systemcount
global _timer_frequency
global _timer_ds
global _timer_function
; expose both calling conventions
global timer_handler_
global _timer_handler
_timer_code_lock_start:
align 4
_timer_ds dw 0
_timer_oldvect dd 0, 0
_timer_count dd 0
_timer_systemcount dw 0
_timer_frequency dw 0
_timer_function dd 0
align 4
timer_handler_:
_timer_handler:
pushad
push DS
push ES
mov DS, [CS:_timer_ds]
mov ES, [CS:_timer_ds]
sti
mov AL, 20h
out 20h, AL
inc dword [_timer_count]
call dword [_timer_function]
mov AX, [_timer_frequency]
add [_timer_systemcount], AX
jc timer_callold
pop ES
pop DS
popad
iretd
timer_callold: pop ES
pop DS
popad
jmp dword far [CS:_timer_oldvect]
_timer_code_lock_end:
; end