Microsoft (R) Macro Assembler Version 5.10                  2/14/25 23:45:27
Critical error or control break exit                        Page     1-1


				page	60,132				;
				name	_replace
				title	Critical error or control break exit
				;-------------------------------------------------------------------
				;
				;	MODULE: 	_replace
				;
				;	PURPOSE:	Supplies assembler exit routines for
				;			critical error or control break situations
				;
				;	CALLING FORMAT:
				;			crit_err_handler;
				;			ctl_brk_handler;
				;
				;	DATE:		10/87
				;
				;-------------------------------------------------------------------
				
				
					public	_crit_err_handler	;AN000;
					public	_ctl_brk_handler	;AN000;
				
				;-------------------------------------------------------------------
 = 004C				RET_EXIT equ	4ch			; terminate				;AN000;
 = 0003				CTLBRK	equ	3			; errorlevel return in al		;AN000;
 = 0002				ABORT	equ	2			; if >=, retry				;AN000;
 = 0001				XABORT	equ	1			; errorlevel return in al		;AN000;
				;-------------------------------------------------------------------
				
				
 0000				NULL	SEGMENT PARA PUBLIC 'BEGDATA'	;AN000;
 0000				NULL	ENDS				;AN000;
 0000				_DATA	SEGMENT PARA PUBLIC 'DATA'	;AN000;
					extrn	_oldint24:dword 	;AN000;
 0000				_DATA	ENDS				;AN000;
 0000				CONST	SEGMENT WORD PUBLIC 'CONST'	;AN000;
 0000				CONST	ENDS				;AN000;
 0000				_BSS	SEGMENT WORD PUBLIC 'BSS'	;AN000;
 0000				_BSS	ENDS				;AN000;
 0000				STACK	SEGMENT PARA STACK 'DATA'	;AN000;
 0000				STACK	ENDS				;AN000;
				
				PGROUP	GROUP	_TEXT			;AN000;
				DGROUP	GROUP	NULL, _DATA, CONST, _BSS, STACK ;AN000;
				
				
				
 0000				_TEXT	segment para public 'CODE'	;AN000;
					ASSUME	CS:PGROUP		;AN000;
				
					extrn	_restore:near		;AN000;
				
				;-------------------------------------------------------------------
				; CRITICAL ERROR HANDLER
				;-------------------------------------------------------------------
 0000  00000000			vector	dd	0			;receives a copy of _oldint24		;AN000;
Microsoft (R) Macro Assembler Version 5.10                  2/14/25 23:45:27
Critical error or control break exit                        Page     1-2


				
 0004				_crit_err_handler proc near		;AN000;
				
 0004  9C				pushf				; req by int24 handler			;AN000;
 0005  50				push	ax			; will use ax				;AN000;
 0006  1E				push	ds			; will use ds				;AN000;
				
 0007  B8 ---- R			mov	ax,dgroup		; setup 				;AN000;
 000A  8E D8				mov	ds,ax			;					;AN000;
					ASSUME	DS:DGROUP		;AN000;
				
 000C  A1 0000 E			mov	ax,word ptr _oldint24	; load vector so we can use it		;AN000;
 000F  2E: A3 0000 R			mov	word ptr vector,ax	;					;AN000;
 0013  A1 0002 E			mov	ax,word ptr _oldint24+2 ;					;AN000;
 0016  2E: A3 0002 R			mov	word ptr vector+2,ax	;					;AN000;
				
 001A  1F				pop	ds			; finished with ds			;AN000;
					ASSUME	DS:NOTHING
				
 001B  58				pop	ax			; finished with ax			;AN000;
				
 001C  2E: FF 1E 0000 R			call	dword ptr vector	; invoke DOS err hndlr			;AN000;
				
 0021  3C 02				cmp	al,ABORT		; what was the user's response          ;AN000;
 0023  7C 06				jnge	retry			;					;AN000;
				
 0025  B8 4C01				mov	ax,(RET_EXIT shl 8)+XABORT ; return to DOS w/criterr error	;AN000;
 0028  E8 0032 R			call	call_restore		; restore user's orig append/x          ;AN000;
				; =================== this call does not return ===============
				
 002B				retry:					;AN000;
					ASSUME	DS:NOTHING
					ASSUME	ES:NOTHING
				
 002B  CF				iret				; user response was "retry"		;AN000;
				
 002C				_crit_err_handler endp			;AN000;
				
				
				;-------------------------------------------------------------------
				; CONTROL BREAK HANDLER
				;-------------------------------------------------------------------
 002C				_ctl_brk_handler proc near		;AN000;
				
					ASSUME	DS:NOTHING
					ASSUME	ES:NOTHING
				
 002C  B8 4C03				mov	ax,(RET_EXIT shl 8)+CTLBRK ; return to DOS w/ctlbrk error	;AN000;
				;-------------------------------------------------------------------
 002F  E8 0032 R			call	call_restore		; restore user's orig append/x          ;AN000;
				;-------------------------------------------------------------------
				; =================== this call does not return ===============
				
 0032				_ctl_brk_handler endp			;AN000;
				
 0032				call_restore proc near
