summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/REPLACE/_REPLACE.ASM
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/CMD/REPLACE/_REPLACE.ASM')
-rw-r--r--v4.0/src/CMD/REPLACE/_REPLACE.ASM142
1 files changed, 142 insertions, 0 deletions
diff --git a/v4.0/src/CMD/REPLACE/_REPLACE.ASM b/v4.0/src/CMD/REPLACE/_REPLACE.ASM
new file mode 100644
index 0000000..b8071d8
--- /dev/null
+++ b/v4.0/src/CMD/REPLACE/_REPLACE.ASM
@@ -0,0 +1,142 @@
1page 60,132 ;
2name _replace
3title Critical error or control break exit
4;-------------------------------------------------------------------
5;
6; MODULE: _replace
7;
8; PURPOSE: Supplies assembler exit routines for
9; critical error or control break situations
10;
11; CALLING FORMAT:
12; crit_err_handler;
13; ctl_brk_handler;
14;
15; DATE: 10/87
16;
17;-------------------------------------------------------------------
18
19
20 public _crit_err_handler ;AN000;
21 public _ctl_brk_handler ;AN000;
22
23;-------------------------------------------------------------------
24RET_EXIT equ 4ch ; terminate ;AN000;
25CTLBRK equ 3 ; errorlevel return in al ;AN000;
26ABORT equ 2 ; if >=, retry ;AN000;
27XABORT equ 1 ; errorlevel return in al ;AN000;
28;-------------------------------------------------------------------
29
30
31NULL SEGMENT PARA PUBLIC 'BEGDATA' ;AN000;
32NULL ENDS ;AN000;
33_DATA SEGMENT PARA PUBLIC 'DATA' ;AN000;
34 extrn _oldint24:dword ;AN000;
35_DATA ENDS ;AN000;
36CONST SEGMENT WORD PUBLIC 'CONST' ;AN000;
37CONST ENDS ;AN000;
38_BSS SEGMENT WORD PUBLIC 'BSS' ;AN000;
39_BSS ENDS ;AN000;
40STACK SEGMENT PARA STACK 'DATA' ;AN000;
41STACK ENDS ;AN000;
42
43PGROUP GROUP _TEXT ;AN000;
44DGROUP GROUP NULL, _DATA, CONST, _BSS, STACK ;AN000;
45
46
47
48_TEXT segment para public 'CODE' ;AN000;
49 ASSUME CS:PGROUP ;AN000;
50
51 extrn _restore:near ;AN000;
52
53;-------------------------------------------------------------------
54; CRITICAL ERROR HANDLER
55;-------------------------------------------------------------------
56vector dd 0 ;receives a copy of _oldint24 ;AN000;
57
58_crit_err_handler proc near ;AN000;
59
60 pushf ; req by int24 handler ;AN000;
61 push ax ; will use ax ;AN000;
62 push ds ; will use ds ;AN000;
63
64 mov ax,dgroup ; setup ;AN000;
65 mov ds,ax ; ;AN000;
66 ASSUME DS:DGROUP ;AN000;
67
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;
72
73 pop ds ; finished with ds ;AN000;
74 ASSUME DS:NOTHING
75
76 pop ax ; finished with ax ;AN000;
77
78 call dword ptr vector ; invoke DOS err hndlr ;AN000;
79
80 cmp al,ABORT ; what was the user's response ;AN000;
81 jnge retry ; ;AN000;
82
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 ===============
86
87retry: ;AN000;
88 ASSUME DS:NOTHING
89 ASSUME ES:NOTHING
90
91 iret ; user response was "retry" ;AN000;
92
93_crit_err_handler endp ;AN000;
94
95
96;-------------------------------------------------------------------
97; CONTROL BREAK HANDLER
98;-------------------------------------------------------------------
99_ctl_brk_handler proc near ;AN000;
100
101 ASSUME DS:NOTHING
102 ASSUME ES:NOTHING
103
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 ===============
109
110_ctl_brk_handler endp ;AN000;
111
112call_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.
116
117 push ax ;save errorlevel return code
118 push ds
119 push es
120
121 mov ax,dgroup ; setup "c" code regs ;AN000;
122 mov ds,ax ; ;AN000;
123 ASSUME DS:DGROUP ;AN000;
124
125 mov es,ax ; ;AN000;
126 ASSUME ES:DGROUP ;AN000;
127
128;-------------------------------------------------------------------
129 call _restore ; restore user's orig append/x ;AN000;
130;-------------------------------------------------------------------
131
132 pop es
133 pop ds
134 pop ax ;restore return code
135 int 21h ; ;AN000;
136 int 20h ; in case int21 fails ;AN000;
137
138call_restore endp
139
140_TEXT ends ; end code segment ;AN000;
141 end ;AN000;
142 \ No newline at end of file