home *** CD-ROM | disk | FTP | other *** search
- ;******************************************************
- ; ISRES.ASM 1.00
- ; Copyright (c) TurboPower Software 1990.
- ; All rights reserved.
- ;******************************************************
-
- ;****************************************************** Equates
-
- IfcSignature1 = 0F0F0h ;Do not change
- IfcSignature2 = 0E0E0h ;Do not change
- WP EQU WORD PTR
-
- ;****************************************************** Structures
-
- ;Structure of a pointer
- Pointer STRUC
- Ofst DW 0
- Segm DW 0
- Pointer ENDS
-
- ;Structure of an IFC record
- IfcRec STRUC
- NamePtr Pointer <>
- Version DW 0400h
- UserPtr Pointer <>
- PrevIfc Pointer <>
- NextIfc Pointer <>
- PrgName DB 9 DUP (0)
- IfcRec ENDS
-
- ;****************************************************** Macros
-
- SetPtr MACRO P, S, O
- MOV P.Ofst, O ;set offset
- MOV P.Segm, S ;set segment
- ENDM
-
- SetPtrByOfst MACRO P, S, O
- MOV AX,Offset O
- MOV P.Ofst, AX ;set offset
- MOV P.Segm, S ;set segment
- ENDM
-
- ;****************************************************** Data
-
- DATA SEGMENT BYTE PUBLIC
-
- EXTRN ThisIfcPtr : DWORD
- EXTRN IfcInstalledPtr : DWORD
-
- DATA ENDS
-
- ;****************************************************** Code
-
- CODE SEGMENT BYTE PUBLIC
-
- ASSUME CS:CODE,DS:DATA
-
- PUBLIC Init16, Restore16, ThisIfc
-
- OldInt16 Pointer <>
- ThisIfc IfcRec <>
- IfcInstalled DB 0
-
- ;****************************************************** Int16
-
- IntraApp = 00F0h ;offset of intraapplication comm area
- BiosDataSeg = 40h ;segment of BIOS data area
-
- Int16 PROC NEAR
-
- STI ;Interrupts on
- CMP CS:IfcInstalled,1 ;Are we in charge of the interface?
- JNE JumpOld16 ;If not, chain to old ISR
- CMP AX,IfcSignature1 ;See if this is a request for info
- JNE NotIfcCheck1 ;If not, continue
- NOT AX ;Flip the bits in AX
- PUSH CS ;ES = CS
- POP ES
- MOV DI,Offset ThisIfc ;ES:DI points to ThisIfc
- MOV WP ES:[DI].NextIfc,0 ;If we're answering this, we're the end
- MOV WP ES:[DI].NextIfc+2,0 ; of the line, so NextIfc is nil
- IRET
-
- NotIfcCheck1:
- CMP AX,IfcSignature2 ;Is this a secondary request?
- JNE JumpOld16
- NOT AX ;Flip the bits in AX
- PUSH ES ;save registers
- PUSH DI
- PUSH BX
- PUSH CX
- MOV CX,BiosDataSeg ;ES:DI => intra-app comm area
- MOV ES,CX
- MOV DI,IntraApp
- MOV CX,CS ;CX:BX => ActualIfc
- MOV BX,Offset ThisIfc
- MOV ES:[DI].Ofst,BX ;store @ThisIfc at Ptr(ES,DI)^
- MOV ES:[DI].Segm,CX
- MOV ES,CX ;ES:BX points to ThisIfc
- MOV WP ES:[BX].NextIfc,0 ;If we're answering this, we're the end
- MOV WP ES:[BX].NextIfc+2,0 ; of the line, so NextIfc is nil
- POP CX
- POP BX
- POP DI
- POP ES
- IRET
-
- JumpOld16:
- CLI ;Interrupts off
- JMP DWORD PTR CS:OldInt16 ;Jump to old vector
-
- Int16 ENDP
-
- ;****************************************************** Init16
-
- ;procedure Init16;
-
- ;Capture INT 16
-
- Init16 PROC FAR
-
- ;set up IFC
- SetPtrByOfst ThisIfc.NamePtr, CS, ThisIfc.PrgName
-
- ;give Pascal routines access to CS-relative data
- SetPtrByOfst ThisIfcPtr, CS, ThisIfc
- SetPtrByOfst IfcInstalledPtr, CS, IfcInstalled
-
- MOV AX,3516h ;Get the current INT $16 vector
- INT 21h
- SetPtr CS:OldInt16, ES, BX ;save it
-
- PUSH DS ;save DS
- PUSH CS ;DS:DX => Int16
- POP DS
- MOV DX,Offset Int16
- MOV AX,2516h ;take over the vector
- INT 21h
- POP DS ;restore DS
- RET
-
- Init16 ENDP
-
- ;****************************************************** Restore16
-
- ;procedure Restore16;
-
- ;Restore INT 16
-
- Restore16 PROC FAR
-
- PUSH DS ;save DS
- LDS DX,CS:OldInt16 ;DS:DX has old vector
- MOV AX,2516h ;restore it
- INT 21h
- POP DS ;restore DS
- RET
-
- Restore16 ENDP
-
- CODE ENDS
-
- END