diff options
| author | 2024-04-25 21:24:10 +0100 | |
|---|---|---|
| committer | 2024-04-25 22:32:27 +0000 | |
| commit | 2d04cacc5322951f187bb17e017c12920ac8ebe2 (patch) | |
| tree | 80ee017efa878dfd5344b44249e6a241f2a7f6e2 /v4.0/src/MAPPER/ERROR.ASM | |
| parent | Merge pull request #430 from jpbaltazar/typoptbr (diff) | |
| download | ms-dos-main.tar.gz ms-dos-main.tar.xz ms-dos-main.zip | |
Diffstat (limited to 'v4.0/src/MAPPER/ERROR.ASM')
| -rw-r--r-- | v4.0/src/MAPPER/ERROR.ASM | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/v4.0/src/MAPPER/ERROR.ASM b/v4.0/src/MAPPER/ERROR.ASM new file mode 100644 index 0000000..bf64801 --- /dev/null +++ b/v4.0/src/MAPPER/ERROR.ASM | |||
| @@ -0,0 +1,149 @@ | |||
| 1 | ;0 | ||
| 2 | page 80,132 | ||
| 3 | |||
| 4 | title CP/DOS DosError mapper | ||
| 5 | |||
| 6 | |||
| 7 | ;********************************************************************** | ||
| 8 | ;* | ||
| 9 | ;* MODULE: doserror | ||
| 10 | ;* | ||
| 11 | ;* ;AN000; PCDOS 4.00 ptm p2629 - Drive not ready yields FORMAT TERMINATED | ||
| 12 | ;* | ||
| 13 | ;********************************************************************* | ||
| 14 | |||
| 15 | SystemIsHandling equ 1 ; system handles errors | ||
| 16 | AppIsHandling equ 0 ; application handle errors | ||
| 17 | |||
| 18 | ;------------------------------------------------------------;;; | ||
| 19 | databuff segment public 'databuff' ;;; | ||
| 20 | ;;; | ||
| 21 | errorstate db SystemIsHandling ;;; | ||
| 22 | ;;; | ||
| 23 | databuff ends ;;; | ||
| 24 | ;------------------------------------------------------------;;; | ||
| 25 | |||
| 26 | |||
| 27 | dosxxx segment byte public 'dos' | ||
| 28 | assume cs:dosxxx,ds:nothing,es:nothing,ss:nothing | ||
| 29 | |||
| 30 | |||
| 31 | public doserror | ||
| 32 | .sall | ||
| 33 | .xlist | ||
| 34 | include macros.inc | ||
| 35 | .list | ||
| 36 | |||
| 37 | str struc | ||
| 38 | old_bp dw ? | ||
| 39 | Return dd ? | ||
| 40 | Flag dw ? ; error flag; 0 = APP handle error | ||
| 41 | str ends ; 1 = System handle error | ||
| 42 | |||
| 43 | |||
| 44 | DosError proc far | ||
| 45 | Enter doserror ; Push registers | ||
| 46 | |||
| 47 | mov ax,seg databuff ;-->RW | ||
| 48 | mov ds,ax ;-->RW | ||
| 49 | assume ds:databuff ;-->RW | ||
| 50 | |||
| 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 | ||
| 56 | |||
| 57 | mov ax,1 ; else, set error code | ||
| 58 | jmp exit ; return | ||
| 59 | |||
| 60 | SysErrorHandle: | ||
| 61 | |||
| 62 | cmp errorstate,SystemIsHandling ; system handles error ?? | ||
| 63 | jne setsys ; branch if not | ||
| 64 | xor ax,ax ; else set good return code | ||
| 65 | jmp exit ; return | ||
| 66 | |||
| 67 | setsys: mov errorstate,SystemIsHandling ; set flag for system | ||
| 68 | lds dx,cs:prevadrs | ||
| 69 | |||
| 70 | mov ax,02524H | ||
| 71 | int 21h ; set new vector | ||
| 72 | |||
| 73 | xor ax,ax ; set good return code | ||
| 74 | jmp exit ; return | ||
| 75 | |||
| 76 | |||
| 77 | AppErrorHandle: | ||
| 78 | cmp errorstate,AppIsHandling ; application handle errors | ||
| 79 | jne setapp ; branch if true | ||
| 80 | |||
| 81 | xor ax,ax ; else, set good error code | ||
| 82 | jmp exit ; return | ||
| 83 | |||
| 84 | setapp: mov errorstate,AppIsHandling ; indicate app handles error | ||
| 85 | mov ax,03524h ; Get Interrupt 24 Vector | ||
| 86 | int 21h | ||
| 87 | |||
| 88 | mov word ptr cs:prevadrs+0,bx ; save it in prevadrs | ||
| 89 | mov word ptr cs:prevadrs+2,es | ||
| 90 | |||
| 91 | mov dx,cs | ||
| 92 | mov ds,dx | ||
| 93 | mov dx,offset ApiErrorHandler ; put error interrupt handler | ||
| 94 | ; as new vector | ||
| 95 | mov ax,02524H | ||
| 96 | int 21h ;set new vector | ||
| 97 | |||
| 98 | xor ax,ax ; set good error return | ||
| 99 | |||
| 100 | exit: mexit ; pop all registers | ||
| 101 | ret size str - 6 ; return | ||
| 102 | |||
| 103 | DosError endp | ||
| 104 | |||
| 105 | page | ||
| 106 | |||
| 107 | |||
| 108 | |||
| 109 | |||
| 110 | |||
| 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; | ||
| 117 | |||
| 118 | Ignore equ 0 ;AN000; | ||
| 119 | Retry equ 1 ;AN000; | ||
| 120 | Terminate equ 2 ;AN000; | ||
| 121 | Fail equ 3 ;AN000; | ||
| 122 | |||
| 123 | prevadrs dd ? ;AN000; ;save old interrupt handler address ;;; | ||
| 124 | |||
| 125 | ApiErrorHandler proc near ;AN000; | ||
| 126 | pushf ;AN000; | ||
| 127 | cmp di,DriveNotReady ;AN000; Is it Drive Not Ready? | ||
| 128 | jne popf_and_fail_it ;AN000; If not, fail call and return | ||
| 129 | |||
| 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 | ||
| 135 | |||
| 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 | ||
| 139 | jmp rett ;AN000; | ||
| 140 | retry_it: ;AN000; Retry the operation | ||
| 141 | mov al,Retry ;AN000; Func code for retry | ||
| 142 | rett: ;AN000; | ||
| 143 | iret ;AN000; return | ||
| 144 | Apierrorhandler endp | ||
| 145 | ;------------------------------------------------------- | ||
| 146 | ;------------------------------------------------------- | ||
| 147 | |||
| 148 | dosxxx ends | ||
| 149 | end | ||