home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programming
/
powerprogramming1994.iso
/
progtool
/
microcrn
/
issue_36.arc
/
INT.FIG
< prev
next >
Wrap
Text File
|
1987-05-21
|
3KB
|
84 lines
title InterruptExample
code segment ; everything goes in code segment
org 100h
assume cs:code
DOS_entry label far
jmp setup
new_int proc far ; beginning of our interrupt handler
sti ; reenable interrupts
push ax ; save registers
push bx
push dx
mov al,0B6h ; set up timer to generate tones
out 43h,al
in al,61h ; turn on 2 LS bits to enable speaker
or al,03h
out 61h,al
mov bx,3000h ; initial tone divisor
top: mov ax,bx ; set up tone
out 42h,al
mov al,ah
out 42h,al
mov dx,30h
delay: dec dx ; sound the tone for a short while
cmp dx,0
jne short delay
dec bx
cmp bx,0
jne short top ; set up new tone
done: in al,61h ; turn off 2 LS bits to disable speaker
and al,0FCh
out 61h,al
mov al,20h ; signal EOI (end of interrupt) to processor
out 20h, al
pop dx ; restore registers
pop bx
pop ax
iret
new_int endp ; end of our interrupt
end_res_code:
sign_on db 'INTERRUPT TEST NOW INSTALLED$'
err_msg db 'INTERRUPT TEST ALLREADY INSTALLED$'
assume ds:code
setup proc near ; install our routine
; as resident code
in ax,21h ; get mask register
and ax,0FBh ; remove mask -- reset bit 2
out 21h,ax ; send new mask to register
mov ax,350Ah ; get address of interrupt 0Ah
int 21h
mov ax,es ; segment is returned in es
cmp ax,0f000h ; is this address in ROM?
jae short install ; if so, install our code
mov dx,offset err_msg ; if not, write msg
mov ah,9 ; that our code is already
int 21h ; installed
int 20h ; exit to DOS
install:mov dx,offset sign_on ; write sign on msg
mov ah,9
int 21h
mov dx,offset new_int ; set up new
mov ax,250Ah ; interrupt vector
int 21h
mov dx,offset end_res_code ; make our code
int 27h ; resident
setup endp
code ends
end DOS_entry