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/SIGHAND.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/SIGHAND.ASM')
| -rw-r--r-- | v4.0/src/MAPPER/SIGHAND.ASM | 204 |
1 files changed, 204 insertions, 0 deletions
diff --git a/v4.0/src/MAPPER/SIGHAND.ASM b/v4.0/src/MAPPER/SIGHAND.ASM new file mode 100644 index 0000000..2258d1c --- /dev/null +++ b/v4.0/src/MAPPER/SIGHAND.ASM | |||
| @@ -0,0 +1,204 @@ | |||
| 1 | page 80,132 | ||
| 2 | |||
| 3 | title CP/DOS DosSetSigHandler mapper | ||
| 4 | |||
| 5 | include msc.inc | ||
| 6 | |||
| 7 | dosxxx segment byte public 'dos' | ||
| 8 | assume cs:dosxxx,ds:nothing,es:nothing,ss:nothing | ||
| 9 | |||
| 10 | ;********************************************************************** | ||
| 11 | ;* | ||
| 12 | ;* MODULE: dossetsighandler | ||
| 13 | ;* | ||
| 14 | ;* FILE NAME: dos007.asm | ||
| 15 | ;* | ||
| 16 | ;* CALLING SEQUENCE: | ||
| 17 | ;* | ||
| 18 | ;* push word file handle | ||
| 19 | ;* push dword distance | ||
| 20 | ;* push word move type | ||
| 21 | ;* push@ dword new pointer | ||
| 22 | ;* call doschgfileptr | ||
| 23 | ;* | ||
| 24 | ;* MODULES CALLED: PC-DOS Int 21h, ah=42h | ||
| 25 | ;* | ||
| 26 | ;********************************************************************* | ||
| 27 | |||
| 28 | public dossetsighandler | ||
| 29 | .sall | ||
| 30 | .xlist | ||
| 31 | include macros.inc | ||
| 32 | .list | ||
| 33 | |||
| 34 | str struc | ||
| 35 | old_bp dw ? | ||
| 36 | return dd ? | ||
| 37 | Signumber dw ? ; signal number | ||
| 38 | Action dw ? ; action code | ||
| 39 | Prevaction dd ? ; previous action code | ||
| 40 | Prevadrs dd ? ; previous vector address | ||
| 41 | Routineadrs dd ? ; interrupt handler address | ||
| 42 | str ends | ||
| 43 | |||
| 44 | ; While we hate to do this, we have to. The following data areas are | ||
| 45 | ; expected to be in the CODE segment. | ||
| 46 | |||
| 47 | NextControlBreakHandler label dword | ||
| 48 | NextControlBreakHandlerOffset dw DummyControlBreakHandler | ||
| 49 | NextControlBreakHandlerSegment dw dosxxx | ||
| 50 | |||
| 51 | NextCriticalErrorHandler label dword | ||
| 52 | NextCriticalErrorHandlerOffset dw DummyCriticalErrorHandler | ||
| 53 | NextCriticalErrorHandlerSegment dw dosxxx | ||
| 54 | |||
| 55 | dossetsighandler proc far | ||
| 56 | |||
| 57 | Enter dossetsighandler ; push registers | ||
| 58 | |||
| 59 | mov ax,[bp].action ; get action code | ||
| 60 | cmp ax,2 ; action code 2 ?? | ||
| 61 | je continue1 ; branch if true | ||
| 62 | mov ax,1 ; else, set error code | ||
| 63 | jmp exit ; return | ||
| 64 | |||
| 65 | continue1: | ||
| 66 | mov ax,[bp].signumber ; get signel number | ||
| 67 | cmp ax,1 ; signal 1 (cntrl chara) ?? | ||
| 68 | je cntrlc ; jump if true | ||
| 69 | cmp ax,4 ; signal 4 (cntrl chara) ?? | ||
| 70 | je cntrlc ; jump if true | ||
| 71 | mov ax,2 ; else, set error code | ||
| 72 | jmp exit ; return | ||
| 73 | |||
| 74 | cntrlc: mov ax,03523h | ||
| 75 | int 21h ; get old vector address | ||
| 76 | |||
| 77 | lds si,[bp].prevadrs ; previous handler pointer | ||
| 78 | mov word ptr [si],bx ; save it in prevsdrs | ||
| 79 | mov word ptr [si]+2,es | ||
| 80 | |||
| 81 | lds dx,[bp].routineadrs ; get address of signal handler | ||
| 82 | |||
| 83 | mov NextControlBreakHandlerOffset,dx ; save it | ||
| 84 | mov NextControlBreakHandlerSegment,ds | ||
| 85 | |||
| 86 | mov dx,cs | ||
| 87 | mov ds,dx | ||
| 88 | mov dx,offset RealControlBreakHandler | ||
| 89 | |||
| 90 | mov ax,02523H | ||
| 91 | int 21h ; set signal handler addrs in vector | ||
| 92 | |||
| 93 | sub ax,ax ; set good return code | ||
| 94 | |||
| 95 | exit: mexit ; pop registers | ||
| 96 | ret size str - 6 ; return | ||
| 97 | |||
| 98 | dossetsighandler endp | ||
| 99 | |||
| 100 | page | ||
| 101 | |||
| 102 | ;------------------------------------------------------------------------------ | ||
| 103 | |||
| 104 | ; This routine will get control on control break, and it will make | ||
| 105 | ; sure that the environment is acceptable prior to calling the new | ||
| 106 | ; handler. NOTE: we expect the new handler to be written in MicroSoft 'C' | ||
| 107 | |||
| 108 | RealControlBreakHandler proc far | ||
| 109 | |||
| 110 | push ds | ||
| 111 | push es | ||
| 112 | push di | ||
| 113 | push si | ||
| 114 | push bp | ||
| 115 | push dx | ||
| 116 | push cx | ||
| 117 | push bx | ||
| 118 | push ax | ||
| 119 | |||
| 120 | ; reestablish the es and ds segment registers before going to 'C' | ||
| 121 | |||
| 122 | mov ax,seg DGroup | ||
| 123 | mov ds,ax | ||
| 124 | mov es,ax | ||
| 125 | |||
| 126 | call NextControlBreakHandler | ||
| 127 | |||
| 128 | pop ax | ||
| 129 | pop bx | ||
| 130 | pop cx | ||
| 131 | pop dx | ||
| 132 | pop bp | ||
| 133 | pop si | ||
| 134 | pop di | ||
| 135 | pop es | ||
| 136 | pop ds | ||
| 137 | |||
| 138 | iret | ||
| 139 | |||
| 140 | RealControlBreakHandler endp | ||
| 141 | |||
| 142 | page | ||
| 143 | |||
| 144 | ;------------------------------------------------------------------------------ | ||
| 145 | |||
| 146 | ; This routine will get control on the control break, and it will make | ||
| 147 | ; sure that the environment is acceptable prior to calling the new | ||
| 148 | ; handler. NOTE: we expect the new handler to be written in MicroSoft 'C' | ||
| 149 | |||
| 150 | RealCriticalErrorHandler proc far | ||
| 151 | |||
| 152 | push ds | ||
| 153 | push es | ||
| 154 | push di | ||
| 155 | push si | ||
| 156 | push bp | ||
| 157 | push dx | ||
| 158 | push cx | ||
| 159 | push bx | ||
| 160 | push ax | ||
| 161 | |||
| 162 | ; reestablish the es and ds segment registers before going to 'C' | ||
| 163 | |||
| 164 | mov ax,seg DGroup | ||
| 165 | mov ds,ax | ||
| 166 | mov es,ax | ||
| 167 | |||
| 168 | call NextControlBreakHandler | ||
| 169 | |||
| 170 | pop ax | ||
| 171 | pop bx | ||
| 172 | pop cx | ||
| 173 | pop dx | ||
| 174 | pop bp | ||
| 175 | pop si | ||
| 176 | pop di | ||
| 177 | pop es | ||
| 178 | pop ds | ||
| 179 | |||
| 180 | iret | ||
| 181 | |||
| 182 | RealCriticalErrorHandler endp | ||
| 183 | |||
| 184 | page | ||
| 185 | |||
| 186 | ;------------------------------------------------------------------------------ | ||
| 187 | |||
| 188 | DummyControlBreakHandler proc far | ||
| 189 | |||
| 190 | iret | ||
| 191 | |||
| 192 | DummyControlBreakHandler endp | ||
| 193 | |||
| 194 | DummyCriticalErrorHandler proc far | ||
| 195 | |||
| 196 | iret | ||
| 197 | |||
| 198 | DummyCriticalErrorHandler endp | ||
| 199 | |||
| 200 | |||
| 201 | |||
| 202 | dosxxx ends | ||
| 203 | |||
| 204 | end | ||