Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:15
CP/DOS DosError   mapper                                    Page     1-1


				;0
				page 80,132
				
				title CP/DOS DosError   mapper
				
				
				;**********************************************************************
				;*
				;*   MODULE:   doserror
				;*
				;*   ;AN000; PCDOS 4.00 ptm p2629 - Drive not ready yields FORMAT TERMINATED
				;*
				;*********************************************************************
				
 = 0001				SystemIsHandling      equ     1       ; system handles errors
 = 0000				AppIsHandling	      equ     0       ; application handle errors
				
				;------------------------------------------------------------;;;
 0000				databuff  segment   public  'databuff'                       ;;;
											     ;;;
 0000  01			errorstate db	SystemIsHandling			     ;;;
											     ;;;
 0001				databuff   ends 					     ;;;
				;------------------------------------------------------------;;;
				
				
 0000				dosxxx	segment byte public 'dos'
					assume	cs:dosxxx,ds:nothing,es:nothing,ss:nothing
				
				
					    public   doserror
					    .sall
					    .list
				
				str	    struc
 0000  0000			old_bp	    dw	     ?
 0002  00000000			Return	    dd	     ?
 0006  0000			Flag	    dw	     ?		; error flag;  0 = APP handle error
 0008				str	    ends		;	       1 = System handle error
				
				
 0000				DosError   proc  far
					Enter	 doserror		; Push registers
				
 000C  B8 ---- R			mov	 ax,seg databuff	;-->RW
 000F  8E D8				mov	 ds,ax			;-->RW
					assume	 ds:databuff		;-->RW
				
 0011  8B 46 06				mov	 ax,[bp].flag		; get error flag
 0014  3D 0000				cmp	 ax,AppIsHandling	; check who should handle errors
 0017  74 2B				je	 apperrorhandle 	; branch if application handles error
 0019  3D 0001				cmp	 ax,SystemIsHandling	; system handle error ??
 001C  74 06				je	 syserrorhandle 	; branch if true
				
 001E  B8 0001				mov	 ax,1			; else, set error code
 0021  EB 4F 90				jmp	 exit			; return
				
 0024				SysErrorHandle:
				
 0024  80 3E 0000 R 01			cmp	 errorstate,SystemIsHandling	; system handles error ??
 0029  75 05				jne	 setsys 			; branch if not
 002B  33 C0				xor	 ax,ax			   ; else set good return code
 002D  EB 43 90				jmp	 exit			; return
				
 0030  C6 06 0000 R 01		setsys: mov	 errorstate,SystemIsHandling	 ; set flag for system
 0035  2E: C5 16 0081 R			lds	 dx,cs:prevadrs
				
 003A  B8 2524				mov	 ax,02524H
 003D  CD 21				int	 21h			; set new vector
				
 003F  33 C0				xor	ax,ax			; set good return code
 0041  EB 2F 90				jmp	exit			; return
				
				
 0044				AppErrorHandle:
 0044  80 3E 0000 R 00			cmp	 errorstate,AppIsHandling    ; application handle errors
Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:15
CP/DOS DosError   mapper                                    Page     1-2


 0049  75 05				jne	 setapp 		     ; branch if true
				
 004B  33 C0				xor	 ax,ax			; else, set good error code
 004D  EB 23 90				jmp	 exit			; return
				
 0050  C6 06 0000 R 00		setapp: mov	 errorstate,AppIsHandling ; indicate app handles error
 0055  B8 3524				mov	 ax,03524h		; Get Interrupt 24 Vector
 0058  CD 21				int	 21h
				
 005A  2E: 89 1E 0081 R			mov	 word ptr cs:prevadrs+0,bx     ; save it in prevadrs
 005F  2E: 8C 06 0083 R			mov	 word ptr cs:prevadrs+2,es
				
 0064  8C CA				mov	dx,cs
 0066  8E DA				mov	ds,dx
 0068  BA 0085 R			mov	dx,offset ApiErrorHandler   ; put error interrupt handler
									    ; as new vector
 006B  B8 2524				mov	 ax,02524H
 006E  CD 21				int	 21h		       ;set new vector
				
 0070  33 C0				xor	 ax,ax		       ; set good error return
				
 0072				exit:	mexit			       ; pop all registers
 007E  CA 0002				ret	 size str - 6	       ; return
				
 0081				DosError    endp
				
Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:15
CP/DOS DosError   mapper                                    Page     1-3


					page
				
				
				
				
				
				;-------------------------------------------------------
				; ****	 Error Handler	******
				; This routine will get control on  a hard error, returning an error.
				; If error is Drive not ready, keep retrying until drive IS ready or ^C
				;-------------------------------------------------------
 = 0002				DriveNotReady	equ	2		;AN000;
				
 = 0000				Ignore		equ	0		;AN000;
 = 0001				Retry		equ	1		;AN000;
 = 0002				Terminate	equ	2		;AN000;
 = 0003				Fail		equ	3		;AN000;
				
 0081  00000000			prevadrs   dd	?			;AN000; ;save old interrupt handler address  ;;;
				
 0085				ApiErrorHandler    proc    near 	;AN000;
 0085  9C				pushf				;AN000;
 0086  83 FF 02				cmp	di,DriveNotReady	;AN000; Is it Drive Not Ready?
 0089  75 0B				jne	popf_and_fail_it	;AN000; If not, fail call and return
				
 008B				Drive_Not_Ready:			;AN000; The drive is not ready!
 008B  2E: FF 1E 0081 R			call	dword ptr cs:prevadrs	;AN000; Get user to respond
 0090  3C 02				cmp	al,Terminate		;AN000; For any resonse other than terminate,
 0092  75 08				jne	retry_it		;AN000;  retry the operation
 0094  CD 23				int	023h			;AN000; Otherwise terminate via INT 023h
				
 0096				popf_and_fail_it:			;AN000; Fail the operation
 0096  58				pop	ax			;AN000; Remove garbage from stack
 0097  B0 03				mov	al,Fail 		;AN000; Func code for fail
 0099  EB 03 90				jmp	rett			;AN000;
 009C				retry_it:				;AN000; Retry the operation
 009C  B0 01				mov	al,Retry		;AN000; Func code for retry
 009E				rett:					;AN000;
 009E  CF				iret				;AN000; return
 009F				Apierrorhandler 	endp
				;-------------------------------------------------------
				;-------------------------------------------------------
				
 009F				dosxxx	    ends
					   end

Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:15
CP/DOS DosError   mapper                                    Symbols-1


