home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
progm
/
tptools.zip
/
FIRSTED.ZIP
/
INT24.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-12-21
|
4KB
|
139 lines
;
; INT24.ASM
; ED 4.0
; Copyright (c) 1985, 87 by Borland International, Inc.
;
; Critical error handling routines
;
DATA SEGMENT BYTE PUBLIC
SaveSeg24 DW ? ;Segment of old Int24 handler
SaveOfs24 DW ? ;Offset of old Int24 handler
DATA ENDS
CODE SEGMENT BYTE PUBLIC
ASSUME CS:CODE,DS:DATA
PUBLIC EdInt24Result, EdInt24On, EdInt24Off
EXTRN IoResultPrim:NEAR ;Pascal routine
;CS-relative data:
Int24Err DB 0 ;Boolean -- 1 means critical error
Int24ErrCode DB 0 ;Byte -- the DOS error code
;****************************************************** EdInt24
;procedure EdInt24
;Interrupt handler for DOS critical errors
EdInt24 PROC NEAR
MOV CS:Int24Err,01 ;Set error flag
PUSH AX ;Save AX
MOV AX,DI ;DI has error code on entry
MOV CS:Int24ErrCode,AL ;Store error code for later
POP AX ;Restore AX
MOV AL,00 ;Tell DOS to I)gnore error
IRET ;Return
EdInt24 ENDP
;****************************************************** EdInt24Result
;function EdInt24Result : Word;
;Returns word in AX. AH has Int24ErrCode, AL has IoResult.
EdInt24Result PROC FAR
CALL IoResultPrim ;Get IoResult into AX
CMP CS:Int24Err,1 ;Critical error flag set?
JNE EirExit ;No? Done
;Merge critical error code into result
MOV AH,CS:Int24ErrCode ;Int24ErrCode into AH
OR AH,AH ;Check for "zero" error
JNZ EIrAHnot0 ;Jump if not
MOV AH,0Dh ;Return a fake non-zero error code
EIrAHnot0:
MOV CS:Int24ErrCode,0 ;Reset Int24ErrCode to 0
EirExit:
RET
EdInt24Result ENDP
;****************************************************** EdInt24On
;Install our critical error handler and save address of old one
EdInt24On PROC FAR
PUSH BP ;Save BP
MOV BP,SP ;Set up stack frame
PUSH DS ;Save DS
;Get and save address of old critical error handler
MOV AX,3524h ;AH = Get vector, AL = vector to get
INT 21h ;Call DOS
MOV SaveSeg24,ES ;Save segment of current ISR
MOV SaveOfs24,BX ;Save offset of current ISR
;Install new critical error handler
PUSH CS ;Get CS...
POP DS ; into DS
MOV DX,Offset(EdInt24) ;DS:DX points to EdInt24
MOV AX,2524h ;AH = Set vector, AL = vector to set
INT 21h ;Call DOS
;Initialize variables
MOV CS:Int24Err,0 ;Clear error flag
MOV CS:Int24ErrCode,0 ;Clear error code
POP DS ;Restore DS
MOV SP,BP ;Restore SP
POP BP ;Restore BP
RET
EdInt24On ENDP
;****************************************************** EdInt24Off
;Restore previous critical error handler
EdInt24Off PROC FAR
PUSH BP ;Save BP
MOV BP,SP ;Set up stack frame
PUSH DS ;Save DS
;Install old critical error handler
MOV DX,SaveOfs24 ;DX = old offset
MOV DS,SaveSeg24 ;DS:DX points to old ISR
MOV AX,2524h ;AH = Set vector, AL = vector to set
INT 21h ;Call DOS
MOV CS:Int24Err,0 ;Clear error flag
POP DS ;Restore DS
MOV SP,BP ;Restore SP
POP BP ;Restore BP
RET
EdInt24Off ENDP
CODE ENDS
END