]>
wirehaze git hosting - MS-DOS.git/blob - v4.0/src/MAPPER/ERROR.ASM
4 title CP
/DOS DosError mapper
7 ;**********************************************************************
11 ;* ;AN000; PCDOS 4.00 ptm p2629 - Drive not ready yields FORMAT TERMINATED
13 ;*********************************************************************
15 SystemIsHandling equ
1 ; system handles errors
16 AppIsHandling equ
0 ; application handle errors
18 ;------------------------------------------------------------;;;
19 databuff
segment public 'databuff' ;;;
21 errorstate db SystemIsHandling
;;;
24 ;------------------------------------------------------------;;;
27 dosxxx
segment byte public 'dos'
28 assume
cs:dosxxx
,ds:nothing
,es:nothing
,ss:nothing
40 Flag dw ?
; error flag; 0 = APP handle error
41 str ends
; 1 = System handle error
45 Enter doserror
; Push registers
47 mov ax,seg databuff
;-->RW
49 assume
ds:databuff
;-->RW
51 mov ax,[bp].flag
; get error flag
52 cmp ax,AppIsHandling
; check who should handle errors
53 je apperrorhandle
; branch if application handles error
54 cmp ax,SystemIsHandling
; system handle error ??
55 je syserrorhandle
; branch if true
57 mov ax,1 ; else, set error code
62 cmp errorstate
,SystemIsHandling
; system handles error ??
63 jne setsys
; branch if not
64 xor ax,ax ; else set good return code
67 setsys: mov errorstate
,SystemIsHandling
; set flag for system
71 int 21h
; set new vector
73 xor ax,ax ; set good return code
78 cmp errorstate
,AppIsHandling
; application handle errors
79 jne setapp
; branch if true
81 xor ax,ax ; else, set good error code
84 setapp: mov errorstate
,AppIsHandling
; indicate app handles error
85 mov ax,03524h ; Get Interrupt 24 Vector
88 mov word ptr cs:prevadrs
+0,bx ; save it in prevadrs
89 mov word ptr cs:prevadrs
+2,es
93 mov dx,offset ApiErrorHandler
; put error interrupt handler
96 int 21h
;set new vector
98 xor ax,ax ; set good error return
100 exit: mexit
; pop all registers
101 ret size
str - 6 ; return
111 ;-------------------------------------------------------
112 ; **** Error Handler ******
113 ; This routine will get control on a hard error, returning an error.
114 ; If error is Drive not ready, keep retrying until drive IS ready or ^C
115 ;-------------------------------------------------------
116 DriveNotReady equ
2 ;AN000;
120 Terminate equ
2 ;AN000;
123 prevadrs dd ?
;AN000; ;save old interrupt handler address ;;;
125 ApiErrorHandler proc
near ;AN000;
127 cmp di,DriveNotReady
;AN000; Is it Drive Not Ready?
128 jne popf_and_fail_it
;AN000; If not, fail call and return
130 Drive_Not_Ready: ;AN000; The drive is not ready!
131 call dword ptr cs:prevadrs
;AN000; Get user to respond
132 cmp al,Terminate
;AN000; For any resonse other than terminate,
133 jne retry_it
;AN000; retry the operation
134 int 023h ;AN000; Otherwise terminate via INT 023h
136 popf_and_fail_it: ;AN000; Fail the operation
137 pop ax ;AN000; Remove garbage from stack
138 mov al,Fail
;AN000; Func code for fail
140 retry_it: ;AN000; Retry the operation
141 mov al,Retry
;AN000; Func code for retry
145 ;-------------------------------------------------------
146 ;-------------------------------------------------------