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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
| ; Variables du Timer 8253
old_irq0 dd ? ;
debut:
; installation de la routine du timer 8253
call rinstall8253irq ;sauvegarde les irq du 8253
lance:
call rselectfreq8253irq ;ajuste le compteur du 8253
;sur la frequence en cours
fin:
call rrestore8253irq ;retabli l'interruption du 8253
;********************************************************************
; TIMER_PROCEDURE
;********************************************************************
timer_procedure proc near
push ds
push es
pushad
mov ax,cs
mov ds,ax
; Vos routines
;
; ICI
;
fintimerprocedure:
popad
pop es
pop ds
iret
timer_procedure endp
; Gestion du timer 8253
CONTROL_8253 equ 43h
COUNTER_0 equ 40h
;********************************************************************
; RINSTALL8253IRQ
;********************************************************************
rinstall8253irq proc near
; Sauve l'ancienne IRQ0
mov eax,gs:[08h*4]
mov old_irq0,eax
; Installe la nouvelle IRQ0
mov ax,cs
shl eax,16
mov ax,offset timer_procedure
mov gs:[08h*4],eax
ret
rinstall8253irq endp
;********************************************************************
; RRESTORE8253IRQ
;********************************************************************
rrestore8253irq proc near
; restore l'ancienne frequence
mov eax,18 ;c'est a dire 1 193 180 fois
mov ebx,eax
mov ax,03ch
out CONTROL_8253,ax
xor edx,edx
mov eax,1193180
div ebx
cmp eax,0ffffh
jb okfreq
mov ax,0ffffh
okfreq:
out COUNTER_0,al
mov al,ah
out COUNTER_0,al
; restore l'ancienne routine
xor eax,eax
mov eax,old_irq0
mov gs:[08h*4],eax
ret
rrestore8253irq endp
;********************************************************************
; RSELECTFREQ8253IRQ
;********************************************************************
rselectfreq8253irq proc near
xor ax,ax
mov ax,frequence
mov ebx,eax
mov ax,03ch
out CONTROL_8253,ax
xor edx,edx
mov eax,1193180
div ebx
cmp eax,0ffffh
jb okfreq
mov ax,0ffffh
okfreq:
out COUNTER_0,al
mov al,ah
out COUNTER_0,al
ret
rselectfreq8253irq endp |
Partager