]>
wirehaze git hosting - MS-DOS.git/blob - v4.0/src/CMD/REPLACE/_REPLACE.ASM
3 title Critical error
or control
break exit
4 ;-------------------------------------------------------------------
8 ; PURPOSE: Supplies assembler exit routines for
9 ; critical error or control break situations
17 ;-------------------------------------------------------------------
20 public _crit_err_handler
;AN000;
21 public _ctl_brk_handler
;AN000;
23 ;-------------------------------------------------------------------
24 RET_EXIT equ 4
ch ; terminate ;AN000;
25 CTLBRK equ
3 ; errorlevel return in al ;AN000;
26 ABORT equ
2 ; if >=, retry ;AN000;
27 XABORT equ
1 ; errorlevel return in al ;AN000;
28 ;-------------------------------------------------------------------
31 NULL
SEGMENT PARA
PUBLIC 'BEGDATA' ;AN000;
33 _DATA
SEGMENT PARA
PUBLIC 'DATA' ;AN000;
34 extrn _oldint24
:dword ;AN000;
36 CONST
SEGMENT WORD PUBLIC 'CONST' ;AN000;
38 _BSS
SEGMENT WORD PUBLIC 'BSS' ;AN000;
40 STACK SEGMENT PARA
STACK 'DATA' ;AN000;
43 PGROUP GROUP _TEXT
;AN000;
44 DGROUP GROUP NULL
, _DATA
, CONST
, _BSS
, STACK ;AN000;
48 _TEXT
segment para
public 'CODE' ;AN000;
49 ASSUME
CS:PGROUP
;AN000;
51 extrn _restore
:near ;AN000;
53 ;-------------------------------------------------------------------
54 ; CRITICAL ERROR HANDLER
55 ;-------------------------------------------------------------------
56 vector dd 0 ;receives a copy of _oldint24 ;AN000;
58 _crit_err_handler proc
near ;AN000;
60 pushf ; req by int24 handler ;AN000;
61 push ax ; will use ax ;AN000;
62 push ds ; will use ds ;AN000;
64 mov ax,dgroup
; setup ;AN000;
66 ASSUME
DS:DGROUP
;AN000;
68 mov ax,word ptr _oldint24
; load vector so we can use it ;AN000;
69 mov word ptr vector
,ax ; ;AN000;
70 mov ax,word ptr _oldint24
+2 ; ;AN000;
71 mov word ptr vector
+2,ax ; ;AN000;
73 pop ds ; finished with ds ;AN000;
76 pop ax ; finished with ax ;AN000;
78 call dword ptr vector
; invoke DOS err hndlr ;AN000;
80 cmp al,ABORT
; what was the user's response ;AN000;
83 mov ax,(RET_EXIT
shl 8)+XABORT ; return to DOS w/criterr error ;AN000;
84 call call_restore
; restore user's orig append/x ;AN000;
85 ; =================== this call does not return ===============
91 iret ; user response was "retry" ;AN000;
93 _crit_err_handler endp
;AN000;
96 ;-------------------------------------------------------------------
97 ; CONTROL BREAK HANDLER
98 ;-------------------------------------------------------------------
99 _ctl_brk_handler proc
near ;AN000;
104 mov ax,(RET_EXIT
shl 8)+CTLBRK
; return to DOS w/ctlbrk error ;AN000;
105 ;-------------------------------------------------------------------
106 call call_restore
; restore user's orig append/x ;AN000;
107 ;-------------------------------------------------------------------
108 ; =================== this call does not return ===============
110 _ctl_brk_handler endp
;AN000;
112 call_restore proc
near
113 ;input: ah has the RETURN TO DOS WITH RET CODE function request
114 ; al has the ERRORLEVEL return code to be passed back to DOS
115 ;output: this routine does NOT RETURN, but exits to DOS with ret code.
117 push ax ;save errorlevel return code
121 mov ax,dgroup
; setup "c" code regs ;AN000;
123 ASSUME
DS:DGROUP
;AN000;
126 ASSUME
ES:DGROUP
;AN000;
128 ;-------------------------------------------------------------------
129 call _restore
; restore user's orig append/x ;AN000;
130 ;-------------------------------------------------------------------
134 pop ax ;restore return code
136 int 20h
; in case int21 fails ;AN000;
140 _TEXT ends
; end code segment ;AN000;