Microsoft (R) Macro Assembler Version 5.10                  2/14/25 23:45:27
Critical error or control break exit                        Page     1-3


				;input: ah has the RETURN TO DOS WITH RET CODE function request
				;	al has the ERRORLEVEL return code to be passed back to DOS
				;output: this routine does NOT RETURN, but exits to DOS with ret code.
				
 0032  50				push	ax			;save errorlevel return code
 0033  1E				push	ds
 0034  06				push	es
				
 0035  B8 ---- R			mov	ax,dgroup		; setup "c" code regs			;AN000;
 0038  8E D8				mov	ds,ax			;					;AN000;
					ASSUME	DS:DGROUP		;AN000;
				
 003A  8E C0				mov	es,ax			;					;AN000;
					ASSUME	ES:DGROUP		;AN000;
				
				;-------------------------------------------------------------------
 003C  E8 0000 E			call	_restore		; restore user's orig append/x          ;AN000;
				;-------------------------------------------------------------------
				
 003F  07				pop	es
 0040  1F				pop	ds
 0041  58				pop	ax			;restore return code
 0042  CD 21				int	21h			;					;AN000;
 0044  CD 20				int	20h			; in case int21 fails			;AN000;
				
 0046				call_restore endp
				
 0046				_TEXT	ends				; end code segment			;AN000;
					end				;AN000;
Microsoft (R) Macro Assembler Version 5.10                  2/14/25 23:45:27
Critical error or control break exit                        Symbols-1


Segments and Groups:

                N a m e         	Length	 Align	Combine Class

DGROUP . . . . . . . . . . . . .  	GROUP
  NULL . . . . . . . . . . . . .  	0000	PARA	PUBLIC	'BEGDATA'
  _DATA  . . . . . . . . . . . .  	0000	PARA	PUBLIC	'DATA'
  CONST  . . . . . . . . . . . .  	0000	WORD	PUBLIC	'CONST'
  _BSS . . . . . . . . . . . . .  	0000	WORD	PUBLIC	'BSS'
  STACK  . . . . . . . . . . . .  	0000	PARA	STACK	'DATA'
PGROUP . . . . . . . . . . . . .  	GROUP
  _TEXT  . . . . . . . . . . . .  	0046	PARA	PUBLIC	'CODE'

Symbols:            

                N a m e         	Type	 Value	 Attr

ABORT  . . . . . . . . . . . . .  	NUMBER	0002	

CALL_RESTORE . . . . . . . . . .  	N PROC	0032	_TEXT	Length = 0014
CTLBRK . . . . . . . . . . . . .  	NUMBER	0003	

RETRY  . . . . . . . . . . . . .  	L NEAR	002B	_TEXT
RET_EXIT . . . . . . . . . . . .  	NUMBER	004C	

VECTOR . . . . . . . . . . . . .  	L DWORD	0000	_TEXT

XABORT . . . . . . . . . . . . .  	NUMBER	0001	

@CPU . . . . . . . . . . . . . .  	TEXT  0101h		
@FILENAME  . . . . . . . . . . .  	TEXT  _replace		
@VERSION . . . . . . . . . . . .  	TEXT  510		
_crit_err_handler  . . . . . . .  	N PROC	0004	_TEXT	Global	Length = 0028
_ctl_brk_handler . . . . . . . .  	N PROC	002C	_TEXT	Global	Length = 0006
_oldint24  . . . . . . . . . . .  	V DWORD	0000	_DATA	External
_restore . . . . . . . . . . . .  	L NEAR	0000	_TEXT	External


    141 Source  Lines
    141 Total   Lines
     28 Symbols

  47444 + 231319 Bytes symbol space free

      0 Warning Errors
      0 Severe  Errors
