home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR4
/
V12N16.ZIP
/
FINDIR.ZIP
/
FINASM.ZIP
/
IRQISR.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-08-24
|
11KB
|
280 lines
;---------------------------------------------------------------
;irqisr.asm - Interrupt service routines for FINDIRQ Utility |
;--------------------------------------------------------------|
;FINDIRQ Copyright (c) 1993 |
; |
;Rick Knoblaugh All rights reserved. |
;First Appeared in PC MAGAZINE, US Edition, |
;September 28, 1993 |
;--------------------------------------------------------------|
; 4/25/93 Rick Knoblaugh |
;--------------------------------------------------------------|
;include files |
;---------------------------------------------------------------
include irqequ.inc
include irqstruc.inc
code segment public 'CODE'
assume cs:code, ds:code, es:code
;--------------------------------------------------------------
;Externals |
;--------------------------------------------------------------
extrn put_to_disk:near ;irqsupt.asm
extrn start_util:near ;irqmain.asm
extrn int_table:byte ;irqmain.asm
extrn get_set_int:near ;irqsupt.asm
;--------------------------------------------------------------
;Publics |
;--------------------------------------------------------------
public int_1c_isr, int_28_isr, int_2f_isr
public old_1c_isr, old_28_isr, old_2f_isr
public atclassf, pic_mask
public read_pic_masks
public startup
org 100h
startup:
jmp start_util
;--------------------------------------------------------------
;Variables |
;--------------------------------------------------------------
even
irq_stack dw IRQ_STACK_SIZE dup('SS')
irq_stack_ptr label word
old_1c_isr dd ?
old_28_isr dd ?
old_2f_isr dd ?
old_stack_ptr dw ?
old_stack_seg dw ?
tick_count dw 0
need_to_write db FALSE ;TRUE if need to update file
atclassf db TRUE ;default to AT class machine
pic_mask dw ? ;mask value for master and slave PICs
;--------------------------------------------------------------
;int_1c_isr - user timer isr. Count the tick. If it's |
; time to check PIC mask, read the values. |
; If any new IRQs have been enabled (other than |
; any we have already seen since monitoring |
; began), set flag to write new hold file values. |
; |
; Enter: |
; |
; Exit: |
; tick_count updated |
; |
; need_to_write=TRUE if new enables found |
; pic_mask updated |
; |
; |
;--------------------------------------------------------------
int_1c_isr proc near
pushf
cmp cs:tick_count, CK_EVERY_UNIT
jb int_1c999
push ax
push bx
push dx
push ds
push cs
pop ds ;get ds=local data seg
mov tick_count, 0 ;reset tick count
call read_pic_masks
int_1c_800:
pop ds
pop dx
pop bx
pop ax
int_1c999:
inc cs:tick_count
popf
jmp dword ptr cs:old_1c_isr
int_1c_isr endp
read_pic_masks proc near
mov ah, pic_mask.d_master
mov dx, MASTER_PIC_MASK ;port for master mask reg
call ck_port
jz read_pic100
mov pic_mask.d_master, ah
read_pic100:
cmp atclassf, TRUE ;AT machine?
jne read_pic900 ;if not, only 1 8259
mov ah, pic_mask.d_slave
mov dx, SLAVE_PIC_MASK ;port for slave mask reg
call ck_port
jz read_pic900
mov pic_mask.d_slave, ah
read_pic900:
ret
read_pic_masks endp
;--------------------------------------------------------------
;ck_port - Check PIC mask register. See if any IRQs have |
; been enabled that we don't know about yet. |
; |
; Enter: |
; dx=i/o port for mask register |
; ah=mask value we have been keeping |
; ds=local data segment |
; |
; Exit: |
; need_to_write=TRUE if new enables found |
; ah=updated PIC mask values |
; ZR if no change from last reading |
; |
;--------------------------------------------------------------
ck_port proc near
mov bh, ah ;save original mask value
in al, dx ;read mask regsiter
and ah, al ;compare with old value
cmp ah, bh ;any new ones enabled?
je ck_port999
mov need_to_write, TRUE ;indicate we should update
ck_port999:
ret
ck_port endp
;--------------------------------------------------------------
; int_28_isr - if flag set for updating file, do it. |
; |
; Enter: |
; cs:need_to_write=TRUE if update pending |
; |
; Exit: |
; cs:need_to_write=FALSE if do update |
; |
;--------------------------------------------------------------
int_28_isr proc near
pushf
cmp cs:need_to_write, TRUE ;should update file?
jne int_28_999
cli
mov cs:old_stack_ptr, sp ;save existing stack
mov cs:old_stack_seg, ss
mov sp, cs ;setup our stack
mov ss, sp
mov sp, offset cs:irq_stack_ptr
sti
push ax ;ensure all preserved
push bx
push cx
push dx
push di
push si
push bp
push ds
push es
push cs
pop ds ;get ds=local data
mov need_to_write, FALSE ;reset flag
mov di, offset old_int24
mov al, 24h ;int 24h critical error handler
mov dx, offset irq_int24 ;our minimal handler
call get_set_int
mov ah, DOS_GET_PSP ;get program segment prefix
int 21h
push bx ;save current PSP
mov bx, cs ;.COM file, this is our PSP
mov ah, DOS_SET_PSP
int 21h
call put_to_disk
pop bx
mov ah, DOS_SET_PSP
int 21h
mov dx, old_int24.d_offset
mov ax, old_int24.d_segment
mov ds, ax
mov al, 24h
mov ah, DOS_SET_INT
int 21h ;restore int 24h handler
pop es
pop ds
pop bp
pop si
pop di
pop dx
pop cx
pop bx
pop ax
cli
mov sp, cs:old_stack_ptr
mov ss, cs:old_stack_seg
sti
int_28_999:
popf
jmp dword ptr cs:old_28_isr
int_28_isr endp
old_int24 dd ?
irq_int24 proc far
mov ax, 3 ;fail the operation
iret
irq_int24 endp
;--------------------------------------------------------------
;int_2f_isr - respond to get installed state function and |
; the next higher function for our id. |
; |
;--------------------------------------------------------------
int_2f_isr proc near
cmp ah, FINDIRQ_ID ;our id?
jne int_2f_900 ;if not, must be for old int
cmp al, GET_INST_STATE + 1 ;the 2 functions we know?
je int_2f_100
jnb int_2f_900 ;must not be for us
mov al, TRUE ;indicate we are installed
jmp short int_2f_999
int_2f_100:
cmp cx, 'Q!' ;extra sure it's us
jne int_2f_900 ;if not, must be for old int
mov byte ptr [bx], TRUE ;let other code know it's us
mov dx, offset int_table ;also pass this back
mov ax, cs
jmp short int_2f_999
int_2f_900:
jmp dword ptr cs:old_2f_isr
int_2f_999:
iret
int_2f_isr endp
code ends
end