Macros:

		N a m e			Lines

ENTER  . . . . . . . . . . . . .  	   3
MEXIT  . . . . . . . . . . . . .  	   3
POPAL  . . . . . . . . . . . . .  	   9
PUSHAL . . . . . . . . . . . . .  	   9

Structures and Records:

                N a m e                 Width   # fields
                                        Shift   Width   Mask    Initial

STR  . . . . . . . . . . . . . .  	0008	0003
  OLD_BP . . . . . . . . . . . .  	0000
  RETURN . . . . . . . . . . . .  	0002
  FLAG . . . . . . . . . . . . .  	0006

Segments and Groups:

                N a m e         	Length	 Align	Combine Class

DATABUFF . . . . . . . . . . . .  	0001	PARA	PUBLIC	'DATABUFF'
DOSXXX . . . . . . . . . . . . .  	009F	BYTE	PUBLIC	'DOS'

Symbols:            

                N a m e         	Type	 Value	 Attr

APIERRORHANDLER  . . . . . . . .  	N PROC	0085	DOSXXX	Length = 001A
APPERRORHANDLE . . . . . . . . .  	L NEAR	0044	DOSXXX
APPISHANDLING  . . . . . . . . .  	NUMBER	0000	

doserror . . . . . . . . . . . .  	F PROC	0000	DOSXXX	Global	Length = 0081
DRIVENOTREADY  . . . . . . . . .  	NUMBER	0002	
DRIVE_NOT_READY  . . . . . . . .  	L NEAR	008B	DOSXXX

ERRORSTATE . . . . . . . . . . .  	L BYTE	0000	DATABUFF
EXIT . . . . . . . . . . . . . .  	L NEAR	0072	DOSXXX

FAIL . . . . . . . . . . . . . .  	NUMBER	0003	

IGNORE . . . . . . . . . . . . .  	NUMBER	0000	

POPF_AND_FAIL_IT . . . . . . . .  	L NEAR	0096	DOSXXX
PREVADRS . . . . . . . . . . . .  	L DWORD	0081	DOSXXX

RETRY  . . . . . . . . . . . . .  	NUMBER	0001	
RETRY_IT . . . . . . . . . . . .  	L NEAR	009C	DOSXXX
RETT . . . . . . . . . . . . . .  	L NEAR	009E	DOSXXX

SETAPP . . . . . . . . . . . . .  	L NEAR	0050	DOSXXX
SETSYS . . . . . . . . . . . . .  	L NEAR	0030	DOSXXX
SYSERRORHANDLE . . . . . . . . .  	L NEAR	0024	DOSXXX
SYSTEMISHANDLING . . . . . . . .  	NUMBER	0001	

TERMINATE  . . . . . . . . . . .  	NUMBER	0002	

@CPU . . . . . . . . . . . . . .  	TEXT  0101h		
@FILENAME  . . . . . . . . . . .  	TEXT  error		
@VERSION . . . . . . . . . . . .  	TEXT  510		


    195 Source  Lines
    219 Total   Lines
     36 Symbols

  47466 + 276547 Bytes symbol space free

      0 Warning Errors
      0 Severe  Errors
