home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
ctcoll95.zip
/
BASTELST
/
PAPI020.ZIP
/
APIA.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-10-06
|
3KB
|
151 lines
.MODEL COMPACT
LOCALS
%MACS
.LALL
.DATA
public Intstk,Stktop,Spsave,Sssave
public Timstk,Tstktop,Tspsave,Tssave
Spsave dw ? ; Save location for SP during interrupts
Sssave dw ? ; Save location for SS during interrupts
Intstk dw 1024 dup(?) ; Interrupt working stack
Stktop equ $ ; SP set here when entering interrupt
Tspsave dw ? ; Save location for SP during interrupts
Tssave dw ? ; Save location for SS during interrupts
Timstk dw 1024 dup(?) ; Interrupt working stack
Tstktop equ $ ; SP set here when entering interrupt
.CODE
extrn _apiint:near
extrn _TimerTick:near
dbase dw @Data
apisema db 0
timsema db 0
apiprbl dw 0
timprbl dw 0
; dirps - disable interrupts and return previous state: 0 = disabled,
; 1 = enabled
public _dirps
_dirps proc
pushf ; save flags on stack
pop ax ; flags -> ax
and ax,200h ; 1<<9 is IF bit
jz @@1 ; ints are already off; return 0
mov ax,1
cli ; interrupts now off
@@1: ret
_dirps endp
; restore - restore interrupt state: 0 = off, nonzero = on
public _restore
_restore proc
arg is:word
test is,0ffffh
jz @@1
sti
ret
@@1: cli ; should already be off, but just in case...
ret
_restore endp
; apivec - ISDN CAPI interrupt handler #0
public _apivec
label _apivec far
push ax ; check for interpt in interpt
mov al,1
xchg al,cs:apisema
and al,al
jz @@1
inc cs:apiprbl
pop ax
iret
@@1: push ds ; save on user stack
mov ds,cs:dbase
mov Sssave,ss ; stash user stack context
mov Spsave,sp
mov ss,cs:dbase
lea sp,Stktop
; save user regs on interrupt stack
push bx
push cx
push dx
push bp
push si
push di
push es
mov ax,cs:apiprbl
push ax
call _apiint
pop ax
pop es
pop di
pop si
pop bp
pop dx
pop cx
pop bx
mov ss,Sssave
mov sp,Spsave ; restore original stack context
pop ds
sub al,al
xchg al,cs:apisema
pop ax
iret
; timevec Timer interrupt handler
public _timevec
label _timevec far
push ax ; check for interpt in interpt
mov al,1
xchg al,cs:timsema
and al,al
jz @@2
inc timprbl
pop ax
iret
@@2: push ds ; save on user stack
mov ds,cs:dbase
mov Tssave,ss ; stash user stack context
mov Tspsave,sp
mov ss,cs:dbase
lea sp,Tstktop
; save user regs on interrupt stack
push bx
push cx
push dx
push bp
push si
push di
push es
mov ax,cs:timprbl
push ax
call _TimerTick
pop ax
pop es
pop di
pop si
pop bp
pop dx
pop cx
pop bx
mov ss,Tssave
mov sp,Tspsave ; restore original stack context
pop ds
sub al,al
xchg al,cs:timsema
pop ax
iret
end