Category : Files from Magazines
Archive   : DDJ8705.ZIP
Filename : GARVLST.LST
Output of file : GARVLST.LST contained in archive : DDJ8705.ZIP
;
; TIMER_ISR is an example of a MIDI interrupt service routine with a semaphore
; This partial listing will help to model a timer int. based on semaphores
;
dseg segment para public 'dseg'
t_sem dw 0 ; make sure this value always starts at zero
dseg ends
cseg segment para public 'cseg'
assume cs:cseg, ds:dseg
public int_vector
int_vector proc far
sti
push si ; save all registers
push di
push ax
push bx
push cx
push dx
push ds
push es
;
mov di,dseg ; set up for access to data seg in this module
mov ds,di
again: ; loop point for retries if more ints hit
mov si,[t_sem] ; 'sample' the semaphore before increment !
inc [t_sem]
;
mov al,20h ; this will acknowledge interrupts on IBM PC
out 20h,al
;
call reset_timer_ff ; toggle flip-flop hooked to the timer chip
;
; Interrupts are now re-enabled
;
or si,si ; Check the 'sampled' semaphore
je i_loop ; If semaphore was zero, execute tmr routine
;
; Skip the main timer routine if this is a nested int - check for ovfl
;
cmp si,200 ; Too many interrupts stacked-up? (overflow?)
jc skip ; If not, exit directly.
;
; Interrupts have overflowed -- stop and check timer values
;
call emergency_stop ; semaphore overflow! timers are set too fast
jmp skip
;
i_loop:
;
; Execute the main timer routine - then check for stacked interrupts
;
call timer_routine ; run main timer chain
;
dec [t_sem] ; if sem dec's to zero, no ints are nested
jnz i_loop ; if ints ARE nested, loop back to catch up
skip:
pop es
pop ds
pop dx
pop cx
pop bx
pop ax
pop di
pop si ; restore registers and return
iret
int_vector endp
cseg ends
;
i_loop:
;
; E î w : Â T` Æ Â &